autoglm-gui 1.5.4__py3-none-any.whl → 1.5.6__py3-none-any.whl
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.
- AutoGLM_GUI/agents/glm/async_agent.py +3 -50
- AutoGLM_GUI/agents/protocols.py +3 -14
- AutoGLM_GUI/api/agents.py +118 -93
- AutoGLM_GUI/api/devices.py +177 -0
- AutoGLM_GUI/api/scheduled_tasks.py +7 -2
- AutoGLM_GUI/device_group_manager.py +354 -0
- AutoGLM_GUI/models/__init__.py +8 -0
- AutoGLM_GUI/models/device_group.py +63 -0
- AutoGLM_GUI/models/scheduled_task.py +47 -4
- AutoGLM_GUI/scheduler_manager.py +255 -80
- AutoGLM_GUI/schemas.py +148 -3
- AutoGLM_GUI/static/assets/{about-BZglkj97.js → about-DVviVdH2.js} +1 -1
- AutoGLM_GUI/static/assets/{alert-dialog-5vNoxwIO.js → alert-dialog-IHmO2JCQ.js} +1 -1
- AutoGLM_GUI/static/assets/chat-C_3D0Ao7.js +134 -0
- AutoGLM_GUI/static/assets/{dialog-DSAhQHru.js → dialog-DOpd71Lu.js} +3 -3
- AutoGLM_GUI/static/assets/{eye-Deqw6dbm.js → eye-CZP5ZJ_Y.js} +1 -1
- AutoGLM_GUI/static/assets/folder-open-_KlT8ZW7.js +1 -0
- AutoGLM_GUI/static/assets/{history-CL-JjUbk.js → history-BXMlCwUV.js} +1 -1
- AutoGLM_GUI/static/assets/index-84TrNz7w.css +1 -0
- AutoGLM_GUI/static/assets/index-Bh2f556h.js +1 -0
- AutoGLM_GUI/static/assets/index-DUNWZsFq.js +11 -0
- AutoGLM_GUI/static/assets/{label-CEmK7RW4.js → label-CRZhpiYG.js} +1 -1
- AutoGLM_GUI/static/assets/logs-DEN9nDRS.js +1 -0
- AutoGLM_GUI/static/assets/popover-DitUZhUk.js +1 -0
- AutoGLM_GUI/static/assets/scheduled-tasks-boxDKe87.js +1 -0
- AutoGLM_GUI/static/assets/{textarea-nLU4tGQH.js → textarea-CvRHzjfV.js} +1 -1
- AutoGLM_GUI/static/assets/{workflows-QIA3_mdp.js → workflows-Bg3qN-6j.js} +1 -1
- AutoGLM_GUI/static/index.html +2 -2
- {autoglm_gui-1.5.4.dist-info → autoglm_gui-1.5.6.dist-info}/METADATA +361 -10
- {autoglm_gui-1.5.4.dist-info → autoglm_gui-1.5.6.dist-info}/RECORD +33 -31
- AutoGLM_GUI/static/assets/chat-ta_RqZfZ.js +0 -129
- AutoGLM_GUI/static/assets/circle-alert-CnwO7Du-.js +0 -1
- AutoGLM_GUI/static/assets/index-BjaUZM-7.js +0 -1
- AutoGLM_GUI/static/assets/index-CX4NAYCk.js +0 -11
- AutoGLM_GUI/static/assets/index-DSIMVL8V.css +0 -1
- AutoGLM_GUI/static/assets/logs-C-Pnb4jI.js +0 -1
- AutoGLM_GUI/static/assets/popover-CauTjrhB.js +0 -1
- AutoGLM_GUI/static/assets/scheduled-tasks-Ds1WrRVN.js +0 -1
- {autoglm_gui-1.5.4.dist-info → autoglm_gui-1.5.6.dist-info}/WHEEL +0 -0
- {autoglm_gui-1.5.4.dist-info → autoglm_gui-1.5.6.dist-info}/entry_points.txt +0 -0
- {autoglm_gui-1.5.4.dist-info → autoglm_gui-1.5.6.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DUNWZsFq.js","assets/index-84TrNz7w.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{b as Ye,j as o,u as pn,r as x,T as ln,v as cn,w as un,B as fe,i as Vn,x as jv,y as Av,z as Sr,R as Ke,A as Pt,D as ta,E as ii,P as gt,G as Pe,H as ga,I as an,J as zu,K as Pv,L as Mv,M as Cn,N as Dv,O as Iv,Q as Lv,S as Ov,U as Fv,V as Hu,W as Bv,e as Ln,X as Uv,Y as Vs,Z as Gv,h as $u,_ as Wv,$ as zv,a0 as Hv,a1 as $v,a2 as Wr,a3 as uu,a4 as qv,a5 as Xv,a6 as Yv,a7 as qu,a8 as Kv,a9 as du,aa as fu,ab as Vv,ac as Qv,ad as Jv,ae as Zv,af as oi,ag as Xu,q as Yu,l as Ku,s as Vu,t as Qu,ah as Ju,ai as e1,aj as t1,ak as n1,al as r1,am as s1,an as i1,ao as o1,ap as a1,aq as l1,ar as c1,as as u1,at as d1,au as f1,av as h1}from"./index-DUNWZsFq.js";import{L as At,T as xa,D as xr,d as _r,e as vr,f as br,h as yr,g as wr,i as p1,u as m1,R as g1,F as x1,C as gi,X as _1}from"./dialog-DOpd71Lu.js";import{S as Zu,L as et,I as dt,P as _a}from"./label-CRZhpiYG.js";import{C as va,E as Wo}from"./eye-CZP5ZJ_Y.js";import{b as ed,C as hu,a as pu,P as ai,c as li,d as ci}from"./popover-DitUZhUk.js";import{F as na,C as dn}from"./folder-open-_KlT8ZW7.js";import{T as td}from"./textarea-CvRHzjfV.js";const v1=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],b1=Ye("arrow-up-down",v1);const y1=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],nd=Ye("brain",y1);const w1=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],rd=Ye("chevron-left",w1);const E1=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],S1=Ye("chevron-up",E1);const C1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ns=Ye("circle-check",C1);const N1=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],R1=Ye("cpu",N1);const T1=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],mu=Ye("external-link",T1);const k1=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],gu=Ye("eye-off",k1);const j1=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],A1=Ye("fingerprint-pattern",j1);const P1=[["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.98a2 2 0 0 1 1.69.9l.66 1.2A2 2 0 0 0 12 6h8a2 2 0 0 1 2 2v3.3",key:"128dxu"}],["path",{d:"m14.305 19.53.923-.382",key:"3m78fa"}],["path",{d:"m15.228 16.852-.923-.383",key:"npixar"}],["path",{d:"m16.852 15.228-.383-.923",key:"5xggr7"}],["path",{d:"m16.852 20.772-.383.924",key:"dpfhf9"}],["path",{d:"m19.148 15.228.383-.923",key:"1reyyz"}],["path",{d:"m19.53 21.696-.382-.924",key:"1goivc"}],["path",{d:"m20.772 16.852.924-.383",key:"htqkph"}],["path",{d:"m20.772 19.148.924.383",key:"9w9pjp"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]],M1=Ye("folder-cog",P1);const D1=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],sd=Ye("grip-vertical",D1);const I1=[["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"}]],xu=Ye("image",I1);const L1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],O1=Ye("info",L1);const F1=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ra=Ye("layers",F1);const B1=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],U1=Ye("maximize",B1);const G1=[["path",{d:"M5 12h14",key:"1ays0h"}]],W1=Ye("minus",G1);const z1=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],H1=Ye("monitor-play",z1);const $1=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],q1=Ye("plug",$1);const X1=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],id=Ye("rotate-ccw",X1);const Y1=[["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"}]],od=Ye("send",Y1);const K1=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],sa=Ye("server",K1);const V1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ad=Ye("settings",V1);const Q1=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Zs=Ye("smartphone",Q1);const J1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],qr=Ye("sparkles",J1);const Z1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ld=Ye("square",Z1);const eb=[["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"}]],tb=Ye("video",eb);const nb=[["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"}]],rb=Ye("wifi-off",nb);const sb=[["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"}]],ui=Ye("wifi",sb);const ib=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ob=Ye("wrench",ib);function ia({isOpen:s,title:n,content:r,onConfirm:a,onCancel:u,confirmText:l="确认",cancelText:m="取消",confirmVariant:b="default",disabled:h=!1}){if(!s)return null;const d=b==="destructive"?"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed":"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed";return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200",children:o.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden transform transition-all animate-in zoom-in-95 duration-200",onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{className:"p-6",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),o.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),o.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[o.jsx("button",{onClick:p=>{p.stopPropagation(),u()},disabled:h,className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:m}),o.jsx("button",{onClick:p=>{p.stopPropagation(),a()},disabled:h,className:d,children:l})]})]})})}function ab({id:s,serial:n,model:r,status:a,connectionType:u,displayName:l,agent:m,isActive:b,onClick:h,onConnectWifi:d,onDisconnectWifi:p,onNameUpdated:_,showToast:y}){const w=pn(),S=a==="device",P=u==="usb",N=u==="wifi",I=u==="remote",[L,k]=x.useState(!1),[B,Y]=x.useState(!1),[T,F]=x.useState(!1),[z,D]=x.useState(!1),[te,U]=x.useState(""),[M,G]=x.useState(!1),H=l||r||w.deviceCard.unknownDevice,Z=()=>{if(!S||!m)return"status-agent-none";switch(m.state){case"idle":return"status-agent-idle";case"busy":return"status-agent-busy";case"error":return"status-agent-error";case"initializing":return"status-agent-initializing";default:return"status-agent-none"}},Q=()=>{if(!S||!m)return w.deviceCard.statusTooltip.none;switch(m.state){case"idle":return w.deviceCard.statusTooltip.idle;case"busy":return w.deviceCard.statusTooltip.busy;case"error":return w.deviceCard.statusTooltip.error;case"initializing":return w.deviceCard.statusTooltip.initializing;default:return w.deviceCard.statusTooltip.none}},ee=le=>{le.stopPropagation(),!(L||!d)&&Y(!0)},ie=le=>{le.stopPropagation(),!(L||!p)&&F(!0)},ne=async()=>{Y(!1),k(!0);try{d&&await d()}finally{k(!1)}},A=async()=>{F(!1),k(!0);try{p&&await p()}finally{k(!1)}},$=le=>{le.stopPropagation(),U(l||r||""),D(!0)},re=async()=>{try{G(!0);const le=te.trim(),ve=await Av(n,le||null);if(!ve.success){y&&y(ve.error||w.deviceCard.saveNameError,"error");return}D(!1),_&&_(),y&&y(w.deviceCard.saveNameSuccess,"success")}catch(le){console.error("Failed to update device name:",le),y&&y(w.deviceCard.saveNameError,"error")}finally{G(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:h,role:"button",tabIndex:0,onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&h()},className:`
|
|
3
|
+
group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
|
|
4
|
+
border-2
|
|
5
|
+
${b?"bg-slate-50 border-[#1d9bf0] dark:bg-slate-800/50 dark:border-[#1d9bf0]":"bg-white border-transparent hover:border-slate-200 dark:bg-slate-900 dark:hover:border-slate-700"}
|
|
6
|
+
`,children:[b&&o.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),o.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsx("div",{className:`relative flex-shrink-0 ${Z()} w-3 h-3 rounded-full transition-all cursor-help ${b?"scale-110":""}`})}),o.jsx(un,{side:"right",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("p",{className:"font-medium",children:[w.deviceCard.statusTooltip.title,Q()]}),o.jsxs("div",{className:"text-xs opacity-80 space-y-0.5",children:[o.jsx("p",{children:w.deviceCard.statusTooltip.legend.green}),o.jsx("p",{children:w.deviceCard.statusTooltip.legend.yellow}),o.jsx("p",{children:w.deviceCard.statusTooltip.legend.red}),o.jsx("p",{children:w.deviceCard.statusTooltip.legend.gray})]})]})})]}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Zs,{className:`w-4 h-4 flex-shrink-0 ${b?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:`font-semibold text-sm truncate ${b?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:H}),o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:$,className:"h-5 w-5 text-slate-400 hover:text-[#1d9bf0] opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(Zu,{className:"w-3 h-3"})})}),o.jsx(un,{children:o.jsx("p",{children:w.deviceCard.editName})})]})]}),o.jsx("span",{className:`text-xs font-mono truncate ${b?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:n})]}),o.jsx("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:I?o.jsxs(Vn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[o.jsx(sa,{className:"w-2.5 h-2.5 mr-1"}),w.deviceCard.remote||"Remote"]}):N?o.jsxs(Vn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[o.jsx(ui,{className:"w-2.5 h-2.5 mr-1"}),w.deviceCard.wifi||"WiFi"]}):P?o.jsx(Vn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:"USB"}):null}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d&&P&&o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:ee,disabled:L,className:"h-7 w-7 text-slate-400 hover:text-[#1d9bf0]",children:L?o.jsx(At,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(ui,{className:"w-3.5 h-3.5"})})}),o.jsx(un,{children:o.jsx("p",{children:w.deviceCard.connectViaWifi})})]}),p&&N&&o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:ie,disabled:L,className:"h-7 w-7 text-slate-400 hover:text-orange-500",children:L?o.jsx(At,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(rb,{className:"w-3.5 h-3.5"})})}),o.jsx(un,{children:o.jsx("p",{children:w.deviceCard.disconnectWifi})})]}),I&&o.jsx(fe,{variant:"ghost",size:"icon",onClick:async le=>{le.stopPropagation(),k(!0);try{await jv(n)}catch(ve){console.error("Failed to remove remote device:",ve)}finally{k(!1)}},disabled:L,className:"h-7 w-7 text-slate-400 hover:text-red-500",title:w.deviceCard.removeRemote||"移除远程设备",children:L?o.jsx(At,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(xa,{className:"w-3.5 h-3.5"})})]})]})]}),o.jsx(ia,{isOpen:B,title:w.deviceCard.connectWifiTitle,content:w.deviceCard.connectWifiContent,onConfirm:ne,onCancel:()=>Y(!1)}),o.jsx(ia,{isOpen:T,title:w.deviceCard.disconnectWifiTitle,content:w.deviceCard.disconnectWifiContent,onConfirm:A,onCancel:()=>F(!1)}),o.jsx(xr,{open:z,onOpenChange:D,children:o.jsxs(_r,{className:"sm:max-w-md",children:[o.jsxs(vr,{children:[o.jsx(br,{children:w.deviceCard.editNameDialogTitle}),o.jsx(yr,{children:w.deviceCard.editNameDialogDescription})]}),o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"device-name",children:w.deviceCard.deviceNameLabel}),o.jsx(dt,{id:"device-name",value:te,onChange:le=>U(le.target.value),placeholder:w.deviceCard.deviceNamePlaceholder,maxLength:100,onKeyDown:le=>{le.key==="Enter"&&!M&&re()}}),o.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[w.deviceCard.deviceSerialLabel,": ",n]})]})}),o.jsxs(wr,{children:[o.jsx(fe,{variant:"outline",onClick:()=>D(!1),disabled:M,children:w.common.cancel}),o.jsx(fe,{onClick:re,disabled:M,children:M?o.jsxs(o.Fragment,{children:[o.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),w.common.loading]}):w.common.save})]})]})})]})}function cd(s){const n=s+"CollectionProvider",[r,a]=Sr(n),[u,l]=r(n,{collectionRef:{current:null},itemMap:new Map}),m=P=>{const{scope:N,children:I}=P,L=Ke.useRef(null),k=Ke.useRef(new Map).current;return o.jsx(u,{scope:N,itemMap:k,collectionRef:L,children:I})};m.displayName=n;const b=s+"CollectionSlot",h=ta(b),d=Ke.forwardRef((P,N)=>{const{scope:I,children:L}=P,k=l(b,I),B=Pt(N,k.collectionRef);return o.jsx(h,{ref:B,children:L})});d.displayName=b;const p=s+"CollectionItemSlot",_="data-radix-collection-item",y=ta(p),w=Ke.forwardRef((P,N)=>{const{scope:I,children:L,...k}=P,B=Ke.useRef(null),Y=Pt(N,B),T=l(p,I);return Ke.useEffect(()=>(T.itemMap.set(B,{ref:B,...k}),()=>void T.itemMap.delete(B))),o.jsx(y,{[_]:"",ref:Y,children:L})});w.displayName=p;function S(P){const N=l(s+"CollectionConsumer",P);return Ke.useCallback(()=>{const L=N.collectionRef.current;if(!L)return[];const k=Array.from(L.querySelectorAll(`[${_}]`));return Array.from(N.itemMap.values()).sort((T,F)=>k.indexOf(T.ref.current)-k.indexOf(F.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:m,Slot:d,ItemSlot:w},S,a]}var lb=x.createContext(void 0);function xi(s){const n=x.useContext(lb);return s||n||"ltr"}var zo="rovingFocusGroup.onEntryFocus",cb={bubbles:!1,cancelable:!0},rs="RovingFocusGroup",[oa,ud,ub]=cd(rs),[db,_i]=Sr(rs,[ub]),[fb,hb]=db(rs),dd=x.forwardRef((s,n)=>o.jsx(oa.Provider,{scope:s.__scopeRovingFocusGroup,children:o.jsx(oa.Slot,{scope:s.__scopeRovingFocusGroup,children:o.jsx(pb,{...s,ref:n})})}));dd.displayName=rs;var pb=x.forwardRef((s,n)=>{const{__scopeRovingFocusGroup:r,orientation:a,loop:u=!1,dir:l,currentTabStopId:m,defaultCurrentTabStopId:b,onCurrentTabStopIdChange:h,onEntryFocus:d,preventScrollOnEntryFocus:p=!1,..._}=s,y=x.useRef(null),w=Pt(n,y),S=xi(l),[P,N]=ga({prop:m,defaultProp:b??null,onChange:h,caller:rs}),[I,L]=x.useState(!1),k=an(d),B=ud(r),Y=x.useRef(!1),[T,F]=x.useState(0);return x.useEffect(()=>{const z=y.current;if(z)return z.addEventListener(zo,k),()=>z.removeEventListener(zo,k)},[k]),o.jsx(fb,{scope:r,orientation:a,dir:S,loop:u,currentTabStopId:P,onItemFocus:x.useCallback(z=>N(z),[N]),onItemShiftTab:x.useCallback(()=>L(!0),[]),onFocusableItemAdd:x.useCallback(()=>F(z=>z+1),[]),onFocusableItemRemove:x.useCallback(()=>F(z=>z-1),[]),children:o.jsx(gt.div,{tabIndex:I||T===0?-1:0,"data-orientation":a,..._,ref:w,style:{outline:"none",...s.style},onMouseDown:Pe(s.onMouseDown,()=>{Y.current=!0}),onFocus:Pe(s.onFocus,z=>{const D=!Y.current;if(z.target===z.currentTarget&&D&&!I){const te=new CustomEvent(zo,cb);if(z.currentTarget.dispatchEvent(te),!te.defaultPrevented){const U=B().filter(Q=>Q.focusable),M=U.find(Q=>Q.active),G=U.find(Q=>Q.id===P),Z=[M,G,...U].filter(Boolean).map(Q=>Q.ref.current);pd(Z,p)}}Y.current=!1}),onBlur:Pe(s.onBlur,()=>L(!1))})})}),fd="RovingFocusGroupItem",hd=x.forwardRef((s,n)=>{const{__scopeRovingFocusGroup:r,focusable:a=!0,active:u=!1,tabStopId:l,children:m,...b}=s,h=ii(),d=l||h,p=hb(fd,r),_=p.currentTabStopId===d,y=ud(r),{onFocusableItemAdd:w,onFocusableItemRemove:S,currentTabStopId:P}=p;return x.useEffect(()=>{if(a)return w(),()=>S()},[a,w,S]),o.jsx(oa.ItemSlot,{scope:r,id:d,focusable:a,active:u,children:o.jsx(gt.span,{tabIndex:_?0:-1,"data-orientation":p.orientation,...b,ref:n,onMouseDown:Pe(s.onMouseDown,N=>{a?p.onItemFocus(d):N.preventDefault()}),onFocus:Pe(s.onFocus,()=>p.onItemFocus(d)),onKeyDown:Pe(s.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){p.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const I=xb(N,p.orientation,p.dir);if(I!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let k=y().filter(B=>B.focusable).map(B=>B.ref.current);if(I==="last")k.reverse();else if(I==="prev"||I==="next"){I==="prev"&&k.reverse();const B=k.indexOf(N.currentTarget);k=p.loop?_b(k,B+1):k.slice(B+1)}setTimeout(()=>pd(k))}}),children:typeof m=="function"?m({isCurrentTabStop:_,hasTabStop:P!=null}):m})})});hd.displayName=fd;var mb={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gb(s,n){return n!=="rtl"?s:s==="ArrowLeft"?"ArrowRight":s==="ArrowRight"?"ArrowLeft":s}function xb(s,n,r){const a=gb(s.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return mb[a]}function pd(s,n=!1){const r=document.activeElement;for(const a of s)if(a===r||(a.focus({preventScroll:n}),document.activeElement!==r))return}function _b(s,n){return s.map((r,a)=>s[(n+a)%s.length])}var md=dd,gd=hd,aa=["Enter"," "],vb=["ArrowDown","PageUp","Home"],xd=["ArrowUp","PageDown","End"],bb=[...vb,...xd],yb={ltr:[...aa,"ArrowRight"],rtl:[...aa,"ArrowLeft"]},wb={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ss="Menu",[Zr,Eb,Sb]=cd(ss),[Jn,_d]=Sr(ss,[Sb,zu,_i]),vi=zu(),vd=_i(),[Cb,Zn]=Jn(ss),[Nb,is]=Jn(ss),bd=s=>{const{__scopeMenu:n,open:r=!1,children:a,dir:u,onOpenChange:l,modal:m=!0}=s,b=vi(n),[h,d]=x.useState(null),p=x.useRef(!1),_=an(l),y=xi(u);return x.useEffect(()=>{const w=()=>{p.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>p.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),o.jsx(Pv,{...b,children:o.jsx(Cb,{scope:n,open:r,onOpenChange:_,content:h,onContentChange:d,children:o.jsx(Nb,{scope:n,onClose:x.useCallback(()=>_(!1),[_]),isUsingKeyboardRef:p,dir:y,modal:m,children:a})})})};bd.displayName=ss;var Rb="MenuAnchor",ba=x.forwardRef((s,n)=>{const{__scopeMenu:r,...a}=s,u=vi(r);return o.jsx(Mv,{...u,...a,ref:n})});ba.displayName=Rb;var ya="MenuPortal",[Tb,yd]=Jn(ya,{forceMount:void 0}),wd=s=>{const{__scopeMenu:n,forceMount:r,children:a,container:u}=s,l=Zn(ya,n);return o.jsx(Tb,{scope:n,forceMount:r,children:o.jsx(Cn,{present:r||l.open,children:o.jsx(Dv,{asChild:!0,container:u,children:a})})})};wd.displayName=ya;var Kt="MenuContent",[kb,wa]=Jn(Kt),Ed=x.forwardRef((s,n)=>{const r=yd(Kt,s.__scopeMenu),{forceMount:a=r.forceMount,...u}=s,l=Zn(Kt,s.__scopeMenu),m=is(Kt,s.__scopeMenu);return o.jsx(Zr.Provider,{scope:s.__scopeMenu,children:o.jsx(Cn,{present:a||l.open,children:o.jsx(Zr.Slot,{scope:s.__scopeMenu,children:m.modal?o.jsx(jb,{...u,ref:n}):o.jsx(Ab,{...u,ref:n})})})})}),jb=x.forwardRef((s,n)=>{const r=Zn(Kt,s.__scopeMenu),a=x.useRef(null),u=Pt(n,a);return x.useEffect(()=>{const l=a.current;if(l)return p1(l)},[]),o.jsx(Ea,{...s,ref:u,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Pe(s.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Ab=x.forwardRef((s,n)=>{const r=Zn(Kt,s.__scopeMenu);return o.jsx(Ea,{...s,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Pb=ta("MenuContent.ScrollLock"),Ea=x.forwardRef((s,n)=>{const{__scopeMenu:r,loop:a=!1,trapFocus:u,onOpenAutoFocus:l,onCloseAutoFocus:m,disableOutsidePointerEvents:b,onEntryFocus:h,onEscapeKeyDown:d,onPointerDownOutside:p,onFocusOutside:_,onInteractOutside:y,onDismiss:w,disableOutsideScroll:S,...P}=s,N=Zn(Kt,r),I=is(Kt,r),L=vi(r),k=vd(r),B=Eb(r),[Y,T]=x.useState(null),F=x.useRef(null),z=Pt(n,F,N.onContentChange),D=x.useRef(0),te=x.useRef(""),U=x.useRef(0),M=x.useRef(null),G=x.useRef("right"),H=x.useRef(0),Z=S?g1:x.Fragment,Q=S?{as:Pb,allowPinchZoom:!0}:void 0,ee=ne=>{const A=te.current+ne,$=B().filter(Le=>!Le.disabled),re=document.activeElement,le=$.find(Le=>Le.ref.current===re)?.textValue,ve=$.map(Le=>Le.textValue),xe=Hb(ve,A,le),Ue=$.find(Le=>Le.textValue===xe)?.ref.current;(function Le(_e){te.current=_e,window.clearTimeout(D.current),_e!==""&&(D.current=window.setTimeout(()=>Le(""),1e3))})(A),Ue&&setTimeout(()=>Ue.focus())};x.useEffect(()=>()=>window.clearTimeout(D.current),[]),m1();const ie=x.useCallback(ne=>G.current===M.current?.side&&qb(ne,M.current?.area),[]);return o.jsx(kb,{scope:r,searchRef:te,onItemEnter:x.useCallback(ne=>{ie(ne)&&ne.preventDefault()},[ie]),onItemLeave:x.useCallback(ne=>{ie(ne)||(F.current?.focus(),T(null))},[ie]),onTriggerLeave:x.useCallback(ne=>{ie(ne)&&ne.preventDefault()},[ie]),pointerGraceTimerRef:U,onPointerGraceIntentChange:x.useCallback(ne=>{M.current=ne},[]),children:o.jsx(Z,{...Q,children:o.jsx(x1,{asChild:!0,trapped:u,onMountAutoFocus:Pe(l,ne=>{ne.preventDefault(),F.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:m,children:o.jsx(Lv,{asChild:!0,disableOutsidePointerEvents:b,onEscapeKeyDown:d,onPointerDownOutside:p,onFocusOutside:_,onInteractOutside:y,onDismiss:w,children:o.jsx(md,{asChild:!0,...k,dir:I.dir,orientation:"vertical",loop:a,currentTabStopId:Y,onCurrentTabStopIdChange:T,onEntryFocus:Pe(h,ne=>{I.isUsingKeyboardRef.current||ne.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(Ov,{role:"menu","aria-orientation":"vertical","data-state":Bd(N.open),"data-radix-menu-content":"",dir:I.dir,...L,...P,ref:z,style:{outline:"none",...P.style},onKeyDown:Pe(P.onKeyDown,ne=>{const $=ne.target.closest("[data-radix-menu-content]")===ne.currentTarget,re=ne.ctrlKey||ne.altKey||ne.metaKey,le=ne.key.length===1;$&&(ne.key==="Tab"&&ne.preventDefault(),!re&&le&&ee(ne.key));const ve=F.current;if(ne.target!==ve||!bb.includes(ne.key))return;ne.preventDefault();const Ue=B().filter(Le=>!Le.disabled).map(Le=>Le.ref.current);xd.includes(ne.key)&&Ue.reverse(),Wb(Ue)}),onBlur:Pe(s.onBlur,ne=>{ne.currentTarget.contains(ne.target)||(window.clearTimeout(D.current),te.current="")}),onPointerMove:Pe(s.onPointerMove,es(ne=>{const A=ne.target,$=H.current!==ne.clientX;if(ne.currentTarget.contains(A)&&$){const re=ne.clientX>H.current?"right":"left";G.current=re,H.current=ne.clientX}}))})})})})})})});Ed.displayName=Kt;var Mb="MenuGroup",Sa=x.forwardRef((s,n)=>{const{__scopeMenu:r,...a}=s;return o.jsx(gt.div,{role:"group",...a,ref:n})});Sa.displayName=Mb;var Db="MenuLabel",Sd=x.forwardRef((s,n)=>{const{__scopeMenu:r,...a}=s;return o.jsx(gt.div,{...a,ref:n})});Sd.displayName=Db;var di="MenuItem",_u="menu.itemSelect",bi=x.forwardRef((s,n)=>{const{disabled:r=!1,onSelect:a,...u}=s,l=x.useRef(null),m=is(di,s.__scopeMenu),b=wa(di,s.__scopeMenu),h=Pt(n,l),d=x.useRef(!1),p=()=>{const _=l.current;if(!r&&_){const y=new CustomEvent(_u,{bubbles:!0,cancelable:!0});_.addEventListener(_u,w=>a?.(w),{once:!0}),Iv(_,y),y.defaultPrevented?d.current=!1:m.onClose()}};return o.jsx(Cd,{...u,ref:h,disabled:r,onClick:Pe(s.onClick,p),onPointerDown:_=>{s.onPointerDown?.(_),d.current=!0},onPointerUp:Pe(s.onPointerUp,_=>{d.current||_.currentTarget?.click()}),onKeyDown:Pe(s.onKeyDown,_=>{const y=b.searchRef.current!=="";r||y&&_.key===" "||aa.includes(_.key)&&(_.currentTarget.click(),_.preventDefault())})})});bi.displayName=di;var Cd=x.forwardRef((s,n)=>{const{__scopeMenu:r,disabled:a=!1,textValue:u,...l}=s,m=wa(di,r),b=vd(r),h=x.useRef(null),d=Pt(n,h),[p,_]=x.useState(!1),[y,w]=x.useState("");return x.useEffect(()=>{const S=h.current;S&&w((S.textContent??"").trim())},[l.children]),o.jsx(Zr.ItemSlot,{scope:r,disabled:a,textValue:u??y,children:o.jsx(gd,{asChild:!0,...b,focusable:!a,children:o.jsx(gt.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...l,ref:d,onPointerMove:Pe(s.onPointerMove,es(S=>{a?m.onItemLeave(S):(m.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(s.onPointerLeave,es(S=>m.onItemLeave(S))),onFocus:Pe(s.onFocus,()=>_(!0)),onBlur:Pe(s.onBlur,()=>_(!1))})})})}),Ib="MenuCheckboxItem",Nd=x.forwardRef((s,n)=>{const{checked:r=!1,onCheckedChange:a,...u}=s;return o.jsx(Ad,{scope:s.__scopeMenu,checked:r,children:o.jsx(bi,{role:"menuitemcheckbox","aria-checked":fi(r)?"mixed":r,...u,ref:n,"data-state":Na(r),onSelect:Pe(u.onSelect,()=>a?.(fi(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Nd.displayName=Ib;var Rd="MenuRadioGroup",[Lb,Ob]=Jn(Rd,{value:void 0,onValueChange:()=>{}}),Td=x.forwardRef((s,n)=>{const{value:r,onValueChange:a,...u}=s,l=an(a);return o.jsx(Lb,{scope:s.__scopeMenu,value:r,onValueChange:l,children:o.jsx(Sa,{...u,ref:n})})});Td.displayName=Rd;var kd="MenuRadioItem",jd=x.forwardRef((s,n)=>{const{value:r,...a}=s,u=Ob(kd,s.__scopeMenu),l=r===u.value;return o.jsx(Ad,{scope:s.__scopeMenu,checked:l,children:o.jsx(bi,{role:"menuitemradio","aria-checked":l,...a,ref:n,"data-state":Na(l),onSelect:Pe(a.onSelect,()=>u.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});jd.displayName=kd;var Ca="MenuItemIndicator",[Ad,Fb]=Jn(Ca,{checked:!1}),Pd=x.forwardRef((s,n)=>{const{__scopeMenu:r,forceMount:a,...u}=s,l=Fb(Ca,r);return o.jsx(Cn,{present:a||fi(l.checked)||l.checked===!0,children:o.jsx(gt.span,{...u,ref:n,"data-state":Na(l.checked)})})});Pd.displayName=Ca;var Bb="MenuSeparator",Md=x.forwardRef((s,n)=>{const{__scopeMenu:r,...a}=s;return o.jsx(gt.div,{role:"separator","aria-orientation":"horizontal",...a,ref:n})});Md.displayName=Bb;var Ub="MenuArrow",Dd=x.forwardRef((s,n)=>{const{__scopeMenu:r,...a}=s,u=vi(r);return o.jsx(Fv,{...u,...a,ref:n})});Dd.displayName=Ub;var Gb="MenuSub",[CE,Id]=Jn(Gb),Xr="MenuSubTrigger",Ld=x.forwardRef((s,n)=>{const r=Zn(Xr,s.__scopeMenu),a=is(Xr,s.__scopeMenu),u=Id(Xr,s.__scopeMenu),l=wa(Xr,s.__scopeMenu),m=x.useRef(null),{pointerGraceTimerRef:b,onPointerGraceIntentChange:h}=l,d={__scopeMenu:s.__scopeMenu},p=x.useCallback(()=>{m.current&&window.clearTimeout(m.current),m.current=null},[]);return x.useEffect(()=>p,[p]),x.useEffect(()=>{const _=b.current;return()=>{window.clearTimeout(_),h(null)}},[b,h]),o.jsx(ba,{asChild:!0,...d,children:o.jsx(Cd,{id:u.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":u.contentId,"data-state":Bd(r.open),...s,ref:Hu(n,u.onTriggerChange),onClick:_=>{s.onClick?.(_),!(s.disabled||_.defaultPrevented)&&(_.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Pe(s.onPointerMove,es(_=>{l.onItemEnter(_),!_.defaultPrevented&&!s.disabled&&!r.open&&!m.current&&(l.onPointerGraceIntentChange(null),m.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Pe(s.onPointerLeave,es(_=>{p();const y=r.content?.getBoundingClientRect();if(y){const w=r.content?.dataset.side,S=w==="right",P=S?-5:5,N=y[S?"left":"right"],I=y[S?"right":"left"];l.onPointerGraceIntentChange({area:[{x:_.clientX+P,y:_.clientY},{x:N,y:y.top},{x:I,y:y.top},{x:I,y:y.bottom},{x:N,y:y.bottom}],side:w}),window.clearTimeout(b.current),b.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(_),_.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(s.onKeyDown,_=>{const y=l.searchRef.current!=="";s.disabled||y&&_.key===" "||yb[a.dir].includes(_.key)&&(r.onOpenChange(!0),r.content?.focus(),_.preventDefault())})})})});Ld.displayName=Xr;var Od="MenuSubContent",Fd=x.forwardRef((s,n)=>{const r=yd(Kt,s.__scopeMenu),{forceMount:a=r.forceMount,...u}=s,l=Zn(Kt,s.__scopeMenu),m=is(Kt,s.__scopeMenu),b=Id(Od,s.__scopeMenu),h=x.useRef(null),d=Pt(n,h);return o.jsx(Zr.Provider,{scope:s.__scopeMenu,children:o.jsx(Cn,{present:a||l.open,children:o.jsx(Zr.Slot,{scope:s.__scopeMenu,children:o.jsx(Ea,{id:b.contentId,"aria-labelledby":b.triggerId,...u,ref:d,align:"start",side:m.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{m.isUsingKeyboardRef.current&&h.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Pe(s.onFocusOutside,p=>{p.target!==b.trigger&&l.onOpenChange(!1)}),onEscapeKeyDown:Pe(s.onEscapeKeyDown,p=>{m.onClose(),p.preventDefault()}),onKeyDown:Pe(s.onKeyDown,p=>{const _=p.currentTarget.contains(p.target),y=wb[m.dir].includes(p.key);_&&y&&(l.onOpenChange(!1),b.trigger?.focus(),p.preventDefault())})})})})})});Fd.displayName=Od;function Bd(s){return s?"open":"closed"}function fi(s){return s==="indeterminate"}function Na(s){return fi(s)?"indeterminate":s?"checked":"unchecked"}function Wb(s){const n=document.activeElement;for(const r of s)if(r===n||(r.focus(),document.activeElement!==n))return}function zb(s,n){return s.map((r,a)=>s[(n+a)%s.length])}function Hb(s,n,r){const u=n.length>1&&Array.from(n).every(d=>d===n[0])?n[0]:n,l=r?s.indexOf(r):-1;let m=zb(s,Math.max(l,0));u.length===1&&(m=m.filter(d=>d!==r));const h=m.find(d=>d.toLowerCase().startsWith(u.toLowerCase()));return h!==r?h:void 0}function $b(s,n){const{x:r,y:a}=s;let u=!1;for(let l=0,m=n.length-1;l<n.length;m=l++){const b=n[l],h=n[m],d=b.x,p=b.y,_=h.x,y=h.y;p>a!=y>a&&r<(_-d)*(a-p)/(y-p)+d&&(u=!u)}return u}function qb(s,n){if(!n)return!1;const r={x:s.clientX,y:s.clientY};return $b(r,n)}function es(s){return n=>n.pointerType==="mouse"?s(n):void 0}var Xb=bd,Yb=ba,Kb=wd,Vb=Ed,Qb=Sa,Jb=Sd,Zb=bi,ey=Nd,ty=Td,ny=jd,ry=Pd,sy=Md,iy=Dd,oy=Ld,ay=Fd,yi="DropdownMenu",[ly]=Sr(yi,[_d]),Nt=_d(),[cy,Ud]=ly(yi),Gd=s=>{const{__scopeDropdownMenu:n,children:r,dir:a,open:u,defaultOpen:l,onOpenChange:m,modal:b=!0}=s,h=Nt(n),d=x.useRef(null),[p,_]=ga({prop:u,defaultProp:l??!1,onChange:m,caller:yi});return o.jsx(cy,{scope:n,triggerId:ii(),triggerRef:d,contentId:ii(),open:p,onOpenChange:_,onOpenToggle:x.useCallback(()=>_(y=>!y),[_]),modal:b,children:o.jsx(Xb,{...h,open:p,onOpenChange:_,dir:a,modal:b,children:r})})};Gd.displayName=yi;var Wd="DropdownMenuTrigger",zd=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,disabled:a=!1,...u}=s,l=Ud(Wd,r),m=Nt(r);return o.jsx(Yb,{asChild:!0,...m,children:o.jsx(gt.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...u,ref:Hu(n,l.triggerRef),onPointerDown:Pe(s.onPointerDown,b=>{!a&&b.button===0&&b.ctrlKey===!1&&(l.onOpenToggle(),l.open||b.preventDefault())}),onKeyDown:Pe(s.onKeyDown,b=>{a||(["Enter"," "].includes(b.key)&&l.onOpenToggle(),b.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(b.key)&&b.preventDefault())})})})});zd.displayName=Wd;var uy="DropdownMenuPortal",Hd=s=>{const{__scopeDropdownMenu:n,...r}=s,a=Nt(n);return o.jsx(Kb,{...a,...r})};Hd.displayName=uy;var $d="DropdownMenuContent",qd=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Ud($d,r),l=Nt(r),m=x.useRef(!1);return o.jsx(Vb,{id:u.contentId,"aria-labelledby":u.triggerId,...l,...a,ref:n,onCloseAutoFocus:Pe(s.onCloseAutoFocus,b=>{m.current||u.triggerRef.current?.focus(),m.current=!1,b.preventDefault()}),onInteractOutside:Pe(s.onInteractOutside,b=>{const h=b.detail.originalEvent,d=h.button===0&&h.ctrlKey===!0,p=h.button===2||d;(!u.modal||p)&&(m.current=!0)}),style:{...s.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qd.displayName=$d;var dy="DropdownMenuGroup",fy=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(Qb,{...u,...a,ref:n})});fy.displayName=dy;var hy="DropdownMenuLabel",py=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(Jb,{...u,...a,ref:n})});py.displayName=hy;var my="DropdownMenuItem",Xd=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(Zb,{...u,...a,ref:n})});Xd.displayName=my;var gy="DropdownMenuCheckboxItem",xy=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(ey,{...u,...a,ref:n})});xy.displayName=gy;var _y="DropdownMenuRadioGroup",vy=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(ty,{...u,...a,ref:n})});vy.displayName=_y;var by="DropdownMenuRadioItem",yy=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(ny,{...u,...a,ref:n})});yy.displayName=by;var wy="DropdownMenuItemIndicator",Ey=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(ry,{...u,...a,ref:n})});Ey.displayName=wy;var Sy="DropdownMenuSeparator",Cy=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(sy,{...u,...a,ref:n})});Cy.displayName=Sy;var Ny="DropdownMenuArrow",Ry=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(iy,{...u,...a,ref:n})});Ry.displayName=Ny;var Ty="DropdownMenuSubTrigger",ky=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(oy,{...u,...a,ref:n})});ky.displayName=Ty;var jy="DropdownMenuSubContent",Ay=x.forwardRef((s,n)=>{const{__scopeDropdownMenu:r,...a}=s,u=Nt(r);return o.jsx(ay,{...u,...a,ref:n,style:{...s.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ay.displayName=jy;var Py=Gd,My=zd,Dy=Hd,Iy=qd,Ly=Xd;function Oy(s,[n,r]){return Math.min(r,Math.max(n,s))}function Fy(s,n){return x.useReducer((r,a)=>n[r][a]??r,s)}var Ra="ScrollArea",[Yd]=Sr(Ra),[By,Vt]=Yd(Ra),Kd=x.forwardRef((s,n)=>{const{__scopeScrollArea:r,type:a="hover",dir:u,scrollHideDelay:l=600,...m}=s,[b,h]=x.useState(null),[d,p]=x.useState(null),[_,y]=x.useState(null),[w,S]=x.useState(null),[P,N]=x.useState(null),[I,L]=x.useState(0),[k,B]=x.useState(0),[Y,T]=x.useState(!1),[F,z]=x.useState(!1),D=Pt(n,U=>h(U)),te=xi(u);return o.jsx(By,{scope:r,type:a,dir:te,scrollHideDelay:l,scrollArea:b,viewport:d,onViewportChange:p,content:_,onContentChange:y,scrollbarX:w,onScrollbarXChange:S,scrollbarXEnabled:Y,onScrollbarXEnabledChange:T,scrollbarY:P,onScrollbarYChange:N,scrollbarYEnabled:F,onScrollbarYEnabledChange:z,onCornerWidthChange:L,onCornerHeightChange:B,children:o.jsx(gt.div,{dir:te,...m,ref:D,style:{position:"relative","--radix-scroll-area-corner-width":I+"px","--radix-scroll-area-corner-height":k+"px",...s.style}})})});Kd.displayName=Ra;var Vd="ScrollAreaViewport",Qd=x.forwardRef((s,n)=>{const{__scopeScrollArea:r,children:a,nonce:u,...l}=s,m=Vt(Vd,r),b=x.useRef(null),h=Pt(n,b,m.onViewportChange);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:u}),o.jsx(gt.div,{"data-radix-scroll-area-viewport":"",...l,ref:h,style:{overflowX:m.scrollbarXEnabled?"scroll":"hidden",overflowY:m.scrollbarYEnabled?"scroll":"hidden",...s.style},children:o.jsx("div",{ref:m.onContentChange,style:{minWidth:"100%",display:"table"},children:a})})]})});Qd.displayName=Vd;var mn="ScrollAreaScrollbar",Jd=x.forwardRef((s,n)=>{const{forceMount:r,...a}=s,u=Vt(mn,s.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:m}=u,b=s.orientation==="horizontal";return x.useEffect(()=>(b?l(!0):m(!0),()=>{b?l(!1):m(!1)}),[b,l,m]),u.type==="hover"?o.jsx(Uy,{...a,ref:n,forceMount:r}):u.type==="scroll"?o.jsx(Gy,{...a,ref:n,forceMount:r}):u.type==="auto"?o.jsx(Zd,{...a,ref:n,forceMount:r}):u.type==="always"?o.jsx(Ta,{...a,ref:n}):null});Jd.displayName=mn;var Uy=x.forwardRef((s,n)=>{const{forceMount:r,...a}=s,u=Vt(mn,s.__scopeScrollArea),[l,m]=x.useState(!1);return x.useEffect(()=>{const b=u.scrollArea;let h=0;if(b){const d=()=>{window.clearTimeout(h),m(!0)},p=()=>{h=window.setTimeout(()=>m(!1),u.scrollHideDelay)};return b.addEventListener("pointerenter",d),b.addEventListener("pointerleave",p),()=>{window.clearTimeout(h),b.removeEventListener("pointerenter",d),b.removeEventListener("pointerleave",p)}}},[u.scrollArea,u.scrollHideDelay]),o.jsx(Cn,{present:r||l,children:o.jsx(Zd,{"data-state":l?"visible":"hidden",...a,ref:n})})}),Gy=x.forwardRef((s,n)=>{const{forceMount:r,...a}=s,u=Vt(mn,s.__scopeScrollArea),l=s.orientation==="horizontal",m=Ei(()=>h("SCROLL_END"),100),[b,h]=Fy("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return x.useEffect(()=>{if(b==="idle"){const d=window.setTimeout(()=>h("HIDE"),u.scrollHideDelay);return()=>window.clearTimeout(d)}},[b,u.scrollHideDelay,h]),x.useEffect(()=>{const d=u.viewport,p=l?"scrollLeft":"scrollTop";if(d){let _=d[p];const y=()=>{const w=d[p];_!==w&&(h("SCROLL"),m()),_=w};return d.addEventListener("scroll",y),()=>d.removeEventListener("scroll",y)}},[u.viewport,l,h,m]),o.jsx(Cn,{present:r||b!=="hidden",children:o.jsx(Ta,{"data-state":b==="hidden"?"hidden":"visible",...a,ref:n,onPointerEnter:Pe(s.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:Pe(s.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),Zd=x.forwardRef((s,n)=>{const r=Vt(mn,s.__scopeScrollArea),{forceMount:a,...u}=s,[l,m]=x.useState(!1),b=s.orientation==="horizontal",h=Ei(()=>{if(r.viewport){const d=r.viewport.offsetWidth<r.viewport.scrollWidth,p=r.viewport.offsetHeight<r.viewport.scrollHeight;m(b?d:p)}},10);return Er(r.viewport,h),Er(r.content,h),o.jsx(Cn,{present:a||l,children:o.jsx(Ta,{"data-state":l?"visible":"hidden",...u,ref:n})})}),Ta=x.forwardRef((s,n)=>{const{orientation:r="vertical",...a}=s,u=Vt(mn,s.__scopeScrollArea),l=x.useRef(null),m=x.useRef(0),[b,h]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=sf(b.viewport,b.content),p={...a,sizes:b,onSizesChange:h,hasThumb:d>0&&d<1,onThumbChange:y=>l.current=y,onThumbPointerUp:()=>m.current=0,onThumbPointerDown:y=>m.current=y};function _(y,w){return Xy(y,m.current,b,w)}return r==="horizontal"?o.jsx(Wy,{...p,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const y=u.viewport.scrollLeft,w=vu(y,b,u.dir);l.current.style.transform=`translate3d(${w}px, 0, 0)`}},onWheelScroll:y=>{u.viewport&&(u.viewport.scrollLeft=y)},onDragScroll:y=>{u.viewport&&(u.viewport.scrollLeft=_(y,u.dir))}}):r==="vertical"?o.jsx(zy,{...p,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const y=u.viewport.scrollTop,w=vu(y,b);l.current.style.transform=`translate3d(0, ${w}px, 0)`}},onWheelScroll:y=>{u.viewport&&(u.viewport.scrollTop=y)},onDragScroll:y=>{u.viewport&&(u.viewport.scrollTop=_(y))}}):null}),Wy=x.forwardRef((s,n)=>{const{sizes:r,onSizesChange:a,...u}=s,l=Vt(mn,s.__scopeScrollArea),[m,b]=x.useState(),h=x.useRef(null),d=Pt(n,h,l.onScrollbarXChange);return x.useEffect(()=>{h.current&&b(getComputedStyle(h.current))},[h]),o.jsx(tf,{"data-orientation":"horizontal",...u,ref:d,sizes:r,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":wi(r)+"px",...s.style},onThumbPointerDown:p=>s.onThumbPointerDown(p.x),onDragScroll:p=>s.onDragScroll(p.x),onWheelScroll:(p,_)=>{if(l.viewport){const y=l.viewport.scrollLeft+p.deltaX;s.onWheelScroll(y),af(y,_)&&p.preventDefault()}},onResize:()=>{h.current&&l.viewport&&m&&a({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:pi(m.paddingLeft),paddingEnd:pi(m.paddingRight)}})}})}),zy=x.forwardRef((s,n)=>{const{sizes:r,onSizesChange:a,...u}=s,l=Vt(mn,s.__scopeScrollArea),[m,b]=x.useState(),h=x.useRef(null),d=Pt(n,h,l.onScrollbarYChange);return x.useEffect(()=>{h.current&&b(getComputedStyle(h.current))},[h]),o.jsx(tf,{"data-orientation":"vertical",...u,ref:d,sizes:r,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":wi(r)+"px",...s.style},onThumbPointerDown:p=>s.onThumbPointerDown(p.y),onDragScroll:p=>s.onDragScroll(p.y),onWheelScroll:(p,_)=>{if(l.viewport){const y=l.viewport.scrollTop+p.deltaY;s.onWheelScroll(y),af(y,_)&&p.preventDefault()}},onResize:()=>{h.current&&l.viewport&&m&&a({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:pi(m.paddingTop),paddingEnd:pi(m.paddingBottom)}})}})}),[Hy,ef]=Yd(mn),tf=x.forwardRef((s,n)=>{const{__scopeScrollArea:r,sizes:a,hasThumb:u,onThumbChange:l,onThumbPointerUp:m,onThumbPointerDown:b,onThumbPositionChange:h,onDragScroll:d,onWheelScroll:p,onResize:_,...y}=s,w=Vt(mn,r),[S,P]=x.useState(null),N=Pt(n,D=>P(D)),I=x.useRef(null),L=x.useRef(""),k=w.viewport,B=a.content-a.viewport,Y=an(p),T=an(h),F=Ei(_,10);function z(D){if(I.current){const te=D.clientX-I.current.left,U=D.clientY-I.current.top;d({x:te,y:U})}}return x.useEffect(()=>{const D=te=>{const U=te.target;S?.contains(U)&&Y(te,B)};return document.addEventListener("wheel",D,{passive:!1}),()=>document.removeEventListener("wheel",D,{passive:!1})},[k,S,B,Y]),x.useEffect(T,[a,T]),Er(S,F),Er(w.content,F),o.jsx(Hy,{scope:r,scrollbar:S,hasThumb:u,onThumbChange:an(l),onThumbPointerUp:an(m),onThumbPositionChange:T,onThumbPointerDown:an(b),children:o.jsx(gt.div,{...y,ref:N,style:{position:"absolute",...y.style},onPointerDown:Pe(s.onPointerDown,D=>{D.button===0&&(D.target.setPointerCapture(D.pointerId),I.current=S.getBoundingClientRect(),L.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),z(D))}),onPointerMove:Pe(s.onPointerMove,z),onPointerUp:Pe(s.onPointerUp,D=>{const te=D.target;te.hasPointerCapture(D.pointerId)&&te.releasePointerCapture(D.pointerId),document.body.style.webkitUserSelect=L.current,w.viewport&&(w.viewport.style.scrollBehavior=""),I.current=null})})})}),hi="ScrollAreaThumb",nf=x.forwardRef((s,n)=>{const{forceMount:r,...a}=s,u=ef(hi,s.__scopeScrollArea);return o.jsx(Cn,{present:r||u.hasThumb,children:o.jsx($y,{ref:n,...a})})}),$y=x.forwardRef((s,n)=>{const{__scopeScrollArea:r,style:a,...u}=s,l=Vt(hi,r),m=ef(hi,r),{onThumbPositionChange:b}=m,h=Pt(n,_=>m.onThumbChange(_)),d=x.useRef(void 0),p=Ei(()=>{d.current&&(d.current(),d.current=void 0)},100);return x.useEffect(()=>{const _=l.viewport;if(_){const y=()=>{if(p(),!d.current){const w=Yy(_,b);d.current=w,b()}};return b(),_.addEventListener("scroll",y),()=>_.removeEventListener("scroll",y)}},[l.viewport,p,b]),o.jsx(gt.div,{"data-state":m.hasThumb?"visible":"hidden",...u,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...a},onPointerDownCapture:Pe(s.onPointerDownCapture,_=>{const w=_.target.getBoundingClientRect(),S=_.clientX-w.left,P=_.clientY-w.top;m.onThumbPointerDown({x:S,y:P})}),onPointerUp:Pe(s.onPointerUp,m.onThumbPointerUp)})});nf.displayName=hi;var ka="ScrollAreaCorner",rf=x.forwardRef((s,n)=>{const r=Vt(ka,s.__scopeScrollArea),a=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&a?o.jsx(qy,{...s,ref:n}):null});rf.displayName=ka;var qy=x.forwardRef((s,n)=>{const{__scopeScrollArea:r,...a}=s,u=Vt(ka,r),[l,m]=x.useState(0),[b,h]=x.useState(0),d=!!(l&&b);return Er(u.scrollbarX,()=>{const p=u.scrollbarX?.offsetHeight||0;u.onCornerHeightChange(p),h(p)}),Er(u.scrollbarY,()=>{const p=u.scrollbarY?.offsetWidth||0;u.onCornerWidthChange(p),m(p)}),d?o.jsx(gt.div,{...a,ref:n,style:{width:l,height:b,position:"absolute",right:u.dir==="ltr"?0:void 0,left:u.dir==="rtl"?0:void 0,bottom:0,...s.style}}):null});function pi(s){return s?parseInt(s,10):0}function sf(s,n){const r=s/n;return isNaN(r)?0:r}function wi(s){const n=sf(s.viewport,s.content),r=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,a=(s.scrollbar.size-r)*n;return Math.max(a,18)}function Xy(s,n,r,a="ltr"){const u=wi(r),l=u/2,m=n||l,b=u-m,h=r.scrollbar.paddingStart+m,d=r.scrollbar.size-r.scrollbar.paddingEnd-b,p=r.content-r.viewport,_=a==="ltr"?[0,p]:[p*-1,0];return of([h,d],_)(s)}function vu(s,n,r="ltr"){const a=wi(n),u=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,l=n.scrollbar.size-u,m=n.content-n.viewport,b=l-a,h=r==="ltr"?[0,m]:[m*-1,0],d=Oy(s,h);return of([0,m],[0,b])(d)}function of(s,n){return r=>{if(s[0]===s[1]||n[0]===n[1])return n[0];const a=(n[1]-n[0])/(s[1]-s[0]);return n[0]+a*(r-s[0])}}function af(s,n){return s>0&&s<n}var Yy=(s,n=()=>{})=>{let r={left:s.scrollLeft,top:s.scrollTop},a=0;return(function u(){const l={left:s.scrollLeft,top:s.scrollTop},m=r.left!==l.left,b=r.top!==l.top;(m||b)&&n(),r=l,a=window.requestAnimationFrame(u)})(),()=>window.cancelAnimationFrame(a)};function Ei(s,n){const r=an(s),a=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(a.current),[]),x.useCallback(()=>{window.clearTimeout(a.current),a.current=window.setTimeout(r,n)},[r,n])}function Er(s,n){const r=an(n);Bv(()=>{let a=0;if(s){const u=new ResizeObserver(()=>{cancelAnimationFrame(a),a=window.requestAnimationFrame(r)});return u.observe(s),()=>{window.cancelAnimationFrame(a),u.unobserve(s)}}},[s,r])}var Ky=Kd,Vy=Qd,Qy=rf,Si="Tabs",[Jy]=Sr(Si,[_i]),lf=_i(),[Zy,ja]=Jy(Si),cf=x.forwardRef((s,n)=>{const{__scopeTabs:r,value:a,onValueChange:u,defaultValue:l,orientation:m="horizontal",dir:b,activationMode:h="automatic",...d}=s,p=xi(b),[_,y]=ga({prop:a,onChange:u,defaultProp:l??"",caller:Si});return o.jsx(Zy,{scope:r,baseId:ii(),value:_,onValueChange:y,orientation:m,dir:p,activationMode:h,children:o.jsx(gt.div,{dir:p,"data-orientation":m,...d,ref:n})})});cf.displayName=Si;var uf="TabsList",df=x.forwardRef((s,n)=>{const{__scopeTabs:r,loop:a=!0,...u}=s,l=ja(uf,r),m=lf(r);return o.jsx(md,{asChild:!0,...m,orientation:l.orientation,dir:l.dir,loop:a,children:o.jsx(gt.div,{role:"tablist","aria-orientation":l.orientation,...u,ref:n})})});df.displayName=uf;var ff="TabsTrigger",hf=x.forwardRef((s,n)=>{const{__scopeTabs:r,value:a,disabled:u=!1,...l}=s,m=ja(ff,r),b=lf(r),h=gf(m.baseId,a),d=xf(m.baseId,a),p=a===m.value;return o.jsx(gd,{asChild:!0,...b,focusable:!u,active:p,children:o.jsx(gt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":d,"data-state":p?"active":"inactive","data-disabled":u?"":void 0,disabled:u,id:h,...l,ref:n,onMouseDown:Pe(s.onMouseDown,_=>{!u&&_.button===0&&_.ctrlKey===!1?m.onValueChange(a):_.preventDefault()}),onKeyDown:Pe(s.onKeyDown,_=>{[" ","Enter"].includes(_.key)&&m.onValueChange(a)}),onFocus:Pe(s.onFocus,()=>{const _=m.activationMode!=="manual";!p&&!u&&_&&m.onValueChange(a)})})})});hf.displayName=ff;var pf="TabsContent",mf=x.forwardRef((s,n)=>{const{__scopeTabs:r,value:a,forceMount:u,children:l,...m}=s,b=ja(pf,r),h=gf(b.baseId,a),d=xf(b.baseId,a),p=a===b.value,_=x.useRef(p);return x.useEffect(()=>{const y=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(y)},[]),o.jsx(Cn,{present:u||p,children:({present:y})=>o.jsx(gt.div,{"data-state":p?"active":"inactive","data-orientation":b.orientation,role:"tabpanel","aria-labelledby":h,hidden:!y,id:d,tabIndex:0,...m,ref:n,style:{...s.style,animationDuration:_.current?"0s":void 0},children:y&&l})})});mf.displayName=pf;function gf(s,n){return`${s}-trigger-${n}`}function xf(s,n){return`${s}-content-${n}`}var ew=cf,tw=df,nw=hf,rw=mf;function sw({...s}){return o.jsx(Py,{"data-slot":"dropdown-menu",...s})}function iw({...s}){return o.jsx(My,{"data-slot":"dropdown-menu-trigger",...s})}function ow({className:s,sideOffset:n=4,...r}){return o.jsx(Dy,{children:o.jsx(Iy,{"data-slot":"dropdown-menu-content",sideOffset:n,className:Ln("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",s),...r})})}function aw({className:s,inset:n,variant:r="default",...a}){return o.jsx(Ly,{"data-slot":"dropdown-menu-item","data-inset":n,"data-variant":r,className:Ln("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),...a})}const _f="device-group-collapsed";function lw(){try{const s=localStorage.getItem(_f);return s?JSON.parse(s):{}}catch{return{}}}function cw({devices:s,groups:n,currentDeviceId:r,onSelectDevice:a,onConnectWifi:u,onDisconnectWifi:l,onRefreshDevices:m,onRefreshGroups:b,showToast:h}){const d=pn(),[p,_]=x.useState(lw),[y,w]=x.useState(null);x.useEffect(()=>{localStorage.setItem(_f,JSON.stringify(p))},[p]);const S=Ke.useMemo(()=>{const L=new Map;for(const k of n)L.set(k.id,[]);for(const k of s){const B=k.group_id||"default",Y=L.get(B)||[];Y.push(k),L.set(B,Y)}return L},[s,n]),P=L=>{_(k=>({...k,[L]:!k[L]}))},N=async(L,k)=>{w(L);try{const B=await Uv(L,k);B.success?(m&&m(),b&&b(),h&&h(d.deviceGroups?.deviceMoved||"设备已移动","success")):h&&h(B.message||d.deviceGroups?.moveFailed||"移动失败","error")}catch(B){console.error("Failed to move device:",B),h&&h(d.deviceGroups?.moveFailed||"移动失败","error")}finally{w(null)}},I=Ke.useMemo(()=>[...n].sort((L,k)=>L.order-k.order),[n]);return o.jsx("div",{className:"space-y-2",children:I.map(L=>{const k=S.get(L.id)||[],B=p[L.id]||!1,Y=k.length;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("button",{onClick:()=>P(L.id),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors text-left",children:[B?o.jsx(va,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}):o.jsx(ed,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),o.jsx(na,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),o.jsx("span",{className:"flex-1 text-sm font-medium text-slate-700 dark:text-slate-300 truncate",children:L.name}),o.jsxs("span",{className:"text-xs text-slate-400 dark:text-slate-500",children:["(",Y,")"]})]}),!B&&o.jsx("div",{className:"pl-2 space-y-1",children:k.length===0?o.jsx("div",{className:"px-4 py-3 text-xs text-slate-400 dark:text-slate-500 italic",children:d.deviceGroups?.noDevicesInGroup||"该分组暂无设备"}):k.map(T=>o.jsxs("div",{className:"group/card relative flex items-center gap-1",children:[o.jsxs(sw,{children:[o.jsx(iw,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover/card:opacity-100 transition-opacity flex-shrink-0 text-slate-400 hover:text-slate-600",disabled:y===T.serial,children:o.jsx(sd,{className:"w-3.5 h-3.5"})})}),o.jsxs(ow,{align:"start",className:"w-48",children:[o.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-slate-500",children:d.deviceGroups?.moveTo||"移动到分组"}),I.map(F=>o.jsxs(aw,{disabled:F.id===T.group_id,onClick:()=>N(T.serial,F.id),className:F.id===T.group_id?"opacity-50":"",children:[o.jsx(na,{className:"w-4 h-4 mr-2"}),F.name,F.id===T.group_id&&o.jsx("span",{className:"ml-auto text-xs text-slate-400",children:d.deviceGroups?.currentGroup||"当前"})]},F.id))]})]}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(ab,{id:T.id,serial:T.serial,model:T.model,displayName:T.display_name,status:T.status,connectionType:T.connection_type,agent:T.agent,isActive:r===T.id,onClick:()=>a(T.id),onConnectWifi:async()=>{await u(T.id)},onDisconnectWifi:async()=>{await l(T.id)},onNameUpdated:()=>{m&&m()},showToast:h})})]},T.id))})]},L.id)})})}function vf({className:s,...n}){return o.jsx(ew,{"data-slot":"tabs",className:Ln("flex flex-col gap-2",s),...n})}function bf({className:s,...n}){return o.jsx(tw,{"data-slot":"tabs-list",className:Ln("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",s),...n})}function Vr({className:s,...n}){return o.jsx(nw,{"data-slot":"tabs-trigger",className:Ln("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),...n})}function Qr({className:s,...n}){return o.jsx(rw,{"data-slot":"tabs-content",className:Ln("flex-1 outline-none",s),...n})}var uw=Object.defineProperty,mi=Object.getOwnPropertySymbols,yf=Object.prototype.hasOwnProperty,wf=Object.prototype.propertyIsEnumerable,bu=(s,n,r)=>n in s?uw(s,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[n]=r,la=(s,n)=>{for(var r in n||(n={}))yf.call(n,r)&&bu(s,r,n[r]);if(mi)for(var r of mi(n))wf.call(n,r)&&bu(s,r,n[r]);return s},ca=(s,n)=>{var r={};for(var a in s)yf.call(s,a)&&n.indexOf(a)<0&&(r[a]=s[a]);if(s!=null&&mi)for(var a of mi(s))n.indexOf(a)<0&&wf.call(s,a)&&(r[a]=s[a]);return r};var Qn;(s=>{const n=class Be{constructor(h,d,p,_){if(this.version=h,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],h<Be.MIN_VERSION||h>Be.MAX_VERSION)throw new RangeError("Version value out of range");if(_<-1||_>7)throw new RangeError("Mask value out of range");this.size=h*4+17;let y=[];for(let S=0;S<this.size;S++)y.push(!1);for(let S=0;S<this.size;S++)this.modules.push(y.slice()),this.isFunction.push(y.slice());this.drawFunctionPatterns();const w=this.addEccAndInterleave(p);if(this.drawCodewords(w),_==-1){let S=1e9;for(let P=0;P<8;P++){this.applyMask(P),this.drawFormatBits(P);const N=this.getPenaltyScore();N<S&&(_=P,S=N),this.applyMask(P)}}u(0<=_&&_<=7),this.mask=_,this.applyMask(_),this.drawFormatBits(_),this.isFunction=[]}static encodeText(h,d){const p=s.QrSegment.makeSegments(h);return Be.encodeSegments(p,d)}static encodeBinary(h,d){const p=s.QrSegment.makeBytes(h);return Be.encodeSegments([p],d)}static encodeSegments(h,d,p=1,_=40,y=-1,w=!0){if(!(Be.MIN_VERSION<=p&&p<=_&&_<=Be.MAX_VERSION)||y<-1||y>7)throw new RangeError("Invalid value");let S,P;for(S=p;;S++){const k=Be.getNumDataCodewords(S,d)*8,B=m.getTotalBits(h,S);if(B<=k){P=B;break}if(S>=_)throw new RangeError("Data too long")}for(const k of[Be.Ecc.MEDIUM,Be.Ecc.QUARTILE,Be.Ecc.HIGH])w&&P<=Be.getNumDataCodewords(S,k)*8&&(d=k);let N=[];for(const k of h){r(k.mode.modeBits,4,N),r(k.numChars,k.mode.numCharCountBits(S),N);for(const B of k.getData())N.push(B)}u(N.length==P);const I=Be.getNumDataCodewords(S,d)*8;u(N.length<=I),r(0,Math.min(4,I-N.length),N),r(0,(8-N.length%8)%8,N),u(N.length%8==0);for(let k=236;N.length<I;k^=253)r(k,8,N);let L=[];for(;L.length*8<N.length;)L.push(0);return N.forEach((k,B)=>L[B>>>3]|=k<<7-(B&7)),new Be(S,d,L,y)}getModule(h,d){return 0<=h&&h<this.size&&0<=d&&d<this.size&&this.modules[d][h]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const h=this.getAlignmentPatternPositions(),d=h.length;for(let p=0;p<d;p++)for(let _=0;_<d;_++)p==0&&_==0||p==0&&_==d-1||p==d-1&&_==0||this.drawAlignmentPattern(h[p],h[_]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(h){const d=this.errorCorrectionLevel.formatBits<<3|h;let p=d;for(let y=0;y<10;y++)p=p<<1^(p>>>9)*1335;const _=(d<<10|p)^21522;u(_>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,a(_,y));this.setFunctionModule(8,7,a(_,6)),this.setFunctionModule(8,8,a(_,7)),this.setFunctionModule(7,8,a(_,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,a(_,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,a(_,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,a(_,y));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let h=this.version;for(let p=0;p<12;p++)h=h<<1^(h>>>11)*7973;const d=this.version<<12|h;u(d>>>18==0);for(let p=0;p<18;p++){const _=a(d,p),y=this.size-11+p%3,w=Math.floor(p/3);this.setFunctionModule(y,w,_),this.setFunctionModule(w,y,_)}}drawFinderPattern(h,d){for(let p=-4;p<=4;p++)for(let _=-4;_<=4;_++){const y=Math.max(Math.abs(_),Math.abs(p)),w=h+_,S=d+p;0<=w&&w<this.size&&0<=S&&S<this.size&&this.setFunctionModule(w,S,y!=2&&y!=4)}}drawAlignmentPattern(h,d){for(let p=-2;p<=2;p++)for(let _=-2;_<=2;_++)this.setFunctionModule(h+_,d+p,Math.max(Math.abs(_),Math.abs(p))!=1)}setFunctionModule(h,d,p){this.modules[d][h]=p,this.isFunction[d][h]=!0}addEccAndInterleave(h){const d=this.version,p=this.errorCorrectionLevel;if(h.length!=Be.getNumDataCodewords(d,p))throw new RangeError("Invalid argument");const _=Be.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d],y=Be.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d],w=Math.floor(Be.getNumRawDataModules(d)/8),S=_-w%_,P=Math.floor(w/_);let N=[];const I=Be.reedSolomonComputeDivisor(y);for(let k=0,B=0;k<_;k++){let Y=h.slice(B,B+P-y+(k<S?0:1));B+=Y.length;const T=Be.reedSolomonComputeRemainder(Y,I);k<S&&Y.push(0),N.push(Y.concat(T))}let L=[];for(let k=0;k<N[0].length;k++)N.forEach((B,Y)=>{(k!=P-y||Y>=S)&&L.push(B[k])});return u(L.length==w),L}drawCodewords(h){if(h.length!=Math.floor(Be.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let _=0;_<this.size;_++)for(let y=0;y<2;y++){const w=p-y,P=(p+1&2)==0?this.size-1-_:_;!this.isFunction[P][w]&&d<h.length*8&&(this.modules[P][w]=a(h[d>>>3],7-(d&7)),d++)}}u(d==h.length*8)}applyMask(h){if(h<0||h>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let p=0;p<this.size;p++){let _;switch(h){case 0:_=(p+d)%2==0;break;case 1:_=d%2==0;break;case 2:_=p%3==0;break;case 3:_=(p+d)%3==0;break;case 4:_=(Math.floor(p/3)+Math.floor(d/2))%2==0;break;case 5:_=p*d%2+p*d%3==0;break;case 6:_=(p*d%2+p*d%3)%2==0;break;case 7:_=((p+d)%2+p*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][p]&&_&&(this.modules[d][p]=!this.modules[d][p])}}getPenaltyScore(){let h=0;for(let y=0;y<this.size;y++){let w=!1,S=0,P=[0,0,0,0,0,0,0];for(let N=0;N<this.size;N++)this.modules[y][N]==w?(S++,S==5?h+=Be.PENALTY_N1:S>5&&h++):(this.finderPenaltyAddHistory(S,P),w||(h+=this.finderPenaltyCountPatterns(P)*Be.PENALTY_N3),w=this.modules[y][N],S=1);h+=this.finderPenaltyTerminateAndCount(w,S,P)*Be.PENALTY_N3}for(let y=0;y<this.size;y++){let w=!1,S=0,P=[0,0,0,0,0,0,0];for(let N=0;N<this.size;N++)this.modules[N][y]==w?(S++,S==5?h+=Be.PENALTY_N1:S>5&&h++):(this.finderPenaltyAddHistory(S,P),w||(h+=this.finderPenaltyCountPatterns(P)*Be.PENALTY_N3),w=this.modules[N][y],S=1);h+=this.finderPenaltyTerminateAndCount(w,S,P)*Be.PENALTY_N3}for(let y=0;y<this.size-1;y++)for(let w=0;w<this.size-1;w++){const S=this.modules[y][w];S==this.modules[y][w+1]&&S==this.modules[y+1][w]&&S==this.modules[y+1][w+1]&&(h+=Be.PENALTY_N2)}let d=0;for(const y of this.modules)d=y.reduce((w,S)=>w+(S?1:0),d);const p=this.size*this.size,_=Math.ceil(Math.abs(d*20-p*10)/p)-1;return u(0<=_&&_<=9),h+=_*Be.PENALTY_N4,u(0<=h&&h<=2568888),h}getAlignmentPatternPositions(){if(this.version==1)return[];{const h=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(h*2-2))*2;let p=[6];for(let _=this.size-7;p.length<h;_-=d)p.splice(1,0,_);return p}}static getNumRawDataModules(h){if(h<Be.MIN_VERSION||h>Be.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*h+128)*h+64;if(h>=2){const p=Math.floor(h/7)+2;d-=(25*p-10)*p-55,h>=7&&(d-=36)}return u(208<=d&&d<=29648),d}static getNumDataCodewords(h,d){return Math.floor(Be.getNumRawDataModules(h)/8)-Be.ECC_CODEWORDS_PER_BLOCK[d.ordinal][h]*Be.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][h]}static reedSolomonComputeDivisor(h){if(h<1||h>255)throw new RangeError("Degree out of range");let d=[];for(let _=0;_<h-1;_++)d.push(0);d.push(1);let p=1;for(let _=0;_<h;_++){for(let y=0;y<d.length;y++)d[y]=Be.reedSolomonMultiply(d[y],p),y+1<d.length&&(d[y]^=d[y+1]);p=Be.reedSolomonMultiply(p,2)}return d}static reedSolomonComputeRemainder(h,d){let p=d.map(_=>0);for(const _ of h){const y=_^p.shift();p.push(0),d.forEach((w,S)=>p[S]^=Be.reedSolomonMultiply(w,y))}return p}static reedSolomonMultiply(h,d){if(h>>>8||d>>>8)throw new RangeError("Byte out of range");let p=0;for(let _=7;_>=0;_--)p=p<<1^(p>>>7)*285,p^=(d>>>_&1)*h;return u(p>>>8==0),p}finderPenaltyCountPatterns(h){const d=h[1];u(d<=this.size*3);const p=d>0&&h[2]==d&&h[3]==d*3&&h[4]==d&&h[5]==d;return(p&&h[0]>=d*4&&h[6]>=d?1:0)+(p&&h[6]>=d*4&&h[0]>=d?1:0)}finderPenaltyTerminateAndCount(h,d,p){return h&&(this.finderPenaltyAddHistory(d,p),d=0),d+=this.size,this.finderPenaltyAddHistory(d,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(h,d){d[0]==0&&(h+=this.size),d.pop(),d.unshift(h)}};n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],s.QrCode=n;function r(b,h,d){if(h<0||h>31||b>>>h)throw new RangeError("Value out of range");for(let p=h-1;p>=0;p--)d.push(b>>>p&1)}function a(b,h){return(b>>>h&1)!=0}function u(b){if(!b)throw new Error("Assertion error")}const l=class rt{constructor(h,d,p){if(this.mode=h,this.numChars=d,this.bitData=p,d<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(h){let d=[];for(const p of h)r(p,8,d);return new rt(rt.Mode.BYTE,h.length,d)}static makeNumeric(h){if(!rt.isNumeric(h))throw new RangeError("String contains non-numeric characters");let d=[];for(let p=0;p<h.length;){const _=Math.min(h.length-p,3);r(parseInt(h.substring(p,p+_),10),_*3+1,d),p+=_}return new rt(rt.Mode.NUMERIC,h.length,d)}static makeAlphanumeric(h){if(!rt.isAlphanumeric(h))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],p;for(p=0;p+2<=h.length;p+=2){let _=rt.ALPHANUMERIC_CHARSET.indexOf(h.charAt(p))*45;_+=rt.ALPHANUMERIC_CHARSET.indexOf(h.charAt(p+1)),r(_,11,d)}return p<h.length&&r(rt.ALPHANUMERIC_CHARSET.indexOf(h.charAt(p)),6,d),new rt(rt.Mode.ALPHANUMERIC,h.length,d)}static makeSegments(h){return h==""?[]:rt.isNumeric(h)?[rt.makeNumeric(h)]:rt.isAlphanumeric(h)?[rt.makeAlphanumeric(h)]:[rt.makeBytes(rt.toUtf8ByteArray(h))]}static makeEci(h){let d=[];if(h<0)throw new RangeError("ECI assignment value out of range");if(h<128)r(h,8,d);else if(h<16384)r(2,2,d),r(h,14,d);else if(h<1e6)r(6,3,d),r(h,21,d);else throw new RangeError("ECI assignment value out of range");return new rt(rt.Mode.ECI,0,d)}static isNumeric(h){return rt.NUMERIC_REGEX.test(h)}static isAlphanumeric(h){return rt.ALPHANUMERIC_REGEX.test(h)}getData(){return this.bitData.slice()}static getTotalBits(h,d){let p=0;for(const _ of h){const y=_.mode.numCharCountBits(d);if(_.numChars>=1<<y)return 1/0;p+=4+y+_.bitData.length}return p}static toUtf8ByteArray(h){h=encodeURI(h);let d=[];for(let p=0;p<h.length;p++)h.charAt(p)!="%"?d.push(h.charCodeAt(p)):(d.push(parseInt(h.substring(p+1,p+3),16)),p+=2);return d}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let m=l;s.QrSegment=l})(Qn||(Qn={}));(s=>{(n=>{const r=class{constructor(u,l){this.ordinal=u,this.formatBits=l}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),n.Ecc=r})(s.QrCode||(s.QrCode={}))})(Qn||(Qn={}));(s=>{(n=>{const r=class{constructor(u,l){this.modeBits=u,this.numBitsCharCount=l}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),n.Mode=r})(s.QrSegment||(s.QrSegment={}))})(Qn||(Qn={}));var gr=Qn;var dw={L:gr.QrCode.Ecc.LOW,M:gr.QrCode.Ecc.MEDIUM,Q:gr.QrCode.Ecc.QUARTILE,H:gr.QrCode.Ecc.HIGH},Ef=128,Sf="L",Cf="#FFFFFF",Nf="#000000",Rf=!1,Tf=1,fw=4,hw=0,pw=.1;function kf(s,n=0){const r=[];return s.forEach(function(a,u){let l=null;a.forEach(function(m,b){if(!m&&l!==null){r.push(`M${l+n} ${u+n}h${b-l}v1H${l+n}z`),l=null;return}if(b===a.length-1){if(!m)return;l===null?r.push(`M${b+n},${u+n} h1v1H${b+n}z`):r.push(`M${l+n},${u+n} h${b+1-l}v1H${l+n}z`);return}m&&l===null&&(l=b)})}),r.join("")}function jf(s,n){return s.slice().map((r,a)=>a<n.y||a>=n.y+n.h?r:r.map((u,l)=>l<n.x||l>=n.x+n.w?u:!1))}function mw(s,n,r,a){if(a==null)return null;const u=s.length+r*2,l=Math.floor(n*pw),m=u/n,b=(a.width||l)*m,h=(a.height||l)*m,d=a.x==null?s.length/2-b/2:a.x*m,p=a.y==null?s.length/2-h/2:a.y*m,_=a.opacity==null?1:a.opacity;let y=null;if(a.excavate){let S=Math.floor(d),P=Math.floor(p),N=Math.ceil(b+d-S),I=Math.ceil(h+p-P);y={x:S,y:P,w:N,h:I}}const w=a.crossOrigin;return{x:d,y:p,h,w:b,excavation:y,opacity:_,crossOrigin:w}}function gw(s,n){return n!=null?Math.max(Math.floor(n),0):s?fw:hw}function Af({value:s,level:n,minVersion:r,includeMargin:a,marginSize:u,imageSettings:l,size:m,boostLevel:b}){let h=Ke.useMemo(()=>{const S=(Array.isArray(s)?s:[s]).reduce((P,N)=>(P.push(...gr.QrSegment.makeSegments(N)),P),[]);return gr.QrCode.encodeSegments(S,dw[n],r,void 0,void 0,b)},[s,n,r,b]);const{cells:d,margin:p,numCells:_,calculatedImageSettings:y}=Ke.useMemo(()=>{let w=h.getModules();const S=gw(a,u),P=w.length+S*2,N=mw(w,m,S,l);return{cells:w,margin:S,numCells:P,calculatedImageSettings:N}},[h,m,l,a,u]);return{qrcode:h,margin:p,cells:d,numCells:_,calculatedImageSettings:y}}var xw=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),_w=Ke.forwardRef(function(n,r){const a=n,{value:u,size:l=Ef,level:m=Sf,bgColor:b=Cf,fgColor:h=Nf,includeMargin:d=Rf,minVersion:p=Tf,boostLevel:_,marginSize:y,imageSettings:w}=a,P=ca(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:N}=P,I=ca(P,["style"]),L=w?.src,k=Ke.useRef(null),B=Ke.useRef(null),Y=Ke.useCallback(H=>{k.current=H,typeof r=="function"?r(H):r&&(r.current=H)},[r]),[T,F]=Ke.useState(!1),{margin:z,cells:D,numCells:te,calculatedImageSettings:U}=Af({value:u,level:m,minVersion:p,boostLevel:_,includeMargin:d,marginSize:y,imageSettings:w,size:l});Ke.useEffect(()=>{if(k.current!=null){const H=k.current,Z=H.getContext("2d");if(!Z)return;let Q=D;const ee=B.current,ie=U!=null&&ee!==null&&ee.complete&&ee.naturalHeight!==0&&ee.naturalWidth!==0;ie&&U.excavation!=null&&(Q=jf(D,U.excavation));const ne=window.devicePixelRatio||1;H.height=H.width=l*ne;const A=l/te*ne;Z.scale(A,A),Z.fillStyle=b,Z.fillRect(0,0,te,te),Z.fillStyle=h,xw?Z.fill(new Path2D(kf(Q,z))):D.forEach(function($,re){$.forEach(function(le,ve){le&&Z.fillRect(ve+z,re+z,1,1)})}),U&&(Z.globalAlpha=U.opacity),ie&&Z.drawImage(ee,U.x+z,U.y+z,U.w,U.h)}}),Ke.useEffect(()=>{F(!1)},[L]);const M=la({height:l,width:l},N);let G=null;return L!=null&&(G=Ke.createElement("img",{src:L,key:L,style:{display:"none"},onLoad:()=>{F(!0)},ref:B,crossOrigin:U?.crossOrigin})),Ke.createElement(Ke.Fragment,null,Ke.createElement("canvas",la({style:M,height:l,width:l,ref:Y,role:"img"},I)),G)});_w.displayName="QRCodeCanvas";var Pf=Ke.forwardRef(function(n,r){const a=n,{value:u,size:l=Ef,level:m=Sf,bgColor:b=Cf,fgColor:h=Nf,includeMargin:d=Rf,minVersion:p=Tf,boostLevel:_,title:y,marginSize:w,imageSettings:S}=a,P=ca(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:N,cells:I,numCells:L,calculatedImageSettings:k}=Af({value:u,level:m,minVersion:p,boostLevel:_,includeMargin:d,marginSize:w,imageSettings:S,size:l});let B=I,Y=null;S!=null&&k!=null&&(k.excavation!=null&&(B=jf(I,k.excavation)),Y=Ke.createElement("image",{href:S.src,height:k.h,width:k.w,x:k.x+N,y:k.y+N,preserveAspectRatio:"none",opacity:k.opacity,crossOrigin:k.crossOrigin}));const T=kf(B,N);return Ke.createElement("svg",la({height:l,width:l,viewBox:`0 0 ${L} ${L}`,ref:r,role:"img"},P),!!y&&Ke.createElement("title",null,y),Ke.createElement("path",{fill:b,d:`M0,0 h${L}v${L}H0z`,shapeRendering:"crispEdges"}),Ke.createElement("path",{fill:h,d:T,shapeRendering:"crispEdges"}),Y)});Pf.displayName="QRCodeSVG";var Yr={exports:{}};var vw=Yr.exports,yu;function bw(){return yu||(yu=1,(function(s,n){(function(){var r,a="4.17.23",u=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",m="Expected a function",b="Invalid `variable` option passed into `_.template`",h="__lodash_hash_undefined__",d=500,p="__lodash_placeholder__",_=1,y=2,w=4,S=1,P=2,N=1,I=2,L=4,k=8,B=16,Y=32,T=64,F=128,z=256,D=512,te=30,U="...",M=800,G=16,H=1,Z=2,Q=3,ee=1/0,ie=9007199254740991,ne=17976931348623157e292,A=NaN,$=4294967295,re=$-1,le=$>>>1,ve=[["ary",F],["bind",N],["bindKey",I],["curry",k],["curryRight",B],["flip",D],["partial",Y],["partialRight",T],["rearg",z]],xe="[object Arguments]",Ue="[object Array]",Le="[object AsyncFunction]",_e="[object Boolean]",ce="[object Date]",K="[object DOMException]",pe="[object Error]",Se="[object Function]",He="[object GeneratorFunction]",ge="[object Map]",Ie="[object Number]",Te="[object Null]",Re="[object Object]",oe="[object Promise]",me="[object Proxy]",Ne="[object RegExp]",ae="[object Set]",Ce="[object String]",de="[object Symbol]",Oe="[object Undefined]",st="[object WeakMap]",ht="[object WeakSet]",wt="[object ArrayBuffer]",lt="[object DataView]",xt="[object Float32Array]",_t="[object Float64Array]",On="[object Int8Array]",Mt="[object Int16Array]",er="[object Int32Array]",Fn="[object Uint8Array]",Bn="[object Uint8ClampedArray]",tr="[object Uint16Array]",Nr="[object Uint32Array]",Un=/\b__p \+= '';/g,os=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ee=/&(?:amp|lt|gt|quot|#39);/g,Qt=/[&<>"']/g,Ti=RegExp(Ee.source),as=RegExp(Qt.source),nh=/<%-([\s\S]+?)%>/g,rh=/<%([\s\S]+?)%>/g,Oa=/<%=([\s\S]+?)%>/g,sh=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ih=/^\w*$/,oh=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ki=/[\\^$.*+?()[\]{}|]/g,ah=RegExp(ki.source),ji=/^\s+/,lh=/\s/,ch=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,uh=/\{\n\/\* \[wrapped with (.+)\] \*/,dh=/,? & /,fh=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,hh=/[()=,{}\[\]\/\s]/,ph=/\\(\\)?/g,mh=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fa=/\w*$/,gh=/^[-+]0x[0-9a-f]+$/i,xh=/^0b[01]+$/i,_h=/^\[object .+?Constructor\]$/,vh=/^0o[0-7]+$/i,bh=/^(?:0|[1-9]\d*)$/,yh=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ls=/($^)/,wh=/['\n\r\u2028\u2029\\]/g,cs="\\ud800-\\udfff",Eh="\\u0300-\\u036f",Sh="\\ufe20-\\ufe2f",Ch="\\u20d0-\\u20ff",Ba=Eh+Sh+Ch,Ua="\\u2700-\\u27bf",Ga="a-z\\xdf-\\xf6\\xf8-\\xff",Nh="\\xac\\xb1\\xd7\\xf7",Rh="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Th="\\u2000-\\u206f",kh=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Wa="A-Z\\xc0-\\xd6\\xd8-\\xde",za="\\ufe0e\\ufe0f",Ha=Nh+Rh+Th+kh,Ai="['’]",jh="["+cs+"]",$a="["+Ha+"]",us="["+Ba+"]",qa="\\d+",Ah="["+Ua+"]",Xa="["+Ga+"]",Ya="[^"+cs+Ha+qa+Ua+Ga+Wa+"]",Pi="\\ud83c[\\udffb-\\udfff]",Ph="(?:"+us+"|"+Pi+")",Ka="[^"+cs+"]",Mi="(?:\\ud83c[\\udde6-\\uddff]){2}",Di="[\\ud800-\\udbff][\\udc00-\\udfff]",nr="["+Wa+"]",Va="\\u200d",Qa="(?:"+Xa+"|"+Ya+")",Mh="(?:"+nr+"|"+Ya+")",Ja="(?:"+Ai+"(?:d|ll|m|re|s|t|ve))?",Za="(?:"+Ai+"(?:D|LL|M|RE|S|T|VE))?",el=Ph+"?",tl="["+za+"]?",Dh="(?:"+Va+"(?:"+[Ka,Mi,Di].join("|")+")"+tl+el+")*",Ih="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Lh="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",nl=tl+el+Dh,Oh="(?:"+[Ah,Mi,Di].join("|")+")"+nl,Fh="(?:"+[Ka+us+"?",us,Mi,Di,jh].join("|")+")",Bh=RegExp(Ai,"g"),Uh=RegExp(us,"g"),Ii=RegExp(Pi+"(?="+Pi+")|"+Fh+nl,"g"),Gh=RegExp([nr+"?"+Xa+"+"+Ja+"(?="+[$a,nr,"$"].join("|")+")",Mh+"+"+Za+"(?="+[$a,nr+Qa,"$"].join("|")+")",nr+"?"+Qa+"+"+Ja,nr+"+"+Za,Lh,Ih,qa,Oh].join("|"),"g"),Wh=RegExp("["+Va+cs+Ba+za+"]"),zh=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Hh=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],$h=-1,Je={};Je[xt]=Je[_t]=Je[On]=Je[Mt]=Je[er]=Je[Fn]=Je[Bn]=Je[tr]=Je[Nr]=!0,Je[xe]=Je[Ue]=Je[wt]=Je[_e]=Je[lt]=Je[ce]=Je[pe]=Je[Se]=Je[ge]=Je[Ie]=Je[Re]=Je[Ne]=Je[ae]=Je[Ce]=Je[st]=!1;var Qe={};Qe[xe]=Qe[Ue]=Qe[wt]=Qe[lt]=Qe[_e]=Qe[ce]=Qe[xt]=Qe[_t]=Qe[On]=Qe[Mt]=Qe[er]=Qe[ge]=Qe[Ie]=Qe[Re]=Qe[Ne]=Qe[ae]=Qe[Ce]=Qe[de]=Qe[Fn]=Qe[Bn]=Qe[tr]=Qe[Nr]=!0,Qe[pe]=Qe[Se]=Qe[st]=!1;var qh={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Xh={"&":"&","<":"<",">":">",'"':""","'":"'"},Yh={"&":"&","<":"<",">":">",""":'"',"'":"'"},Kh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Vh=parseFloat,Qh=parseInt,rl=typeof Vs=="object"&&Vs&&Vs.Object===Object&&Vs,Jh=typeof self=="object"&&self&&self.Object===Object&&self,pt=rl||Jh||Function("return this")(),Li=n&&!n.nodeType&&n,Gn=Li&&!0&&s&&!s.nodeType&&s,sl=Gn&&Gn.exports===Li,Oi=sl&&rl.process,Ut=(function(){try{var R=Gn&&Gn.require&&Gn.require("util").types;return R||Oi&&Oi.binding&&Oi.binding("util")}catch{}})(),il=Ut&&Ut.isArrayBuffer,ol=Ut&&Ut.isDate,al=Ut&&Ut.isMap,ll=Ut&&Ut.isRegExp,cl=Ut&&Ut.isSet,ul=Ut&&Ut.isTypedArray;function Dt(R,W,O){switch(O.length){case 0:return R.call(W);case 1:return R.call(W,O[0]);case 2:return R.call(W,O[0],O[1]);case 3:return R.call(W,O[0],O[1],O[2])}return R.apply(W,O)}function Zh(R,W,O,ue){for(var ke=-1,$e=R==null?0:R.length;++ke<$e;){var ct=R[ke];W(ue,ct,O(ct),R)}return ue}function Gt(R,W){for(var O=-1,ue=R==null?0:R.length;++O<ue&&W(R[O],O,R)!==!1;);return R}function ep(R,W){for(var O=R==null?0:R.length;O--&&W(R[O],O,R)!==!1;);return R}function dl(R,W){for(var O=-1,ue=R==null?0:R.length;++O<ue;)if(!W(R[O],O,R))return!1;return!0}function Nn(R,W){for(var O=-1,ue=R==null?0:R.length,ke=0,$e=[];++O<ue;){var ct=R[O];W(ct,O,R)&&($e[ke++]=ct)}return $e}function ds(R,W){var O=R==null?0:R.length;return!!O&&rr(R,W,0)>-1}function Fi(R,W,O){for(var ue=-1,ke=R==null?0:R.length;++ue<ke;)if(O(W,R[ue]))return!0;return!1}function Ze(R,W){for(var O=-1,ue=R==null?0:R.length,ke=Array(ue);++O<ue;)ke[O]=W(R[O],O,R);return ke}function Rn(R,W){for(var O=-1,ue=W.length,ke=R.length;++O<ue;)R[ke+O]=W[O];return R}function Bi(R,W,O,ue){var ke=-1,$e=R==null?0:R.length;for(ue&&$e&&(O=R[++ke]);++ke<$e;)O=W(O,R[ke],ke,R);return O}function tp(R,W,O,ue){var ke=R==null?0:R.length;for(ue&&ke&&(O=R[--ke]);ke--;)O=W(O,R[ke],ke,R);return O}function Ui(R,W){for(var O=-1,ue=R==null?0:R.length;++O<ue;)if(W(R[O],O,R))return!0;return!1}var np=Gi("length");function rp(R){return R.split("")}function sp(R){return R.match(fh)||[]}function fl(R,W,O){var ue;return O(R,function(ke,$e,ct){if(W(ke,$e,ct))return ue=$e,!1}),ue}function fs(R,W,O,ue){for(var ke=R.length,$e=O+(ue?1:-1);ue?$e--:++$e<ke;)if(W(R[$e],$e,R))return $e;return-1}function rr(R,W,O){return W===W?gp(R,W,O):fs(R,hl,O)}function ip(R,W,O,ue){for(var ke=O-1,$e=R.length;++ke<$e;)if(ue(R[ke],W))return ke;return-1}function hl(R){return R!==R}function pl(R,W){var O=R==null?0:R.length;return O?zi(R,W)/O:A}function Gi(R){return function(W){return W==null?r:W[R]}}function Wi(R){return function(W){return R==null?r:R[W]}}function ml(R,W,O,ue,ke){return ke(R,function($e,ct,Ve){O=ue?(ue=!1,$e):W(O,$e,ct,Ve)}),O}function op(R,W){var O=R.length;for(R.sort(W);O--;)R[O]=R[O].value;return R}function zi(R,W){for(var O,ue=-1,ke=R.length;++ue<ke;){var $e=W(R[ue]);$e!==r&&(O=O===r?$e:O+$e)}return O}function Hi(R,W){for(var O=-1,ue=Array(R);++O<R;)ue[O]=W(O);return ue}function ap(R,W){return Ze(W,function(O){return[O,R[O]]})}function gl(R){return R&&R.slice(0,bl(R)+1).replace(ji,"")}function It(R){return function(W){return R(W)}}function $i(R,W){return Ze(W,function(O){return R[O]})}function Rr(R,W){return R.has(W)}function xl(R,W){for(var O=-1,ue=R.length;++O<ue&&rr(W,R[O],0)>-1;);return O}function _l(R,W){for(var O=R.length;O--&&rr(W,R[O],0)>-1;);return O}function lp(R,W){for(var O=R.length,ue=0;O--;)R[O]===W&&++ue;return ue}var cp=Wi(qh),up=Wi(Xh);function dp(R){return"\\"+Kh[R]}function fp(R,W){return R==null?r:R[W]}function sr(R){return Wh.test(R)}function hp(R){return zh.test(R)}function pp(R){for(var W,O=[];!(W=R.next()).done;)O.push(W.value);return O}function qi(R){var W=-1,O=Array(R.size);return R.forEach(function(ue,ke){O[++W]=[ke,ue]}),O}function vl(R,W){return function(O){return R(W(O))}}function Tn(R,W){for(var O=-1,ue=R.length,ke=0,$e=[];++O<ue;){var ct=R[O];(ct===W||ct===p)&&(R[O]=p,$e[ke++]=O)}return $e}function hs(R){var W=-1,O=Array(R.size);return R.forEach(function(ue){O[++W]=ue}),O}function mp(R){var W=-1,O=Array(R.size);return R.forEach(function(ue){O[++W]=[ue,ue]}),O}function gp(R,W,O){for(var ue=O-1,ke=R.length;++ue<ke;)if(R[ue]===W)return ue;return-1}function xp(R,W,O){for(var ue=O+1;ue--;)if(R[ue]===W)return ue;return ue}function ir(R){return sr(R)?vp(R):np(R)}function Jt(R){return sr(R)?bp(R):rp(R)}function bl(R){for(var W=R.length;W--&&lh.test(R.charAt(W)););return W}var _p=Wi(Yh);function vp(R){for(var W=Ii.lastIndex=0;Ii.test(R);)++W;return W}function bp(R){return R.match(Ii)||[]}function yp(R){return R.match(Gh)||[]}var wp=(function R(W){W=W==null?pt:or.defaults(pt.Object(),W,or.pick(pt,Hh));var O=W.Array,ue=W.Date,ke=W.Error,$e=W.Function,ct=W.Math,Ve=W.Object,Xi=W.RegExp,Ep=W.String,Wt=W.TypeError,ps=O.prototype,Sp=$e.prototype,ar=Ve.prototype,ms=W["__core-js_shared__"],gs=Sp.toString,qe=ar.hasOwnProperty,Cp=0,yl=(function(){var e=/[^.]+$/.exec(ms&&ms.keys&&ms.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),xs=ar.toString,Np=gs.call(Ve),Rp=pt._,Tp=Xi("^"+gs.call(qe).replace(ki,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_s=sl?W.Buffer:r,kn=W.Symbol,vs=W.Uint8Array,wl=_s?_s.allocUnsafe:r,bs=vl(Ve.getPrototypeOf,Ve),El=Ve.create,Sl=ar.propertyIsEnumerable,ys=ps.splice,Cl=kn?kn.isConcatSpreadable:r,Tr=kn?kn.iterator:r,Wn=kn?kn.toStringTag:r,ws=(function(){try{var e=Xn(Ve,"defineProperty");return e({},"",{}),e}catch{}})(),kp=W.clearTimeout!==pt.clearTimeout&&W.clearTimeout,jp=ue&&ue.now!==pt.Date.now&&ue.now,Ap=W.setTimeout!==pt.setTimeout&&W.setTimeout,Es=ct.ceil,Ss=ct.floor,Yi=Ve.getOwnPropertySymbols,Pp=_s?_s.isBuffer:r,Nl=W.isFinite,Mp=ps.join,Dp=vl(Ve.keys,Ve),ut=ct.max,vt=ct.min,Ip=ue.now,Lp=W.parseInt,Rl=ct.random,Op=ps.reverse,Ki=Xn(W,"DataView"),kr=Xn(W,"Map"),Vi=Xn(W,"Promise"),lr=Xn(W,"Set"),jr=Xn(W,"WeakMap"),Ar=Xn(Ve,"create"),Cs=jr&&new jr,cr={},Fp=Yn(Ki),Bp=Yn(kr),Up=Yn(Vi),Gp=Yn(lr),Wp=Yn(jr),Ns=kn?kn.prototype:r,Pr=Ns?Ns.valueOf:r,Tl=Ns?Ns.toString:r;function g(e){if(nt(e)&&!je(e)&&!(e instanceof Ge)){if(e instanceof zt)return e;if(qe.call(e,"__wrapped__"))return kc(e)}return new zt(e)}var ur=(function(){function e(){}return function(t){if(!tt(t))return{};if(El)return El(t);e.prototype=t;var i=new e;return e.prototype=r,i}})();function Rs(){}function zt(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}g.templateSettings={escape:nh,evaluate:rh,interpolate:Oa,variable:"",imports:{_:g}},g.prototype=Rs.prototype,g.prototype.constructor=g,zt.prototype=ur(Rs.prototype),zt.prototype.constructor=zt;function Ge(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=$,this.__views__=[]}function zp(){var e=new Ge(this.__wrapped__);return e.__actions__=Rt(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Rt(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Rt(this.__views__),e}function Hp(){if(this.__filtered__){var e=new Ge(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function $p(){var e=this.__wrapped__.value(),t=this.__dir__,i=je(e),c=t<0,f=i?e.length:0,v=r0(0,f,this.__views__),E=v.start,C=v.end,j=C-E,q=c?C:E-1,X=this.__iteratees__,J=X.length,se=0,he=vt(j,this.__takeCount__);if(!i||!c&&f==j&&he==j)return Jl(e,this.__actions__);var ye=[];e:for(;j--&&se<he;){q+=t;for(var Me=-1,we=e[q];++Me<J;){var Fe=X[Me],We=Fe.iteratee,Ft=Fe.type,Ct=We(we);if(Ft==Z)we=Ct;else if(!Ct){if(Ft==H)continue e;break e}}ye[se++]=we}return ye}Ge.prototype=ur(Rs.prototype),Ge.prototype.constructor=Ge;function zn(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var c=e[t];this.set(c[0],c[1])}}function qp(){this.__data__=Ar?Ar(null):{},this.size=0}function Xp(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Yp(e){var t=this.__data__;if(Ar){var i=t[e];return i===h?r:i}return qe.call(t,e)?t[e]:r}function Kp(e){var t=this.__data__;return Ar?t[e]!==r:qe.call(t,e)}function Vp(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Ar&&t===r?h:t,this}zn.prototype.clear=qp,zn.prototype.delete=Xp,zn.prototype.get=Yp,zn.prototype.has=Kp,zn.prototype.set=Vp;function gn(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var c=e[t];this.set(c[0],c[1])}}function Qp(){this.__data__=[],this.size=0}function Jp(e){var t=this.__data__,i=Ts(t,e);if(i<0)return!1;var c=t.length-1;return i==c?t.pop():ys.call(t,i,1),--this.size,!0}function Zp(e){var t=this.__data__,i=Ts(t,e);return i<0?r:t[i][1]}function em(e){return Ts(this.__data__,e)>-1}function tm(e,t){var i=this.__data__,c=Ts(i,e);return c<0?(++this.size,i.push([e,t])):i[c][1]=t,this}gn.prototype.clear=Qp,gn.prototype.delete=Jp,gn.prototype.get=Zp,gn.prototype.has=em,gn.prototype.set=tm;function xn(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var c=e[t];this.set(c[0],c[1])}}function nm(){this.size=0,this.__data__={hash:new zn,map:new(kr||gn),string:new zn}}function rm(e){var t=Us(this,e).delete(e);return this.size-=t?1:0,t}function sm(e){return Us(this,e).get(e)}function im(e){return Us(this,e).has(e)}function om(e,t){var i=Us(this,e),c=i.size;return i.set(e,t),this.size+=i.size==c?0:1,this}xn.prototype.clear=nm,xn.prototype.delete=rm,xn.prototype.get=sm,xn.prototype.has=im,xn.prototype.set=om;function Hn(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new xn;++t<i;)this.add(e[t])}function am(e){return this.__data__.set(e,h),this}function lm(e){return this.__data__.has(e)}Hn.prototype.add=Hn.prototype.push=am,Hn.prototype.has=lm;function Zt(e){var t=this.__data__=new gn(e);this.size=t.size}function cm(){this.__data__=new gn,this.size=0}function um(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}function dm(e){return this.__data__.get(e)}function fm(e){return this.__data__.has(e)}function hm(e,t){var i=this.__data__;if(i instanceof gn){var c=i.__data__;if(!kr||c.length<u-1)return c.push([e,t]),this.size=++i.size,this;i=this.__data__=new xn(c)}return i.set(e,t),this.size=i.size,this}Zt.prototype.clear=cm,Zt.prototype.delete=um,Zt.prototype.get=dm,Zt.prototype.has=fm,Zt.prototype.set=hm;function kl(e,t){var i=je(e),c=!i&&Kn(e),f=!i&&!c&&Dn(e),v=!i&&!c&&!f&&pr(e),E=i||c||f||v,C=E?Hi(e.length,Ep):[],j=C.length;for(var q in e)(t||qe.call(e,q))&&!(E&&(q=="length"||f&&(q=="offset"||q=="parent")||v&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||yn(q,j)))&&C.push(q);return C}function jl(e){var t=e.length;return t?e[ao(0,t-1)]:r}function pm(e,t){return Gs(Rt(e),$n(t,0,e.length))}function mm(e){return Gs(Rt(e))}function Qi(e,t,i){(i!==r&&!en(e[t],i)||i===r&&!(t in e))&&_n(e,t,i)}function Mr(e,t,i){var c=e[t];(!(qe.call(e,t)&&en(c,i))||i===r&&!(t in e))&&_n(e,t,i)}function Ts(e,t){for(var i=e.length;i--;)if(en(e[i][0],t))return i;return-1}function gm(e,t,i,c){return jn(e,function(f,v,E){t(c,f,i(f),E)}),c}function Al(e,t){return e&&sn(t,ft(t),e)}function xm(e,t){return e&&sn(t,kt(t),e)}function _n(e,t,i){t=="__proto__"&&ws?ws(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function Ji(e,t){for(var i=-1,c=t.length,f=O(c),v=e==null;++i<c;)f[i]=v?r:Mo(e,t[i]);return f}function $n(e,t,i){return e===e&&(i!==r&&(e=e<=i?e:i),t!==r&&(e=e>=t?e:t)),e}function Ht(e,t,i,c,f,v){var E,C=t&_,j=t&y,q=t&w;if(i&&(E=f?i(e,c,f,v):i(e)),E!==r)return E;if(!tt(e))return e;var X=je(e);if(X){if(E=i0(e),!C)return Rt(e,E)}else{var J=bt(e),se=J==Se||J==He;if(Dn(e))return tc(e,C);if(J==Re||J==xe||se&&!f){if(E=j||se?{}:bc(e),!C)return j?Ym(e,xm(E,e)):Xm(e,Al(E,e))}else{if(!Qe[J])return f?e:{};E=o0(e,J,C)}}v||(v=new Zt);var he=v.get(e);if(he)return he;v.set(e,E),Kc(e)?e.forEach(function(we){E.add(Ht(we,t,i,we,e,v))}):Xc(e)&&e.forEach(function(we,Fe){E.set(Fe,Ht(we,t,i,Fe,e,v))});var ye=q?j?vo:_o:j?kt:ft,Me=X?r:ye(e);return Gt(Me||e,function(we,Fe){Me&&(Fe=we,we=e[Fe]),Mr(E,Fe,Ht(we,t,i,Fe,e,v))}),E}function _m(e){var t=ft(e);return function(i){return Pl(i,e,t)}}function Pl(e,t,i){var c=i.length;if(e==null)return!c;for(e=Ve(e);c--;){var f=i[c],v=t[f],E=e[f];if(E===r&&!(f in e)||!v(E))return!1}return!0}function Ml(e,t,i){if(typeof e!="function")throw new Wt(m);return Ur(function(){e.apply(r,i)},t)}function Dr(e,t,i,c){var f=-1,v=ds,E=!0,C=e.length,j=[],q=t.length;if(!C)return j;i&&(t=Ze(t,It(i))),c?(v=Fi,E=!1):t.length>=u&&(v=Rr,E=!1,t=new Hn(t));e:for(;++f<C;){var X=e[f],J=i==null?X:i(X);if(X=c||X!==0?X:0,E&&J===J){for(var se=q;se--;)if(t[se]===J)continue e;j.push(X)}else v(t,J,c)||j.push(X)}return j}var jn=oc(rn),Dl=oc(eo,!0);function vm(e,t){var i=!0;return jn(e,function(c,f,v){return i=!!t(c,f,v),i}),i}function ks(e,t,i){for(var c=-1,f=e.length;++c<f;){var v=e[c],E=t(v);if(E!=null&&(C===r?E===E&&!Ot(E):i(E,C)))var C=E,j=v}return j}function bm(e,t,i,c){var f=e.length;for(i=Ae(i),i<0&&(i=-i>f?0:f+i),c=c===r||c>f?f:Ae(c),c<0&&(c+=f),c=i>c?0:Qc(c);i<c;)e[i++]=t;return e}function Il(e,t){var i=[];return jn(e,function(c,f,v){t(c,f,v)&&i.push(c)}),i}function mt(e,t,i,c,f){var v=-1,E=e.length;for(i||(i=l0),f||(f=[]);++v<E;){var C=e[v];t>0&&i(C)?t>1?mt(C,t-1,i,c,f):Rn(f,C):c||(f[f.length]=C)}return f}var Zi=ac(),Ll=ac(!0);function rn(e,t){return e&&Zi(e,t,ft)}function eo(e,t){return e&&Ll(e,t,ft)}function js(e,t){return Nn(t,function(i){return wn(e[i])})}function qn(e,t){t=Pn(t,e);for(var i=0,c=t.length;e!=null&&i<c;)e=e[on(t[i++])];return i&&i==c?e:r}function Ol(e,t,i){var c=t(e);return je(e)?c:Rn(c,i(e))}function Et(e){return e==null?e===r?Oe:Te:Wn&&Wn in Ve(e)?n0(e):m0(e)}function to(e,t){return e>t}function ym(e,t){return e!=null&&qe.call(e,t)}function wm(e,t){return e!=null&&t in Ve(e)}function Em(e,t,i){return e>=vt(t,i)&&e<ut(t,i)}function no(e,t,i){for(var c=i?Fi:ds,f=e[0].length,v=e.length,E=v,C=O(v),j=1/0,q=[];E--;){var X=e[E];E&&t&&(X=Ze(X,It(t))),j=vt(X.length,j),C[E]=!i&&(t||f>=120&&X.length>=120)?new Hn(E&&X):r}X=e[0];var J=-1,se=C[0];e:for(;++J<f&&q.length<j;){var he=X[J],ye=t?t(he):he;if(he=i||he!==0?he:0,!(se?Rr(se,ye):c(q,ye,i))){for(E=v;--E;){var Me=C[E];if(!(Me?Rr(Me,ye):c(e[E],ye,i)))continue e}se&&se.push(ye),q.push(he)}}return q}function Sm(e,t,i,c){return rn(e,function(f,v,E){t(c,i(f),v,E)}),c}function Ir(e,t,i){t=Pn(t,e),e=Sc(e,t);var c=e==null?e:e[on(qt(t))];return c==null?r:Dt(c,e,i)}function Fl(e){return nt(e)&&Et(e)==xe}function Cm(e){return nt(e)&&Et(e)==wt}function Nm(e){return nt(e)&&Et(e)==ce}function Lr(e,t,i,c,f){return e===t?!0:e==null||t==null||!nt(e)&&!nt(t)?e!==e&&t!==t:Rm(e,t,i,c,Lr,f)}function Rm(e,t,i,c,f,v){var E=je(e),C=je(t),j=E?Ue:bt(e),q=C?Ue:bt(t);j=j==xe?Re:j,q=q==xe?Re:q;var X=j==Re,J=q==Re,se=j==q;if(se&&Dn(e)){if(!Dn(t))return!1;E=!0,X=!1}if(se&&!X)return v||(v=new Zt),E||pr(e)?xc(e,t,i,c,f,v):e0(e,t,j,i,c,f,v);if(!(i&S)){var he=X&&qe.call(e,"__wrapped__"),ye=J&&qe.call(t,"__wrapped__");if(he||ye){var Me=he?e.value():e,we=ye?t.value():t;return v||(v=new Zt),f(Me,we,i,c,v)}}return se?(v||(v=new Zt),t0(e,t,i,c,f,v)):!1}function Tm(e){return nt(e)&&bt(e)==ge}function ro(e,t,i,c){var f=i.length,v=f,E=!c;if(e==null)return!v;for(e=Ve(e);f--;){var C=i[f];if(E&&C[2]?C[1]!==e[C[0]]:!(C[0]in e))return!1}for(;++f<v;){C=i[f];var j=C[0],q=e[j],X=C[1];if(E&&C[2]){if(q===r&&!(j in e))return!1}else{var J=new Zt;if(c)var se=c(q,X,j,e,t,J);if(!(se===r?Lr(X,q,S|P,c,J):se))return!1}}return!0}function Bl(e){if(!tt(e)||u0(e))return!1;var t=wn(e)?Tp:_h;return t.test(Yn(e))}function km(e){return nt(e)&&Et(e)==Ne}function jm(e){return nt(e)&&bt(e)==ae}function Am(e){return nt(e)&&Xs(e.length)&&!!Je[Et(e)]}function Ul(e){return typeof e=="function"?e:e==null?jt:typeof e=="object"?je(e)?zl(e[0],e[1]):Wl(e):lu(e)}function so(e){if(!Br(e))return Dp(e);var t=[];for(var i in Ve(e))qe.call(e,i)&&i!="constructor"&&t.push(i);return t}function Pm(e){if(!tt(e))return p0(e);var t=Br(e),i=[];for(var c in e)c=="constructor"&&(t||!qe.call(e,c))||i.push(c);return i}function io(e,t){return e<t}function Gl(e,t){var i=-1,c=Tt(e)?O(e.length):[];return jn(e,function(f,v,E){c[++i]=t(f,v,E)}),c}function Wl(e){var t=yo(e);return t.length==1&&t[0][2]?wc(t[0][0],t[0][1]):function(i){return i===e||ro(i,e,t)}}function zl(e,t){return Eo(e)&&yc(t)?wc(on(e),t):function(i){var c=Mo(i,e);return c===r&&c===t?Do(i,e):Lr(t,c,S|P)}}function As(e,t,i,c,f){e!==t&&Zi(t,function(v,E){if(f||(f=new Zt),tt(v))Mm(e,t,E,i,As,c,f);else{var C=c?c(Co(e,E),v,E+"",e,t,f):r;C===r&&(C=v),Qi(e,E,C)}},kt)}function Mm(e,t,i,c,f,v,E){var C=Co(e,i),j=Co(t,i),q=E.get(j);if(q){Qi(e,i,q);return}var X=v?v(C,j,i+"",e,t,E):r,J=X===r;if(J){var se=je(j),he=!se&&Dn(j),ye=!se&&!he&&pr(j);X=j,se||he||ye?je(C)?X=C:it(C)?X=Rt(C):he?(J=!1,X=tc(j,!0)):ye?(J=!1,X=nc(j,!0)):X=[]:Gr(j)||Kn(j)?(X=C,Kn(C)?X=Jc(C):(!tt(C)||wn(C))&&(X=bc(j))):J=!1}J&&(E.set(j,X),f(X,j,c,v,E),E.delete(j)),Qi(e,i,X)}function Hl(e,t){var i=e.length;if(i)return t+=t<0?i:0,yn(t,i)?e[t]:r}function $l(e,t,i){t.length?t=Ze(t,function(v){return je(v)?function(E){return qn(E,v.length===1?v[0]:v)}:v}):t=[jt];var c=-1;t=Ze(t,It(be()));var f=Gl(e,function(v,E,C){var j=Ze(t,function(q){return q(v)});return{criteria:j,index:++c,value:v}});return op(f,function(v,E){return qm(v,E,i)})}function Dm(e,t){return ql(e,t,function(i,c){return Do(e,c)})}function ql(e,t,i){for(var c=-1,f=t.length,v={};++c<f;){var E=t[c],C=qn(e,E);i(C,E)&&Or(v,Pn(E,e),C)}return v}function Im(e){return function(t){return qn(t,e)}}function oo(e,t,i,c){var f=c?ip:rr,v=-1,E=t.length,C=e;for(e===t&&(t=Rt(t)),i&&(C=Ze(e,It(i)));++v<E;)for(var j=0,q=t[v],X=i?i(q):q;(j=f(C,X,j,c))>-1;)C!==e&&ys.call(C,j,1),ys.call(e,j,1);return e}function Xl(e,t){for(var i=e?t.length:0,c=i-1;i--;){var f=t[i];if(i==c||f!==v){var v=f;yn(f)?ys.call(e,f,1):uo(e,f)}}return e}function ao(e,t){return e+Ss(Rl()*(t-e+1))}function Lm(e,t,i,c){for(var f=-1,v=ut(Es((t-e)/(i||1)),0),E=O(v);v--;)E[c?v:++f]=e,e+=i;return E}function lo(e,t){var i="";if(!e||t<1||t>ie)return i;do t%2&&(i+=e),t=Ss(t/2),t&&(e+=e);while(t);return i}function De(e,t){return No(Ec(e,t,jt),e+"")}function Om(e){return jl(mr(e))}function Fm(e,t){var i=mr(e);return Gs(i,$n(t,0,i.length))}function Or(e,t,i,c){if(!tt(e))return e;t=Pn(t,e);for(var f=-1,v=t.length,E=v-1,C=e;C!=null&&++f<v;){var j=on(t[f]),q=i;if(j==="__proto__"||j==="constructor"||j==="prototype")return e;if(f!=E){var X=C[j];q=c?c(X,j,C):r,q===r&&(q=tt(X)?X:yn(t[f+1])?[]:{})}Mr(C,j,q),C=C[j]}return e}var Yl=Cs?function(e,t){return Cs.set(e,t),e}:jt,Bm=ws?function(e,t){return ws(e,"toString",{configurable:!0,enumerable:!1,value:Lo(t),writable:!0})}:jt;function Um(e){return Gs(mr(e))}function $t(e,t,i){var c=-1,f=e.length;t<0&&(t=-t>f?0:f+t),i=i>f?f:i,i<0&&(i+=f),f=t>i?0:i-t>>>0,t>>>=0;for(var v=O(f);++c<f;)v[c]=e[c+t];return v}function Gm(e,t){var i;return jn(e,function(c,f,v){return i=t(c,f,v),!i}),!!i}function Ps(e,t,i){var c=0,f=e==null?c:e.length;if(typeof t=="number"&&t===t&&f<=le){for(;c<f;){var v=c+f>>>1,E=e[v];E!==null&&!Ot(E)&&(i?E<=t:E<t)?c=v+1:f=v}return f}return co(e,t,jt,i)}function co(e,t,i,c){var f=0,v=e==null?0:e.length;if(v===0)return 0;t=i(t);for(var E=t!==t,C=t===null,j=Ot(t),q=t===r;f<v;){var X=Ss((f+v)/2),J=i(e[X]),se=J!==r,he=J===null,ye=J===J,Me=Ot(J);if(E)var we=c||ye;else q?we=ye&&(c||se):C?we=ye&&se&&(c||!he):j?we=ye&&se&&!he&&(c||!Me):he||Me?we=!1:we=c?J<=t:J<t;we?f=X+1:v=X}return vt(v,re)}function Kl(e,t){for(var i=-1,c=e.length,f=0,v=[];++i<c;){var E=e[i],C=t?t(E):E;if(!i||!en(C,j)){var j=C;v[f++]=E===0?0:E}}return v}function Vl(e){return typeof e=="number"?e:Ot(e)?A:+e}function Lt(e){if(typeof e=="string")return e;if(je(e))return Ze(e,Lt)+"";if(Ot(e))return Tl?Tl.call(e):"";var t=e+"";return t=="0"&&1/e==-ee?"-0":t}function An(e,t,i){var c=-1,f=ds,v=e.length,E=!0,C=[],j=C;if(i)E=!1,f=Fi;else if(v>=u){var q=t?null:Jm(e);if(q)return hs(q);E=!1,f=Rr,j=new Hn}else j=t?[]:C;e:for(;++c<v;){var X=e[c],J=t?t(X):X;if(X=i||X!==0?X:0,E&&J===J){for(var se=j.length;se--;)if(j[se]===J)continue e;t&&j.push(J),C.push(X)}else f(j,J,i)||(j!==C&&j.push(J),C.push(X))}return C}function uo(e,t){t=Pn(t,e);var i=-1,c=t.length;if(!c)return!0;for(var f=e==null||typeof e!="object"&&typeof e!="function";++i<c;){var v=t[i];if(typeof v=="string"){if(v==="__proto__"&&!qe.call(e,"__proto__"))return!1;if(v==="constructor"&&i+1<c&&typeof t[i+1]=="string"&&t[i+1]==="prototype"){if(f&&i===0)continue;return!1}}}var E=Sc(e,t);return E==null||delete E[on(qt(t))]}function Ql(e,t,i,c){return Or(e,t,i(qn(e,t)),c)}function Ms(e,t,i,c){for(var f=e.length,v=c?f:-1;(c?v--:++v<f)&&t(e[v],v,e););return i?$t(e,c?0:v,c?v+1:f):$t(e,c?v+1:0,c?f:v)}function Jl(e,t){var i=e;return i instanceof Ge&&(i=i.value()),Bi(t,function(c,f){return f.func.apply(f.thisArg,Rn([c],f.args))},i)}function fo(e,t,i){var c=e.length;if(c<2)return c?An(e[0]):[];for(var f=-1,v=O(c);++f<c;)for(var E=e[f],C=-1;++C<c;)C!=f&&(v[f]=Dr(v[f]||E,e[C],t,i));return An(mt(v,1),t,i)}function Zl(e,t,i){for(var c=-1,f=e.length,v=t.length,E={};++c<f;){var C=c<v?t[c]:r;i(E,e[c],C)}return E}function ho(e){return it(e)?e:[]}function po(e){return typeof e=="function"?e:jt}function Pn(e,t){return je(e)?e:Eo(e,t)?[e]:Tc(Xe(e))}var Wm=De;function Mn(e,t,i){var c=e.length;return i=i===r?c:i,!t&&i>=c?e:$t(e,t,i)}var ec=kp||function(e){return pt.clearTimeout(e)};function tc(e,t){if(t)return e.slice();var i=e.length,c=wl?wl(i):new e.constructor(i);return e.copy(c),c}function mo(e){var t=new e.constructor(e.byteLength);return new vs(t).set(new vs(e)),t}function zm(e,t){var i=t?mo(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}function Hm(e){var t=new e.constructor(e.source,Fa.exec(e));return t.lastIndex=e.lastIndex,t}function $m(e){return Pr?Ve(Pr.call(e)):{}}function nc(e,t){var i=t?mo(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function rc(e,t){if(e!==t){var i=e!==r,c=e===null,f=e===e,v=Ot(e),E=t!==r,C=t===null,j=t===t,q=Ot(t);if(!C&&!q&&!v&&e>t||v&&E&&j&&!C&&!q||c&&E&&j||!i&&j||!f)return 1;if(!c&&!v&&!q&&e<t||q&&i&&f&&!c&&!v||C&&i&&f||!E&&f||!j)return-1}return 0}function qm(e,t,i){for(var c=-1,f=e.criteria,v=t.criteria,E=f.length,C=i.length;++c<E;){var j=rc(f[c],v[c]);if(j){if(c>=C)return j;var q=i[c];return j*(q=="desc"?-1:1)}}return e.index-t.index}function sc(e,t,i,c){for(var f=-1,v=e.length,E=i.length,C=-1,j=t.length,q=ut(v-E,0),X=O(j+q),J=!c;++C<j;)X[C]=t[C];for(;++f<E;)(J||f<v)&&(X[i[f]]=e[f]);for(;q--;)X[C++]=e[f++];return X}function ic(e,t,i,c){for(var f=-1,v=e.length,E=-1,C=i.length,j=-1,q=t.length,X=ut(v-C,0),J=O(X+q),se=!c;++f<X;)J[f]=e[f];for(var he=f;++j<q;)J[he+j]=t[j];for(;++E<C;)(se||f<v)&&(J[he+i[E]]=e[f++]);return J}function Rt(e,t){var i=-1,c=e.length;for(t||(t=O(c));++i<c;)t[i]=e[i];return t}function sn(e,t,i,c){var f=!i;i||(i={});for(var v=-1,E=t.length;++v<E;){var C=t[v],j=c?c(i[C],e[C],C,i,e):r;j===r&&(j=e[C]),f?_n(i,C,j):Mr(i,C,j)}return i}function Xm(e,t){return sn(e,wo(e),t)}function Ym(e,t){return sn(e,_c(e),t)}function Ds(e,t){return function(i,c){var f=je(i)?Zh:gm,v=t?t():{};return f(i,e,be(c,2),v)}}function dr(e){return De(function(t,i){var c=-1,f=i.length,v=f>1?i[f-1]:r,E=f>2?i[2]:r;for(v=e.length>3&&typeof v=="function"?(f--,v):r,E&&St(i[0],i[1],E)&&(v=f<3?r:v,f=1),t=Ve(t);++c<f;){var C=i[c];C&&e(t,C,c,v)}return t})}function oc(e,t){return function(i,c){if(i==null)return i;if(!Tt(i))return e(i,c);for(var f=i.length,v=t?f:-1,E=Ve(i);(t?v--:++v<f)&&c(E[v],v,E)!==!1;);return i}}function ac(e){return function(t,i,c){for(var f=-1,v=Ve(t),E=c(t),C=E.length;C--;){var j=E[e?C:++f];if(i(v[j],j,v)===!1)break}return t}}function Km(e,t,i){var c=t&N,f=Fr(e);function v(){var E=this&&this!==pt&&this instanceof v?f:e;return E.apply(c?i:this,arguments)}return v}function lc(e){return function(t){t=Xe(t);var i=sr(t)?Jt(t):r,c=i?i[0]:t.charAt(0),f=i?Mn(i,1).join(""):t.slice(1);return c[e]()+f}}function fr(e){return function(t){return Bi(ou(iu(t).replace(Bh,"")),e,"")}}function Fr(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var i=ur(e.prototype),c=e.apply(i,t);return tt(c)?c:i}}function Vm(e,t,i){var c=Fr(e);function f(){for(var v=arguments.length,E=O(v),C=v,j=hr(f);C--;)E[C]=arguments[C];var q=v<3&&E[0]!==j&&E[v-1]!==j?[]:Tn(E,j);if(v-=q.length,v<i)return hc(e,t,Is,f.placeholder,r,E,q,r,r,i-v);var X=this&&this!==pt&&this instanceof f?c:e;return Dt(X,this,E)}return f}function cc(e){return function(t,i,c){var f=Ve(t);if(!Tt(t)){var v=be(i,3);t=ft(t),i=function(C){return v(f[C],C,f)}}var E=e(t,i,c);return E>-1?f[v?t[E]:E]:r}}function uc(e){return bn(function(t){var i=t.length,c=i,f=zt.prototype.thru;for(e&&t.reverse();c--;){var v=t[c];if(typeof v!="function")throw new Wt(m);if(f&&!E&&Bs(v)=="wrapper")var E=new zt([],!0)}for(c=E?c:i;++c<i;){v=t[c];var C=Bs(v),j=C=="wrapper"?bo(v):r;j&&So(j[0])&&j[1]==(F|k|Y|z)&&!j[4].length&&j[9]==1?E=E[Bs(j[0])].apply(E,j[3]):E=v.length==1&&So(v)?E[C]():E.thru(v)}return function(){var q=arguments,X=q[0];if(E&&q.length==1&&je(X))return E.plant(X).value();for(var J=0,se=i?t[J].apply(this,q):X;++J<i;)se=t[J].call(this,se);return se}})}function Is(e,t,i,c,f,v,E,C,j,q){var X=t&F,J=t&N,se=t&I,he=t&(k|B),ye=t&D,Me=se?r:Fr(e);function we(){for(var Fe=arguments.length,We=O(Fe),Ft=Fe;Ft--;)We[Ft]=arguments[Ft];if(he)var Ct=hr(we),Bt=lp(We,Ct);if(c&&(We=sc(We,c,f,he)),v&&(We=ic(We,v,E,he)),Fe-=Bt,he&&Fe<q){var ot=Tn(We,Ct);return hc(e,t,Is,we.placeholder,i,We,ot,C,j,q-Fe)}var tn=J?i:this,Sn=se?tn[e]:e;return Fe=We.length,C?We=g0(We,C):ye&&Fe>1&&We.reverse(),X&&j<Fe&&(We.length=j),this&&this!==pt&&this instanceof we&&(Sn=Me||Fr(Sn)),Sn.apply(tn,We)}return we}function dc(e,t){return function(i,c){return Sm(i,e,t(c),{})}}function Ls(e,t){return function(i,c){var f;if(i===r&&c===r)return t;if(i!==r&&(f=i),c!==r){if(f===r)return c;typeof i=="string"||typeof c=="string"?(i=Lt(i),c=Lt(c)):(i=Vl(i),c=Vl(c)),f=e(i,c)}return f}}function go(e){return bn(function(t){return t=Ze(t,It(be())),De(function(i){var c=this;return e(t,function(f){return Dt(f,c,i)})})})}function Os(e,t){t=t===r?" ":Lt(t);var i=t.length;if(i<2)return i?lo(t,e):t;var c=lo(t,Es(e/ir(t)));return sr(t)?Mn(Jt(c),0,e).join(""):c.slice(0,e)}function Qm(e,t,i,c){var f=t&N,v=Fr(e);function E(){for(var C=-1,j=arguments.length,q=-1,X=c.length,J=O(X+j),se=this&&this!==pt&&this instanceof E?v:e;++q<X;)J[q]=c[q];for(;j--;)J[q++]=arguments[++C];return Dt(se,f?i:this,J)}return E}function fc(e){return function(t,i,c){return c&&typeof c!="number"&&St(t,i,c)&&(i=c=r),t=En(t),i===r?(i=t,t=0):i=En(i),c=c===r?t<i?1:-1:En(c),Lm(t,i,c,e)}}function Fs(e){return function(t,i){return typeof t=="string"&&typeof i=="string"||(t=Xt(t),i=Xt(i)),e(t,i)}}function hc(e,t,i,c,f,v,E,C,j,q){var X=t&k,J=X?E:r,se=X?r:E,he=X?v:r,ye=X?r:v;t|=X?Y:T,t&=~(X?T:Y),t&L||(t&=-4);var Me=[e,t,f,he,J,ye,se,C,j,q],we=i.apply(r,Me);return So(e)&&Cc(we,Me),we.placeholder=c,Nc(we,e,t)}function xo(e){var t=ct[e];return function(i,c){if(i=Xt(i),c=c==null?0:vt(Ae(c),292),c&&Nl(i)){var f=(Xe(i)+"e").split("e"),v=t(f[0]+"e"+(+f[1]+c));return f=(Xe(v)+"e").split("e"),+(f[0]+"e"+(+f[1]-c))}return t(i)}}var Jm=lr&&1/hs(new lr([,-0]))[1]==ee?function(e){return new lr(e)}:Bo;function pc(e){return function(t){var i=bt(t);return i==ge?qi(t):i==ae?mp(t):ap(t,e(t))}}function vn(e,t,i,c,f,v,E,C){var j=t&I;if(!j&&typeof e!="function")throw new Wt(m);var q=c?c.length:0;if(q||(t&=-97,c=f=r),E=E===r?E:ut(Ae(E),0),C=C===r?C:Ae(C),q-=f?f.length:0,t&T){var X=c,J=f;c=f=r}var se=j?r:bo(e),he=[e,t,i,c,f,X,J,v,E,C];if(se&&h0(he,se),e=he[0],t=he[1],i=he[2],c=he[3],f=he[4],C=he[9]=he[9]===r?j?0:e.length:ut(he[9]-q,0),!C&&t&(k|B)&&(t&=-25),!t||t==N)var ye=Km(e,t,i);else t==k||t==B?ye=Vm(e,t,C):(t==Y||t==(N|Y))&&!f.length?ye=Qm(e,t,i,c):ye=Is.apply(r,he);var Me=se?Yl:Cc;return Nc(Me(ye,he),e,t)}function mc(e,t,i,c){return e===r||en(e,ar[i])&&!qe.call(c,i)?t:e}function gc(e,t,i,c,f,v){return tt(e)&&tt(t)&&(v.set(t,e),As(e,t,r,gc,v),v.delete(t)),e}function Zm(e){return Gr(e)?r:e}function xc(e,t,i,c,f,v){var E=i&S,C=e.length,j=t.length;if(C!=j&&!(E&&j>C))return!1;var q=v.get(e),X=v.get(t);if(q&&X)return q==t&&X==e;var J=-1,se=!0,he=i&P?new Hn:r;for(v.set(e,t),v.set(t,e);++J<C;){var ye=e[J],Me=t[J];if(c)var we=E?c(Me,ye,J,t,e,v):c(ye,Me,J,e,t,v);if(we!==r){if(we)continue;se=!1;break}if(he){if(!Ui(t,function(Fe,We){if(!Rr(he,We)&&(ye===Fe||f(ye,Fe,i,c,v)))return he.push(We)})){se=!1;break}}else if(!(ye===Me||f(ye,Me,i,c,v))){se=!1;break}}return v.delete(e),v.delete(t),se}function e0(e,t,i,c,f,v,E){switch(i){case lt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case wt:return!(e.byteLength!=t.byteLength||!v(new vs(e),new vs(t)));case _e:case ce:case Ie:return en(+e,+t);case pe:return e.name==t.name&&e.message==t.message;case Ne:case Ce:return e==t+"";case ge:var C=qi;case ae:var j=c&S;if(C||(C=hs),e.size!=t.size&&!j)return!1;var q=E.get(e);if(q)return q==t;c|=P,E.set(e,t);var X=xc(C(e),C(t),c,f,v,E);return E.delete(e),X;case de:if(Pr)return Pr.call(e)==Pr.call(t)}return!1}function t0(e,t,i,c,f,v){var E=i&S,C=_o(e),j=C.length,q=_o(t),X=q.length;if(j!=X&&!E)return!1;for(var J=j;J--;){var se=C[J];if(!(E?se in t:qe.call(t,se)))return!1}var he=v.get(e),ye=v.get(t);if(he&&ye)return he==t&&ye==e;var Me=!0;v.set(e,t),v.set(t,e);for(var we=E;++J<j;){se=C[J];var Fe=e[se],We=t[se];if(c)var Ft=E?c(We,Fe,se,t,e,v):c(Fe,We,se,e,t,v);if(!(Ft===r?Fe===We||f(Fe,We,i,c,v):Ft)){Me=!1;break}we||(we=se=="constructor")}if(Me&&!we){var Ct=e.constructor,Bt=t.constructor;Ct!=Bt&&"constructor"in e&&"constructor"in t&&!(typeof Ct=="function"&&Ct instanceof Ct&&typeof Bt=="function"&&Bt instanceof Bt)&&(Me=!1)}return v.delete(e),v.delete(t),Me}function bn(e){return No(Ec(e,r,Pc),e+"")}function _o(e){return Ol(e,ft,wo)}function vo(e){return Ol(e,kt,_c)}var bo=Cs?function(e){return Cs.get(e)}:Bo;function Bs(e){for(var t=e.name+"",i=cr[t],c=qe.call(cr,t)?i.length:0;c--;){var f=i[c],v=f.func;if(v==null||v==e)return f.name}return t}function hr(e){var t=qe.call(g,"placeholder")?g:e;return t.placeholder}function be(){var e=g.iteratee||Oo;return e=e===Oo?Ul:e,arguments.length?e(arguments[0],arguments[1]):e}function Us(e,t){var i=e.__data__;return c0(t)?i[typeof t=="string"?"string":"hash"]:i.map}function yo(e){for(var t=ft(e),i=t.length;i--;){var c=t[i],f=e[c];t[i]=[c,f,yc(f)]}return t}function Xn(e,t){var i=fp(e,t);return Bl(i)?i:r}function n0(e){var t=qe.call(e,Wn),i=e[Wn];try{e[Wn]=r;var c=!0}catch{}var f=xs.call(e);return c&&(t?e[Wn]=i:delete e[Wn]),f}var wo=Yi?function(e){return e==null?[]:(e=Ve(e),Nn(Yi(e),function(t){return Sl.call(e,t)}))}:Uo,_c=Yi?function(e){for(var t=[];e;)Rn(t,wo(e)),e=bs(e);return t}:Uo,bt=Et;(Ki&&bt(new Ki(new ArrayBuffer(1)))!=lt||kr&&bt(new kr)!=ge||Vi&&bt(Vi.resolve())!=oe||lr&&bt(new lr)!=ae||jr&&bt(new jr)!=st)&&(bt=function(e){var t=Et(e),i=t==Re?e.constructor:r,c=i?Yn(i):"";if(c)switch(c){case Fp:return lt;case Bp:return ge;case Up:return oe;case Gp:return ae;case Wp:return st}return t});function r0(e,t,i){for(var c=-1,f=i.length;++c<f;){var v=i[c],E=v.size;switch(v.type){case"drop":e+=E;break;case"dropRight":t-=E;break;case"take":t=vt(t,e+E);break;case"takeRight":e=ut(e,t-E);break}}return{start:e,end:t}}function s0(e){var t=e.match(uh);return t?t[1].split(dh):[]}function vc(e,t,i){t=Pn(t,e);for(var c=-1,f=t.length,v=!1;++c<f;){var E=on(t[c]);if(!(v=e!=null&&i(e,E)))break;e=e[E]}return v||++c!=f?v:(f=e==null?0:e.length,!!f&&Xs(f)&&yn(E,f)&&(je(e)||Kn(e)))}function i0(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&qe.call(e,"index")&&(i.index=e.index,i.input=e.input),i}function bc(e){return typeof e.constructor=="function"&&!Br(e)?ur(bs(e)):{}}function o0(e,t,i){var c=e.constructor;switch(t){case wt:return mo(e);case _e:case ce:return new c(+e);case lt:return zm(e,i);case xt:case _t:case On:case Mt:case er:case Fn:case Bn:case tr:case Nr:return nc(e,i);case ge:return new c;case Ie:case Ce:return new c(e);case Ne:return Hm(e);case ae:return new c;case de:return $m(e)}}function a0(e,t){var i=t.length;if(!i)return e;var c=i-1;return t[c]=(i>1?"& ":"")+t[c],t=t.join(i>2?", ":" "),e.replace(ch,`{
|
|
7
|
+
/* [wrapped with `+t+`] */
|
|
8
|
+
`)}function l0(e){return je(e)||Kn(e)||!!(Cl&&e&&e[Cl])}function yn(e,t){var i=typeof e;return t=t??ie,!!t&&(i=="number"||i!="symbol"&&bh.test(e))&&e>-1&&e%1==0&&e<t}function St(e,t,i){if(!tt(i))return!1;var c=typeof t;return(c=="number"?Tt(i)&&yn(t,i.length):c=="string"&&t in i)?en(i[t],e):!1}function Eo(e,t){if(je(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Ot(e)?!0:ih.test(e)||!sh.test(e)||t!=null&&e in Ve(t)}function c0(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function So(e){var t=Bs(e),i=g[t];if(typeof i!="function"||!(t in Ge.prototype))return!1;if(e===i)return!0;var c=bo(i);return!!c&&e===c[0]}function u0(e){return!!yl&&yl in e}var d0=ms?wn:Go;function Br(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||ar;return e===i}function yc(e){return e===e&&!tt(e)}function wc(e,t){return function(i){return i==null?!1:i[e]===t&&(t!==r||e in Ve(i))}}function f0(e){var t=$s(e,function(c){return i.size===d&&i.clear(),c}),i=t.cache;return t}function h0(e,t){var i=e[1],c=t[1],f=i|c,v=f<(N|I|F),E=c==F&&i==k||c==F&&i==z&&e[7].length<=t[8]||c==(F|z)&&t[7].length<=t[8]&&i==k;if(!(v||E))return e;c&N&&(e[2]=t[2],f|=i&N?0:L);var C=t[3];if(C){var j=e[3];e[3]=j?sc(j,C,t[4]):C,e[4]=j?Tn(e[3],p):t[4]}return C=t[5],C&&(j=e[5],e[5]=j?ic(j,C,t[6]):C,e[6]=j?Tn(e[5],p):t[6]),C=t[7],C&&(e[7]=C),c&F&&(e[8]=e[8]==null?t[8]:vt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=f,e}function p0(e){var t=[];if(e!=null)for(var i in Ve(e))t.push(i);return t}function m0(e){return xs.call(e)}function Ec(e,t,i){return t=ut(t===r?e.length-1:t,0),function(){for(var c=arguments,f=-1,v=ut(c.length-t,0),E=O(v);++f<v;)E[f]=c[t+f];f=-1;for(var C=O(t+1);++f<t;)C[f]=c[f];return C[t]=i(E),Dt(e,this,C)}}function Sc(e,t){return t.length<2?e:qn(e,$t(t,0,-1))}function g0(e,t){for(var i=e.length,c=vt(t.length,i),f=Rt(e);c--;){var v=t[c];e[c]=yn(v,i)?f[v]:r}return e}function Co(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Cc=Rc(Yl),Ur=Ap||function(e,t){return pt.setTimeout(e,t)},No=Rc(Bm);function Nc(e,t,i){var c=t+"";return No(e,a0(c,x0(s0(c),i)))}function Rc(e){var t=0,i=0;return function(){var c=Ip(),f=G-(c-i);if(i=c,f>0){if(++t>=M)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Gs(e,t){var i=-1,c=e.length,f=c-1;for(t=t===r?c:t;++i<t;){var v=ao(i,f),E=e[v];e[v]=e[i],e[i]=E}return e.length=t,e}var Tc=f0(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(oh,function(i,c,f,v){t.push(f?v.replace(ph,"$1"):c||i)}),t});function on(e){if(typeof e=="string"||Ot(e))return e;var t=e+"";return t=="0"&&1/e==-ee?"-0":t}function Yn(e){if(e!=null){try{return gs.call(e)}catch{}try{return e+""}catch{}}return""}function x0(e,t){return Gt(ve,function(i){var c="_."+i[0];t&i[1]&&!ds(e,c)&&e.push(c)}),e.sort()}function kc(e){if(e instanceof Ge)return e.clone();var t=new zt(e.__wrapped__,e.__chain__);return t.__actions__=Rt(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function _0(e,t,i){(i?St(e,t,i):t===r)?t=1:t=ut(Ae(t),0);var c=e==null?0:e.length;if(!c||t<1)return[];for(var f=0,v=0,E=O(Es(c/t));f<c;)E[v++]=$t(e,f,f+=t);return E}function v0(e){for(var t=-1,i=e==null?0:e.length,c=0,f=[];++t<i;){var v=e[t];v&&(f[c++]=v)}return f}function b0(){var e=arguments.length;if(!e)return[];for(var t=O(e-1),i=arguments[0],c=e;c--;)t[c-1]=arguments[c];return Rn(je(i)?Rt(i):[i],mt(t,1))}var y0=De(function(e,t){return it(e)?Dr(e,mt(t,1,it,!0)):[]}),w0=De(function(e,t){var i=qt(t);return it(i)&&(i=r),it(e)?Dr(e,mt(t,1,it,!0),be(i,2)):[]}),E0=De(function(e,t){var i=qt(t);return it(i)&&(i=r),it(e)?Dr(e,mt(t,1,it,!0),r,i):[]});function S0(e,t,i){var c=e==null?0:e.length;return c?(t=i||t===r?1:Ae(t),$t(e,t<0?0:t,c)):[]}function C0(e,t,i){var c=e==null?0:e.length;return c?(t=i||t===r?1:Ae(t),t=c-t,$t(e,0,t<0?0:t)):[]}function N0(e,t){return e&&e.length?Ms(e,be(t,3),!0,!0):[]}function R0(e,t){return e&&e.length?Ms(e,be(t,3),!0):[]}function T0(e,t,i,c){var f=e==null?0:e.length;return f?(i&&typeof i!="number"&&St(e,t,i)&&(i=0,c=f),bm(e,t,i,c)):[]}function jc(e,t,i){var c=e==null?0:e.length;if(!c)return-1;var f=i==null?0:Ae(i);return f<0&&(f=ut(c+f,0)),fs(e,be(t,3),f)}function Ac(e,t,i){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return i!==r&&(f=Ae(i),f=i<0?ut(c+f,0):vt(f,c-1)),fs(e,be(t,3),f,!0)}function Pc(e){var t=e==null?0:e.length;return t?mt(e,1):[]}function k0(e){var t=e==null?0:e.length;return t?mt(e,ee):[]}function j0(e,t){var i=e==null?0:e.length;return i?(t=t===r?1:Ae(t),mt(e,t)):[]}function A0(e){for(var t=-1,i=e==null?0:e.length,c={};++t<i;){var f=e[t];c[f[0]]=f[1]}return c}function Mc(e){return e&&e.length?e[0]:r}function P0(e,t,i){var c=e==null?0:e.length;if(!c)return-1;var f=i==null?0:Ae(i);return f<0&&(f=ut(c+f,0)),rr(e,t,f)}function M0(e){var t=e==null?0:e.length;return t?$t(e,0,-1):[]}var D0=De(function(e){var t=Ze(e,ho);return t.length&&t[0]===e[0]?no(t):[]}),I0=De(function(e){var t=qt(e),i=Ze(e,ho);return t===qt(i)?t=r:i.pop(),i.length&&i[0]===e[0]?no(i,be(t,2)):[]}),L0=De(function(e){var t=qt(e),i=Ze(e,ho);return t=typeof t=="function"?t:r,t&&i.pop(),i.length&&i[0]===e[0]?no(i,r,t):[]});function O0(e,t){return e==null?"":Mp.call(e,t)}function qt(e){var t=e==null?0:e.length;return t?e[t-1]:r}function F0(e,t,i){var c=e==null?0:e.length;if(!c)return-1;var f=c;return i!==r&&(f=Ae(i),f=f<0?ut(c+f,0):vt(f,c-1)),t===t?xp(e,t,f):fs(e,hl,f,!0)}function B0(e,t){return e&&e.length?Hl(e,Ae(t)):r}var U0=De(Dc);function Dc(e,t){return e&&e.length&&t&&t.length?oo(e,t):e}function G0(e,t,i){return e&&e.length&&t&&t.length?oo(e,t,be(i,2)):e}function W0(e,t,i){return e&&e.length&&t&&t.length?oo(e,t,r,i):e}var z0=bn(function(e,t){var i=e==null?0:e.length,c=Ji(e,t);return Xl(e,Ze(t,function(f){return yn(f,i)?+f:f}).sort(rc)),c});function H0(e,t){var i=[];if(!(e&&e.length))return i;var c=-1,f=[],v=e.length;for(t=be(t,3);++c<v;){var E=e[c];t(E,c,e)&&(i.push(E),f.push(c))}return Xl(e,f),i}function Ro(e){return e==null?e:Op.call(e)}function $0(e,t,i){var c=e==null?0:e.length;return c?(i&&typeof i!="number"&&St(e,t,i)?(t=0,i=c):(t=t==null?0:Ae(t),i=i===r?c:Ae(i)),$t(e,t,i)):[]}function q0(e,t){return Ps(e,t)}function X0(e,t,i){return co(e,t,be(i,2))}function Y0(e,t){var i=e==null?0:e.length;if(i){var c=Ps(e,t);if(c<i&&en(e[c],t))return c}return-1}function K0(e,t){return Ps(e,t,!0)}function V0(e,t,i){return co(e,t,be(i,2),!0)}function Q0(e,t){var i=e==null?0:e.length;if(i){var c=Ps(e,t,!0)-1;if(en(e[c],t))return c}return-1}function J0(e){return e&&e.length?Kl(e):[]}function Z0(e,t){return e&&e.length?Kl(e,be(t,2)):[]}function eg(e){var t=e==null?0:e.length;return t?$t(e,1,t):[]}function tg(e,t,i){return e&&e.length?(t=i||t===r?1:Ae(t),$t(e,0,t<0?0:t)):[]}function ng(e,t,i){var c=e==null?0:e.length;return c?(t=i||t===r?1:Ae(t),t=c-t,$t(e,t<0?0:t,c)):[]}function rg(e,t){return e&&e.length?Ms(e,be(t,3),!1,!0):[]}function sg(e,t){return e&&e.length?Ms(e,be(t,3)):[]}var ig=De(function(e){return An(mt(e,1,it,!0))}),og=De(function(e){var t=qt(e);return it(t)&&(t=r),An(mt(e,1,it,!0),be(t,2))}),ag=De(function(e){var t=qt(e);return t=typeof t=="function"?t:r,An(mt(e,1,it,!0),r,t)});function lg(e){return e&&e.length?An(e):[]}function cg(e,t){return e&&e.length?An(e,be(t,2)):[]}function ug(e,t){return t=typeof t=="function"?t:r,e&&e.length?An(e,r,t):[]}function To(e){if(!(e&&e.length))return[];var t=0;return e=Nn(e,function(i){if(it(i))return t=ut(i.length,t),!0}),Hi(t,function(i){return Ze(e,Gi(i))})}function Ic(e,t){if(!(e&&e.length))return[];var i=To(e);return t==null?i:Ze(i,function(c){return Dt(t,r,c)})}var dg=De(function(e,t){return it(e)?Dr(e,t):[]}),fg=De(function(e){return fo(Nn(e,it))}),hg=De(function(e){var t=qt(e);return it(t)&&(t=r),fo(Nn(e,it),be(t,2))}),pg=De(function(e){var t=qt(e);return t=typeof t=="function"?t:r,fo(Nn(e,it),r,t)}),mg=De(To);function gg(e,t){return Zl(e||[],t||[],Mr)}function xg(e,t){return Zl(e||[],t||[],Or)}var _g=De(function(e){var t=e.length,i=t>1?e[t-1]:r;return i=typeof i=="function"?(e.pop(),i):r,Ic(e,i)});function Lc(e){var t=g(e);return t.__chain__=!0,t}function vg(e,t){return t(e),e}function Ws(e,t){return t(e)}var bg=bn(function(e){var t=e.length,i=t?e[0]:0,c=this.__wrapped__,f=function(v){return Ji(v,e)};return t>1||this.__actions__.length||!(c instanceof Ge)||!yn(i)?this.thru(f):(c=c.slice(i,+i+(t?1:0)),c.__actions__.push({func:Ws,args:[f],thisArg:r}),new zt(c,this.__chain__).thru(function(v){return t&&!v.length&&v.push(r),v}))});function yg(){return Lc(this)}function wg(){return new zt(this.value(),this.__chain__)}function Eg(){this.__values__===r&&(this.__values__=Vc(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function Sg(){return this}function Cg(e){for(var t,i=this;i instanceof Rs;){var c=kc(i);c.__index__=0,c.__values__=r,t?f.__wrapped__=c:t=c;var f=c;i=i.__wrapped__}return f.__wrapped__=e,t}function Ng(){var e=this.__wrapped__;if(e instanceof Ge){var t=e;return this.__actions__.length&&(t=new Ge(this)),t=t.reverse(),t.__actions__.push({func:Ws,args:[Ro],thisArg:r}),new zt(t,this.__chain__)}return this.thru(Ro)}function Rg(){return Jl(this.__wrapped__,this.__actions__)}var Tg=Ds(function(e,t,i){qe.call(e,i)?++e[i]:_n(e,i,1)});function kg(e,t,i){var c=je(e)?dl:vm;return i&&St(e,t,i)&&(t=r),c(e,be(t,3))}function jg(e,t){var i=je(e)?Nn:Il;return i(e,be(t,3))}var Ag=cc(jc),Pg=cc(Ac);function Mg(e,t){return mt(zs(e,t),1)}function Dg(e,t){return mt(zs(e,t),ee)}function Ig(e,t,i){return i=i===r?1:Ae(i),mt(zs(e,t),i)}function Oc(e,t){var i=je(e)?Gt:jn;return i(e,be(t,3))}function Fc(e,t){var i=je(e)?ep:Dl;return i(e,be(t,3))}var Lg=Ds(function(e,t,i){qe.call(e,i)?e[i].push(t):_n(e,i,[t])});function Og(e,t,i,c){e=Tt(e)?e:mr(e),i=i&&!c?Ae(i):0;var f=e.length;return i<0&&(i=ut(f+i,0)),Ys(e)?i<=f&&e.indexOf(t,i)>-1:!!f&&rr(e,t,i)>-1}var Fg=De(function(e,t,i){var c=-1,f=typeof t=="function",v=Tt(e)?O(e.length):[];return jn(e,function(E){v[++c]=f?Dt(t,E,i):Ir(E,t,i)}),v}),Bg=Ds(function(e,t,i){_n(e,i,t)});function zs(e,t){var i=je(e)?Ze:Gl;return i(e,be(t,3))}function Ug(e,t,i,c){return e==null?[]:(je(t)||(t=t==null?[]:[t]),i=c?r:i,je(i)||(i=i==null?[]:[i]),$l(e,t,i))}var Gg=Ds(function(e,t,i){e[i?0:1].push(t)},function(){return[[],[]]});function Wg(e,t,i){var c=je(e)?Bi:ml,f=arguments.length<3;return c(e,be(t,4),i,f,jn)}function zg(e,t,i){var c=je(e)?tp:ml,f=arguments.length<3;return c(e,be(t,4),i,f,Dl)}function Hg(e,t){var i=je(e)?Nn:Il;return i(e,qs(be(t,3)))}function $g(e){var t=je(e)?jl:Om;return t(e)}function qg(e,t,i){(i?St(e,t,i):t===r)?t=1:t=Ae(t);var c=je(e)?pm:Fm;return c(e,t)}function Xg(e){var t=je(e)?mm:Um;return t(e)}function Yg(e){if(e==null)return 0;if(Tt(e))return Ys(e)?ir(e):e.length;var t=bt(e);return t==ge||t==ae?e.size:so(e).length}function Kg(e,t,i){var c=je(e)?Ui:Gm;return i&&St(e,t,i)&&(t=r),c(e,be(t,3))}var Vg=De(function(e,t){if(e==null)return[];var i=t.length;return i>1&&St(e,t[0],t[1])?t=[]:i>2&&St(t[0],t[1],t[2])&&(t=[t[0]]),$l(e,mt(t,1),[])}),Hs=jp||function(){return pt.Date.now()};function Qg(e,t){if(typeof t!="function")throw new Wt(m);return e=Ae(e),function(){if(--e<1)return t.apply(this,arguments)}}function Bc(e,t,i){return t=i?r:t,t=e&&t==null?e.length:t,vn(e,F,r,r,r,r,t)}function Uc(e,t){var i;if(typeof t!="function")throw new Wt(m);return e=Ae(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var ko=De(function(e,t,i){var c=N;if(i.length){var f=Tn(i,hr(ko));c|=Y}return vn(e,c,t,i,f)}),Gc=De(function(e,t,i){var c=N|I;if(i.length){var f=Tn(i,hr(Gc));c|=Y}return vn(t,c,e,i,f)});function Wc(e,t,i){t=i?r:t;var c=vn(e,k,r,r,r,r,r,t);return c.placeholder=Wc.placeholder,c}function zc(e,t,i){t=i?r:t;var c=vn(e,B,r,r,r,r,r,t);return c.placeholder=zc.placeholder,c}function Hc(e,t,i){var c,f,v,E,C,j,q=0,X=!1,J=!1,se=!0;if(typeof e!="function")throw new Wt(m);t=Xt(t)||0,tt(i)&&(X=!!i.leading,J="maxWait"in i,v=J?ut(Xt(i.maxWait)||0,t):v,se="trailing"in i?!!i.trailing:se);function he(ot){var tn=c,Sn=f;return c=f=r,q=ot,E=e.apply(Sn,tn),E}function ye(ot){return q=ot,C=Ur(Fe,t),X?he(ot):E}function Me(ot){var tn=ot-j,Sn=ot-q,cu=t-tn;return J?vt(cu,v-Sn):cu}function we(ot){var tn=ot-j,Sn=ot-q;return j===r||tn>=t||tn<0||J&&Sn>=v}function Fe(){var ot=Hs();if(we(ot))return We(ot);C=Ur(Fe,Me(ot))}function We(ot){return C=r,se&&c?he(ot):(c=f=r,E)}function Ft(){C!==r&&ec(C),q=0,c=j=f=C=r}function Ct(){return C===r?E:We(Hs())}function Bt(){var ot=Hs(),tn=we(ot);if(c=arguments,f=this,j=ot,tn){if(C===r)return ye(j);if(J)return ec(C),C=Ur(Fe,t),he(j)}return C===r&&(C=Ur(Fe,t)),E}return Bt.cancel=Ft,Bt.flush=Ct,Bt}var Jg=De(function(e,t){return Ml(e,1,t)}),Zg=De(function(e,t,i){return Ml(e,Xt(t)||0,i)});function ex(e){return vn(e,D)}function $s(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Wt(m);var i=function(){var c=arguments,f=t?t.apply(this,c):c[0],v=i.cache;if(v.has(f))return v.get(f);var E=e.apply(this,c);return i.cache=v.set(f,E)||v,E};return i.cache=new($s.Cache||xn),i}$s.Cache=xn;function qs(e){if(typeof e!="function")throw new Wt(m);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function tx(e){return Uc(2,e)}var nx=Wm(function(e,t){t=t.length==1&&je(t[0])?Ze(t[0],It(be())):Ze(mt(t,1),It(be()));var i=t.length;return De(function(c){for(var f=-1,v=vt(c.length,i);++f<v;)c[f]=t[f].call(this,c[f]);return Dt(e,this,c)})}),jo=De(function(e,t){var i=Tn(t,hr(jo));return vn(e,Y,r,t,i)}),$c=De(function(e,t){var i=Tn(t,hr($c));return vn(e,T,r,t,i)}),rx=bn(function(e,t){return vn(e,z,r,r,r,t)});function sx(e,t){if(typeof e!="function")throw new Wt(m);return t=t===r?t:Ae(t),De(e,t)}function ix(e,t){if(typeof e!="function")throw new Wt(m);return t=t==null?0:ut(Ae(t),0),De(function(i){var c=i[t],f=Mn(i,0,t);return c&&Rn(f,c),Dt(e,this,f)})}function ox(e,t,i){var c=!0,f=!0;if(typeof e!="function")throw new Wt(m);return tt(i)&&(c="leading"in i?!!i.leading:c,f="trailing"in i?!!i.trailing:f),Hc(e,t,{leading:c,maxWait:t,trailing:f})}function ax(e){return Bc(e,1)}function lx(e,t){return jo(po(t),e)}function cx(){if(!arguments.length)return[];var e=arguments[0];return je(e)?e:[e]}function ux(e){return Ht(e,w)}function dx(e,t){return t=typeof t=="function"?t:r,Ht(e,w,t)}function fx(e){return Ht(e,_|w)}function hx(e,t){return t=typeof t=="function"?t:r,Ht(e,_|w,t)}function px(e,t){return t==null||Pl(e,t,ft(t))}function en(e,t){return e===t||e!==e&&t!==t}var mx=Fs(to),gx=Fs(function(e,t){return e>=t}),Kn=Fl((function(){return arguments})())?Fl:function(e){return nt(e)&&qe.call(e,"callee")&&!Sl.call(e,"callee")},je=O.isArray,xx=il?It(il):Cm;function Tt(e){return e!=null&&Xs(e.length)&&!wn(e)}function it(e){return nt(e)&&Tt(e)}function _x(e){return e===!0||e===!1||nt(e)&&Et(e)==_e}var Dn=Pp||Go,vx=ol?It(ol):Nm;function bx(e){return nt(e)&&e.nodeType===1&&!Gr(e)}function yx(e){if(e==null)return!0;if(Tt(e)&&(je(e)||typeof e=="string"||typeof e.splice=="function"||Dn(e)||pr(e)||Kn(e)))return!e.length;var t=bt(e);if(t==ge||t==ae)return!e.size;if(Br(e))return!so(e).length;for(var i in e)if(qe.call(e,i))return!1;return!0}function wx(e,t){return Lr(e,t)}function Ex(e,t,i){i=typeof i=="function"?i:r;var c=i?i(e,t):r;return c===r?Lr(e,t,r,i):!!c}function Ao(e){if(!nt(e))return!1;var t=Et(e);return t==pe||t==K||typeof e.message=="string"&&typeof e.name=="string"&&!Gr(e)}function Sx(e){return typeof e=="number"&&Nl(e)}function wn(e){if(!tt(e))return!1;var t=Et(e);return t==Se||t==He||t==Le||t==me}function qc(e){return typeof e=="number"&&e==Ae(e)}function Xs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ie}function tt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function nt(e){return e!=null&&typeof e=="object"}var Xc=al?It(al):Tm;function Cx(e,t){return e===t||ro(e,t,yo(t))}function Nx(e,t,i){return i=typeof i=="function"?i:r,ro(e,t,yo(t),i)}function Rx(e){return Yc(e)&&e!=+e}function Tx(e){if(d0(e))throw new ke(l);return Bl(e)}function kx(e){return e===null}function jx(e){return e==null}function Yc(e){return typeof e=="number"||nt(e)&&Et(e)==Ie}function Gr(e){if(!nt(e)||Et(e)!=Re)return!1;var t=bs(e);if(t===null)return!0;var i=qe.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&gs.call(i)==Np}var Po=ll?It(ll):km;function Ax(e){return qc(e)&&e>=-ie&&e<=ie}var Kc=cl?It(cl):jm;function Ys(e){return typeof e=="string"||!je(e)&&nt(e)&&Et(e)==Ce}function Ot(e){return typeof e=="symbol"||nt(e)&&Et(e)==de}var pr=ul?It(ul):Am;function Px(e){return e===r}function Mx(e){return nt(e)&&bt(e)==st}function Dx(e){return nt(e)&&Et(e)==ht}var Ix=Fs(io),Lx=Fs(function(e,t){return e<=t});function Vc(e){if(!e)return[];if(Tt(e))return Ys(e)?Jt(e):Rt(e);if(Tr&&e[Tr])return pp(e[Tr]());var t=bt(e),i=t==ge?qi:t==ae?hs:mr;return i(e)}function En(e){if(!e)return e===0?e:0;if(e=Xt(e),e===ee||e===-ee){var t=e<0?-1:1;return t*ne}return e===e?e:0}function Ae(e){var t=En(e),i=t%1;return t===t?i?t-i:t:0}function Qc(e){return e?$n(Ae(e),0,$):0}function Xt(e){if(typeof e=="number")return e;if(Ot(e))return A;if(tt(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=tt(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=gl(e);var i=xh.test(e);return i||vh.test(e)?Qh(e.slice(2),i?2:8):gh.test(e)?A:+e}function Jc(e){return sn(e,kt(e))}function Ox(e){return e?$n(Ae(e),-ie,ie):e===0?e:0}function Xe(e){return e==null?"":Lt(e)}var Fx=dr(function(e,t){if(Br(t)||Tt(t)){sn(t,ft(t),e);return}for(var i in t)qe.call(t,i)&&Mr(e,i,t[i])}),Zc=dr(function(e,t){sn(t,kt(t),e)}),Ks=dr(function(e,t,i,c){sn(t,kt(t),e,c)}),Bx=dr(function(e,t,i,c){sn(t,ft(t),e,c)}),Ux=bn(Ji);function Gx(e,t){var i=ur(e);return t==null?i:Al(i,t)}var Wx=De(function(e,t){e=Ve(e);var i=-1,c=t.length,f=c>2?t[2]:r;for(f&&St(t[0],t[1],f)&&(c=1);++i<c;)for(var v=t[i],E=kt(v),C=-1,j=E.length;++C<j;){var q=E[C],X=e[q];(X===r||en(X,ar[q])&&!qe.call(e,q))&&(e[q]=v[q])}return e}),zx=De(function(e){return e.push(r,gc),Dt(eu,r,e)});function Hx(e,t){return fl(e,be(t,3),rn)}function $x(e,t){return fl(e,be(t,3),eo)}function qx(e,t){return e==null?e:Zi(e,be(t,3),kt)}function Xx(e,t){return e==null?e:Ll(e,be(t,3),kt)}function Yx(e,t){return e&&rn(e,be(t,3))}function Kx(e,t){return e&&eo(e,be(t,3))}function Vx(e){return e==null?[]:js(e,ft(e))}function Qx(e){return e==null?[]:js(e,kt(e))}function Mo(e,t,i){var c=e==null?r:qn(e,t);return c===r?i:c}function Jx(e,t){return e!=null&&vc(e,t,ym)}function Do(e,t){return e!=null&&vc(e,t,wm)}var Zx=dc(function(e,t,i){t!=null&&typeof t.toString!="function"&&(t=xs.call(t)),e[t]=i},Lo(jt)),e_=dc(function(e,t,i){t!=null&&typeof t.toString!="function"&&(t=xs.call(t)),qe.call(e,t)?e[t].push(i):e[t]=[i]},be),t_=De(Ir);function ft(e){return Tt(e)?kl(e):so(e)}function kt(e){return Tt(e)?kl(e,!0):Pm(e)}function n_(e,t){var i={};return t=be(t,3),rn(e,function(c,f,v){_n(i,t(c,f,v),c)}),i}function r_(e,t){var i={};return t=be(t,3),rn(e,function(c,f,v){_n(i,f,t(c,f,v))}),i}var s_=dr(function(e,t,i){As(e,t,i)}),eu=dr(function(e,t,i,c){As(e,t,i,c)}),i_=bn(function(e,t){var i={};if(e==null)return i;var c=!1;t=Ze(t,function(v){return v=Pn(v,e),c||(c=v.length>1),v}),sn(e,vo(e),i),c&&(i=Ht(i,_|y|w,Zm));for(var f=t.length;f--;)uo(i,t[f]);return i});function o_(e,t){return tu(e,qs(be(t)))}var a_=bn(function(e,t){return e==null?{}:Dm(e,t)});function tu(e,t){if(e==null)return{};var i=Ze(vo(e),function(c){return[c]});return t=be(t),ql(e,i,function(c,f){return t(c,f[0])})}function l_(e,t,i){t=Pn(t,e);var c=-1,f=t.length;for(f||(f=1,e=r);++c<f;){var v=e==null?r:e[on(t[c])];v===r&&(c=f,v=i),e=wn(v)?v.call(e):v}return e}function c_(e,t,i){return e==null?e:Or(e,t,i)}function u_(e,t,i,c){return c=typeof c=="function"?c:r,e==null?e:Or(e,t,i,c)}var nu=pc(ft),ru=pc(kt);function d_(e,t,i){var c=je(e),f=c||Dn(e)||pr(e);if(t=be(t,4),i==null){var v=e&&e.constructor;f?i=c?new v:[]:tt(e)?i=wn(v)?ur(bs(e)):{}:i={}}return(f?Gt:rn)(e,function(E,C,j){return t(i,E,C,j)}),i}function f_(e,t){return e==null?!0:uo(e,t)}function h_(e,t,i){return e==null?e:Ql(e,t,po(i))}function p_(e,t,i,c){return c=typeof c=="function"?c:r,e==null?e:Ql(e,t,po(i),c)}function mr(e){return e==null?[]:$i(e,ft(e))}function m_(e){return e==null?[]:$i(e,kt(e))}function g_(e,t,i){return i===r&&(i=t,t=r),i!==r&&(i=Xt(i),i=i===i?i:0),t!==r&&(t=Xt(t),t=t===t?t:0),$n(Xt(e),t,i)}function x_(e,t,i){return t=En(t),i===r?(i=t,t=0):i=En(i),e=Xt(e),Em(e,t,i)}function __(e,t,i){if(i&&typeof i!="boolean"&&St(e,t,i)&&(t=i=r),i===r&&(typeof t=="boolean"?(i=t,t=r):typeof e=="boolean"&&(i=e,e=r)),e===r&&t===r?(e=0,t=1):(e=En(e),t===r?(t=e,e=0):t=En(t)),e>t){var c=e;e=t,t=c}if(i||e%1||t%1){var f=Rl();return vt(e+f*(t-e+Vh("1e-"+((f+"").length-1))),t)}return ao(e,t)}var v_=fr(function(e,t,i){return t=t.toLowerCase(),e+(i?su(t):t)});function su(e){return Io(Xe(e).toLowerCase())}function iu(e){return e=Xe(e),e&&e.replace(yh,cp).replace(Uh,"")}function b_(e,t,i){e=Xe(e),t=Lt(t);var c=e.length;i=i===r?c:$n(Ae(i),0,c);var f=i;return i-=t.length,i>=0&&e.slice(i,f)==t}function y_(e){return e=Xe(e),e&&as.test(e)?e.replace(Qt,up):e}function w_(e){return e=Xe(e),e&&ah.test(e)?e.replace(ki,"\\$&"):e}var E_=fr(function(e,t,i){return e+(i?"-":"")+t.toLowerCase()}),S_=fr(function(e,t,i){return e+(i?" ":"")+t.toLowerCase()}),C_=lc("toLowerCase");function N_(e,t,i){e=Xe(e),t=Ae(t);var c=t?ir(e):0;if(!t||c>=t)return e;var f=(t-c)/2;return Os(Ss(f),i)+e+Os(Es(f),i)}function R_(e,t,i){e=Xe(e),t=Ae(t);var c=t?ir(e):0;return t&&c<t?e+Os(t-c,i):e}function T_(e,t,i){e=Xe(e),t=Ae(t);var c=t?ir(e):0;return t&&c<t?Os(t-c,i)+e:e}function k_(e,t,i){return i||t==null?t=0:t&&(t=+t),Lp(Xe(e).replace(ji,""),t||0)}function j_(e,t,i){return(i?St(e,t,i):t===r)?t=1:t=Ae(t),lo(Xe(e),t)}function A_(){var e=arguments,t=Xe(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var P_=fr(function(e,t,i){return e+(i?"_":"")+t.toLowerCase()});function M_(e,t,i){return i&&typeof i!="number"&&St(e,t,i)&&(t=i=r),i=i===r?$:i>>>0,i?(e=Xe(e),e&&(typeof t=="string"||t!=null&&!Po(t))&&(t=Lt(t),!t&&sr(e))?Mn(Jt(e),0,i):e.split(t,i)):[]}var D_=fr(function(e,t,i){return e+(i?" ":"")+Io(t)});function I_(e,t,i){return e=Xe(e),i=i==null?0:$n(Ae(i),0,e.length),t=Lt(t),e.slice(i,i+t.length)==t}function L_(e,t,i){var c=g.templateSettings;i&&St(e,t,i)&&(t=r),e=Xe(e),t=Ks({},t,c,mc);var f=Ks({},t.imports,c.imports,mc),v=ft(f),E=$i(f,v),C,j,q=0,X=t.interpolate||ls,J="__p += '",se=Xi((t.escape||ls).source+"|"+X.source+"|"+(X===Oa?mh:ls).source+"|"+(t.evaluate||ls).source+"|$","g"),he="//# sourceURL="+(qe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++$h+"]")+`
|
|
9
|
+
`;e.replace(se,function(we,Fe,We,Ft,Ct,Bt){return We||(We=Ft),J+=e.slice(q,Bt).replace(wh,dp),Fe&&(C=!0,J+=`' +
|
|
10
|
+
__e(`+Fe+`) +
|
|
11
|
+
'`),Ct&&(j=!0,J+=`';
|
|
12
|
+
`+Ct+`;
|
|
13
|
+
__p += '`),We&&(J+=`' +
|
|
14
|
+
((__t = (`+We+`)) == null ? '' : __t) +
|
|
15
|
+
'`),q=Bt+we.length,we}),J+=`';
|
|
16
|
+
`;var ye=qe.call(t,"variable")&&t.variable;if(!ye)J=`with (obj) {
|
|
17
|
+
`+J+`
|
|
18
|
+
}
|
|
19
|
+
`;else if(hh.test(ye))throw new ke(b);J=(j?J.replace(Un,""):J).replace(os,"$1").replace(V,"$1;"),J="function("+(ye||"obj")+`) {
|
|
20
|
+
`+(ye?"":`obj || (obj = {});
|
|
21
|
+
`)+"var __t, __p = ''"+(C?", __e = _.escape":"")+(j?`, __j = Array.prototype.join;
|
|
22
|
+
function print() { __p += __j.call(arguments, '') }
|
|
23
|
+
`:`;
|
|
24
|
+
`)+J+`return __p
|
|
25
|
+
}`;var Me=au(function(){return $e(v,he+"return "+J).apply(r,E)});if(Me.source=J,Ao(Me))throw Me;return Me}function O_(e){return Xe(e).toLowerCase()}function F_(e){return Xe(e).toUpperCase()}function B_(e,t,i){if(e=Xe(e),e&&(i||t===r))return gl(e);if(!e||!(t=Lt(t)))return e;var c=Jt(e),f=Jt(t),v=xl(c,f),E=_l(c,f)+1;return Mn(c,v,E).join("")}function U_(e,t,i){if(e=Xe(e),e&&(i||t===r))return e.slice(0,bl(e)+1);if(!e||!(t=Lt(t)))return e;var c=Jt(e),f=_l(c,Jt(t))+1;return Mn(c,0,f).join("")}function G_(e,t,i){if(e=Xe(e),e&&(i||t===r))return e.replace(ji,"");if(!e||!(t=Lt(t)))return e;var c=Jt(e),f=xl(c,Jt(t));return Mn(c,f).join("")}function W_(e,t){var i=te,c=U;if(tt(t)){var f="separator"in t?t.separator:f;i="length"in t?Ae(t.length):i,c="omission"in t?Lt(t.omission):c}e=Xe(e);var v=e.length;if(sr(e)){var E=Jt(e);v=E.length}if(i>=v)return e;var C=i-ir(c);if(C<1)return c;var j=E?Mn(E,0,C).join(""):e.slice(0,C);if(f===r)return j+c;if(E&&(C+=j.length-C),Po(f)){if(e.slice(C).search(f)){var q,X=j;for(f.global||(f=Xi(f.source,Xe(Fa.exec(f))+"g")),f.lastIndex=0;q=f.exec(X);)var J=q.index;j=j.slice(0,J===r?C:J)}}else if(e.indexOf(Lt(f),C)!=C){var se=j.lastIndexOf(f);se>-1&&(j=j.slice(0,se))}return j+c}function z_(e){return e=Xe(e),e&&Ti.test(e)?e.replace(Ee,_p):e}var H_=fr(function(e,t,i){return e+(i?" ":"")+t.toUpperCase()}),Io=lc("toUpperCase");function ou(e,t,i){return e=Xe(e),t=i?r:t,t===r?hp(e)?yp(e):sp(e):e.match(t)||[]}var au=De(function(e,t){try{return Dt(e,r,t)}catch(i){return Ao(i)?i:new ke(i)}}),$_=bn(function(e,t){return Gt(t,function(i){i=on(i),_n(e,i,ko(e[i],e))}),e});function q_(e){var t=e==null?0:e.length,i=be();return e=t?Ze(e,function(c){if(typeof c[1]!="function")throw new Wt(m);return[i(c[0]),c[1]]}):[],De(function(c){for(var f=-1;++f<t;){var v=e[f];if(Dt(v[0],this,c))return Dt(v[1],this,c)}})}function X_(e){return _m(Ht(e,_))}function Lo(e){return function(){return e}}function Y_(e,t){return e==null||e!==e?t:e}var K_=uc(),V_=uc(!0);function jt(e){return e}function Oo(e){return Ul(typeof e=="function"?e:Ht(e,_))}function Q_(e){return Wl(Ht(e,_))}function J_(e,t){return zl(e,Ht(t,_))}var Z_=De(function(e,t){return function(i){return Ir(i,e,t)}}),ev=De(function(e,t){return function(i){return Ir(e,i,t)}});function Fo(e,t,i){var c=ft(t),f=js(t,c);i==null&&!(tt(t)&&(f.length||!c.length))&&(i=t,t=e,e=this,f=js(t,ft(t)));var v=!(tt(i)&&"chain"in i)||!!i.chain,E=wn(e);return Gt(f,function(C){var j=t[C];e[C]=j,E&&(e.prototype[C]=function(){var q=this.__chain__;if(v||q){var X=e(this.__wrapped__),J=X.__actions__=Rt(this.__actions__);return J.push({func:j,args:arguments,thisArg:e}),X.__chain__=q,X}return j.apply(e,Rn([this.value()],arguments))})}),e}function tv(){return pt._===this&&(pt._=Rp),this}function Bo(){}function nv(e){return e=Ae(e),De(function(t){return Hl(t,e)})}var rv=go(Ze),sv=go(dl),iv=go(Ui);function lu(e){return Eo(e)?Gi(on(e)):Im(e)}function ov(e){return function(t){return e==null?r:qn(e,t)}}var av=fc(),lv=fc(!0);function Uo(){return[]}function Go(){return!1}function cv(){return{}}function uv(){return""}function dv(){return!0}function fv(e,t){if(e=Ae(e),e<1||e>ie)return[];var i=$,c=vt(e,$);t=be(t),e-=$;for(var f=Hi(c,t);++i<e;)t(i);return f}function hv(e){return je(e)?Ze(e,on):Ot(e)?[e]:Rt(Tc(Xe(e)))}function pv(e){var t=++Cp;return Xe(e)+t}var mv=Ls(function(e,t){return e+t},0),gv=xo("ceil"),xv=Ls(function(e,t){return e/t},1),_v=xo("floor");function vv(e){return e&&e.length?ks(e,jt,to):r}function bv(e,t){return e&&e.length?ks(e,be(t,2),to):r}function yv(e){return pl(e,jt)}function wv(e,t){return pl(e,be(t,2))}function Ev(e){return e&&e.length?ks(e,jt,io):r}function Sv(e,t){return e&&e.length?ks(e,be(t,2),io):r}var Cv=Ls(function(e,t){return e*t},1),Nv=xo("round"),Rv=Ls(function(e,t){return e-t},0);function Tv(e){return e&&e.length?zi(e,jt):0}function kv(e,t){return e&&e.length?zi(e,be(t,2)):0}return g.after=Qg,g.ary=Bc,g.assign=Fx,g.assignIn=Zc,g.assignInWith=Ks,g.assignWith=Bx,g.at=Ux,g.before=Uc,g.bind=ko,g.bindAll=$_,g.bindKey=Gc,g.castArray=cx,g.chain=Lc,g.chunk=_0,g.compact=v0,g.concat=b0,g.cond=q_,g.conforms=X_,g.constant=Lo,g.countBy=Tg,g.create=Gx,g.curry=Wc,g.curryRight=zc,g.debounce=Hc,g.defaults=Wx,g.defaultsDeep=zx,g.defer=Jg,g.delay=Zg,g.difference=y0,g.differenceBy=w0,g.differenceWith=E0,g.drop=S0,g.dropRight=C0,g.dropRightWhile=N0,g.dropWhile=R0,g.fill=T0,g.filter=jg,g.flatMap=Mg,g.flatMapDeep=Dg,g.flatMapDepth=Ig,g.flatten=Pc,g.flattenDeep=k0,g.flattenDepth=j0,g.flip=ex,g.flow=K_,g.flowRight=V_,g.fromPairs=A0,g.functions=Vx,g.functionsIn=Qx,g.groupBy=Lg,g.initial=M0,g.intersection=D0,g.intersectionBy=I0,g.intersectionWith=L0,g.invert=Zx,g.invertBy=e_,g.invokeMap=Fg,g.iteratee=Oo,g.keyBy=Bg,g.keys=ft,g.keysIn=kt,g.map=zs,g.mapKeys=n_,g.mapValues=r_,g.matches=Q_,g.matchesProperty=J_,g.memoize=$s,g.merge=s_,g.mergeWith=eu,g.method=Z_,g.methodOf=ev,g.mixin=Fo,g.negate=qs,g.nthArg=nv,g.omit=i_,g.omitBy=o_,g.once=tx,g.orderBy=Ug,g.over=rv,g.overArgs=nx,g.overEvery=sv,g.overSome=iv,g.partial=jo,g.partialRight=$c,g.partition=Gg,g.pick=a_,g.pickBy=tu,g.property=lu,g.propertyOf=ov,g.pull=U0,g.pullAll=Dc,g.pullAllBy=G0,g.pullAllWith=W0,g.pullAt=z0,g.range=av,g.rangeRight=lv,g.rearg=rx,g.reject=Hg,g.remove=H0,g.rest=sx,g.reverse=Ro,g.sampleSize=qg,g.set=c_,g.setWith=u_,g.shuffle=Xg,g.slice=$0,g.sortBy=Vg,g.sortedUniq=J0,g.sortedUniqBy=Z0,g.split=M_,g.spread=ix,g.tail=eg,g.take=tg,g.takeRight=ng,g.takeRightWhile=rg,g.takeWhile=sg,g.tap=vg,g.throttle=ox,g.thru=Ws,g.toArray=Vc,g.toPairs=nu,g.toPairsIn=ru,g.toPath=hv,g.toPlainObject=Jc,g.transform=d_,g.unary=ax,g.union=ig,g.unionBy=og,g.unionWith=ag,g.uniq=lg,g.uniqBy=cg,g.uniqWith=ug,g.unset=f_,g.unzip=To,g.unzipWith=Ic,g.update=h_,g.updateWith=p_,g.values=mr,g.valuesIn=m_,g.without=dg,g.words=ou,g.wrap=lx,g.xor=fg,g.xorBy=hg,g.xorWith=pg,g.zip=mg,g.zipObject=gg,g.zipObjectDeep=xg,g.zipWith=_g,g.entries=nu,g.entriesIn=ru,g.extend=Zc,g.extendWith=Ks,Fo(g,g),g.add=mv,g.attempt=au,g.camelCase=v_,g.capitalize=su,g.ceil=gv,g.clamp=g_,g.clone=ux,g.cloneDeep=fx,g.cloneDeepWith=hx,g.cloneWith=dx,g.conformsTo=px,g.deburr=iu,g.defaultTo=Y_,g.divide=xv,g.endsWith=b_,g.eq=en,g.escape=y_,g.escapeRegExp=w_,g.every=kg,g.find=Ag,g.findIndex=jc,g.findKey=Hx,g.findLast=Pg,g.findLastIndex=Ac,g.findLastKey=$x,g.floor=_v,g.forEach=Oc,g.forEachRight=Fc,g.forIn=qx,g.forInRight=Xx,g.forOwn=Yx,g.forOwnRight=Kx,g.get=Mo,g.gt=mx,g.gte=gx,g.has=Jx,g.hasIn=Do,g.head=Mc,g.identity=jt,g.includes=Og,g.indexOf=P0,g.inRange=x_,g.invoke=t_,g.isArguments=Kn,g.isArray=je,g.isArrayBuffer=xx,g.isArrayLike=Tt,g.isArrayLikeObject=it,g.isBoolean=_x,g.isBuffer=Dn,g.isDate=vx,g.isElement=bx,g.isEmpty=yx,g.isEqual=wx,g.isEqualWith=Ex,g.isError=Ao,g.isFinite=Sx,g.isFunction=wn,g.isInteger=qc,g.isLength=Xs,g.isMap=Xc,g.isMatch=Cx,g.isMatchWith=Nx,g.isNaN=Rx,g.isNative=Tx,g.isNil=jx,g.isNull=kx,g.isNumber=Yc,g.isObject=tt,g.isObjectLike=nt,g.isPlainObject=Gr,g.isRegExp=Po,g.isSafeInteger=Ax,g.isSet=Kc,g.isString=Ys,g.isSymbol=Ot,g.isTypedArray=pr,g.isUndefined=Px,g.isWeakMap=Mx,g.isWeakSet=Dx,g.join=O0,g.kebabCase=E_,g.last=qt,g.lastIndexOf=F0,g.lowerCase=S_,g.lowerFirst=C_,g.lt=Ix,g.lte=Lx,g.max=vv,g.maxBy=bv,g.mean=yv,g.meanBy=wv,g.min=Ev,g.minBy=Sv,g.stubArray=Uo,g.stubFalse=Go,g.stubObject=cv,g.stubString=uv,g.stubTrue=dv,g.multiply=Cv,g.nth=B0,g.noConflict=tv,g.noop=Bo,g.now=Hs,g.pad=N_,g.padEnd=R_,g.padStart=T_,g.parseInt=k_,g.random=__,g.reduce=Wg,g.reduceRight=zg,g.repeat=j_,g.replace=A_,g.result=l_,g.round=Nv,g.runInContext=R,g.sample=$g,g.size=Yg,g.snakeCase=P_,g.some=Kg,g.sortedIndex=q0,g.sortedIndexBy=X0,g.sortedIndexOf=Y0,g.sortedLastIndex=K0,g.sortedLastIndexBy=V0,g.sortedLastIndexOf=Q0,g.startCase=D_,g.startsWith=I_,g.subtract=Rv,g.sum=Tv,g.sumBy=kv,g.template=L_,g.times=fv,g.toFinite=En,g.toInteger=Ae,g.toLength=Qc,g.toLower=O_,g.toNumber=Xt,g.toSafeInteger=Ox,g.toString=Xe,g.toUpper=F_,g.trim=B_,g.trimEnd=U_,g.trimStart=G_,g.truncate=W_,g.unescape=z_,g.uniqueId=pv,g.upperCase=H_,g.upperFirst=Io,g.each=Oc,g.eachRight=Fc,g.first=Mc,Fo(g,(function(){var e={};return rn(g,function(t,i){qe.call(g.prototype,i)||(e[i]=t)}),e})(),{chain:!1}),g.VERSION=a,Gt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){g[e].placeholder=g}),Gt(["drop","take"],function(e,t){Ge.prototype[e]=function(i){i=i===r?1:ut(Ae(i),0);var c=this.__filtered__&&!t?new Ge(this):this.clone();return c.__filtered__?c.__takeCount__=vt(i,c.__takeCount__):c.__views__.push({size:vt(i,$),type:e+(c.__dir__<0?"Right":"")}),c},Ge.prototype[e+"Right"]=function(i){return this.reverse()[e](i).reverse()}}),Gt(["filter","map","takeWhile"],function(e,t){var i=t+1,c=i==H||i==Q;Ge.prototype[e]=function(f){var v=this.clone();return v.__iteratees__.push({iteratee:be(f,3),type:i}),v.__filtered__=v.__filtered__||c,v}}),Gt(["head","last"],function(e,t){var i="take"+(t?"Right":"");Ge.prototype[e]=function(){return this[i](1).value()[0]}}),Gt(["initial","tail"],function(e,t){var i="drop"+(t?"":"Right");Ge.prototype[e]=function(){return this.__filtered__?new Ge(this):this[i](1)}}),Ge.prototype.compact=function(){return this.filter(jt)},Ge.prototype.find=function(e){return this.filter(e).head()},Ge.prototype.findLast=function(e){return this.reverse().find(e)},Ge.prototype.invokeMap=De(function(e,t){return typeof e=="function"?new Ge(this):this.map(function(i){return Ir(i,e,t)})}),Ge.prototype.reject=function(e){return this.filter(qs(be(e)))},Ge.prototype.slice=function(e,t){e=Ae(e);var i=this;return i.__filtered__&&(e>0||t<0)?new Ge(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==r&&(t=Ae(t),i=t<0?i.dropRight(-t):i.take(t-e)),i)},Ge.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Ge.prototype.toArray=function(){return this.take($)},rn(Ge.prototype,function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),c=/^(?:head|last)$/.test(t),f=g[c?"take"+(t=="last"?"Right":""):t],v=c||/^find/.test(t);f&&(g.prototype[t]=function(){var E=this.__wrapped__,C=c?[1]:arguments,j=E instanceof Ge,q=C[0],X=j||je(E),J=function(Fe){var We=f.apply(g,Rn([Fe],C));return c&&se?We[0]:We};X&&i&&typeof q=="function"&&q.length!=1&&(j=X=!1);var se=this.__chain__,he=!!this.__actions__.length,ye=v&&!se,Me=j&&!he;if(!v&&X){E=Me?E:new Ge(this);var we=e.apply(E,C);return we.__actions__.push({func:Ws,args:[J],thisArg:r}),new zt(we,se)}return ye&&Me?e.apply(this,C):(we=this.thru(J),ye?c?we.value()[0]:we.value():we)})}),Gt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ps[e],i=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);g.prototype[e]=function(){var f=arguments;if(c&&!this.__chain__){var v=this.value();return t.apply(je(v)?v:[],f)}return this[i](function(E){return t.apply(je(E)?E:[],f)})}}),rn(Ge.prototype,function(e,t){var i=g[t];if(i){var c=i.name+"";qe.call(cr,c)||(cr[c]=[]),cr[c].push({name:t,func:i})}}),cr[Is(r,I).name]=[{name:"wrapper",func:r}],Ge.prototype.clone=zp,Ge.prototype.reverse=Hp,Ge.prototype.value=$p,g.prototype.at=bg,g.prototype.chain=yg,g.prototype.commit=wg,g.prototype.next=Eg,g.prototype.plant=Cg,g.prototype.reverse=Ng,g.prototype.toJSON=g.prototype.valueOf=g.prototype.value=Rg,g.prototype.first=g.prototype.head,Tr&&(g.prototype[Tr]=Sg),g}),or=wp();Gn?((Gn.exports=or)._=or,Li._=or):pt._=or}).call(vw)})(Yr,Yr.exports)),Yr.exports}var Mf=bw();const yw=Gv(Mf);function ww(s,n){const[r,a]=x.useState(s),u=x.useRef(yw.debounce(a,n)),l=x.useCallback(m=>{u.current(m)},[]);return[r,l]}const Ew=[{id:"mumu",nameKey:"emulatorMumu",ip:"127.0.0.1",port:7555},{id:"nox",nameKey:"emulatorNox",ip:"127.0.0.1",port:62001},{id:"ldplayer",nameKey:"emulatorLdplayer",ip:"127.0.0.1",port:5555},{id:"bluestacks",nameKey:"emulatorBluestacks",ip:"127.0.0.1",port:5555},{id:"custom",nameKey:"emulatorCustom",ip:"",port:5555}],Sw=()=>{try{const s=localStorage.getItem("sidebar-collapsed");return s!==null?JSON.parse(s):!1}catch(s){return console.warn("Failed to load sidebar collapsed state:",s),!1}};function Cw({devices:s,currentDeviceId:n,onSelectDevice:r,onOpenConfig:a,onConnectWifi:u,onDisconnectWifi:l,onRefreshDevices:m,onOpenGroupManager:b,showToast:h}){const d=pn(),[p,_]=x.useState(Sw),[y,w]=x.useState([]),S=x.useCallback(async()=>{try{const V=await $u();w(V.groups)}catch(V){console.error("Failed to fetch device groups:",V)}},[]);x.useEffect(()=>{S()},[S]),x.useEffect(()=>{S()},[s,S]);const[P,N]=x.useState(!1),[I,L]=x.useState(""),[k,B]=x.useState("5555"),[Y,T]=x.useState(""),[F,z]=x.useState(""),[D,te]=x.useState("custom"),[U,M]=x.useState("direct"),[G,H]=x.useState(""),[Z,Q]=x.useState(""),[ee,ie]=x.useState("5555"),[ne,A]=x.useState(""),[$,re]=x.useState(!1),[le,ve]=x.useState([]),[xe,Ue]=ww(!1,300),[Le,_e]=x.useState(""),[ce,K]=x.useState(null),[pe,Se]=x.useState(!1),He=x.useRef(null),[ge,Ie]=x.useState(""),[Te,Re]=x.useState(""),[oe,me]=x.useState(!1),[Ne,ae]=x.useState([]),[Ce,de]=x.useState(null),[Oe,st]=x.useState(!1);x.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(p))},[p]),x.useEffect(()=>{const V=Ee=>{(Ee.metaKey||Ee.ctrlKey)&&Ee.key==="b"&&(Ee.preventDefault(),_(!p))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[p]);const ht=()=>{_(!p)},wt=V=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(V)?V.split(".").every(Ti=>{const as=parseInt(Ti,10);return as>=0&&as<=255}):!1,lt=V=>{const Ee=parseInt(V,10);return!isNaN(Ee)&&Ee>=1&&Ee<=65535},xt=V=>/^\d{6}$/.test(V),_t=async()=>{T(""),z("");let V=!1;if(wt(I)||(T(d.deviceSidebar.invalidIpError),V=!0),lt(k)||(z(d.deviceSidebar.invalidPortError),V=!0),!V){re(!0);try{const Ee=await uu({ip:I,port:parseInt(k,10)});Ee.success?(N(!1),L(""),B("5555")):T(Ee.message||d.toasts.wifiManualConnectError)}catch{T(d.toasts.wifiManualConnectError)}finally{re(!1)}}},On=async()=>{A(""),T(""),z("");let V=!1;if(wt(I)||(T(d.deviceSidebar.invalidIpError),V=!0),lt(Z)||(z(d.deviceSidebar.invalidPortError),V=!0),lt(ee)||(z(d.deviceSidebar.invalidPortError),V=!0),xt(G)||(A(d.deviceSidebar.invalidPairingCodeError),V=!0),!V){re(!0);try{const Ee=await qv({ip:I,pairing_port:parseInt(Z,10),pairing_code:G,connection_port:parseInt(ee,10)});Ee.success?(N(!1),L(""),B("5555"),H(""),Q(""),ie("5555"),M("direct")):Ee.error==="invalid_pairing_code"?A(Ee.message):Ee.error==="invalid_ip"?T(Ee.message):T(Ee.message||d.toasts.wifiPairError)}catch{T(d.toasts.wifiPairError)}finally{re(!1)}}},Mt=x.useCallback(()=>{He.current!==null&&(clearInterval(He.current),He.current=null)},[]),er=x.useCallback(V=>{Mt(),He.current=window.setInterval(async()=>{try{const Ee=await Wv(V);K(Qt=>Qt?{...Qt,status:Ee.status}:null),["connected","timeout","error"].includes(Ee.status)&&(Mt(),Ee.status==="connected"&&setTimeout(()=>{N(!1),K(null)},2e3))}catch(Ee){console.error("[QR Pairing] Status poll failed:",Ee)}},1e3)},[Mt]),Fn=x.useCallback(async()=>{Se(!0);try{const V=await zv();V.success&&V.qr_payload&&V.session_id&&(K({sessionId:V.session_id,payload:V.qr_payload,status:"listening",expiresAt:V.expires_at??Date.now()+12e4}),er(V.session_id))}catch(V){console.error("[QR Pairing] Generation failed:",V)}finally{Se(!1)}},[er]),Bn=x.useCallback(async()=>{if(ce)try{await Hv(ce.sessionId),K(null),Mt()}catch(V){console.error("[QR Pairing] Cancel failed:",V)}},[ce,Mt]),tr=async()=>{if(Re(""),!ge.trim()){Re(d.deviceSidebar.remoteUrlRequired||"请输入远程服务器地址");return}if(!ge.startsWith("http://")&&!ge.startsWith("https://")){Re(d.deviceSidebar.remoteUrlInvalid||"地址必须以 http:// 或 https:// 开头");return}me(!0);try{const V=await Xv({base_url:ge,timeout:5});V.success?(ae(V.devices),de(null)):(Re(V.message||"发现设备失败"),ae([]))}catch{Re("连接失败,请检查地址是否正确"),ae([])}finally{me(!1)}},Nr=async()=>{if(Ce){st(!0);try{const V=await Yv({base_url:ge,device_id:Ce});V.success?(N(!1),Ie(""),ae([]),de(null)):Re(V.message||d.toasts.remoteDeviceAddError)}catch{Re(d.toasts.remoteDeviceAddError)}finally{st(!1)}}};x.useEffect(()=>{(!P||U!=="pair")&&(ce&&ce.status==="listening"&&Bn(),Mt())},[P,U,ce,Mt,Bn]),x.useEffect(()=>()=>{Mt()},[Mt]),x.useEffect(()=>{P&&U==="pair"&&!ce&&!pe&&Fn()},[P,U,ce,pe,Fn]);const Un=x.useCallback(async()=>{Ue(!0),_e("");try{const V=await $v();V.success?ve(V.devices):(_e(V.error||d.deviceSidebar.scanError.replace("{error}","Unknown error")),ve([]))}catch(V){_e(d.deviceSidebar.scanError.replace("{error}",String(V))),ve([])}finally{Ue(!1)}},[d.deviceSidebar.scanError,Ue]),os=async(V,Ee)=>{if(!Ee&&!V.has_pairing){re(!0),T("");try{const Qt=await uu({ip:V.ip,port:V.port});Qt.success?N(!1):T(Qt.message||d.toasts.wifiManualConnectError)}catch(Qt){T(d.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",Qt)}finally{re(!1)}}else Ee&&V.has_pairing&&(L(V.ip),Q(V.pairing_port?String(V.pairing_port):""),ie(String(V.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return x.useEffect(()=>{if(P){Un();const V=setInterval(()=>{Un()},5e3);return()=>{clearInterval(V)}}},[P,Un]),o.jsxs(o.Fragment,{children:[p&&o.jsx(fe,{variant:"outline",size:"icon",onClick:ht,className:"absolute left-0 top-20 z-50 h-16 w-8 rounded-r-lg rounded-l-none border-l-0 bg-slate-100 hover:bg-slate-200 dark:bg-slate-800 dark:hover:bg-slate-700",title:"Expand sidebar",children:o.jsx(va,{className:"h-4 w-4"})}),o.jsxs("div",{className:`
|
|
26
|
+
${p?"w-0 -ml-4 opacity-0":"w-80 opacity-100"}
|
|
27
|
+
transition-all duration-300 ease-in-out
|
|
28
|
+
h-full min-h-0
|
|
29
|
+
bg-white dark:bg-slate-950
|
|
30
|
+
border-r border-slate-200 dark:border-slate-800
|
|
31
|
+
flex flex-col
|
|
32
|
+
overflow-hidden
|
|
33
|
+
`,children:[o.jsxs("div",{className:"flex items-center justify-between p-4",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("div",{children:[o.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),o.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[s.length," ",(s.length===1,d.deviceSidebar.devices)]})]})}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:ht,className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:"Collapse sidebar",children:o.jsx(rd,{className:"h-4 w-4"})})]}),o.jsx(Wr,{className:"mx-4"}),o.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:s.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:o.jsx(q1,{className:"h-8 w-8 text-slate-400"})}),o.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.noDevicesConnected}),o.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.clickToRefresh})]}):o.jsx(cw,{devices:s,groups:y,currentDeviceId:n,onSelectDevice:r,onConnectWifi:u,onDisconnectWifi:l,onRefreshDevices:m,onRefreshGroups:S,showToast:h})}),o.jsx(Wr,{className:"mx-4"}),o.jsxs("div",{className:"p-3 space-y-2",children:[o.jsxs(fe,{variant:"outline",onClick:()=>N(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[o.jsx(_a,{className:"h-4 w-4"}),d.deviceSidebar.addDevice]}),b&&o.jsxs(fe,{variant:"outline",onClick:b,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[o.jsx(M1,{className:"h-4 w-4"}),d.deviceSidebar.manageGroups||"管理分组"]}),o.jsxs(fe,{variant:"outline",onClick:a,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[o.jsx(ad,{className:"h-4 w-4"}),d.deviceSidebar.settings]})]}),o.jsx(xr,{open:P,onOpenChange:N,children:o.jsxs(_r,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[o.jsxs(vr,{children:[o.jsx(br,{children:d.deviceSidebar.manualConnectTitle}),o.jsx(yr,{children:d.deviceSidebar.manualConnectDescription})]}),o.jsxs(vf,{value:U,onValueChange:M,className:"w-full",children:[o.jsxs(bf,{className:"grid w-full grid-cols-3",children:[o.jsx(Vr,{value:"direct",children:d.deviceSidebar.directConnectTab}),o.jsx(Vr,{value:"pair",children:d.deviceSidebar.pairTab}),o.jsx(Vr,{value:"remote",children:d.deviceSidebar.remoteTab||"远程设备"})]}),o.jsxs(Qr,{value:"direct",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.discoveredDevices}),o.jsx(fe,{variant:"outline",size:"sm",onClick:Un,disabled:xe,className:"h-8",children:xe?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),d.deviceSidebar.scanning]}):d.deviceSidebar.scanAgain})]}),Le&&o.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:o.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:Le})}),(()=>{const V=le.filter(Ee=>!Ee.has_pairing);return!xe&&V.length===0?o.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[o.jsx(ui,{className:"mx-auto h-8 w-8 text-slate-400"}),o.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.noDirectDevices})]}):V.length>0?o.jsx("div",{className:"space-y-2",children:V.map(Ee=>o.jsx("button",{onClick:()=>os(Ee,!1),disabled:$,className:"w-full rounded-lg border border-slate-200 dark:border-slate-700 p-3 text-left transition-colors hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed",children:o.jsx("div",{className:"flex items-start justify-between",children:o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Zs,{className:"h-4 w-4 text-[#1d9bf0]"}),o.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:Ee.name})]}),o.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[Ee.ip,":",Ee.port]})]})})},`${Ee.ip}:${Ee.port}`))}):null})(),Y&&U==="direct"&&o.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:o.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:Y})}),o.jsxs("div",{className:"relative my-4",children:[o.jsx(Wr,{}),o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:d.deviceSidebar.orManualConnect})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{children:d.deviceSidebar.emulatorPreset}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ew.map(V=>o.jsx("button",{onClick:()=>{te(V.id),V.id!=="custom"&&(L(V.ip),B(String(V.port))),T(""),z("")},className:`rounded-lg border p-2 text-xs text-center transition-colors ${D===V.id?"border-blue-500 bg-blue-50 dark:bg-blue-950/30 text-blue-700 dark:text-blue-300":"border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800"}`,children:d.deviceSidebar[V.nameKey]||V.nameKey},V.id))})]}),o.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:o.jsx("p",{className:"text-blue-800 dark:text-blue-200",children:d.deviceSidebar.emulatorNote})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"ip",children:d.deviceSidebar.ipAddress}),o.jsx(dt,{id:"ip",placeholder:"192.168.1.100",value:I,onChange:V=>{L(V.target.value),D!=="custom"&&te("custom")},onKeyDown:V=>V.key==="Enter"&&_t(),className:Y?"border-red-500":""})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"port",children:d.deviceSidebar.port}),o.jsx(dt,{id:"port",type:"number",value:k,onChange:V=>{B(V.target.value),D!=="custom"&&te("custom")},onKeyDown:V=>V.key==="Enter"&&_t(),className:F?"border-red-500":""}),F&&o.jsx("p",{className:"text-sm text-red-500",children:F})]}),o.jsx(fe,{onClick:_t,disabled:$,className:"w-full",children:$?d.common.loading:d.deviceSidebar.connect})]})]}),o.jsxs(Qr,{value:"pair",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.discoveredDevices}),o.jsx(fe,{variant:"outline",size:"sm",onClick:Un,disabled:xe,className:"h-8",children:xe?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),d.deviceSidebar.scanning]}):d.deviceSidebar.scanAgain})]}),Le&&o.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:o.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:Le})}),(()=>{const V=le.filter(Ee=>Ee.has_pairing);return!xe&&V.length===0?o.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[o.jsx(ui,{className:"mx-auto h-8 w-8 text-slate-400"}),o.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.noPairingDevices})]}):V.length>0?o.jsx("div",{className:"space-y-2",children:V.map(Ee=>o.jsx("button",{onClick:()=>os(Ee,!0),disabled:$,className:"w-full rounded-lg border border-slate-200 dark:border-slate-700 p-3 text-left transition-colors hover:bg-slate-50 dark:hover:bg-slate-800 disabled:opacity-50 disabled:cursor-not-allowed",children:o.jsx("div",{className:"flex items-start justify-between",children:o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Zs,{className:"h-4 w-4 text-[#1d9bf0]"}),o.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:Ee.name})]}),o.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[Ee.ip,":",Ee.port]}),o.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[o.jsx(dn,{className:"h-3 w-3"}),o.jsx("span",{children:d.deviceSidebar.pairingRequired})]})]})})},`${Ee.ip}:${Ee.port}`))}):null})(),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"relative my-4",children:[o.jsx(Wr,{}),o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:d.deviceSidebar.orQrPair})]}),o.jsxs("div",{className:"rounded-lg bg-purple-50 dark:bg-purple-950/20 p-3 text-sm",children:[o.jsx("p",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:d.deviceSidebar.qrPairingTitle}),o.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[o.jsx("li",{children:d.deviceSidebar.qrStep1}),o.jsx("li",{children:d.deviceSidebar.qrStep2}),o.jsx("li",{children:d.deviceSidebar.qrStep3})]})]}),ce&&o.jsx("div",{className:"rounded-lg border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900",children:o.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[o.jsx("div",{className:"bg-white p-4 rounded-lg",children:o.jsx(Pf,{value:ce.payload,size:200,level:"M"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[ce.status==="listening"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse"}),o.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:d.deviceSidebar.qrWaitingForScan})]}),ce.status==="pairing"&&o.jsxs(o.Fragment,{children:[o.jsx(At,{className:"h-4 w-4 animate-spin text-blue-500"}),o.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:d.deviceSidebar.qrPairing})]}),ce.status==="connected"&&o.jsxs(o.Fragment,{children:[o.jsx(hu,{className:"h-4 w-4 text-green-500"}),o.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:d.deviceSidebar.qrConnected})]}),ce.status==="timeout"&&o.jsxs(o.Fragment,{children:[o.jsx(pu,{className:"h-4 w-4 text-amber-500"}),o.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:d.deviceSidebar.qrTimeout})]}),ce.status==="error"&&o.jsxs(o.Fragment,{children:[o.jsx(pu,{className:"h-4 w-4 text-red-500"}),o.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:d.deviceSidebar.qrError})]})]}),o.jsxs("div",{className:"flex gap-2 w-full",children:[(ce.status==="timeout"||ce.status==="error")&&o.jsx(fe,{variant:"outline",onClick:Fn,className:"flex-1",children:d.deviceSidebar.qrRegenerate}),ce.status==="listening"&&o.jsx(fe,{variant:"outline",onClick:Bn,className:"flex-1",children:d.common.cancel}),ce.status==="connected"&&o.jsx(fe,{onClick:()=>N(!1),className:"flex-1",children:d.common.confirm})]})]})}),!ce&&pe&&o.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[o.jsx(At,{className:"h-4 w-4 animate-spin"}),o.jsx("span",{className:"text-sm",children:d.common.loading})]})]}),o.jsxs("div",{className:"relative my-4",children:[o.jsx(Wr,{}),o.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:d.deviceSidebar.orManualPair})]}),o.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:[o.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:d.deviceSidebar.pairingInstructions}),o.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[o.jsx("li",{children:d.deviceSidebar.pairingStep1}),o.jsx("li",{children:d.deviceSidebar.pairingStep2}),o.jsx("li",{children:d.deviceSidebar.pairingStep3}),o.jsx("li",{children:d.deviceSidebar.pairingStep4})]}),o.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:d.deviceSidebar.pairingNote})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"pair-ip",children:d.deviceSidebar.ipAddress}),o.jsx(dt,{id:"pair-ip",placeholder:"192.168.1.100",value:I,onChange:V=>L(V.target.value),className:Y?"border-red-500":""}),Y&&U==="pair"&&o.jsx("p",{className:"text-sm text-red-500",children:Y})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"pairing-port",children:d.deviceSidebar.pairingPort}),o.jsx(dt,{id:"pairing-port",type:"number",placeholder:"37831",value:Z,onChange:V=>Q(V.target.value),className:F?"border-red-500":""}),F&&o.jsx("p",{className:"text-sm text-red-500",children:F})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"pairing-code",children:d.deviceSidebar.pairingCode}),o.jsx(dt,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:G,onChange:V=>H(V.target.value.replace(/\D/g,"")),onKeyDown:V=>V.key==="Enter"&&On(),className:ne?"border-red-500":""}),ne&&o.jsx("p",{className:"text-sm text-red-500",children:ne})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"connection-port",children:d.deviceSidebar.connectionPort}),o.jsx(dt,{id:"connection-port",type:"number",value:ee,onChange:V=>ie(V.target.value),onKeyDown:V=>V.key==="Enter"&&On()})]}),o.jsx(fe,{onClick:On,disabled:$,className:"w-full",children:$?d.common.loading:d.deviceSidebar.pairAndConnect})]})]}),o.jsxs(Qr,{value:"remote",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"remote-url",children:d.deviceSidebar.remoteUrl||"远程服务器地址"}),o.jsx(dt,{id:"remote-url",placeholder:"http://192.168.1.100:8001",value:ge,onChange:V=>{Ie(V.target.value),Re("")},disabled:oe,onKeyDown:V=>V.key==="Enter"&&tr(),className:Te?"border-red-500":""}),Te&&o.jsx("p",{className:"text-sm text-red-500",children:Te}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:d.deviceSidebar.remoteUrlHint||"运行 Device Agent Server 的地址"}),o.jsx(fe,{onClick:tr,disabled:oe||!ge,className:"w-full",children:oe?"正在发现...":"发现设备"})]}),Ne.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{children:"可用设备"}),o.jsx("div",{className:"space-y-2",children:Ne.map(V=>o.jsx("button",{onClick:()=>de(V.device_id),className:`
|
|
34
|
+
w-full rounded-lg border p-3 text-left transition-colors
|
|
35
|
+
${Ce===V.device_id?"border-[#1d9bf0] bg-blue-50 dark:bg-blue-950/20":"border-slate-200 hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"}
|
|
36
|
+
`,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Zs,{className:"h-4 w-4 text-[#1d9bf0]"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"font-medium text-sm",children:V.device_id}),o.jsxs("p",{className:"text-xs text-slate-500",children:[V.model," · ",V.platform]})]}),Ce===V.device_id&&o.jsx(hu,{className:"h-4 w-4 text-[#1d9bf0]"})]})},V.device_id))})]}),Ce&&o.jsx(fe,{onClick:Nr,disabled:Oe,className:"w-full",children:Oe?"正在连接...":"连接远程设备"})]})]}),o.jsx(wr,{children:o.jsx(fe,{variant:"outline",onClick:()=>{N(!1),T(""),z(""),A(""),_e(""),L(""),B("5555"),H(""),Q(""),ie("5555"),M("direct"),ve([])},children:d.common.cancel})})]})})]})]})}const hn=Object.create(null);hn.open="0";hn.close="1";hn.ping="2";hn.pong="3";hn.message="4";hn.upgrade="5";hn.noop="6";const ei=Object.create(null);Object.keys(hn).forEach(s=>{ei[hn[s]]=s});const ua={type:"error",data:"parser error"},Df=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",If=typeof ArrayBuffer=="function",Lf=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Aa=({type:s,data:n},r,a)=>Df&&n instanceof Blob?r?a(n):wu(n,a):If&&(n instanceof ArrayBuffer||Lf(n))?r?a(n):wu(new Blob([n]),a):a(hn[s]+(n||"")),wu=(s,n)=>{const r=new FileReader;return r.onload=function(){const a=r.result.split(",")[1];n("b"+(a||""))},r.readAsDataURL(s)};function Eu(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Ho;function Nw(s,n){if(Df&&s.data instanceof Blob)return s.data.arrayBuffer().then(Eu).then(n);if(If&&(s.data instanceof ArrayBuffer||Lf(s.data)))return n(Eu(s.data));Aa(s,!1,r=>{Ho||(Ho=new TextEncoder),n(Ho.encode(r))})}const Su="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<Su.length;s++)Kr[Su.charCodeAt(s)]=s;const Rw=s=>{let n=s.length*.75,r=s.length,a,u=0,l,m,b,h;s[s.length-1]==="="&&(n--,s[s.length-2]==="="&&n--);const d=new ArrayBuffer(n),p=new Uint8Array(d);for(a=0;a<r;a+=4)l=Kr[s.charCodeAt(a)],m=Kr[s.charCodeAt(a+1)],b=Kr[s.charCodeAt(a+2)],h=Kr[s.charCodeAt(a+3)],p[u++]=l<<2|m>>4,p[u++]=(m&15)<<4|b>>2,p[u++]=(b&3)<<6|h&63;return d},Tw=typeof ArrayBuffer=="function",Pa=(s,n)=>{if(typeof s!="string")return{type:"message",data:Of(s,n)};const r=s.charAt(0);return r==="b"?{type:"message",data:kw(s.substring(1),n)}:ei[r]?s.length>1?{type:ei[r],data:s.substring(1)}:{type:ei[r]}:ua},kw=(s,n)=>{if(Tw){const r=Rw(s);return Of(r,n)}else return{base64:!0,data:s}},Of=(s,n)=>{switch(n){case"blob":return s instanceof Blob?s:new Blob([s]);case"arraybuffer":default:return s instanceof ArrayBuffer?s:s.buffer}},Ff="",jw=(s,n)=>{const r=s.length,a=new Array(r);let u=0;s.forEach((l,m)=>{Aa(l,!1,b=>{a[m]=b,++u===r&&n(a.join(Ff))})})},Aw=(s,n)=>{const r=s.split(Ff),a=[];for(let u=0;u<r.length;u++){const l=Pa(r[u],n);if(a.push(l),l.type==="error")break}return a};function Pw(){return new TransformStream({transform(s,n){Nw(s,r=>{const a=r.length;let u;if(a<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,a);else if(a<65536){u=new Uint8Array(3);const l=new DataView(u.buffer);l.setUint8(0,126),l.setUint16(1,a)}else{u=new Uint8Array(9);const l=new DataView(u.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(a))}s.data&&typeof s.data!="string"&&(u[0]|=128),n.enqueue(u),n.enqueue(r)})}})}let $o;function Qs(s){return s.reduce((n,r)=>n+r.length,0)}function Js(s,n){if(s[0].length===n)return s.shift();const r=new Uint8Array(n);let a=0;for(let u=0;u<n;u++)r[u]=s[0][a++],a===s[0].length&&(s.shift(),a=0);return s.length&&a<s[0].length&&(s[0]=s[0].slice(a)),r}function Mw(s,n){$o||($o=new TextDecoder);const r=[];let a=0,u=-1,l=!1;return new TransformStream({transform(m,b){for(r.push(m);;){if(a===0){if(Qs(r)<1)break;const h=Js(r,1);l=(h[0]&128)===128,u=h[0]&127,u<126?a=3:u===126?a=1:a=2}else if(a===1){if(Qs(r)<2)break;const h=Js(r,2);u=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),a=3}else if(a===2){if(Qs(r)<8)break;const h=Js(r,8),d=new DataView(h.buffer,h.byteOffset,h.length),p=d.getUint32(0);if(p>Math.pow(2,21)-1){b.enqueue(ua);break}u=p*Math.pow(2,32)+d.getUint32(4),a=3}else{if(Qs(r)<u)break;const h=Js(r,u);b.enqueue(Pa(l?h:$o.decode(h),n)),a=0}if(u===0||u>s){b.enqueue(ua);break}}}})}const Bf=4;function at(s){if(s)return Dw(s)}function Dw(s){for(var n in at.prototype)s[n]=at.prototype[n];return s}at.prototype.on=at.prototype.addEventListener=function(s,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(n),this};at.prototype.once=function(s,n){function r(){this.off(s,r),n.apply(this,arguments)}return r.fn=n,this.on(s,r),this};at.prototype.off=at.prototype.removeListener=at.prototype.removeAllListeners=at.prototype.removeEventListener=function(s,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+s];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var a,u=0;u<r.length;u++)if(a=r[u],a===n||a.fn===n){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+s],this};at.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),r=this._callbacks["$"+s],a=1;a<arguments.length;a++)n[a-1]=arguments[a];if(r){r=r.slice(0);for(var a=0,u=r.length;a<u;++a)r[a].apply(this,n)}return this};at.prototype.emitReserved=at.prototype.emit;at.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]};at.prototype.hasListeners=function(s){return!!this.listeners(s).length};const Ci=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,r)=>r(n,0),Yt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Iw="arraybuffer";function Uf(s,...n){return n.reduce((r,a)=>(s.hasOwnProperty(a)&&(r[a]=s[a]),r),{})}const Lw=Yt.setTimeout,Ow=Yt.clearTimeout;function Ni(s,n){n.useNativeTimers?(s.setTimeoutFn=Lw.bind(Yt),s.clearTimeoutFn=Ow.bind(Yt)):(s.setTimeoutFn=Yt.setTimeout.bind(Yt),s.clearTimeoutFn=Yt.clearTimeout.bind(Yt))}const Fw=1.33;function Bw(s){return typeof s=="string"?Uw(s):Math.ceil((s.byteLength||s.size)*Fw)}function Uw(s){let n=0,r=0;for(let a=0,u=s.length;a<u;a++)n=s.charCodeAt(a),n<128?r+=1:n<2048?r+=2:n<55296||n>=57344?r+=3:(a++,r+=4);return r}function Gf(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Gw(s){let n="";for(let r in s)s.hasOwnProperty(r)&&(n.length&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s[r]));return n}function Ww(s){let n={},r=s.split("&");for(let a=0,u=r.length;a<u;a++){let l=r[a].split("=");n[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return n}class zw extends Error{constructor(n,r,a){super(n),this.description=r,this.context=a,this.type="TransportError"}}class Ma extends at{constructor(n){super(),this.writable=!1,Ni(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,r,a){return super.emitReserved("error",new zw(n,r,a)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(n){this.readyState==="open"&&this.write(n)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(n){const r=Pa(n,this.socket.binaryType);this.onPacket(r)}onPacket(n){super.emitReserved("packet",n)}onClose(n){this.readyState="closed",super.emitReserved("close",n)}pause(n){}createUri(n,r={}){return n+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const n=this.opts.hostname;return n.indexOf(":")===-1?n:"["+n+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(n){const r=Gw(n);return r.length?"?"+r:""}}class Hw extends Ma{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(n){this.readyState="pausing";const r=()=>{this.readyState="paused",n()};if(this._polling||!this.writable){let a=0;this._polling&&(a++,this.once("pollComplete",function(){--a||r()})),this.writable||(a++,this.once("drain",function(){--a||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(n){const r=a=>{if(this.readyState==="opening"&&a.type==="open"&&this.onOpen(),a.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(a)};Aw(n,this.socket.binaryType).forEach(r),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const n=()=>{this.write([{type:"close"}])};this.readyState==="open"?n():this.once("open",n)}write(n){this.writable=!1,jw(n,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const n=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=Gf()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let Wf=!1;try{Wf=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const $w=Wf;function qw(){}class Xw extends Hw{constructor(n){if(super(n),typeof location<"u"){const r=location.protocol==="https:";let a=location.port;a||(a=r?"443":"80"),this.xd=typeof location<"u"&&n.hostname!==location.hostname||a!==n.port}}doWrite(n,r){const a=this.request({method:"POST",data:n});a.on("success",r),a.on("error",(u,l)=>{this.onError("xhr post error",u,l)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(r,a)=>{this.onError("xhr poll error",r,a)}),this.pollXhr=n}}class fn extends at{constructor(n,r,a){super(),this.createRequest=n,Ni(this,a),this._opts=a,this._method=a.method||"GET",this._uri=r,this._data=a.data!==void 0?a.data:null,this._create()}_create(){var n;const r=Uf(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const a=this._xhr=this.createRequest(r);try{a.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){a.setDisableHeaderCheck&&a.setDisableHeaderCheck(!0);for(let u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&a.setRequestHeader(u,this._opts.extraHeaders[u])}}catch{}if(this._method==="POST")try{a.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{a.setRequestHeader("Accept","*/*")}catch{}(n=this._opts.cookieJar)===null||n===void 0||n.addCookies(a),"withCredentials"in a&&(a.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(a.timeout=this._opts.requestTimeout),a.onreadystatechange=()=>{var u;a.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.parseCookies(a.getResponseHeader("set-cookie"))),a.readyState===4&&(a.status===200||a.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof a.status=="number"?a.status:0)},0))},a.send(this._data)}catch(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=fn.requestsCount++,fn.requests[this._index]=this)}_onError(n){this.emitReserved("error",n,this._xhr),this._cleanup(!0)}_cleanup(n){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=qw,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete fn.requests[this._index],this._xhr=null}}_onLoad(){const n=this._xhr.responseText;n!==null&&(this.emitReserved("data",n),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}fn.requestsCount=0;fn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Cu);else if(typeof addEventListener=="function"){const s="onpagehide"in Yt?"pagehide":"unload";addEventListener(s,Cu,!1)}}function Cu(){for(let s in fn.requests)fn.requests.hasOwnProperty(s)&&fn.requests[s].abort()}const Yw=(function(){const s=zf({xdomain:!1});return s&&s.responseType!==null})();class Kw extends Xw{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=Yw&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new fn(zf,this.uri(),n)}}function zf(s){const n=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||$w))return new XMLHttpRequest}catch{}if(!n)try{return new Yt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Hf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Vw extends Ma{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,a=Hf?{}:Uf(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(a.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(n,r,a)}catch(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=n=>this.onClose({description:"websocket connection closed",context:n}),this.ws.onmessage=n=>this.onData(n.data),this.ws.onerror=n=>this.onError("websocket error",n)}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const a=n[r],u=r===n.length-1;Aa(a,this.supportsBinary,l=>{try{this.doWrite(a,l)}catch{}u&&Ci(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const n=this.opts.secure?"wss":"ws",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=Gf()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const qo=Yt.WebSocket||Yt.MozWebSocket;class Qw extends Vw{createSocket(n,r,a){return Hf?new qo(n,r,a):r?new qo(n,r):new qo(n)}doWrite(n,r){this.ws.send(r)}}class Jw extends Ma{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(n){return this.emitReserved("error",n)}this._transport.closed.then(()=>{this.onClose()}).catch(n=>{this.onError("webtransport error",n)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(n=>{const r=Mw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),a=n.readable.pipeThrough(r).getReader(),u=Pw();u.readable.pipeTo(n.writable),this._writer=u.writable.getWriter();const l=()=>{a.read().then(({done:b,value:h})=>{b||(this.onPacket(h),l())}).catch(b=>{})};l();const m={type:"open"};this.query.sid&&(m.data=`{"sid":"${this.query.sid}"}`),this._writer.write(m).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const a=n[r],u=r===n.length-1;this._writer.write(a).then(()=>{u&&Ci(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const Zw={websocket:Qw,webtransport:Jw,polling:Kw},e2=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,t2=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function da(s){if(s.length>8e3)throw"URI too long";const n=s,r=s.indexOf("["),a=s.indexOf("]");r!=-1&&a!=-1&&(s=s.substring(0,r)+s.substring(r,a).replace(/:/g,";")+s.substring(a,s.length));let u=e2.exec(s||""),l={},m=14;for(;m--;)l[t2[m]]=u[m]||"";return r!=-1&&a!=-1&&(l.source=n,l.host=l.host.substring(1,l.host.length-1).replace(/;/g,":"),l.authority=l.authority.replace("[","").replace("]","").replace(/;/g,":"),l.ipv6uri=!0),l.pathNames=n2(l,l.path),l.queryKey=r2(l,l.query),l}function n2(s,n){const r=/\/{2,9}/g,a=n.replace(r,"/").split("/");return(n.slice(0,1)=="/"||n.length===0)&&a.splice(0,1),n.slice(-1)=="/"&&a.splice(a.length-1,1),a}function r2(s,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(a,u,l){u&&(r[u]=l)}),r}const fa=typeof addEventListener=="function"&&typeof removeEventListener=="function",ti=[];fa&&addEventListener("offline",()=>{ti.forEach(s=>s())},!1);class In extends at{constructor(n,r){if(super(),this.binaryType=Iw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,n&&typeof n=="object"&&(r=n,n=null),n){const a=da(n);r.hostname=a.host,r.secure=a.protocol==="https"||a.protocol==="wss",r.port=a.port,a.query&&(r.query=a.query)}else r.host&&(r.hostname=da(r.host).host);Ni(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(a=>{const u=a.prototype.name;this.transports.push(u),this._transportsByName[u]=a}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ww(this.opts.query)),fa&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ti.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const r=Object.assign({},this.opts.query);r.EIO=Bf,r.transport=n,this.id&&(r.sid=this.id);const a=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[n]);return new this._transportsByName[n](a)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const n=this.opts.rememberUpgrade&&In.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(n);r.open(),this.setTransport(r)}setTransport(n){this.transport&&this.transport.removeAllListeners(),this.transport=n,n.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",In.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",n),this.emitReserved("heartbeat"),n.type){case"open":this.onHandshake(JSON.parse(n.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=n.data,this._onError(r);break;case"message":this.emitReserved("data",n.data),this.emitReserved("message",n.data);break}}onHandshake(n){this.emitReserved("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this._pingInterval=n.pingInterval,this._pingTimeout=n.pingTimeout,this._maxPayload=n.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const n=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+n,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},n),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const n=this._getWritablePackets();this.transport.send(n),this._prevBufferLen=n.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let a=0;a<this.writeBuffer.length;a++){const u=this.writeBuffer[a].data;if(u&&(r+=Bw(u)),a>0&&r>this._maxPayload)return this.writeBuffer.slice(0,a);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const n=Date.now()>this._pingTimeoutTime;return n&&(this._pingTimeoutTime=0,Ci(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),n}write(n,r,a){return this._sendPacket("message",n,r,a),this}send(n,r,a){return this._sendPacket("message",n,r,a),this}_sendPacket(n,r,a,u){if(typeof r=="function"&&(u=r,r=void 0),typeof a=="function"&&(u=a,a=null),this.readyState==="closing"||this.readyState==="closed")return;a=a||{},a.compress=a.compress!==!1;const l={type:n,data:r,options:a};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),u&&this.once("flush",u),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),n()},a=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?a():n()}):this.upgrading?a():n()),this}_onError(n){if(In.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",n),this._onClose("transport error",n)}_onClose(n,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),fa&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const a=ti.indexOf(this._offlineEventListener);a!==-1&&ti.splice(a,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}In.protocol=Bf;class s2 extends In{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let n=0;n<this._upgrades.length;n++)this._probe(this._upgrades[n])}_probe(n){let r=this.createTransport(n),a=!1;In.priorWebsocketSuccess=!1;const u=()=>{a||(r.send([{type:"ping",data:"probe"}]),r.once("packet",_=>{if(!a)if(_.type==="pong"&&_.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;In.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{a||this.readyState!=="closed"&&(p(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const y=new Error("probe error");y.transport=r.name,this.emitReserved("upgradeError",y)}}))};function l(){a||(a=!0,p(),r.close(),r=null)}const m=_=>{const y=new Error("probe error: "+_);y.transport=r.name,l(),this.emitReserved("upgradeError",y)};function b(){m("transport closed")}function h(){m("socket closed")}function d(_){r&&_.name!==r.name&&l()}const p=()=>{r.removeListener("open",u),r.removeListener("error",m),r.removeListener("close",b),this.off("close",h),this.off("upgrading",d)};r.once("open",u),r.once("error",m),r.once("close",b),this.once("close",h),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&n!=="webtransport"?this.setTimeoutFn(()=>{a||r.open()},200):r.open()}onHandshake(n){this._upgrades=this._filterUpgrades(n.upgrades),super.onHandshake(n)}_filterUpgrades(n){const r=[];for(let a=0;a<n.length;a++)~this.transports.indexOf(n[a])&&r.push(n[a]);return r}}let i2=class extends s2{constructor(n,r={}){const a=typeof n=="object"?n:r;(!a.transports||a.transports&&typeof a.transports[0]=="string")&&(a.transports=(a.transports||["polling","websocket","webtransport"]).map(u=>Zw[u]).filter(u=>!!u)),super(n,a)}};function o2(s,n="",r){let a=s;r=r||typeof location<"u"&&location,s==null&&(s=r.protocol+"//"+r.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=r.protocol+s:s=r.host+s),/^(https?|wss?):\/\//.test(s)||(typeof r<"u"?s=r.protocol+"//"+s:s="https://"+s),a=da(s)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const l=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+l+":"+a.port+n,a.href=a.protocol+"://"+l+(r&&r.port===a.port?"":":"+a.port),a}const a2=typeof ArrayBuffer=="function",l2=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,$f=Object.prototype.toString,c2=typeof Blob=="function"||typeof Blob<"u"&&$f.call(Blob)==="[object BlobConstructor]",u2=typeof File=="function"||typeof File<"u"&&$f.call(File)==="[object FileConstructor]";function Da(s){return a2&&(s instanceof ArrayBuffer||l2(s))||c2&&s instanceof Blob||u2&&s instanceof File}function ni(s,n){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let r=0,a=s.length;r<a;r++)if(ni(s[r]))return!0;return!1}if(Da(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return ni(s.toJSON(),!0);for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)&&ni(s[r]))return!0;return!1}function d2(s){const n=[],r=s.data,a=s;return a.data=ha(r,n),a.attachments=n.length,{packet:a,buffers:n}}function ha(s,n){if(!s)return s;if(Da(s)){const r={_placeholder:!0,num:n.length};return n.push(s),r}else if(Array.isArray(s)){const r=new Array(s.length);for(let a=0;a<s.length;a++)r[a]=ha(s[a],n);return r}else if(typeof s=="object"&&!(s instanceof Date)){const r={};for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=ha(s[a],n));return r}return s}function f2(s,n){return s.data=pa(s.data,n),delete s.attachments,s}function pa(s,n){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<n.length)return n[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let r=0;r<s.length;r++)s[r]=pa(s[r],n);else if(typeof s=="object")for(const r in s)Object.prototype.hasOwnProperty.call(s,r)&&(s[r]=pa(s[r],n));return s}const h2=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],p2=5;var ze;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(ze||(ze={}));class m2{constructor(n){this.replacer=n}encode(n){return(n.type===ze.EVENT||n.type===ze.ACK)&&ni(n)?this.encodeAsBinary({type:n.type===ze.EVENT?ze.BINARY_EVENT:ze.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let r=""+n.type;return(n.type===ze.BINARY_EVENT||n.type===ze.BINARY_ACK)&&(r+=n.attachments+"-"),n.nsp&&n.nsp!=="/"&&(r+=n.nsp+","),n.id!=null&&(r+=n.id),n.data!=null&&(r+=JSON.stringify(n.data,this.replacer)),r}encodeAsBinary(n){const r=d2(n),a=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(a),u}}function Nu(s){return Object.prototype.toString.call(s)==="[object Object]"}class Ia extends at{constructor(n){super(),this.reviver=n}add(n){let r;if(typeof n=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(n);const a=r.type===ze.BINARY_EVENT;a||r.type===ze.BINARY_ACK?(r.type=a?ze.EVENT:ze.ACK,this.reconstructor=new g2(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Da(n)||n.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(n),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+n)}decodeString(n){let r=0;const a={type:Number(n.charAt(0))};if(ze[a.type]===void 0)throw new Error("unknown packet type "+a.type);if(a.type===ze.BINARY_EVENT||a.type===ze.BINARY_ACK){const l=r+1;for(;n.charAt(++r)!=="-"&&r!=n.length;);const m=n.substring(l,r);if(m!=Number(m)||n.charAt(r)!=="-")throw new Error("Illegal attachments");a.attachments=Number(m)}if(n.charAt(r+1)==="/"){const l=r+1;for(;++r&&!(n.charAt(r)===","||r===n.length););a.nsp=n.substring(l,r)}else a.nsp="/";const u=n.charAt(r+1);if(u!==""&&Number(u)==u){const l=r+1;for(;++r;){const m=n.charAt(r);if(m==null||Number(m)!=m){--r;break}if(r===n.length)break}a.id=Number(n.substring(l,r+1))}if(n.charAt(++r)){const l=this.tryParse(n.substr(r));if(Ia.isPayloadValid(a.type,l))a.data=l;else throw new Error("invalid payload")}return a}tryParse(n){try{return JSON.parse(n,this.reviver)}catch{return!1}}static isPayloadValid(n,r){switch(n){case ze.CONNECT:return Nu(r);case ze.DISCONNECT:return r===void 0;case ze.CONNECT_ERROR:return typeof r=="string"||Nu(r);case ze.EVENT:case ze.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&h2.indexOf(r[0])===-1);case ze.ACK:case ze.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class g2{constructor(n){this.packet=n,this.buffers=[],this.reconPack=n}takeBinaryData(n){if(this.buffers.push(n),this.buffers.length===this.reconPack.attachments){const r=f2(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const x2=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ia,Encoder:m2,get PacketType(){return ze},protocol:p2},Symbol.toStringTag,{value:"Module"}));function nn(s,n,r){return s.on(n,r),function(){s.off(n,r)}}const _2=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class qf extends at{constructor(n,r,a){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=n,this.nsp=r,a&&a.auth&&(this.auth=a.auth),this._opts=Object.assign({},a),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const n=this.io;this.subs=[nn(n,"open",this.onopen.bind(this)),nn(n,"packet",this.onpacket.bind(this)),nn(n,"error",this.onerror.bind(this)),nn(n,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...n){return n.unshift("message"),this.emit.apply(this,n),this}emit(n,...r){var a,u,l;if(_2.hasOwnProperty(n))throw new Error('"'+n.toString()+'" is a reserved event name');if(r.unshift(n),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const m={type:ze.EVENT,data:r};if(m.options={},m.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const p=this.ids++,_=r.pop();this._registerAckCallback(p,_),m.id=p}const b=(u=(a=this.io.engine)===null||a===void 0?void 0:a.transport)===null||u===void 0?void 0:u.writable,h=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!b||(h?(this.notifyOutgoingListeners(m),this.packet(m)):this.sendBuffer.push(m)),this.flags={},this}_registerAckCallback(n,r){var a;const u=(a=this.flags.timeout)!==null&&a!==void 0?a:this._opts.ackTimeout;if(u===void 0){this.acks[n]=r;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let b=0;b<this.sendBuffer.length;b++)this.sendBuffer[b].id===n&&this.sendBuffer.splice(b,1);r.call(this,new Error("operation has timed out"))},u),m=(...b)=>{this.io.clearTimeoutFn(l),r.apply(this,b)};m.withError=!0,this.acks[n]=m}emitWithAck(n,...r){return new Promise((a,u)=>{const l=(m,b)=>m?u(m):a(b);l.withError=!0,r.push(l),this.emit(n,...r)})}_addToQueue(n){let r;typeof n[n.length-1]=="function"&&(r=n.pop());const a={id:this._queueSeq++,tryCount:0,pending:!1,args:n,flags:Object.assign({fromQueue:!0},this.flags)};n.push((u,...l)=>a!==this._queue[0]?void 0:(u!==null?a.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(this._queue.shift(),r&&r(null,...l)),a.pending=!1,this._drainQueue())),this._queue.push(a),this._drainQueue()}_drainQueue(n=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!n||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.args))}packet(n){n.nsp=this.nsp,this.io._packet(n)}onopen(){typeof this.auth=="function"?this.auth(n=>{this._sendConnectPacket(n)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(n){this.packet({type:ze.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},n):n})}onerror(n){this.connected||this.emitReserved("connect_error",n)}onclose(n,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",n,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(n=>{if(!this.sendBuffer.some(a=>String(a.id)===n)){const a=this.acks[n];delete this.acks[n],a.withError&&a.call(this,new Error("socket has been disconnected"))}})}onpacket(n){if(n.nsp===this.nsp)switch(n.type){case ze.CONNECT:n.data&&n.data.sid?this.onconnect(n.data.sid,n.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ze.EVENT:case ze.BINARY_EVENT:this.onevent(n);break;case ze.ACK:case ze.BINARY_ACK:this.onack(n);break;case ze.DISCONNECT:this.ondisconnect();break;case ze.CONNECT_ERROR:this.destroy();const a=new Error(n.data.message);a.data=n.data.data,this.emitReserved("connect_error",a);break}}onevent(n){const r=n.data||[];n.id!=null&&r.push(this.ack(n.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(n){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const a of r)a.apply(this,n)}super.emit.apply(this,n),this._pid&&n.length&&typeof n[n.length-1]=="string"&&(this._lastOffset=n[n.length-1])}ack(n){const r=this;let a=!1;return function(...u){a||(a=!0,r.packet({type:ze.ACK,id:n,data:u}))}}onack(n){const r=this.acks[n.id];typeof r=="function"&&(delete this.acks[n.id],r.withError&&n.data.unshift(null),r.apply(this,n.data))}onconnect(n,r){this.id=n,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(n=>this.emitEvent(n)),this.receiveBuffer=[],this.sendBuffer.forEach(n=>{this.notifyOutgoingListeners(n),this.packet(n)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(n=>n()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ze.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(n){return this.flags.compress=n,this}get volatile(){return this.flags.volatile=!0,this}timeout(n){return this.flags.timeout=n,this}onAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(n),this}prependAny(n){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(n),this}offAny(n){if(!this._anyListeners)return this;if(n){const r=this._anyListeners;for(let a=0;a<r.length;a++)if(n===r[a])return r.splice(a,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(n),this}prependAnyOutgoing(n){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(n),this}offAnyOutgoing(n){if(!this._anyOutgoingListeners)return this;if(n){const r=this._anyOutgoingListeners;for(let a=0;a<r.length;a++)if(n===r[a])return r.splice(a,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(n){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const a of r)a.apply(this,n.data)}}}function Cr(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}Cr.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),r=Math.floor(n*this.jitter*s);s=(Math.floor(n*10)&1)==0?s-r:s+r}return Math.min(s,this.max)|0};Cr.prototype.reset=function(){this.attempts=0};Cr.prototype.setMin=function(s){this.ms=s};Cr.prototype.setMax=function(s){this.max=s};Cr.prototype.setJitter=function(s){this.jitter=s};class ma extends at{constructor(n,r){var a;super(),this.nsps={},this.subs=[],n&&typeof n=="object"&&(r=n,n=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,Ni(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((a=r.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new Cr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=n;const u=r.parser||x2;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(n){return arguments.length?(this._reconnection=!!n,n||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(n){return n===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=n,this)}reconnectionDelay(n){var r;return n===void 0?this._reconnectionDelay:(this._reconnectionDelay=n,(r=this.backoff)===null||r===void 0||r.setMin(n),this)}randomizationFactor(n){var r;return n===void 0?this._randomizationFactor:(this._randomizationFactor=n,(r=this.backoff)===null||r===void 0||r.setJitter(n),this)}reconnectionDelayMax(n){var r;return n===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=n,(r=this.backoff)===null||r===void 0||r.setMax(n),this)}timeout(n){return arguments.length?(this._timeout=n,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(n){if(~this._readyState.indexOf("open"))return this;this.engine=new i2(this.uri,this.opts);const r=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const u=nn(r,"open",function(){a.onopen(),n&&n()}),l=b=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",b),n?n(b):this.maybeReconnectOnOpen()},m=nn(r,"error",l);if(this._timeout!==!1){const b=this._timeout,h=this.setTimeoutFn(()=>{u(),l(new Error("timeout")),r.close()},b);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(u),this.subs.push(m),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(nn(n,"ping",this.onping.bind(this)),nn(n,"data",this.ondata.bind(this)),nn(n,"error",this.onerror.bind(this)),nn(n,"close",this.onclose.bind(this)),nn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(n){try{this.decoder.add(n)}catch(r){this.onclose("parse error",r)}}ondecoded(n){Ci(()=>{this.emitReserved("packet",n)},this.setTimeoutFn)}onerror(n){this.emitReserved("error",n)}socket(n,r){let a=this.nsps[n];return a?this._autoConnect&&!a.active&&a.connect():(a=new qf(this,n,r),this.nsps[n]=a),a}_destroy(n){const r=Object.keys(this.nsps);for(const a of r)if(this.nsps[a].active)return;this._close()}_packet(n){const r=this.encoder.encode(n);for(let a=0;a<r.length;a++)this.engine.write(r[a],n.options)}cleanup(){this.subs.forEach(n=>n()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(n,r){var a;this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",n,r),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const n=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const r=this.backoff.duration();this._reconnecting=!0;const a=this.setTimeoutFn(()=>{n.skipReconnect||(this.emitReserved("reconnect_attempt",n.backoff.attempts),!n.skipReconnect&&n.open(u=>{u?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",u)):n.onreconnect()}))},r);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const n=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",n)}}const zr={};function ri(s,n){typeof s=="object"&&(n=s,s=void 0),n=n||{};const r=o2(s,n.path||"/socket.io"),a=r.source,u=r.id,l=r.path,m=zr[u]&&l in zr[u].nsps,b=n.forceNew||n["force new connection"]||n.multiplex===!1||m;let h;return b?h=new ma(a,n):(zr[u]||(zr[u]=new ma(a,n)),h=zr[u]),r.query&&!n.query&&(n.query=r.queryKey),h.socket(r.path,n)}Object.assign(ri,{Manager:ma,Socket:qf,io:ri,connect:ri});function v2(s,n){return(s[n]|s[n+1]<<8|s[n+2]<<16|s[n+3]<<24)>>>0}const si={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:b2}=globalThis;class y2{#e;#t;#n=0;#r=7;get byteAligned(){return this.#r===7}get ended(){return this.#n>=this.#e.length}constructor(n){this.#e=n,this.#t=n[0]}f1(){const n=this.#t>>this.#r;return this.#r-=1,this.#r<0&&(this.#n+=1,this.#r=7,this.#t=this.#e[this.#n]),n&1}f(n){let r=0;for(;n>0;n-=1)r<<=1,r|=this.f1();return r}skip(n){if(n<=this.#r+1){this.#n+=1,this.#r=7,this.#t=this.#e[this.#n];return}n-=this.#r+1,this.#n+=1;const r=n/8|0;r>0&&(this.#n+=r,n-=r*8),this.#r=7-n,this.#t=this.#e[this.#n]}readBytes(n){if(!this.byteAligned)throw new Error("Bytes must be byte-aligned");const r=this.#e.subarray(this.#n,this.#n+n);return this.#n+=n,this.#t=this.#e[this.#n],r}getPosition(){return[this.#n,this.#r]}setPosition([n,r]){this.#n=n,this.#r=r,this.#t=this.#e[n]}}const w2={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},E2={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},S2={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,Linear:8,Log100:9,Log100Sqrt10:10,Iec61966:11,Bt1361:12,Srgb:13,Bt2020Ten:14,Bt2020Twelve:15,Smpte2084:16,Smpte428:17,Hlg:18},C2={Identity:0,Bt709:1,Unspecified:2,Fcc:4,Bt470BG:5,Bt601:6,Smpte240:7,YCgCo:8,Bt2020Ncl:9,Bt2020Cl:10,Smpte2085:11,ChromatNcl:12,ChromatCl:13,ICtCp:14};class yt extends y2{static ObuType=w2;static ColorPrimaries=E2;static TransferCharacteristics=S2;static MatrixCoefficients=C2;#e=0;uvlc(){let n=0;for(;!this.f1();)n+=1;return n>=32?2**32-1:this.f(n)+(1<<n>>>0)-1}leb128(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");let n=0n;this.#e=0;for(let r=0n;r<8n;r+=1n){const a=this.f(8);if(n|=BigInt(a&127)<<7n*r,this.#e+=1,(a&128)==0)break}return n}*annexBBitstream(){for(;!this.ended;){const n=this.leb128();yield*this.temporalUnit(n)}}*temporalUnit(n){for(;n>0;){const r=this.leb128();n-=BigInt(this.#e),yield*this.frameUnit(r),n-=r}}*frameUnit(n){for(;n>0;){const r=this.leb128();n-=BigInt(this.#e);const a=this.openBitstreamUnit(r);a&&(yield a),n-=r}}#t=0;openBitstreamUnit(n){const r=this.obuHeader();let a;if(r.obu_has_size_field)a=this.leb128();else if(n!==void 0)a=n-1n-(r.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const u=this.getPosition();if(r.obu_type!==yt.ObuType.SequenceHeader&&r.obu_type!==yt.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const h=!!(this.#t&1<<r.obu_extension_header.temporal_id),d=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!h||!d){this.skip(Number(a));return}}let l;switch(r.obu_type){case yt.ObuType.SequenceHeader:l=this.sequenceHeaderObu();break}const m=this.getPosition(),b=(m[0]-u[0])*8+(u[1]-m[1]);return a>0&&this.skip(Number(a)*8-b),{obu_header:r,obu_size:a,sequence_header_obu:l}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const r=this.f(4),a=!!this.f1(),u=!!this.f1();this.f1();let l;return a&&(l=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:a,obu_has_size_field:u,obu_extension_header:l}}obuExtensionHeader(){const n=this.f(3),r=this.f(2);return this.skip(3),{temporal_id:n,spatial_id:r}}static SelectScreenContentTools=2;static SelectIntegerMv=2;sequenceHeaderObu(){const n=this.f(3),r=!!this.f1(),a=!!this.f1();let u=!1,l,m=!1,b,h=!1,d=0;const p=[],_=[],y=[],w=[],S=[];let P,N;if(a)p[0]=0,_[0]=this.f(5),y[0]=0,w[0]=!1,S[0]=!1;else{u=!!this.f1(),u&&(l=this.timingInfo(),m=!!this.f1(),m&&(b=this.decoderModelInfo(),P=[])),h=!!this.f1(),h&&(N=[]),d=this.f(5);for(let ce=0;ce<=d;ce+=1)p[ce]=this.f(12),_[ce]=this.f(5),_[ce]>7?y[ce]=this.f1():y[ce]=0,m?(w[ce]=!!this.f1(),w[ce]&&(P[ce]=this.operatingParametersInfo(b))):w[ce]=!1,h&&(S[ce]=!!this.f1(),S[ce]&&(N[ce]=this.f(4)))}const I=this.chooseOperatingPoint();this.#t=p[I];const L=this.f(4),k=this.f(4),B=this.f(L+1),Y=this.f(k+1);let T=!1,F,z;a||(T=!!this.f1(),T&&(F=this.f(4),z=this.f(3)));const D=!!this.f1(),te=!!this.f1(),U=!!this.f1();let M=!1,G=!1,H=!1,Z=!1,Q=!1,ee=!1,ie=!1,ne=!1,A=yt.SelectScreenContentTools,$=!1,re=yt.SelectIntegerMv,le;a||(M=!!this.f1(),G=!!this.f1(),H=!!this.f1(),Z=!!this.f1(),Q=!!this.f1(),Q&&(ee=!!this.f1(),ie=!!this.f1()),ne=!!this.f1(),ne||(A=this.f1()),A>0&&($=!!this.f1(),$||(re=this.f1())),Q&&(le=this.f(3)));const ve=!!this.f1(),xe=!!this.f1(),Ue=!!this.f1(),Le=this.colorConfig(n),_e=!!this.f1();return{seq_profile:n,still_picture:r,reduced_still_picture_header:a,timing_info_present_flag:u,timing_info:l,decoder_model_info_present_flag:m,decoder_model_info:b,initial_display_delay_present_flag:h,initial_display_delay_minus_1:N,operating_points_cnt_minus_1:d,operating_point_idc:p,seq_level_idx:_,seq_tier:y,decoder_model_present_for_this_op:w,operating_parameters_info:P,initial_display_delay_present_for_this_op:S,frame_width_bits_minus_1:L,frame_height_bits_minus_1:k,max_frame_width_minus_1:B,max_frame_height_minus_1:Y,frame_id_numbers_present_flag:T,delta_frame_id_length_minus_2:F,additional_frame_id_length_minus_1:z,use_128x128_superblock:D,enable_filter_intra:te,enable_intra_edge_filter:U,enable_interintra_compound:M,enable_masked_compound:G,enable_warped_motion:H,enable_dual_filter:Z,enable_order_hint:Q,enable_jnt_comp:ee,enable_ref_frame_mvs:ie,seq_choose_screen_content_tools:ne,seq_force_screen_content_tools:A,seq_choose_integer_mv:$,seq_force_integer_mv:re,order_hint_bits_minus_1:le,enable_superres:ve,enable_cdef:xe,enable_restoration:Ue,color_config:Le,film_grain_params_present:_e}}searchSequenceHeaderObu(){for(;!this.ended;){const n=this.openBitstreamUnit();if(n&&n.sequence_header_obu)return n.sequence_header_obu}}timingInfo(){const n=this.f(32),r=this.f(32),a=!!this.f1();let u;return a&&(u=this.uvlc()),{num_units_in_display_tick:n,time_scale:r,equal_picture_interval:a,num_ticks_per_picture_minus_1:u}}decoderModelInfo(){const n=this.f(5),r=this.f(32),a=this.f(5),u=this.f(5);return{buffer_delay_length_minus_1:n,num_units_in_decoding_tick:r,buffer_removal_time_length_minus_1:a,frame_presentation_time_length_minus_1:u}}operatingParametersInfo(n){const r=n.buffer_delay_length_minus_1+1,a=this.f(r),u=this.f(r),l=!!this.f1();return{decoder_buffer_delay:a,encoder_buffer_delay:u,low_delay_mode_flag:l}}chooseOperatingPoint(){return 0}colorConfig(n){const r=!!this.f1();let a=!1,u=8;n===2&&r?(a=!!this.f1(),u=a?12:10):n<=2&&(u=r?10:8);let l=!1;n===1&&(l=!!this.f1());const m=!!this.f1();let b=yt.ColorPrimaries.Unspecified,h=yt.TransferCharacteristics.Unspecified,d=yt.MatrixCoefficients.Unspecified;m&&(b=this.f(8),h=this.f(8),d=this.f(8));let p=!1,_,y,w=0,S=!1;if(l)p=!!this.f1(),_=!0,y=!0;else{if(b===yt.ColorPrimaries.Bt709&&h===yt.TransferCharacteristics.Srgb&&d===yt.MatrixCoefficients.Identity)p=!0,_=!1,y=!1;else{switch(p=!!this.f1(),n){case 0:_=!0,y=!0;break;case 1:_=!1,y=!1;break;default:u==12?(_=!!this.f1(),_?y=!!this.f1():y=!1):(_=!0,y=!1);break}_&&y&&(w=this.f(2))}S=!!this.f1()}return{high_bitdepth:r,twelve_bit:a,BitDepth:u,mono_chrome:l,color_description_present_flag:m,color_primaries:b,transfer_characteristics:h,matrix_coefficients:d,color_range:p,subsampling_x:_,subsampling_y:y,chroma_sample_position:w,separate_uv_delta_q:S}}}function*Xf(s){let n=-1,r=0,a=!1;for(let u=0;u<s.length;u+=1){const l=s[u];if(a){if(l>3)throw new Error("Invalid data");a=!1;continue}if(l===0){r+=1;continue}const m=r;if(r=0,n===-1){if(m>=2&&l===1){n=u+1;continue}throw new Error("Invalid data")}if(!(m<2)){if(l===1){yield s.subarray(n,u-m),n=u+1;continue}if(m>2)throw new Error("Invalid data");switch(l){case 2:throw new Error("Invalid data");case 3:a=!0;break}}}if(a)throw new Error("Invalid data");yield s.subarray(n,s.length)}class Ri{#e;#t;#n;#r=0;#i=0;#s=7;#o=0;get byteLength(){return this.#t}get stopBitIndex(){return this.#n}get bytePosition(){return this.#i}get bitPosition(){return this.#s}get ended(){return this.#i>=this.#t&&this.#s<=this.#n}constructor(n){this.#e=n;for(let r=n.length-1;r>=0;r-=1){if(this.#e[r]===0)continue;const a=n[r];for(let u=0;u<8;u+=1)if((a>>u&1)===1){this.#t=r,this.#n=u,this.#l();return}}throw new Error("Stop bit not found")}#l(){if(this.#o=this.#e[this.#i],this.#r===2&&this.#o===3){this.#r=0,this.#i+=1,this.#l();return}this.#o===0?this.#r+=1:this.#r=0}next(){if(this.ended)throw new Error("Bit index out of bounds");const n=this.#o>>this.#s&1;return this.#s-=1,this.#s<0&&(this.#i+=1,this.#s=7,this.#l()),n}read(n){if(n>32)throw new Error("Read length too large");let r=0;for(let a=0;a<n;a+=1)r=r<<1|this.next();return r}#c(){if(this.#i>=this.#t&&this.#s<this.#n)throw new Error("Bit index out of bounds")}skip(n){if(n<=this.#s+1){this.#s-=n,this.#c();return}for(n-=this.#s+1,this.#i+=1,this.#s=7,this.#l(),this.#c();n>=8;n-=8)this.#i+=1,this.#l(),this.#c();this.#s=7-n,this.#c()}decodeExponentialGolombNumber(){let n=0;for(;this.next()===0;)n+=1;return n===0?0:(1<<n|this.read(n))-1}#d(){return{zeroCount:this.#r,bytePosition:this.#i,bitPosition:this.#s,byte:this.#o}}#a(n){this.#r=n.zeroCount,this.#i=n.bytePosition,this.#s=n.bitPosition,this.#o=n.byte}peek(n){const r=this.#d(),a=this.read(n);return this.#a(r),a}readBytes(n){const r=new Uint8Array(n);for(let a=0;a<n;a+=1)r[a]=this.read(8);return r}peekBytes(n){const r=this.#d(),a=this.readBytes(n);return this.#a(r),a}}function N2(s){const n=new Ri(s);if(n.next()!==0)throw new Error("Invalid data");const r=n.read(2);if(n.read(5)!==7)throw new Error("Invalid data");if(r===0)throw new Error("Invalid data");const u=n.read(8),l=n.peek(8),m=!!n.next(),b=!!n.next(),h=!!n.next(),d=!!n.next(),p=!!n.next(),_=!!n.next();if(n.read(2)!==0)throw new Error("Invalid data");const y=n.read(8),w=n.decodeExponentialGolombNumber();if(u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128||u===138||u===139||u===134){const F=n.decodeExponentialGolombNumber();if(F===3&&n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber(),n.next(),!!n.next())for(let D=0;D<(F!==3?8:12);D+=1)n.next()}n.decodeExponentialGolombNumber();const S=n.decodeExponentialGolombNumber();if(S===0)n.decodeExponentialGolombNumber();else if(S===1){n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber();const F=n.decodeExponentialGolombNumber();for(let z=0;z<F;z+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const P=n.decodeExponentialGolombNumber(),N=n.decodeExponentialGolombNumber(),I=n.next();I||n.next(),n.next();const L=!!n.next();let k,B,Y,T;return L?(k=n.decodeExponentialGolombNumber(),B=n.decodeExponentialGolombNumber(),Y=n.decodeExponentialGolombNumber(),T=n.decodeExponentialGolombNumber()):(k=0,B=0,Y=0,T=0),n.next(),{profile_idc:u,constraint_set:l,constraint_set0_flag:m,constraint_set1_flag:b,constraint_set2_flag:h,constraint_set3_flag:d,constraint_set4_flag:p,constraint_set5_flag:_,level_idc:y,seq_parameter_set_id:w,pic_width_in_mbs_minus1:P,pic_height_in_map_units_minus1:N,frame_mbs_only_flag:I,frame_cropping_flag:L,frame_crop_left_offset:k,frame_crop_right_offset:B,frame_crop_top_offset:Y,frame_crop_bottom_offset:T}}function R2(s){let n,r;for(const a of Xf(s))switch(a[0]&31){case 7:if(n=a,r)return{sequenceParameterSet:n,pictureParameterSet:r};break;case 8:if(r=a,n)return{sequenceParameterSet:n,pictureParameterSet:r};break}throw new Error("Invalid data")}function T2(s){const{sequenceParameterSet:n,pictureParameterSet:r}=R2(s),{profile_idc:a,constraint_set:u,level_idc:l,pic_width_in_mbs_minus1:m,pic_height_in_map_units_minus1:b,frame_mbs_only_flag:h,frame_crop_left_offset:d,frame_crop_right_offset:p,frame_crop_top_offset:_,frame_crop_bottom_offset:y}=N2(n),w=(m+1)*16,S=(b+1)*(2-h)*16,P=d*2,N=p*2,I=_*2,L=y*2,k=w-P-N,B=S-I-L;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:a,constraintSet:u,levelIndex:l,encodedWidth:w,encodedHeight:S,cropLeft:P,cropRight:N,cropTop:I,cropBottom:L,croppedWidth:k,croppedHeight:B}}function k2(s){switch(s){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function j2(s){switch(s){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function A2(s){const n=new Ri(s);if(n.next()!==0)throw new Error("Invalid NALU header");const r=n.read(6),a=n.read(6),u=n.read(3);return{nal_unit_type:r,nuh_layer_id:a,nuh_temporal_id_plus1:u}}function P2(s){const n=new Ri(s),r=n.read(4),a=!!n.next(),u=!!n.next(),l=n.read(6),m=n.read(3),b=!!n.next();n.skip(16);const h=Yf(n,!0,m),d=!!n.next(),p=[],_=[],y=[];for(let te=d?0:m;te<=m;te+=1)p[te]=n.decodeExponentialGolombNumber(),_[te]=n.decodeExponentialGolombNumber(),y[te]=n.decodeExponentialGolombNumber();const w=n.read(6),S=n.decodeExponentialGolombNumber(),P=[];for(let te=1;te<=S;te+=1){P[te]=[];for(let U=0;U<=w;U+=1)P[te][U]=!!n.next()}const N=!!n.next();let I,L,k,B,Y,T,F,z;if(N){I=n.read(32),L=n.read(32),k=!!n.next(),k&&(B=n.decodeExponentialGolombNumber()),Y=n.decodeExponentialGolombNumber(),T=[],F=[!0],z=[];for(let te=0;te<Y;te+=1)T[te]=n.decodeExponentialGolombNumber(),te>0&&(F[te]=!!n.next()),z[te]=Kf(n,F[te],m)}const D=!!n.next();return{vps_video_parameter_set_id:r,vps_base_layer_internal_flag:a,vps_base_layer_available_flag:u,vps_max_layers_minus1:l,vps_max_sub_layers_minus1:m,vps_temporal_id_nesting_flag:b,profileTierLevel:h,vps_sub_layer_ordering_info_present_flag:d,vps_max_dec_pic_buffering_minus1:p,vps_max_num_reorder_pics:_,vps_max_latency_increase_plus1:y,vps_max_layer_id:w,vps_num_layer_sets_minus1:S,layer_id_included_flag:P,vps_timing_info_present_flag:N,vps_num_units_in_tick:I,vps_time_scale:L,vps_poc_proportional_to_timing_flag:k,vps_num_ticks_poc_diff_one_minus1:B,vps_num_hrd_parameters:Y,hrd_layer_set_idx:T,cprms_present_flag:F,hrdParameters:z,vps_extension_flag:D}}function M2(s){const n=new Ri(s),r=n.read(4),a=n.read(3),u=!!n.next(),l=Yf(n,!0,a),m=n.decodeExponentialGolombNumber(),b=n.decodeExponentialGolombNumber();let h;b===3&&(h=!!n.next());const d=n.decodeExponentialGolombNumber(),p=n.decodeExponentialGolombNumber(),_=!!n.next();let y,w,S,P;_&&(y=n.decodeExponentialGolombNumber(),w=n.decodeExponentialGolombNumber(),S=n.decodeExponentialGolombNumber(),P=n.decodeExponentialGolombNumber());const N=n.decodeExponentialGolombNumber(),I=n.decodeExponentialGolombNumber(),L=n.decodeExponentialGolombNumber(),k=[],B=[],Y=[],T=!!n.next();for(let de=T?0:a;de<=a;de+=1)k[de]=n.decodeExponentialGolombNumber(),B[de]=n.decodeExponentialGolombNumber(),Y[de]=n.decodeExponentialGolombNumber();const F=n.decodeExponentialGolombNumber(),z=n.decodeExponentialGolombNumber(),D=n.decodeExponentialGolombNumber(),te=n.decodeExponentialGolombNumber(),U=n.decodeExponentialGolombNumber(),M=n.decodeExponentialGolombNumber(),G=!!n.next();let H,Z;G&&(H=!!n.next(),H&&(Z=D2(n)));const Q=!!n.next(),ee=!!n.next(),ie=!!n.next();let ne,A,$,re,le;ie&&(ne=n.read(4),A=n.read(4),$=n.read(4),re=n.read(4),le=!!n.next());const ve=n.decodeExponentialGolombNumber(),xe=[];for(let de=0;de<ve;de+=1)xe[de]=I2(n,de,ve,xe);const Ue=!!n.next();let Le,_e,ce;if(Ue){Le=n.decodeExponentialGolombNumber(),_e=[],ce=[];for(let de=0;de<Le;de+=1)_e[de]=n.read(L+4),ce[de]=!!n.next()}const K=!!n.next(),pe=!!n.next(),Se=!!n.next();let He;Se&&(He=L2(n,a));const ge=!!n.next();let Ie,Te,Re,oe,me;if(ge&&(Ie=!!n.next(),Te=!!n.next(),Re=!!n.next(),oe=!!n.next(),me=n.read(4)),Ie)throw new Error("Not implemented");let Ne;Te&&(Ne=F2(n));let ae;if(Re&&(ae=B2(n)),oe)throw new Error("Not implemented");let Ce;if(me){Ce=[];let de=0;for(;!n.ended;)Ce[de]=!!n.next(),de+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:a,sps_temporal_id_nesting_flag:u,profileTierLevel:l,sps_seq_parameter_set_id:m,chroma_format_idc:b,separate_colour_plane_flag:h,pic_width_in_luma_samples:d,pic_height_in_luma_samples:p,conformance_window_flag:_,conf_win_left_offset:y,conf_win_right_offset:w,conf_win_top_offset:S,conf_win_bottom_offset:P,bit_depth_luma_minus8:N,bit_depth_chroma_minus8:I,log2_max_pic_order_cnt_lsb_minus4:L,sps_sub_layer_ordering_info_present_flag:T,sps_max_dec_pic_buffering_minus1:k,sps_max_num_reorder_pics:B,sps_max_latency_increase_plus1:Y,log2_min_luma_coding_block_size_minus3:F,log2_diff_max_min_luma_coding_block_size:z,log2_min_luma_transform_block_size_minus2:D,log2_diff_max_min_luma_transform_block_size:te,max_transform_hierarchy_depth_inter:U,max_transform_hierarchy_depth_intra:M,scaling_list_enabled_flag:G,sps_scaling_list_data_present_flag:H,scalingListData:Z,amp_enabled_flag:Q,sample_adaptive_offset_enabled_flag:ee,pcm_enabled_flag:ie,pcm_sample_bit_depth_luma_minus1:ne,pcm_sample_bit_depth_chroma_minus1:A,log2_min_pcm_luma_coding_block_size_minus3:$,log2_diff_max_min_pcm_luma_coding_block_size:re,pcm_loop_filter_disabled_flag:le,num_short_term_ref_pic_sets:ve,shortTermRefPicSets:xe,long_term_ref_pics_present_flag:Ue,num_long_term_ref_pics_sps:Le,lt_ref_pic_poc_lsb_sps:_e,used_by_curr_pic_lt_sps_flag:ce,sps_temporal_mvp_enabled_flag:K,strong_intra_smoothing_enabled_flag:pe,vui_parameters_present_flag:Se,vuiParameters:He,sps_extension_present_flag:ge,sps_range_extension_flag:Ie,sps_multilayer_extension_flag:Te,sps_3d_extension_flag:Re,sps_scc_extension_flag:oe,sps_extension_4bits:me,spsMultilayerExtension:Ne,sps3dExtension:ae,sps_extension_data_flag:Ce}}function Ru(s){const n=s.read(2),r=!!s.next(),a=s.read(5),u=s.peekBytes(4),l=[];for(let T=0;T<32;T+=1)l[T]=!!s.next();const m=s.peekBytes(6),b=!!s.next(),h=!!s.next(),d=!!s.next(),p=!!s.next();let _,y,w,S,P,N,I,L,k,B;a===4||l[4]||a===5||l[5]||a===6||l[6]||a===7||l[7]||a===8||l[8]||a===9||l[9]||a===10||l[10]||a===11||l[11]?(_=!!s.next(),y=!!s.next(),w=!!s.next(),S=!!s.next(),P=!!s.next(),N=!!s.next(),I=!!s.next(),L=!!s.next(),k=!!s.next(),a===5||l[5]||a===9||l[9]||a===10||l[10]||a===11||l[11]?(B=!!s.next(),s.skip(33)):s.skip(34)):a===2||l[2]?(s.skip(7),L=!!s.next(),s.skip(35)):s.skip(43);let Y;return a===1||l[1]||a===2||l[2]||a===3||l[3]||a===4||l[4]||a===5||l[5]||a===9||l[9]||a===11||l[11]?Y=!!s.next():s.skip(1),{profile_space:n,tier_flag:r,profile_idc:a,profileCompatibilitySet:u,profile_compatibility_flag:l,constraintSet:m,progressive_source_flag:b,interlaced_source_flag:h,non_packed_constraint_flag:d,frame_only_constraint_flag:p,max_12bit_constraint_flag:_,max_10bit_constraint_flag:y,max_8bit_constraint_flag:w,max_422chroma_constraint_flag:S,max_420chroma_constraint_flag:P,max_monochrome_constraint_flag:N,intra_constraint_flag:I,one_picture_only_constraint_flag:L,lower_bit_rate_constraint_flag:k,max_14bit_constraint_flag:B,inbld_flag:Y}}function Yf(s,n,r){let a;a=Ru(s);const u=s.read(8),l=[],m=[];for(let d=0;d<r;d+=1)l[d]=!!s.next(),m[d]=!!s.next();if(r>0)for(let d=r;d<8;d+=1)s.read(2);const b=[],h=[];for(let d=0;d<r;d+=1)l[d]&&(b[d]=Ru(s)),m[d]&&(h[d]=s.read(8));return{generalProfileTier:a,general_level_idc:u,sub_layer_profile_present_flag:l,sub_layer_level_present_flag:m,subLayerProfileTier:b,sub_layer_level_idc:h}}function D2(s){const n=[];for(let r=0;r<4;r+=1){n[r]=[];for(let a=0;a<6;a+=r===3?3:1)if(!!!s.next())s.decodeExponentialGolombNumber();else{let l=8;const m=Math.min(64,1<<4+(r<<1));r>1&&(l=s.decodeExponentialGolombNumber()+8),n[r][a]=[];for(let b=0;b<m;b+=1){const h=s.decodeExponentialGolombNumber();l=(l+h+256)%256,n[r][a][b]=l}}}return n}function I2(s,n,r,a){let u=!1;n!==0&&(u=!!s.next());let l=0,m=!1,b=0;const h=[],d=[];let p=0,_=0;const y=[],w=[],S=[],P=[];if(u){n===r&&(l=s.decodeExponentialGolombNumber()),m=!!s.next(),b=s.decodeExponentialGolombNumber();const N=n-(l+1),I=a[N],L=I.num_negative_pics+I.num_positive_pics;for(let U=0;U<=L;U+=1)h[U]=!!s.next(),h[U]?d[U]=!0:d[U]=!!s.next();const k=(1-2*Number(m))*(b+1),B=[],Y=[],T=[],F=[];let z=0;for(let U=0;U<I.num_negative_pics;U+=1)z-=I.delta_poc_s0_minus1[U]+1,B[U]=z;z=0;for(let U=0;U<I.num_positive_pics;U+=1)z+=I.delta_poc_s1_minus1[U]+1,Y[U]=z;let D=0;if(I.num_positive_pics>0)for(let U=I.num_positive_pics-1;U>=0;U-=1)z=Y[U]+k,z<0&&d[I.num_negative_pics+U]&&(T[D]=z,w[D]=h[I.num_negative_pics+U],D+=1);k<0&&d[L]&&(T[D]=k,w[D]=h[L],D+=1);for(let U=0;U<I.num_negative_pics;U+=1)z=B[U]+k,z<0&&d[U]&&(T[D]=z,w[D]=h[U],D+=1);p=D;let te=0;for(D=0;D<p;D+=1){const U=T[D];y[D]=-(U-te-1),te=U}if(D=0,I.num_negative_pics>0)for(let U=I.num_negative_pics-1;U>=0;U-=1)z=B[U]+k,z>0&&d[U]&&(F[D]=z,P[D]=h[U],D+=1);k>0&&d[L]&&(F[D]=k,P[D]=h[L],D+=1);for(let U=0;U<I.num_positive_pics;U+=1)z=Y[U]+k,z>0&&d[I.num_negative_pics+U]&&(F[D]=z,P[D]=h[I.num_negative_pics+U],D+=1);for(_=D,te=0,D=0;D<_;D+=1){const U=F[D];S[D]=U-te-1,te=U}}else{p=s.decodeExponentialGolombNumber(),_=s.decodeExponentialGolombNumber();for(let N=0;N<p;N+=1)y[N]=s.decodeExponentialGolombNumber(),w[N]=!!s.next();for(let N=0;N<_;N+=1)S[N]=s.decodeExponentialGolombNumber(),P[N]=!!s.next()}return{stRpsIdx:n,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:u,delta_idx_minus1:l,delta_rps_sign:m,abs_delta_rps_minus1:b,used_by_curr_pic_flag:h,use_delta_flag:d,num_negative_pics:p,num_positive_pics:_,delta_poc_s0_minus1:y,used_by_curr_pic_s0_flag:w,delta_poc_s1_minus1:S,used_by_curr_pic_s1_flag:P}}function L2(s,n){const r=!!s.next();let a,u,l;r&&(a=s.read(8),a===255&&(u=s.read(16),l=s.read(16)));const m=!!s.next();let b;m&&(b=!!s.next());const h=!!s.next();let d,p,_,y,w,S;h&&(d=s.read(3),p=!!s.next(),_=!!s.next(),_&&(y=s.read(8),w=s.read(8),S=s.read(8)));const P=!!s.next();let N,I;P&&(N=s.decodeExponentialGolombNumber(),I=s.decodeExponentialGolombNumber());const L=!!s.next(),k=!!s.next(),B=!!s.next(),Y=!!s.next();let T,F,z,D;Y&&(T=s.decodeExponentialGolombNumber(),F=s.decodeExponentialGolombNumber(),z=s.decodeExponentialGolombNumber(),D=s.decodeExponentialGolombNumber());const te=!!s.next();let U,M,G,H,Z,Q;te&&(U=s.read(32),M=s.read(32),G=!!s.next(),G&&(H=s.decodeExponentialGolombNumber()),Z=!!s.next(),Z&&(Q=Kf(s,!0,n)));const ee=!!s.next();let ie,ne,A,$,re,le,ve,xe;return ee&&(ie=!!s.next(),ne=!!s.next(),A=!!s.next(),$=s.decodeExponentialGolombNumber(),re=s.decodeExponentialGolombNumber(),le=s.decodeExponentialGolombNumber(),ve=s.decodeExponentialGolombNumber(),xe=s.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:a,sar_width:u,sar_height:l,overscan_info_present_flag:m,overscan_appropriate_flag:b,video_signal_type_present_flag:h,video_format:d,video_full_range_flag:p,colour_description_present_flag:_,colour_primaries:y,transfer_characteristics:w,matrix_coeffs:S,chroma_loc_info_present_flag:P,chroma_sample_loc_type_top_field:N,chroma_sample_loc_type_bottom_field:I,neutral_chroma_indication_flag:L,field_seq_flag:k,frame_field_info_present_flag:B,default_display_window_flag:Y,def_disp_win_left_offset:T,def_disp_win_right_offset:F,def_disp_win_top_offset:z,def_disp_win_bottom_offset:D,vui_timing_info_present_flag:te,vui_num_units_in_tick:U,vui_time_scale:M,vui_poc_proportional_to_timing_flag:G,vui_num_ticks_poc_diff_one_minus1:H,vui_hrd_parameters_present_flag:Z,vui_hrd_parameters:Q,bitstream_restriction_flag:ee,tiles_fixed_structure_flag:ie,motion_vectors_over_pic_boundaries_flag:ne,restricted_ref_pic_lists_flag:A,min_spatial_segmentation_idc:$,max_bytes_per_pic_denom:re,max_bits_per_min_cu_denom:le,log2_max_mv_length_horizontal:ve,log2_max_mv_length_vertical:xe}}function Kf(s,n,r){let a,u,l,m,b,h,d,p,_,y,w,S,P;n&&(a=!!s.next(),u=!!s.next(),(a||u)&&(l=!!s.next(),l&&(m=s.read(8),b=s.read(5),h=!!s.next(),d=s.read(5)),p=s.read(4),_=s.read(4),l&&(y=s.read(4)),w=s.read(5),S=s.read(5),P=s.read(5)));const N=[],I=[],L=[],k=[],B=[],Y=[],T=[];for(let F=0;F<=r;F+=1)N[F]=!!s.next(),N[F]||(I[F]=!!s.next()),I[F]?L[F]=s.decodeExponentialGolombNumber():k[F]=!!s.next(),k[F]||(B[F]=s.decodeExponentialGolombNumber()),a&&(Y[F]=Tu(s,F,ku(B[F]))),u&&(T[F]=Tu(s,F,ku(B[F])));return{nal_hrd_parameters_present_flag:a,vcl_hrd_parameters_present_flag:u,sub_pic_hrd_params_present_flag:l,tick_divisor_minus2:m,du_cpb_removal_delay_increment_length_minus1:b,sub_pic_cpb_params_in_pic_timing_sei_flag:h,dpb_output_delay_du_length_minus1:d,bit_rate_scale:p,cpb_size_scale:_,cpb_size_du_scale:y,initial_cpb_removal_delay_length_minus1:w,au_cpb_removal_delay_length_minus1:S,dpb_output_delay_length_minus1:P,fixed_pic_rate_general_flag:N,fixed_pic_rate_within_cvs_flag:I,elemental_duration_in_tc_minus1:L,low_delay_hrd_flag:k,cpb_cnt_minus1:B,nalHrdParameters:Y,vclHrdParameters:T}}function Tu(s,n,r){const a=[],u=[],l=[],m=[],b=[];for(let h=0;h<r;h+=1)a[h]=s.decodeExponentialGolombNumber(),u[h]=s.decodeExponentialGolombNumber(),n>0&&(b[h]=!!s.next());return{bit_rate_value_minus1:a,cpb_size_value_minus1:u,cpb_size_du_value_minus1:l,bit_rate_du_value_minus1:m,cbr_flag:b}}function ku(s){return s+1}function O2(s){let n,r,a,u=0;for(const l of Xf(s)){const m=A2(l),b={...m,data:l,rbsp:l.subarray(2)};switch(m.nal_unit_type){case 32:n=b;break;case 33:r=b;break;case 34:a=b;break;default:continue}if(u+=1,u===3)return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:a}}throw new Error("Invalid data")}function F2(s){return{inter_view_mv_vert_constraint_flag:!!s.next()}}function B2(s){const n=[],r=[];n[0]=!!s.next(),r[0]=!!s.next();const a=s.decodeExponentialGolombNumber(),u=!!s.next(),l=!!s.next(),m=!!s.next(),b=!!s.next();n[1]=!!s.next(),r[1]=!!s.next();const h=!!s.next(),d=s.decodeExponentialGolombNumber(),p=!!s.next(),_=!!s.next(),y=!!s.next(),w=!!s.next(),S=!!s.next();return{iv_di_mc_enabled_flag:n,iv_mv_scal_enabled_flag:r,log2_ivmc_sub_pb_size_minus3:a,iv_res_pred_enabled_flag:u,depth_ref_enabled_flag:l,vsp_mc_enabled_flag:m,dbbp_enabled_flag:b,tex_mc_enabled_flag:h,log2_texmc_sub_pb_size_minus3:d,intra_contour_enabled_flag:p,intra_dc_only_wedge_enabled_flag:_,cqt_cu_part_pred_enabled_flag:y,inter_dc_only_enabled_flag:w,skip_intra_enabled_flag:S}}function U2(s){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:a}=O2(s),{profileTierLevel:{generalProfileTier:{profile_space:u,tier_flag:l,profile_idc:m,profileCompatibilitySet:b,constraintSet:h},general_level_idc:d}}=P2(n.rbsp),{chroma_format_idc:p,pic_width_in_luma_samples:_,pic_height_in_luma_samples:y,conf_win_left_offset:w=0,conf_win_right_offset:S=0,conf_win_top_offset:P=0,conf_win_bottom_offset:N=0}=M2(r.rbsp),I=k2(p),L=j2(p),k=_-I*(w+S),B=y-L*(P+N);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:a,generalProfileSpace:u,generalProfileIndex:m,generalProfileCompatibilitySet:b,generalTierFlag:l,generalLevelIndex:d,generalConstraintSet:h,encodedWidth:_,encodedHeight:y,cropLeft:w,cropRight:S,cropTop:P,cropBottom:N,croppedWidth:k,croppedHeight:B}}function ju(s){return s.toString(16).toUpperCase()}function Xo(s){return s.toString(16).toUpperCase().padStart(2,"0")}function Hr(s){return s.toString(10).padStart(2,"0")}class G2{#e;#t;constructor(n,r){this.#e=n,this.#t=r}#n(n){const a=new yt(n).searchSequenceHeaderObu();if(!a)return;const{seq_profile:u,seq_level_idx:[l=0],max_frame_width_minus_1:m,max_frame_height_minus_1:b,color_config:{BitDepth:h,mono_chrome:d,subsampling_x:p,subsampling_y:_,chroma_sample_position:y,color_description_present_flag:w}}=a;let S,P,N,I;w?{color_primaries:S,transfer_characteristics:P,matrix_coefficients:N,color_range:I}=a.color_config:(S=yt.ColorPrimaries.Bt709,P=yt.TransferCharacteristics.Bt709,N=yt.MatrixCoefficients.Bt709,I=!1);const L=m+1,k=b+1;this.#t(L,k);const B=["av01",u.toString(16),Hr(l)+(a.seq_tier[0]?"H":"M"),Hr(h),d?"1":"0",(p?"1":"0")+(_?"1":"0")+y.toString(),Hr(S),Hr(P),Hr(N),I?"1":"0"].join(".");this.#e.configure({codec:B,optimizeForLatency:!0})}decode(n){n.type!=="configuration"&&(this.#n(n.data),this.#e.decode(new EncodedVideoChunk({type:n.keyframe===!1?"delta":"key",timestamp:0,data:n.data})))}}class Vf{#e;#t;constructor(n){this.#t=n}decode(n){if(n.type==="configuration"){this.#e=n.data,this.configure(n.data);return}let r;this.#e!==void 0?(r=new Uint8Array(this.#e.length+n.data.length),r.set(this.#e,0),r.set(n.data,this.#e.length),this.#e=void 0):r=n.data,this.#t.decode(new EncodedVideoChunk({type:n.keyframe===!1?"delta":"key",timestamp:0,data:r}))}}class W2 extends Vf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{profileIndex:r,constraintSet:a,levelIndex:u,croppedWidth:l,croppedHeight:m}=T2(n);this.#t(l,m);const b="avc1."+Xo(r)+Xo(a)+Xo(u);this.#e.configure({codec:b,optimizeForLatency:!0})}}class z2 extends Vf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{generalProfileSpace:r,generalProfileIndex:a,generalProfileCompatibilitySet:u,generalTierFlag:l,generalLevelIndex:m,generalConstraintSet:b,croppedWidth:h,croppedHeight:d}=U2(n);this.#t(h,d);const p=["hev1",["","A","B","C"][r]+a.toString(),ju(v2(u,0)),(l?"H":"L")+m.toString(),...Array.from(b,ju)].join(".");this.#e.configure({codec:p,codedWidth:h,codedHeight:d,optimizeForLatency:!0})}}class H2{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(n){this.listeners.push(n);const r=()=>{const a=this.listeners.indexOf(n);a!==-1&&this.listeners.splice(a,1)};return r.dispose=r,r}event=(n,r,...a)=>{const u={listener:n,thisArg:r,args:a};return this.addEventListener(u)};fire(n){for(const r of this.listeners.slice())r.listener.apply(r.thisArg,[n,...r.args])}dispose(){this.listeners.length=0}}class $2{#e;#t=new ReadableStream({start:n=>{this.#e=n},pull:n=>{n.enqueue(this.#r())}},{highWaterMark:0});#n=this.#t.getReader();#r;#i=0;#s;constructor(n,r){this.#r=n,this.#s=r}async borrow(){return(await this.#n.read()).value}return(n){this.#i<this.#s&&(this.#e.enqueue(n),this.#i+=1)}}class q2{#e;#t;constructor(){typeof OffscreenCanvas<"u"?this.#e=new OffscreenCanvas(1,1):(this.#e=document.createElement("canvas"),this.#e.width=1,this.#e.height=1),this.#t=this.#e.getContext("bitmaprenderer",{alpha:!1})}async capture(n){this.#e.width=n.displayWidth,this.#e.height=n.displayHeight;const r=await createImageBitmap(n);return this.#t.transferFromImageBitmap(r),this.#e instanceof OffscreenCanvas?await this.#e.convertToBlob({type:"image/png"}):new Promise((a,u)=>{this.#e.toBlob(l=>{l?a(l):u(new Error("Failed to convert canvas to blob"))},"image/png")})}}const Au=new $2(()=>new q2,4);class Pu{static get isSupported(){return typeof globalThis.VideoDecoder<"u"}static capabilities={h264:{},h265:{},av1:{}};#e;get codec(){return this.#e}#t;#n;get writable(){return this.#n}#r;#i;#s;get renderer(){return this.#s}#o=0;#l=0;get framesRendered(){return this.#l}#c=0;get framesSkipped(){return this.#c}#d=new H2;get sizeChanged(){return this.#d.event}#a;#p=!1;#u;#f;#m=0;constructor({codec:n,renderer:r}){switch(this.#e=n,this.#s=r,this.#a=new VideoDecoder({output:a=>{if(this.#f?.close(),this.#f=a.clone(),this.#p){this.#u&&(this.#u.close(),this.#c+=1),this.#u=a;return}this.#x(a)},error:a=>{this.#g(a)}}),this.#e){case si.H264:this.#t=new W2(this.#a,this.#h);break;case si.H265:this.#t=new z2(this.#a,this.#h);break;case si.AV1:this.#t=new G2(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new b2({start:a=>{this.#r?a.error(this.#r):this.#i=a},write:a=>{this.#t.decode(a)}}),this.#_()}#g(n){if(this.#i)try{this.#i.error(n)}catch{}else this.#r=n}async#x(n){try{if(this.#p=!0,this.#h(n.displayWidth,n.displayHeight),await this.#s.draw(n),this.#o+=1,n.close(),this.#u){const r=this.#u;this.#u=void 0,await this.#x(r)}this.#p=!1}catch(r){this.#g(r)}}#h=(n,r)=>{this.#s.setSize(n,r),this.#d.fire({width:n,height:r})};#_=()=>{this.#o>0&&(this.#l+=1,this.#c+=this.#o-1,this.#o=0),this.#m=requestAnimationFrame(this.#_)};async snapshot(){const n=this.#f;if(!n)return;const r=await Au.borrow(),a=await r.capture(n);return Au.return(r),a}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#f?.close()}}var Yo={exports:{}},Ko={exports:{}},Mu;function La(){return Mu||(Mu=1,(function(){function s(n,r){throw new Error("abstract")}s.prototype.drawFrame=function(n){throw new Error("abstract")},s.prototype.clear=function(){throw new Error("abstract")},Ko.exports=s})()),Ko.exports}var Vo={exports:{}},Qo={exports:{}},Jo={exports:{}},Du;function X2(){return Du||(Du=1,(function(){function s(n){for(var r=0,a=n>>1;a!=0;)a=a>>1,r++;if(n!==1<<r)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+n;return r}Jo.exports=s})()),Jo.exports}var Iu;function Y2(){return Iu||(Iu=1,(function(){var s=X2();function n(r,a){var u=r.format.width|0,l=r.format.height|0,m=s(r.format.width/r.format.chromaWidth)|0,b=s(r.format.height/r.format.chromaHeight)|0,h=r.y.bytes,d=r.u.bytes,p=r.v.bytes,_=r.y.stride|0,y=r.u.stride|0,w=r.v.stride|0,S=u<<2,P=0,N=0,I=0,L=0,k=0,B=0,Y=0,T=0,F=0,z=0,D=0,te=0,U=0,M=0,G=0,H=0,Z=0,Q=0;if(m==1&&b==1)for(Y=0,T=S,Q=0,H=0;H<l;H+=2){for(N=H*_|0,I=N+_|0,L=Q*y|0,k=Q*w|0,G=0;G<u;G+=2)F=d[L++]|0,z=p[k++]|0,te=(409*z|0)-57088|0,U=(100*F|0)+(208*z|0)-34816|0,M=(516*F|0)-70912|0,D=298*h[N++]|0,a[Y]=D+te>>8,a[Y+1]=D-U>>8,a[Y+2]=D+M>>8,Y+=4,D=298*h[N++]|0,a[Y]=D+te>>8,a[Y+1]=D-U>>8,a[Y+2]=D+M>>8,Y+=4,D=298*h[I++]|0,a[T]=D+te>>8,a[T+1]=D-U>>8,a[T+2]=D+M>>8,T+=4,D=298*h[I++]|0,a[T]=D+te>>8,a[T+1]=D-U>>8,a[T+2]=D+M>>8,T+=4;Y+=S,T+=S,Q++}else for(B=0,H=0;H<l;H++)for(Z=0,Q=H>>b,P=H*_|0,L=Q*y|0,k=Q*w|0,G=0;G<u;G++)Z=G>>m,F=d[L+Z]|0,z=p[k+Z]|0,te=(409*z|0)-57088|0,U=(100*F|0)+(208*z|0)-34816|0,M=(516*F|0)-70912|0,D=298*h[P++]|0,a[B]=D+te>>8,a[B+1]=D-U>>8,a[B+2]=D+M>>8,B+=4}Qo.exports={convertYCbCr:n}})()),Qo.exports}var Lu;function K2(){return Lu||(Lu=1,(function(){var s=La(),n=Y2();function r(a){var u=this,l=a.getContext("2d"),m=null,b=null,h=null;function d(_,y){m=l.createImageData(_,y);for(var w=m.data,S=_*y*4,P=0;P<S;P+=4)w[P+3]=255}function p(_,y){b=document.createElement("canvas"),b.width=_,b.height=y,h=b.getContext("2d")}return u.drawFrame=function(y){var w=y.format;(a.width!==w.displayWidth||a.height!==w.displayHeight)&&(a.width=w.displayWidth,a.height=w.displayHeight),(m===null||m.width!=w.width||m.height!=w.height)&&d(w.width,w.height),n.convertYCbCr(y,m.data);var S=w.cropWidth!=w.displayWidth||w.cropHeight!=w.displayHeight,P;S?(b||p(w.cropWidth,w.cropHeight),P=h):P=l,P.putImageData(m,-w.cropLeft,-w.cropTop,w.cropLeft,w.cropTop,w.cropWidth,w.cropHeight),S&&l.drawImage(b,0,0,w.displayWidth,w.displayHeight)},u.clear=function(){l.clearRect(0,0,a.width,a.height)},u}r.prototype=Object.create(s.prototype),Vo.exports=r})()),Vo.exports}var Zo={exports:{}},ea,Ou;function V2(){return Ou||(Ou=1,ea={vertex:`precision mediump float;
|
|
37
|
+
|
|
38
|
+
attribute vec2 aPosition;
|
|
39
|
+
attribute vec2 aLumaPosition;
|
|
40
|
+
attribute vec2 aChromaPosition;
|
|
41
|
+
varying vec2 vLumaPosition;
|
|
42
|
+
varying vec2 vChromaPosition;
|
|
43
|
+
void main() {
|
|
44
|
+
gl_Position = vec4(aPosition, 0, 1);
|
|
45
|
+
vLumaPosition = aLumaPosition;
|
|
46
|
+
vChromaPosition = aChromaPosition;
|
|
47
|
+
}
|
|
48
|
+
`,fragment:`// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js
|
|
49
|
+
|
|
50
|
+
precision mediump float;
|
|
51
|
+
|
|
52
|
+
uniform sampler2D uTextureY;
|
|
53
|
+
uniform sampler2D uTextureCb;
|
|
54
|
+
uniform sampler2D uTextureCr;
|
|
55
|
+
varying vec2 vLumaPosition;
|
|
56
|
+
varying vec2 vChromaPosition;
|
|
57
|
+
void main() {
|
|
58
|
+
// Y, Cb, and Cr planes are uploaded as ALPHA textures.
|
|
59
|
+
float fY = texture2D(uTextureY, vLumaPosition).w;
|
|
60
|
+
float fCb = texture2D(uTextureCb, vChromaPosition).w;
|
|
61
|
+
float fCr = texture2D(uTextureCr, vChromaPosition).w;
|
|
62
|
+
|
|
63
|
+
// Premultipy the Y...
|
|
64
|
+
float fYmul = fY * 1.1643828125;
|
|
65
|
+
|
|
66
|
+
// And convert that to RGB!
|
|
67
|
+
gl_FragColor = vec4(
|
|
68
|
+
fYmul + 1.59602734375 * fCr - 0.87078515625,
|
|
69
|
+
fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,
|
|
70
|
+
fYmul + 2.017234375 * fCb - 1.081390625,
|
|
71
|
+
1
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
`,vertexStripe:`precision mediump float;
|
|
75
|
+
|
|
76
|
+
attribute vec2 aPosition;
|
|
77
|
+
attribute vec2 aTexturePosition;
|
|
78
|
+
varying vec2 vTexturePosition;
|
|
79
|
+
|
|
80
|
+
void main() {
|
|
81
|
+
gl_Position = vec4(aPosition, 0, 1);
|
|
82
|
+
vTexturePosition = aTexturePosition;
|
|
83
|
+
}
|
|
84
|
+
`,fragmentStripe:`// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures
|
|
85
|
+
|
|
86
|
+
precision mediump float;
|
|
87
|
+
|
|
88
|
+
uniform sampler2D uStripe;
|
|
89
|
+
uniform sampler2D uTexture;
|
|
90
|
+
varying vec2 vTexturePosition;
|
|
91
|
+
void main() {
|
|
92
|
+
// Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture
|
|
93
|
+
// so we can upload them without expanding the bytes on IE 11
|
|
94
|
+
// which doesn't allow LUMINANCE or ALPHA textures
|
|
95
|
+
// The stripe textures mark which channel to keep for each pixel.
|
|
96
|
+
// Each texture extraction will contain the relevant value in one
|
|
97
|
+
// channel only.
|
|
98
|
+
|
|
99
|
+
float fLuminance = dot(
|
|
100
|
+
texture2D(uStripe, vTexturePosition),
|
|
101
|
+
texture2D(uTexture, vTexturePosition)
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
gl_FragColor = vec4(0, 0, 0, fLuminance);
|
|
105
|
+
}
|
|
106
|
+
`}),ea}var Fu;function Q2(){return Fu||(Fu=1,(function(){var s=La(),n=V2();function r(a){var u=this,l=r.contextForCanvas(a);if(l===null)throw new Error("WebGL unavailable");function m(H,Z){var Q=l.createShader(H);if(l.shaderSource(Q,Z),l.compileShader(Q),!l.getShaderParameter(Q,l.COMPILE_STATUS)){var ee=l.getShaderInfoLog(Q);throw l.deleteShader(Q),new Error("GL shader compilation for "+H+" failed: "+ee)}return Q}var b,h,d=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),p={},_={},y={},w,S,P,N,I,L,k,B,Y,T;function F(H,Z){return(!p[H]||Z)&&(p[H]=l.createTexture()),p[H]}function z(H,Z,Q,ee,ie){var ne=!p[H]||Z,A=F(H,Z);if(l.activeTexture(l.TEXTURE0),r.stripe){var $=!p[H+"_temp"]||Z,re=F(H+"_temp",Z);l.bindTexture(l.TEXTURE_2D,re),$?(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,Q/4,ee,0,l.RGBA,l.UNSIGNED_BYTE,ie)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,Q/4,ee,l.RGBA,l.UNSIGNED_BYTE,ie);var le=p[H+"_stripe"],ve=!le||Z;ve&&(le=F(H+"_stripe",Z)),l.bindTexture(l.TEXTURE_2D,le),ve&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,Q,1,0,l.RGBA,l.UNSIGNED_BYTE,U(Q)))}else l.bindTexture(l.TEXTURE_2D,A),ne?(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texImage2D(l.TEXTURE_2D,0,l.ALPHA,Q,ee,0,l.ALPHA,l.UNSIGNED_BYTE,ie)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,Q,ee,l.ALPHA,l.UNSIGNED_BYTE,ie)}function D(H,Z,Q,ee){var ie=p[H];l.useProgram(h);var ne=_[H];(!ne||Z)&&(l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,ie),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,Q,ee,0,l.RGBA,l.UNSIGNED_BYTE,null),ne=_[H]=l.createFramebuffer()),l.bindFramebuffer(l.FRAMEBUFFER,ne),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,ie,0);var A=p[H+"_temp"];l.activeTexture(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,A),l.uniform1i(L,1);var $=p[H+"_stripe"];l.activeTexture(l.TEXTURE2),l.bindTexture(l.TEXTURE_2D,$),l.uniform1i(I,2),l.bindBuffer(l.ARRAY_BUFFER,w),l.enableVertexAttribArray(S),l.vertexAttribPointer(S,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,P),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.viewport(0,0,Q,ee),l.drawArrays(l.TRIANGLES,0,d.length/2),l.bindFramebuffer(l.FRAMEBUFFER,null)}function te(H,Z,Q){l.activeTexture(Z),l.bindTexture(l.TEXTURE_2D,p[H]),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.uniform1i(l.getUniformLocation(b,H),Q)}function U(H){if(y[H])return y[H];for(var Z=H,Q=new Uint32Array(Z),ee=0;ee<Z;ee+=4)Q[ee]=255,Q[ee+1]=65280,Q[ee+2]=16711680,Q[ee+3]=4278190080;return y[H]=new Uint8Array(Q.buffer)}function M(H,Z){var Q=m(l.VERTEX_SHADER,H),ee=m(l.FRAGMENT_SHADER,Z),ie=l.createProgram();if(l.attachShader(ie,Q),l.attachShader(ie,ee),l.linkProgram(ie),!l.getProgramParameter(ie,l.LINK_STATUS)){var ne=l.getProgramInfoLog(ie);throw l.deleteProgram(ie),new Error("GL program linking failed: "+ne)}return ie}function G(){if(r.stripe){h=M(n.vertexStripe,n.fragmentStripe),l.getAttribLocation(h,"aPosition"),P=l.createBuffer();var H=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);l.bindBuffer(l.ARRAY_BUFFER,P),l.bufferData(l.ARRAY_BUFFER,H,l.STATIC_DRAW),N=l.getAttribLocation(h,"aTexturePosition"),I=l.getUniformLocation(h,"uStripe"),L=l.getUniformLocation(h,"uTexture")}b=M(n.vertex,n.fragment),w=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,w),l.bufferData(l.ARRAY_BUFFER,d,l.STATIC_DRAW),S=l.getAttribLocation(b,"aPosition"),k=l.createBuffer(),B=l.getAttribLocation(b,"aLumaPosition"),Y=l.createBuffer(),T=l.getAttribLocation(b,"aChromaPosition")}return u.drawFrame=function(H){var Z=H.format,Q=!b||a.width!==Z.displayWidth||a.height!==Z.displayHeight;if(Q&&(a.width=Z.displayWidth,a.height=Z.displayHeight,u.clear()),b||G(),Q){var ee=function(ie,ne,A){var $=Z.cropLeft/A,re=(Z.cropLeft+Z.cropWidth)/A,le=(Z.cropTop+Z.cropHeight)/Z.height,ve=Z.cropTop/Z.height,xe=new Float32Array([$,le,re,le,$,ve,$,ve,re,le,re,ve]);l.bindBuffer(l.ARRAY_BUFFER,ie),l.bufferData(l.ARRAY_BUFFER,xe,l.STATIC_DRAW)};ee(k,B,H.y.stride),ee(Y,T,H.u.stride*Z.width/Z.chromaWidth)}z("uTextureY",Q,H.y.stride,Z.height,H.y.bytes),z("uTextureCb",Q,H.u.stride,Z.chromaHeight,H.u.bytes),z("uTextureCr",Q,H.v.stride,Z.chromaHeight,H.v.bytes),r.stripe&&(D("uTextureY",Q,H.y.stride,Z.height),D("uTextureCb",Q,H.u.stride,Z.chromaHeight),D("uTextureCr",Q,H.v.stride,Z.chromaHeight)),l.useProgram(b),l.viewport(0,0,a.width,a.height),te("uTextureY",l.TEXTURE0,0),te("uTextureCb",l.TEXTURE1,1),te("uTextureCr",l.TEXTURE2,2),l.bindBuffer(l.ARRAY_BUFFER,w),l.enableVertexAttribArray(S),l.vertexAttribPointer(S,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,k),l.enableVertexAttribArray(B),l.vertexAttribPointer(B,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,Y),l.enableVertexAttribArray(T),l.vertexAttribPointer(T,2,l.FLOAT,!1,0,0),l.drawArrays(l.TRIANGLES,0,d.length/2)},u.clear=function(){l.viewport(0,0,a.width,a.height),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT)},u.clear(),u}r.stripe=!1,r.contextForCanvas=function(a){var u={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return a.getContext("webgl",u)||a.getContext("experimental-webgl",u)},r.isAvailable=function(){var a=document.createElement("canvas"),u;a.width=1,a.height=1;try{u=r.contextForCanvas(a)}catch{return!1}if(u){var l=u.TEXTURE0,m=4,b=4,h=u.createTexture(),d=new Uint8Array(m*b),p=r.stripe?m/4:m,_=r.stripe?u.RGBA:u.ALPHA,y=r.stripe?u.NEAREST:u.LINEAR;u.activeTexture(l),u.bindTexture(u.TEXTURE_2D,h),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,y),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,y),u.texImage2D(u.TEXTURE_2D,0,_,p,b,0,_,u.UNSIGNED_BYTE,d);var w=u.getError();return!w}else return!1},r.prototype=Object.create(s.prototype),Zo.exports=r})()),Zo.exports}var Bu;function J2(){return Bu||(Bu=1,(function(){var s=La(),n=K2(),r=Q2(),a={FrameSink:s,SoftwareFrameSink:n,WebGLFrameSink:r,attach:function(u,l){l=l||{};var m="webGL"in l?l.webGL:r.isAvailable();return m?new r(u,l):new n(u,l)}};Yo.exports=a})()),Yo.exports}J2();function Qf(){if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("no canvas input found nor any canvas can be created")}class Jf{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=Qf()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class Z2 extends Jf{#e;constructor(n){super(n),this.#e=this.canvas.getContext("bitmaprenderer",{alpha:!1})}async draw(n){const r=await createImageBitmap(n);this.#e.transferFromImageBitmap(r)}}const eE=Promise.resolve();function Uu(s,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return s.getContext("webgl2",r)||s.getContext("webgl",r)}class ts extends Jf{static vertexShaderSource=`
|
|
107
|
+
attribute vec2 xy;
|
|
108
|
+
|
|
109
|
+
varying highp vec2 uv;
|
|
110
|
+
|
|
111
|
+
void main(void) {
|
|
112
|
+
gl_Position = vec4(xy, 0.0, 1.0);
|
|
113
|
+
// Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).
|
|
114
|
+
// UV coordinates are Y-flipped relative to vertex coordinates.
|
|
115
|
+
uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);
|
|
116
|
+
}
|
|
117
|
+
`;static fragmentShaderSource=`
|
|
118
|
+
varying highp vec2 uv;
|
|
119
|
+
|
|
120
|
+
uniform sampler2D texture;
|
|
121
|
+
|
|
122
|
+
void main(void) {
|
|
123
|
+
gl_FragColor = texture2D(texture, uv);
|
|
124
|
+
}
|
|
125
|
+
`;static get isSupported(){const n=Qf();return!!Uu(n)}#e;constructor(n,r){super(n);const a=Uu(this.canvas,r);if(!a)throw new Error("WebGL not supported");this.#e=a;const u=a.createShader(a.VERTEX_SHADER);if(a.shaderSource(u,ts.vertexShaderSource),a.compileShader(u),!a.getShaderParameter(u,a.COMPILE_STATUS))throw new Error(a.getShaderInfoLog(u));const l=a.createShader(a.FRAGMENT_SHADER);if(a.shaderSource(l,ts.fragmentShaderSource),a.compileShader(l),!a.getShaderParameter(l,a.COMPILE_STATUS))throw new Error(a.getShaderInfoLog(l));const m=a.createProgram();if(a.attachShader(m,u),a.attachShader(m,l),a.linkProgram(m),!a.getProgramParameter(m,a.LINK_STATUS))throw new Error(a.getProgramInfoLog(m));a.useProgram(m);const b=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b),a.bufferData(a.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),a.STATIC_DRAW);const h=a.getAttribLocation(m,"xy");a.vertexAttribPointer(h,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(h);const d=a.createTexture();a.bindTexture(a.TEXTURE_2D,d),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}draw(n){const r=this.#e;return r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.drawArrays(r.TRIANGLE_FAN,0,4),eE}}function Gu(){return typeof window>"u"||!window.VideoDecoder?"browser_unsupported":window.isSecureContext?null:"insecure_context"}const Zf="webcodecs_warning_dismissed";function tE(){return!sessionStorage.getItem(Zf)}function nE(){sessionStorage.setItem(Zf,"true")}const Wu=50,rE=300;function sE({deviceId:s,className:n,onFallback:r,fallbackTimeout:a=2e4,enableControl:u=!1,onTapSuccess:l,onTapError:m,onSwipeSuccess:b,onSwipeError:h,onStreamReady:d,isVisible:p=!0}){const _=x.useRef(null),y=x.useRef(null),w=x.useRef(null),S=x.useRef(null),P=x.useRef(null),N=x.useRef(null),I=x.useRef(null),L=x.useRef(!1),k=x.useRef(!1),B=x.useRef(r),Y=x.useRef(a),T=x.useRef(d),F=x.useRef(p),[z,D]=x.useState("connecting"),[te,U]=x.useState(null),[M,G]=x.useState(null),[H,Z]=x.useState(null),Q=x.useRef(!1),ee=x.useRef(null),ie=x.useRef(!1),ne=x.useRef(0),A=x.useRef(null),$=x.useRef(null),re=x.useRef(null),le=x.useRef(null);x.useEffect(()=>{B.current=r,Y.current=a,T.current=d,F.current=p},[r,a,d,p]),x.useEffect(()=>{(async()=>{try{const me=await qu(s);me.success&&Z({width:me.width,height:me.height})}catch(me){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",me)}})()},[s]);const ve=x.useCallback(()=>{const oe=S.current,me=w.current;if(!oe||!me||!M)return;const Ne=me.clientWidth,ae=me.clientHeight,{width:Ce,height:de}=M,Oe=Ce/de;let st=Ne,ht=Ne/Oe;ht>ae&&(ht=ae,st=ae*Oe),oe.width=Ce,oe.height=de,oe.style.width=`${st}px`,oe.style.height=`${ht}px`},[M]);x.useEffect(()=>{const oe=()=>ve();return window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[ve]),x.useEffect(()=>{ve()},[M,ve]);const xe=x.useCallback(async()=>{if(ts.isSupported){const me=new ts;return{renderer:me,element:me.canvas}}const oe=new Z2;return{renderer:oe,element:oe.canvas}},[]),Ue=x.useCallback(async oe=>{if(!Pu.isSupported){const ae=Gu()||"decoder_unsupported";throw B.current?.(ae),new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.")}const{renderer:me,element:Ne}=await xe();return S.current=Ne,w.current&&!Ne.parentElement&&w.current.appendChild(Ne),new Pu({codec:oe,renderer:me})},[xe]),Le=x.useCallback(()=>{L.current||(L.current=!0,P.current&&(clearTimeout(P.current),P.current=null))},[]),_e=x.useCallback(oe=>{let me=!1,Ne=[];const ae=new TransformStream({transform(de,Oe){if(de.type==="configuration"){Oe.enqueue(de),me=!0,Ne.length>0&&(Ne.forEach(st=>Oe.enqueue(st)),Ne=[]);return}if(de.type==="data"&&!me){Ne.push(de);return}Oe.enqueue(de)}});return new ReadableStream({start(de){let Oe=!1;const st=xt=>{if(!Oe)try{Le();const _t={...xt,data:xt.data instanceof Uint8Array?xt.data:new Uint8Array(xt.data)};de.enqueue(_t)}catch(_t){console.error("[ScrcpyPlayer] Video enqueue error:",_t),Oe=!0,lt()}},ht=xt=>{Oe||(de.error(new Error(xt?.message||"Socket error")),Oe=!0,lt())},wt=()=>{Oe||(de.close(),Oe=!0,lt())},lt=()=>{_.current?.off("video-data",st),_.current?.off("error",ht),_.current?.off("disconnect",wt)};return _.current?.on("video-data",st),_.current?.on("error",ht),_.current?.on("disconnect",wt),()=>{Oe=!0,lt()}}}).pipeThrough(ae)},[Le]),ce=x.useCallback((oe=!1)=>{if(console.log(`[ScrcpyPlayer] [${s}] Disconnecting...`,{suppressReconnect:oe,isVisible:F.current,socketConnected:_.current?.connected}),oe&&(k.current=!0),y.current){try{y.current.dispose()}catch(me){console.error("[ScrcpyPlayer] Failed to dispose decoder:",me)}y.current=null}S.current=null,_.current&&(_.current.disconnect(),_.current=null),T.current?.(null),N.current&&(clearTimeout(N.current),N.current=null),P.current&&(clearTimeout(P.current),P.current=null),D("disconnected"),G(null),U(null)},[s]),K=x.useCallback(()=>{console.log(`[ScrcpyPlayer] [${s}] Connecting...`,{isVisible:F.current,suppressReconnect:k.current}),ce(!0),L.current=!1,D("connecting"),U(null);const oe=ri({path:"/socket.io",transports:["websocket"],timeout:1e4});_.current=oe,oe.on("connect",()=>{console.log(`[ScrcpyPlayer] [${s}] Socket connected, emitting connect-device`),oe.emit("connect-device",{device_id:s,maxSize:1280,bitRate:4e6}),P.current=setTimeout(()=>{L.current||(D("error"),U("Video stream timeout"),k.current=!0,oe.close(),B.current?.())},Y.current)}),oe.on("video-metadata",async me=>{try{y.current&&(y.current.dispose(),y.current=null);const Ne=me?.codec?me.codec:si.H264;y.current=await Ue(Ne),y.current.sizeChanged(({width:Ce,height:de})=>{G({width:Ce,height:de})}),_e(me).pipeTo(y.current.writable).catch(Ce=>{console.error("[ScrcpyPlayer] Video stream error:",Ce)}),D("connected"),T.current?.({close:()=>oe.close()})}catch(Ne){console.error("[ScrcpyPlayer] Decoder initialization failed:",Ne),D("error"),U("Decoder initialization failed"),k.current=!0,oe.close();const ae=Gu()||"decoder_error";B.current?.(ae)}}),oe.on("error",me=>{if(console.error(`[ScrcpyPlayer] [${s}] Socket error:`,me,{suppressReconnect:k.current,isVisible:F.current}),D("error"),U(me?.message||"Socket error"),!k.current){if(!F.current){console.log(`[ScrcpyPlayer] [${s}] Skipping reconnect on error (not visible)`),T.current?.(null);return}T.current?.(null),N.current||(console.log(`[ScrcpyPlayer] [${s}] Scheduling reconnect after error in 3s`),N.current=setTimeout(()=>{N.current=null,I.current?.()},3e3))}}),oe.on("disconnect",()=>{if(console.log(`[ScrcpyPlayer] [${s}] Socket disconnected`,{suppressReconnect:k.current,isVisible:F.current,reconnectTimerActive:!!N.current}),k.current){k.current=!1;return}if(!F.current){console.log(`[ScrcpyPlayer] [${s}] Skipping reconnect (not visible)`),D("disconnected"),T.current?.(null);return}D("disconnected"),T.current?.(null),N.current||(console.log(`[ScrcpyPlayer] [${s}] Scheduling reconnect in 3s`),N.current=setTimeout(()=>{console.log(`[ScrcpyPlayer] [${s}] Reconnecting now`),N.current=null,I.current?.()},3e3))})},[s,ce,Ue,_e]);x.useEffect(()=>{I.current=K},[K]),x.useEffect(()=>(queueMicrotask(()=>{K()}),()=>{$.current&&(clearTimeout($.current),$.current=null),re.current&&(clearTimeout(re.current),re.current=null),ce(!0)}),[K,ce]),x.useEffect(()=>{if(!p&&_.current?.connected)console.log(`[ScrcpyPlayer] [${s}] Component hidden, disconnecting stream`),queueMicrotask(()=>{ce(!0)});else if(p&&z==="disconnected"&&!_.current?.connected){console.log(`[ScrcpyPlayer] [${s}] Component visible again, reconnecting`);const oe=setTimeout(()=>{K()},100);return()=>clearTimeout(oe)}},[p,z,s,ce,K]);const pe=()=>{if(M)return{width:M.width,height:M.height};const oe=S.current;return oe?{width:oe.width,height:oe.height}:null},Se=(oe,me)=>{const Ne=S.current,ae=pe();if(!Ne||!ae)return null;const Ce=Ne.getBoundingClientRect();if(oe<Ce.left||oe>Ce.right||me<Ce.top||me>Ce.bottom)return null;const de=oe-Ce.left,Oe=me-Ce.top,st=Math.round(de/Ce.width*ae.width),ht=Math.round(Oe/Ce.height*ae.height),wt=H?H.width/ae.width:1,lt=H?H.height/ae.height:1;return{x:Math.round(st*wt),y:Math.round(ht*lt)}},He=async oe=>{if(!u||z!=="connected")return;const me=Se(oe.clientX,oe.clientY);if(me){Q.current=!0,ie.current=!1,ee.current={x:oe.clientX,y:oe.clientY};try{await Vv(me.x,me.y,s)}catch(Ne){console.error("[ScrcpyPlayer] Touch down failed:",Ne)}}},ge=oe=>{if(!Q.current||z!=="connected")return;const me=Date.now(),Ne=Se(oe.clientX,oe.clientY);if(Ne){if(ee.current){const ae=oe.clientX-ee.current.x,Ce=oe.clientY-ee.current.y;Math.hypot(ae,Ce)>4&&(ie.current=!0)}if(A.current=Ne,me-ne.current<Wu){$.current||($.current=setTimeout(()=>{$.current=null,A.current&&(fu(A.current.x,A.current.y,s).catch(ae=>{console.error("[ScrcpyPlayer] Touch move failed:",ae)}),A.current=null,ne.current=Date.now())},Wu));return}ne.current=me,fu(Ne.x,Ne.y,s).catch(ae=>{console.error("[ScrcpyPlayer] Touch move failed:",ae)})}},Ie=async oe=>{if(!Q.current||z!=="connected")return;const me=Se(oe.clientX,oe.clientY);if(Q.current=!1,ee.current=null,!!me)try{await du(me.x,me.y,s),ie.current?b?.():l?.()}catch(Ne){const ae=String(Ne);ie.current?h?.(ae):m?.(ae)}},Te=async oe=>{if(!Q.current||z!=="connected")return;const me=Se(oe.clientX,oe.clientY);if(Q.current=!1,ee.current=null,!!me)try{await du(me.x,me.y,s)}catch(Ne){console.error("[ScrcpyPlayer] Touch cancel failed:",Ne)}},Re=oe=>{if(!u||z!=="connected")return;oe.preventDefault();const me=oe.deltaY;le.current||(le.current={deltaY:0}),le.current.deltaY+=me,re.current&&clearTimeout(re.current),re.current=setTimeout(async()=>{const Ne=le.current;if(le.current=null,!Ne)return;const ae=S.current,Ce=pe();if(!ae||!Ce)return;const de=ae.getBoundingClientRect(),Oe=de.left+de.width/2,st=de.top+de.height/2,ht=Se(Oe,st);if(!ht)return;const wt=Math.max(Math.min(Ne.deltaY,600),-600),lt=st+wt,xt=Se(Oe,lt);if(xt)try{const _t=await Kv(ht.x,ht.y,xt.x,xt.y,300,s);_t.success?b?.():h?.(_t.error||"Scroll failed")}catch(_t){h?.(String(_t))}},rE)};return o.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${n||""}`,children:o.jsx("div",{ref:w,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:He,onMouseMove:ge,onMouseUp:Ie,onMouseLeave:Te,onWheel:Re,children:z!=="connected"&&o.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[z==="connecting"&&"Connecting...",z==="error"&&(te||"Connection error"),z==="disconnected"&&"Disconnected"]})})})}const iE={compact:320,standard:400,wide:480,auto:"auto"};function oE({currentWidth:s,onWidthChange:n}){const r=pn(),a=m=>{n(iE[m])},u=()=>{if(typeof s!="number")return;const m=Math.max(240,s-40);n(m)},l=()=>{if(typeof s!="number")return;const m=Math.min(640,s+40);n(m)};return o.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[typeof s=="number"&&o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"sm",onClick:u,className:"h-7 w-7 p-0 rounded-lg",disabled:s<=240,children:o.jsx(W1,{className:"w-3 h-3"})})}),o.jsx(un,{children:o.jsx("p",{children:r.deviceMonitor?.decreaseWidth||"Decrease width"})})]}),o.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>a("compact"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${s===320?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.compact||"Compact"}),o.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>a("standard"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${s===400?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.standard||"Standard"}),o.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>a("wide"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${s===480?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.wide||"Wide"}),o.jsxs(fe,{variant:"ghost",size:"sm",onClick:()=>a("auto"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${s==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[o.jsx(U1,{className:"w-3 h-3 mr-1"}),r.deviceMonitor?.auto||"Auto"]}),typeof s=="number"&&o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 rounded-lg",disabled:s>=640,children:o.jsx(_a,{className:"w-3 h-3"})})}),o.jsx(un,{children:o.jsx("p",{children:r.deviceMonitor?.increaseWidth||"Increase width"})})]})]})}function aE({onResize:s,onResizeStart:n,onResizeEnd:r,minWidth:a=240,maxWidth:u=640,className:l=""}){const[m,b]=x.useState(!1),h=x.useRef(0),d=x.useRef(0),p=x.useRef(null),_=y=>{if(y.preventDefault(),b(!0),h.current=y.clientX,p.current?.parentElement){const w=p.current.parentElement.getBoundingClientRect();d.current=w.width}n?.()};return x.useEffect(()=>{if(!m)return;const y=S=>{const P=S.clientX-h.current,N=Math.min(u,Math.max(a,d.current+P));s(N-d.current)},w=()=>{b(!1),r?.()};return document.addEventListener("mousemove",y),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",w)}},[m,a,u,s,r]),o.jsx("div",{ref:p,className:`absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary transition-colors group ${m?"bg-primary":""} ${l}`,onMouseDown:_,children:o.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx("div",{className:"w-1 h-8 bg-primary rounded-full"})})})}function lE(s,n){const[r,a]=x.useState(()=>{if(typeof window>"u")return n;try{const l=window.localStorage.getItem(s);return l?JSON.parse(l):n}catch(l){return console.error(`Error loading localStorage key "${s}":`,l),n}});return[r,l=>{try{const m=l instanceof Function?l(r):l;a(m),typeof window<"u"&&window.localStorage.setItem(s,JSON.stringify(m))}catch(m){console.error(`Error setting localStorage key "${s}":`,m)}}]}function eh({deviceId:s,serial:n,connectionType:r,isVisible:a=!0,className:u=""}){const l=pn(),m=r==="remote",[b,h]=x.useState(null),[d,p]=x.useState(!m),[_,y]=x.useState(!1),[w,S]=x.useState(m?"screenshot":"auto"),[P,N]=x.useState(null),[I,L]=x.useState("success"),[k,B]=x.useState(!1),[Y,T]=x.useState(!1),[F,z]=lE("device-monitor-width",320),[D,te]=x.useState(null),[U,M]=x.useState(!1),G=x.useRef(null),H=x.useRef(!1),Z=x.useRef(null),Q=x.useRef(null),ee=(_e,ce=2e3,K="success")=>{Z.current&&clearTimeout(Z.current),L(K),N(_e),Z.current=setTimeout(()=>{N(null)},ce)},ie=()=>{Q.current&&clearTimeout(Q.current),B(!0)},ne=()=>{Q.current=setTimeout(()=>{B(!1)},500)},A=()=>{T(_e=>!_e)},$=_e=>{z(_e)},re=_e=>{if(typeof F!="number")return;const ce=Math.min(640,Math.max(240,F+_e));z(ce)},le=x.useCallback(_e=>{G.current=_e},[]),ve=x.useCallback(_e=>{y(!0),p(!1),te(_e||null),w==="video"&&_e&&tE()&&M(!0)},[w]),xe=_e=>{S(_e)};x.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),Q.current&&clearTimeout(Q.current),G.current&&G.current.close()},[]),x.useEffect(()=>{if(!s||!a||!(w==="screenshot"||w==="auto"&&_))return;const ce=async()=>{if(!H.current){H.current=!0;try{const pe=await qu(s);pe.success&&h(pe)}catch(pe){console.error("Failed to fetch screenshot:",pe)}finally{H.current=!1}}};ce();const K=setInterval(ce,500);return()=>clearInterval(K)},[s,_,w,a]);const Ue=_e=>({insecure_context:l.deviceMonitor?.requireHttpsOrLocalhost||"视频流需要 HTTPS 或 localhost 环境。建议下载桌面应用以获得完整功能。",browser_unsupported:l.deviceMonitor?.browserNotSupported||"当前浏览器不支持 WebCodecs API。请使用最新版 Chrome 或 Edge 浏览器。",decoder_error:l.deviceMonitor?.decoderInitFailed||"视频解码器初始化失败。",decoder_unsupported:l.deviceMonitor?.codecNotSupported||"设备编解码器不支持。"})[_e]||l.deviceMonitor?.unknownError||"未知错误",Le=typeof F=="number"?`${F}px`:"auto";return o.jsxs(gi,{className:`flex-shrink-0 relative min-h-0 overflow-hidden bg-background ${u}`,style:{width:Le,minWidth:typeof F=="number"?void 0:"240px",maxWidth:typeof F=="number"?void 0:"640px"},onMouseEnter:ie,onMouseLeave:ne,children:[typeof F=="number"&&o.jsx(aE,{onResize:re,minWidth:240,maxWidth:640,className:"z-20"}),o.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${k?"opacity-100":"opacity-0 pointer-events-none"}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsxs("div",{className:`flex flex-col items-end gap-2 transition-all duration-300 ${Y?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[o.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[!m&&o.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>xe("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${w==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:l.devicePanel?.auto||"Auto"}),!m&&o.jsxs(fe,{variant:"ghost",size:"sm",onClick:()=>xe("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${w==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[o.jsx(tb,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),o.jsxs(fe,{variant:"ghost",size:"sm",onClick:()=>xe("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${w==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[o.jsx(xu,{className:"w-3 h-3 mr-1"}),l.devicePanel?.image||"Image"]})]}),o.jsx(oE,{currentWidth:F,onWidthChange:$})]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:A,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:Y?"Hide controls":"Show controls",children:Y?o.jsx(va,{className:"w-4 h-4"}):o.jsx(rd,{className:"w-4 h-4"})})]})}),o.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:o.jsxs(Vn,{variant:"secondary",className:"bg-white/90 text-slate-700 border border-slate-200 dark:bg-slate-900/90 dark:text-slate-300 dark:border-slate-700",children:[w==="auto"&&(l.devicePanel?.auto||"Auto"),w==="video"&&o.jsxs(o.Fragment,{children:[o.jsx(H1,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),w==="screenshot"&&o.jsxs(o.Fragment,{children:[o.jsx(xu,{className:"w-3 h-3 mr-1"}),l.devicePanel?.imageRefresh||"Screenshot"]})]})}),P&&o.jsxs("div",{className:"absolute bottom-4 right-4 z-20 flex items-center gap-2 px-3 py-2 bg-[#1d9bf0] text-white text-sm rounded-xl shadow-lg",children:[I==="error"&&o.jsx(dn,{className:"w-4 h-4"}),I==="tap"&&o.jsx(A1,{className:"w-4 h-4"}),I==="swipe"&&o.jsx(b1,{className:"w-4 h-4"}),I==="success"&&o.jsx(ns,{className:"w-4 h-4"}),o.jsx("span",{children:P})]}),w==="video"||w==="auto"&&d&&!_?o.jsxs(o.Fragment,{children:[U&&D&&o.jsx("div",{className:"absolute top-0 left-0 right-0 z-20 bg-amber-50/95 dark:bg-amber-950/95 border-b border-amber-200 dark:border-amber-800 backdrop-blur-sm",children:o.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[o.jsx(dn,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-100",children:l.deviceMonitor?.videoUnavailableWarning||"视频流不可用"}),o.jsx(fe,{variant:"ghost",size:"icon",className:"h-5 w-5 -mr-2 hover:bg-amber-100 dark:hover:bg-amber-900",onClick:()=>{M(!1),nE()},children:o.jsx(_1,{className:"w-3 h-3"})})]}),o.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:Ue(D)}),D==="insecure_context"&&o.jsx(fe,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open("https://github.com/suyiiyii/AutoGLM-GUI/releases","_blank"),children:l.deviceMonitor?.downloadElectron||"下载桌面应用"})]})]})}),o.jsx(sE,{deviceId:s,className:"w-full h-full",enableControl:!0,onFallback:ve,onTapSuccess:()=>ee(l.devicePanel?.tapped||"Tapped",2e3,"tap"),onTapError:_e=>ee((l.devicePanel?.tapError||"Tap error: {error}").replace("{error}",_e),3e3,"error"),onSwipeSuccess:()=>ee(l.devicePanel?.swiped||"Swiped",2e3,"swipe"),onSwipeError:_e=>ee((l.devicePanel?.swipeError||"Swipe error: {error}").replace("{error}",_e),3e3,"error"),onStreamReady:le,fallbackTimeout:2e4,isVisible:a})]}):o.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:b&&b.success?o.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[o.jsx("img",{src:`data:image/png;base64,${b.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:b.width>b.height?"100%":"auto",height:b.width>b.height?"auto":"100%"}}),b.is_sensitive&&o.jsx("div",{className:"absolute top-12 right-2 px-2 py-1 bg-yellow-500 text-white text-xs rounded-lg",children:l.devicePanel?.sensitiveContent||"Sensitive Content"})]}):b?.error?o.jsxs("div",{className:"text-center text-destructive",children:[o.jsx(dn,{className:"w-8 h-8 mx-auto mb-2"}),o.jsx("p",{className:"font-medium",children:l.devicePanel?.screenshotFailed||"Screenshot Failed"}),o.jsx("p",{className:"text-xs mt-1 opacity-60",children:b.error})]}):o.jsxs("div",{className:"text-center text-muted-foreground",children:[o.jsx(At,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),o.jsx("p",{className:"text-sm",children:l.devicePanel?.loading||"Loading..."})]})})]})}function Jr({className:s,children:n,...r}){return o.jsxs(Ky,{"data-slot":"scroll-area",className:Ln("relative",s),...r,children:[o.jsx(Vy,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:n}),o.jsx(cE,{}),o.jsx(Qy,{})]})}function cE({className:s,orientation:n="vertical",...r}){return o.jsx(Jd,{"data-slot":"scroll-area-scrollbar",orientation:n,className:Ln("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",s),...r,children:o.jsx(nf,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function uE(s){const n=new Date(s),a=new Date().getTime()-n.getTime(),u=Math.floor(a/6e4),l=Math.floor(a/36e5),m=Math.floor(a/864e5);return u<1?"Just now":u<60?`${u}m ago`:l<24?`${l}h ago`:m<7?`${m}d ago`:n.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function dE(s){const n=Math.floor(s/1e3),r=Math.floor(n/60),a=n%60;return r===0?`${a}s`:`${r}m ${a}s`}function th({item:s,onSelect:n,onDelete:r}){const a=pn(),u=l=>{l.stopPropagation(),confirm(a.history.deleteConfirm)&&r(s.id)};return o.jsx(gi,{className:"hover:bg-slate-50 dark:hover:bg-slate-800/50 transition-colors cursor-pointer group",onClick:()=>n(s),children:o.jsxs("div",{className:"p-3 space-y-2",children:[o.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2",children:s.task_text}),o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[o.jsx("span",{children:uE(s.start_time)}),o.jsx("span",{children:"•"}),o.jsxs("span",{children:[s.steps," ",s.steps===1?"step":"steps"]}),o.jsx("span",{children:"•"}),o.jsx("span",{children:dE(s.duration_ms)})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Vn,{variant:s.success?"success":"destructive",className:"shrink-0",children:s.success?o.jsxs(o.Fragment,{children:[o.jsx(ns,{className:"w-3 h-3 mr-1"}),a.history.success]}):o.jsxs(o.Fragment,{children:[o.jsx(dn,{className:"w-3 h-3 mr-1"}),a.history.failed]})}),o.jsx(fe,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-red-500 dark:text-slate-500 dark:hover:text-red-400",onClick:u,title:a.history.deleteItem,children:o.jsx(xa,{className:"w-3 h-3"})})]})]})]})})}function fE({deviceId:s,deviceSerial:n,deviceName:r,deviceConnectionType:a,isConfigured:u,isVisible:l=!0}){const m=pn(),[b,h]=x.useState([]),[d,p]=x.useState(""),[_,y]=x.useState(!1),[w,S]=x.useState(!1),[P,N]=x.useState(null),[I,L]=x.useState(!1),[k,B]=x.useState([]),[Y,T]=x.useState([]),[F,z]=x.useState(!1),D=x.useRef(null),te=x.useRef(null),U=x.useRef(null),M=x.useRef(0),G=x.useRef(null),[H,Z]=x.useState(!0),[Q,ee]=x.useState(!1),ie=x.useRef(Mf.throttle(()=>{const K=U.current;if(!K)return;const pe=80,Se=K.scrollHeight-K.scrollTop-K.clientHeight,He=Se<=1;Z(He),Se<=pe&&ee(!1)},100));x.useEffect(()=>{const K=ie.current;return()=>{K.cancel()}},[]),x.useEffect(()=>{I&&(async()=>{try{const pe=await Yu(n,20,0);B(pe.records)}catch(pe){console.error("Failed to load history:",pe),B([])}})()},[I,n]);const ne=K=>{const pe=[],Se=K.messages.find(Te=>Te.role==="user");Se?pe.push({id:`${K.id}-user`,role:"user",content:Se.content||K.task_text,timestamp:new Date(Se.timestamp)}):pe.push({id:`${K.id}-user`,role:"user",content:K.task_text,timestamp:new Date(K.start_time)});const He=[],ge=[];K.messages.filter(Te=>Te.role==="assistant").forEach(Te=>{Te.thinking&&He.push(Te.thinking),Te.action&&ge.push(Te.action)});const Ie={id:`${K.id}-agent`,role:"assistant",content:K.final_message,timestamp:K.end_time?new Date(K.end_time):new Date(K.start_time),steps:K.steps,success:K.success,thinking:He,actions:ge,isStreaming:!1};pe.push(Ie),h(pe),M.current=pe.length,G.current=[Ie.id,Ie.content?.length??0,Ie.currentThinking?.length??0,Ie.thinking?JSON.stringify(Ie.thinking).length:0,Ie.steps??"",Ie.isStreaming?1:0].join("|"),ee(!1),Z(!0),L(!1)},A=async()=>{if(confirm(m.history.clearAllConfirm))try{await Vu(n),B([])}catch(K){console.error("Failed to clear history:",K)}},$=async K=>{try{await Qu(n,K),B(pe=>pe.filter(Se=>Se.id!==K))}catch(pe){console.error("Failed to delete history item:",pe)}},re=x.useCallback(async()=>{const K=d.trim();if(!K||_)return;const pe={id:Date.now().toString(),role:"user",content:K,timestamp:new Date};h(ae=>[...ae,pe]),p(""),y(!0),N(null);const Se=[],He=[];let ge="";const Ie=[];let Te=null;const Re=(Date.now()+1).toString(),oe={id:Re,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};h(ae=>[...ae,oe]);const me=()=>{if(Ie.length>0){const ae=Ie.join("");Ie.length=0,ge+=ae,h(Ce=>Ce.map(de=>de.id===Re?{...de,currentThinking:ge}:de))}Te=null},Ne=Qv(pe.content,s,ae=>{Ie.push(ae.chunk),Te===null&&(Te=setTimeout(me,50))},ae=>{Te!==null&&(clearTimeout(Te),me());const Ce=ae.thinking&&ae.thinking.length>0?ae.thinking:ge;Ce&&Se.push(Ce),ge="",He.push(ae.action),h(de=>de.map(Oe=>Oe.id===Re?{...Oe,thinking:[...Se],actions:[...He],steps:ae.step,currentThinking:""}:Oe))},ae=>{Te!==null&&clearTimeout(Te);const Ce={...oe,content:ae.message,success:ae.success,isStreaming:!1,steps:ae.steps,thinking:[...Se],actions:[...He],timestamp:new Date,currentThinking:void 0};h(de=>de.map(Oe=>Oe.id===Re?Ce:Oe)),y(!1),D.current=null},ae=>{Te!==null&&clearTimeout(Te);const Ce={...oe,content:`Error: ${ae.message}`,success:!1,isStreaming:!1,thinking:[...Se],actions:[...He],timestamp:new Date,currentThinking:void 0};h(de=>de.map(Oe=>Oe.id===Re?Ce:Oe)),y(!1),N(ae.message),D.current=null},ae=>{Te!==null&&clearTimeout(Te);const Ce={...oe,content:ae.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...Se],actions:[...He],timestamp:new Date,currentThinking:void 0};h(de=>de.map(Oe=>Oe.id===Re?Ce:Oe)),y(!1),D.current=null});D.current=Ne},[d,_,s]),le=x.useCallback(async()=>{D.current&&D.current.close(),h([]),y(!1),N(null),ee(!1),Z(!0),D.current=null,M.current=0,G.current=null,await Jv(s)},[s]),ve=x.useCallback(async()=>{if(D.current){S(!0);try{D.current&&(D.current.close(),D.current=null),h(K=>{const pe=K[K.length-1];return pe&&pe.role==="assistant"&&pe.isStreaming?K.map((Se,He)=>He===K.length-1?{...Se,content:Se.content||m.chat.aborted,isStreaming:!1,success:!1,currentThinking:void 0}:Se):K}),Zv(s).catch(K=>console.error("Backend abort failed:",K))}catch(K){console.error("Failed to abort chat:",K)}finally{y(!1),S(!1)}}},[s,m]),xe=x.useCallback(()=>{te.current?.scrollIntoView({behavior:"smooth"})},[]);x.useEffect(()=>{const K=b[b.length-1],pe=K?.thinking?JSON.stringify(K.thinking).length:0,Se=K?[K.id,K.content?.length??0,K.currentThinking?.length??0,pe,K.steps??"",K.isStreaming?1:0].join("|"):null,He=b.length>M.current,ge=Se!==G.current&&b.length>0;if(M.current=b.length,G.current=Se,H){xe(),ee(!1);return}if(b.length===0){ee(!1);return}(He||ge)&&ee(!0)},[b,H,xe]),x.useEffect(()=>()=>{D.current&&D.current.close()},[s]),x.useEffect(()=>{(async()=>{try{const pe=await Ku();T(pe.workflows)}catch(pe){console.error("Failed to load workflows:",pe)}})()},[]);const Ue=K=>{p(K.text),z(!1)},Le=()=>{ie.current()},_e=()=>{xe(),ee(!1),Z(!0)},ce=K=>{(K.metaKey||K.ctrlKey)&&K.key==="Enter"&&(K.preventDefault(),re())};return o.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[o.jsxs(gi,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:o.jsx(qr,{className:"h-5 w-5 text-[#1d9bf0]"})}),o.jsxs("div",{className:"group",children:[o.jsx("div",{className:"flex items-center gap-1",children:o.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:r})}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:s})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ai,{open:I,onOpenChange:L,children:[o.jsx(li,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:m.history.title,children:o.jsx(oi,{className:"h-4 w-4"})})}),o.jsxs(ci,{className:"w-96 p-0",align:"end",sideOffset:8,children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:m.history.title}),k.length>0&&o.jsx(fe,{variant:"ghost",size:"sm",onClick:A,className:"h-7 text-xs",children:m.history.clearAll})]}),o.jsx(Jr,{className:"h-[400px]",children:o.jsx("div",{className:"p-4 space-y-2",children:k.length>0?k.map(K=>o.jsx(th,{item:K,onSelect:ne,onDelete:$},K.id)):o.jsxs("div",{className:"text-center py-8",children:[o.jsx(oi,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),o.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:m.history.noHistory}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:m.history.noHistoryDescription})]})})})]})]}),!u&&o.jsxs(Vn,{variant:"warning",children:[o.jsx(dn,{className:"w-3 h-3 mr-1"}),m.devicePanel.noConfig]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:le,className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:"Reset chat",children:o.jsx(id,{className:"h-4 w-4"})})]})]}),P&&o.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[o.jsx(dn,{className:"w-4 h-4 flex-shrink-0"}),P]}),o.jsxs("div",{className:"flex-1 min-h-0 relative",children:[o.jsxs("div",{className:"h-full overflow-y-auto p-4",ref:U,onScroll:Le,children:[b.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:o.jsx(qr,{className:"h-8 w-8 text-slate-400"})}),o.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:m.devicePanel.readyToHelp}),o.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:m.devicePanel.describeTask})]}):b.map(K=>o.jsx("div",{className:`flex ${K.role==="user"?"justify-end":"justify-start"}`,children:K.role==="assistant"?o.jsxs("div",{className:"max-w-[85%] space-y-3",children:[K.thinking?.map((pe,Se)=>o.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:o.jsx(qr,{className:"h-3 w-3 text-[#1d9bf0]"})}),o.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",Se+1]})]}),o.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:pe}),K.actions?.[Se]&&o.jsxs("details",{className:"mt-2 text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),o.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(K.actions[Se],null,2)})]})]},Se)),K.currentThinking&&o.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:o.jsx(qr,{className:"h-3 w-3 text-[#1d9bf0] animate-pulse"})}),o.jsx("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Thinking..."})]}),o.jsxs("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:[K.currentThinking,o.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),K.content&&o.jsxs("div",{className:`
|
|
126
|
+
rounded-2xl px-4 py-3 flex items-start gap-2
|
|
127
|
+
${K.success===!1?"bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300"}
|
|
128
|
+
`,children:[o.jsx(ns,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${K.success===!1?"text-red-500":"text-green-500"}`}),o.jsxs("div",{children:[o.jsx("p",{className:"whitespace-pre-wrap",children:K.content}),K.steps!==void 0&&o.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[K.steps," steps completed"]})]})]}),K.isStreaming&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[o.jsx(At,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):o.jsxs("div",{className:"max-w-[75%]",children:[o.jsx("div",{className:"chat-bubble-user px-4 py-3",children:o.jsx("p",{className:"whitespace-pre-wrap",children:K.content})}),o.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:K.timestamp.toLocaleTimeString()})]})},K.id)),o.jsx("div",{ref:te})]}),Q&&o.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:o.jsx(fe,{onClick:_e,size:"sm",className:"pointer-events-auto shadow-lg bg-[#1d9bf0] text-white hover:bg-[#1a8cd8]","aria-label":m.devicePanel.newMessages,children:m.devicePanel.newMessages})})]}),o.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsx(td,{value:d,onChange:K=>p(K.target.value),onKeyDown:ce,placeholder:u?m.devicePanel.whatToDo:m.devicePanel.configureFirst,disabled:_,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsxs(ai,{open:F,onOpenChange:z,children:[o.jsx(li,{asChild:!0,children:o.jsx(fe,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:o.jsx(Xu,{className:"w-4 h-4"})})}),o.jsx(ci,{align:"start",className:"w-72 p-3",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"font-medium text-sm",children:m.workflows.selectWorkflow}),Y.length===0?o.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[o.jsx("p",{children:m.workflows.empty}),o.jsxs("p",{children:["前往"," ",o.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):o.jsx(Jr,{className:"h-64",children:o.jsx("div",{className:"space-y-1",children:Y.map(K=>o.jsxs("button",{onClick:()=>Ue(K),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[o.jsx("div",{className:"font-medium text-sm",children:K.name}),o.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:K.text})]},K.uuid))})})]})})]})}),o.jsx(un,{side:"top",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:m.devicePanel.tooltips.workflowButton}),o.jsx("p",{className:"text-xs opacity-80",children:m.devicePanel.tooltips.workflowButtonDesc})]})})]}),_&&o.jsx(fe,{onClick:ve,disabled:w,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:m.chat.abortChat,children:w?o.jsx(At,{className:"h-4 w-4 animate-spin"}):o.jsx(ld,{className:"h-4 w-4"})}),!_&&o.jsx(fe,{onClick:re,disabled:!d.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:o.jsx(od,{className:"h-4 w-4"})})]})})]}),o.jsx(eh,{deviceId:s,serial:n,connectionType:a,isVisible:l})]})}function hE({deviceId:s,deviceSerial:n,deviceName:r,deviceConnectionType:a,isVisible:u}){const l=pn(),[m,b]=x.useState([]),[h,d]=x.useState(""),[p,_]=x.useState(!1),[y,w]=x.useState(!1),[S,P]=x.useState(null),N=x.useRef(null),I=x.useRef(null),L=x.useRef(null),[k,B]=x.useState([]),[Y,T]=x.useState(!1),[F,z]=x.useState([]),[D,te]=x.useState(!1);x.useEffect(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[m]),x.useEffect(()=>()=>{I.current&&I.current.close()},[]),x.useEffect(()=>{(async()=>{try{const $=await Ku();B($.workflows)}catch($){console.error("Failed to load workflows:",$)}})()},[]),x.useEffect(()=>{D&&(async()=>{try{const $=await Yu(n,20,0);z($.records)}catch($){console.error("Failed to load history:",$),z([])}})()},[D,n]);const U=A=>{d(A.text),T(!1)},M=A=>{const $={id:`${A.id}-user`,role:"user",content:A.task_text,timestamp:new Date(A.start_time)},re={id:`${A.id}-agent`,role:"assistant",content:A.final_message,timestamp:A.end_time?new Date(A.end_time):new Date(A.start_time),steps:[],success:A.success,isStreaming:!1};b([$,re]),te(!1)},G=async()=>{if(confirm(l.history?.clearAllConfirm||"Clear all history?"))try{await Vu(n),z([])}catch(A){console.error("Failed to clear history:",A)}},H=async A=>{try{await Qu(n,A),z($=>$.filter(re=>re.id!==A))}catch($){console.error("Failed to delete history item:",$)}},Z=(A,$)=>{b(re=>re.map(le=>le.id===A?{...le,steps:le.steps?.map(ve=>ve.id===$?{...ve,isExpanded:!ve.isExpanded}:ve)}:le))},Q=x.useCallback(async()=>{const A=h.trim();if(!A||p)return;const $={id:Date.now().toString(),role:"user",content:A,timestamp:new Date};b(xe=>[...xe,$]),d(""),_(!0),P(null);const re=(Date.now()+1).toString(),le={id:re,role:"assistant",content:"",timestamp:new Date,steps:[],isStreaming:!0};b(xe=>[...xe,le]);const ve=new AbortController;L.current=ve;try{const xe=await fetch("/api/layered-agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:A,device_id:s,session_id:s}),signal:ve.signal});if(!xe.ok){let K=`HTTP error! status: ${xe.status}`;try{const pe=await xe.json();pe.detail&&(K=pe.detail)}catch{}throw new Error(K)}const Ue=xe.body?.getReader();if(!Ue)throw new Error("No response body");const Le=new TextDecoder;let _e="";const ce=[];for(;;){const{done:K,value:pe}=await Ue.read();if(K)break;_e+=Le.decode(pe,{stream:!0});const Se=_e.split(`
|
|
129
|
+
`);_e=Se.pop()||"";for(const He of Se)if(He.startsWith("data: "))try{const ge=JSON.parse(He.slice(6));if(ge.type==="tool_call"){const Ie={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:ge.tool_name==="chat"?"发送指令给 Phone Agent":ge.tool_name==="list_devices"?"获取设备列表":`调用工具: ${ge.tool_name}`,toolName:ge.tool_name,toolArgs:ge.tool_args||{},timestamp:new Date,isExpanded:!0};ce.push(Ie),b(Te=>Te.map(Re=>Re.id===re?{...Re,steps:[...ce]}:Re))}else if(ge.type==="tool_result"){const Ie={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:ge.tool_name==="chat"?"Phone Agent 执行结果":`${ge.tool_name} 结果`,toolResult:ge.result,timestamp:new Date,isExpanded:!0};ce.push(Ie),b(Te=>Te.map(Re=>Re.id===re?{...Re,steps:[...ce]}:Re))}else if(ge.type==="message")b(Ie=>Ie.map(Te=>Te.id===re?{...Te,content:ge.content}:Te));else if(ge.type==="done"){const Ie={...le,content:ge.content||"",isStreaming:!1,success:ge.success,steps:[...ce],timestamp:new Date};b(Te=>Te.map(Re=>Re.id===re?Ie:Re))}else if(ge.type==="error"){const Ie={...le,content:`错误: ${ge.message}`,isStreaming:!1,success:!1,steps:[...ce],timestamp:new Date};b(Te=>Te.map(Re=>Re.id===re?Ie:Re)),P(ge.message)}}catch(ge){console.error("Failed to parse SSE data:",ge,He)}}b(K=>K.map(pe=>pe.id===re&&pe.isStreaming?{...pe,isStreaming:!1,success:!0}:pe))}catch(xe){if(xe instanceof Error&&xe.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",xe);const Ue=Ju(xe);P(Ue),b(Le=>Le.map(_e=>_e.id===re?{..._e,content:`错误: ${Ue}`,isStreaming:!1,success:!1}:_e))}finally{_(!1),L.current=null}},[h,p,s]),ee=x.useCallback(()=>{if(L.current){w(!0);try{L.current.abort(),L.current=null,b(A=>{const $=A[A.length-1];return $&&$.role==="assistant"&&$.isStreaming?A.map((re,le)=>le===A.length-1?{...re,content:re.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:re):A}),e1(async()=>{const{abortLayeredAgentChat:A}=await import("./index-DUNWZsFq.js").then($=>$.ay);return{abortLayeredAgentChat:A}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:A})=>{A(s).catch($=>console.error("Backend abort failed:",$))})}catch(A){console.error("Failed to abort chat:",A)}finally{_(!1),w(!1)}}},[l,s]),ie=x.useCallback(async()=>{L.current&&(L.current.abort(),L.current=null),b([]),P(null),I.current&&(I.current.close(),I.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:s})})}catch(A){console.warn("Failed to reset backend session:",A)}},[s]),ne=A=>{(A.metaKey||A.ctrlKey)&&A.key==="Enter"&&(A.preventDefault(),Q())};return o.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[o.jsxs(gi,{className:"flex-1 flex flex-col min-h-0 max-w-2xl overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-purple-500/10",children:o.jsx(ra,{className:"h-5 w-5 text-purple-500"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"AI Agent"}),o.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[r," • ",l.chatkit?.layeredAgent||"分层代理模式"]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Vn,{variant:"secondary",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",children:l.chatkit?.layeredAgent||"分层代理模式"}),o.jsxs(ai,{open:D,onOpenChange:te,children:[o.jsx(li,{asChild:!0,children:o.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:l.history?.title||"History",children:o.jsx(oi,{className:"h-4 w-4"})})}),o.jsxs(ci,{className:"w-96 p-0",align:"end",sideOffset:8,children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[o.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history?.title||"History"}),F.length>0&&o.jsx(fe,{variant:"ghost",size:"sm",onClick:G,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),o.jsx(Jr,{className:"h-[400px]",children:o.jsx("div",{className:"p-4 space-y-2",children:F.length>0?F.map(A=>o.jsx(th,{item:A,onSelect:M,onDelete:H},A.id)):o.jsxs("div",{className:"text-center py-8",children:[o.jsx(oi,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),o.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history?.noHistory||"No history yet"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history?.noHistoryDescription||"Your completed tasks will appear here"})]})})})]})]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:ie,className:"h-8 w-8 rounded-full",title:"重置对话",children:o.jsx(id,{className:"h-4 w-4"})})]})]}),S&&o.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[o.jsx(dn,{className:"w-4 h-4 flex-shrink-0"}),S]}),o.jsx(Jr,{className:"flex-1 min-h-0",children:o.jsxs("div",{className:"p-4 space-y-4",children:[m.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-12",children:[o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-purple-100 dark:bg-purple-900/30 mb-4",children:o.jsx(ra,{className:"h-8 w-8 text-purple-500"})}),o.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"分层代理模式"}),o.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400 max-w-xs",children:l.chatkit?.layeredAgentDesc||"决策模型负责规划任务,视觉模型负责执行。你可以看到每一步的执行过程。"})]}):m.map(A=>o.jsx("div",{className:"space-y-2",children:A.role==="user"?o.jsx("div",{className:"flex justify-end",children:o.jsxs("div",{className:"max-w-[80%]",children:[o.jsx("div",{className:"bg-purple-600 text-white px-4 py-2 rounded-2xl rounded-br-sm",children:o.jsx("p",{className:"whitespace-pre-wrap",children:A.content})}),o.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:A.timestamp.toLocaleTimeString()})]})}):o.jsxs("div",{className:"space-y-3",children:[A.steps&&A.steps.length>0&&o.jsx("div",{className:"space-y-2",children:A.steps.map(($,re)=>o.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[o.jsxs("button",{onClick:()=>Z(A.id,$.id),className:"w-full flex items-center justify-between p-3 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium ${$.type==="tool_call"?"bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"bg-green-100 text-green-600 dark:bg-green-900/30 dark:text-green-400"}`,children:$.type==="tool_call"?o.jsx(ob,{className:"w-3 h-3"}):o.jsx(t1,{className:"w-3 h-3"})}),o.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",re+1,": ",$.content]})]}),$.isExpanded?o.jsx(S1,{className:"w-4 h-4 text-slate-400"}):o.jsx(ed,{className:"w-4 h-4 text-slate-400"})]}),$.isExpanded&&o.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[$.type==="tool_call"&&$.toolArgs&&o.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[o.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:$.toolName==="chat"?"发送给 Phone Agent 的指令:":"工具参数:"}),$.toolName==="chat"?o.jsx("p",{className:"text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:$.toolArgs.message||JSON.stringify($.toolArgs,null,2)}):o.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto",children:JSON.stringify($.toolArgs,null,2)})]}),$.type==="tool_result"&&$.toolResult&&o.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[o.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:"执行结果:"}),o.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto whitespace-pre-wrap",children:typeof $.toolResult=="string"?$.toolResult:JSON.stringify($.toolResult,null,2)})]})]})]},$.id))}),A.content&&o.jsx("div",{className:"flex justify-start",children:o.jsx("div",{className:`max-w-[85%] rounded-2xl rounded-tl-sm px-4 py-3 ${A.success===!1?"bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300"}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[A.success!==void 0&&o.jsx(ns,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${A.success?"text-green-500":"text-red-500"}`}),o.jsx("p",{className:"whitespace-pre-wrap",children:A.content})]})})}),A.isStreaming&&!A.content&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[o.jsx(At,{className:"w-4 h-4 animate-spin"}),"正在思考和执行..."]})]})},A.id)),o.jsx("div",{ref:N})]})}),o.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsx(td,{value:h,onChange:A=>d(A.target.value),onKeyDown:ne,placeholder:"描述你想要完成的任务... (Cmd+Enter 发送)",disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsxs(ai,{open:Y,onOpenChange:T,children:[o.jsx(li,{asChild:!0,children:o.jsx(fe,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:o.jsx(Xu,{className:"w-4 h-4"})})}),o.jsx(ci,{align:"start",className:"w-72 p-3",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"font-medium text-sm",children:l.workflows?.selectWorkflow||"Select Workflow"}),k.length===0?o.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[o.jsx("p",{children:l.workflows?.empty||"No workflows yet"}),o.jsxs("p",{children:["前往"," ",o.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):o.jsx(Jr,{className:"h-64",children:o.jsx("div",{className:"space-y-1",children:k.map(A=>o.jsxs("button",{onClick:()=>U(A),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[o.jsx("div",{className:"font-medium text-sm",children:A.name}),o.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:A.text})]},A.uuid))})})]})})]})}),o.jsx(un,{side:"top",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:l.devicePanel?.tooltips?.workflowButton||"Quick Workflow"}),o.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel?.tooltips?.workflowButtonDesc||"Select a workflow to quickly fill in the task"})]})})]}),p&&o.jsx(fe,{onClick:ee,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat?.abortChat||"中断任务",children:y?o.jsx(At,{className:"h-4 w-4 animate-spin"}):o.jsx(ld,{className:"h-4 w-4"})}),!p&&o.jsx(fe,{onClick:Q,disabled:!h.trim(),size:"icon",className:"h-10 w-10 rounded-full flex-shrink-0 bg-purple-600 hover:bg-purple-700",children:o.jsx(od,{className:"h-4 w-4"})})]})})]}),o.jsx(eh,{deviceId:s,serial:n,connectionType:a,isVisible:u})]})}function pE({isOpen:s,onClose:n,onGroupsChanged:r,showToast:a}){const u=pn(),[l,m]=x.useState([]),[b,h]=x.useState(!1),[d,p]=x.useState(null),[_,y]=x.useState(!1),[w,S]=x.useState(""),[P,N]=x.useState(!1),[I,L]=x.useState(null),[k,B]=x.useState(""),[Y,T]=x.useState(!1),[F,z]=x.useState(null),[D,te]=x.useState(!1),[U,M]=x.useState(null),G=x.useCallback(async()=>{h(!0),p(null);try{const A=await $u();m(A.groups.sort(($,re)=>$.order-re.order))}catch(A){console.error("Failed to fetch groups:",A),p(u.deviceGroups?.fetchError||"获取分组失败")}finally{h(!1)}},[u.deviceGroups?.fetchError]);x.useEffect(()=>{s&&G()},[s,G]);const H=async()=>{if(w.trim()){N(!0);try{await r1(w.trim()),y(!1),S(""),await G(),r&&r(),a&&a(u.deviceGroups?.createSuccess||"分组创建成功","success")}catch(A){console.error("Failed to create group:",A),a&&a(u.deviceGroups?.createError||"创建分组失败","error")}finally{N(!1)}}},Z=async()=>{if(!(!I||!k.trim())){T(!0);try{await s1(I.id,k.trim()),L(null),B(""),await G(),r&&r(),a&&a(u.deviceGroups?.updateSuccess||"分组更新成功","success")}catch(A){console.error("Failed to update group:",A),a&&a(u.deviceGroups?.updateError||"更新分组失败","error")}finally{T(!1)}}},Q=async()=>{if(F){te(!0);try{const A=await i1(F.id);A.success?(z(null),await G(),r&&r(),a&&a(u.deviceGroups?.deleteSuccess||"分组删除成功","success")):a&&a(A.message||u.deviceGroups?.deleteError||"删除分组失败","error")}catch(A){console.error("Failed to delete group:",A),a&&a(u.deviceGroups?.deleteError||"删除分组失败","error")}finally{te(!1)}}},ee=A=>{M(A)},ie=(A,$)=>{if(A.preventDefault(),!U||U===$)return;const re=[...l],le=re.findIndex(Ue=>Ue.id===U),ve=re.findIndex(Ue=>Ue.id===$);if(le===-1||ve===-1)return;const[xe]=re.splice(le,1);re.splice(ve,0,xe),m(re)},ne=async()=>{if(!U)return;const A=l.map($=>$.id);try{await n1(A),r&&r()}catch($){console.error("Failed to reorder groups:",$),await G(),a&&a(u.deviceGroups?.reorderError||"调整顺序失败","error")}finally{M(null)}};return o.jsxs(o.Fragment,{children:[o.jsx(xr,{open:s,onOpenChange:A=>!A&&n(),children:o.jsxs(_r,{className:"sm:max-w-md max-h-[80vh] overflow-hidden flex flex-col",children:[o.jsxs(vr,{children:[o.jsx(br,{children:u.deviceGroups?.manageTitle||"管理设备分组"}),o.jsx(yr,{children:u.deviceGroups?.manageDescription||"创建、编辑、删除和排序设备分组。拖拽分组可调整顺序。"})]}),o.jsx("div",{className:"flex-1 overflow-y-auto py-4",children:b?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(At,{className:"h-6 w-6 animate-spin text-slate-400"})}):d?o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.jsx(dn,{className:"h-8 w-8 text-red-500 mb-2"}),o.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:d}),o.jsx(fe,{variant:"outline",size:"sm",onClick:G,className:"mt-2",children:u.common?.retry||"重试"})]}):o.jsxs("div",{className:"space-y-2",children:[l.map(A=>o.jsxs("div",{draggable:!A.is_default,onDragStart:()=>ee(A.id),onDragOver:$=>ie($,A.id),onDragEnd:ne,className:`
|
|
130
|
+
flex items-center gap-2 p-3 rounded-lg border
|
|
131
|
+
${U===A.id?"border-[#1d9bf0] bg-blue-50 dark:bg-blue-950/20":"border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800"}
|
|
132
|
+
${A.is_default?"opacity-80":"cursor-move"}
|
|
133
|
+
transition-colors
|
|
134
|
+
`,children:[!A.is_default&&o.jsx(sd,{className:"w-4 h-4 text-slate-400 flex-shrink-0 cursor-grab"}),A.is_default&&o.jsx("div",{className:"w-4"}),o.jsx(na,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 truncate block",children:A.name}),o.jsxs("span",{className:"text-xs text-slate-400 dark:text-slate-500",children:[A.device_count," ",u.deviceGroups?.deviceCount||"台设备",A.is_default&&o.jsxs("span",{className:"ml-2 text-slate-400",children:["(",u.deviceGroups?.defaultGroup||"默认",")"]})]})]}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx(fe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-[#1d9bf0]",onClick:()=>{L(A),B(A.name)},children:o.jsx(Zu,{className:"w-3.5 h-3.5"})}),!A.is_default&&o.jsx(fe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400 hover:text-red-500",onClick:()=>z(A),children:o.jsx(xa,{className:"w-3.5 h-3.5"})})]})]},A.id)),o.jsxs(fe,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>y(!0),children:[o.jsx(_a,{className:"w-4 h-4"}),u.deviceGroups?.createNew||"新建分组"]})]})}),o.jsx(wr,{children:o.jsx(fe,{variant:"outline",onClick:n,children:u.common?.close||"关闭"})})]})}),o.jsx(xr,{open:_,onOpenChange:y,children:o.jsxs(_r,{className:"sm:max-w-sm",children:[o.jsxs(vr,{children:[o.jsx(br,{children:u.deviceGroups?.createTitle||"新建分组"}),o.jsx(yr,{children:u.deviceGroups?.createDescription||"为设备创建一个新的分组。"})]}),o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"new-group-name",children:u.deviceGroups?.groupNameLabel||"分组名称"}),o.jsx(dt,{id:"new-group-name",value:w,onChange:A=>S(A.target.value),placeholder:u.deviceGroups?.groupNamePlaceholder||"请输入分组名称",maxLength:50,onKeyDown:A=>{A.key==="Enter"&&!P&&H()}})]})}),o.jsxs(wr,{children:[o.jsx(fe,{variant:"outline",onClick:()=>y(!1),disabled:P,children:u.common?.cancel||"取消"}),o.jsx(fe,{onClick:H,disabled:!w.trim()||P,children:P?o.jsxs(o.Fragment,{children:[o.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),u.common?.loading||"加载中..."]}):u.common?.create||"创建"})]})]})}),o.jsx(xr,{open:!!I,onOpenChange:A=>!A&&L(null),children:o.jsxs(_r,{className:"sm:max-w-sm",children:[o.jsxs(vr,{children:[o.jsx(br,{children:u.deviceGroups?.editTitle||"编辑分组"}),o.jsx(yr,{children:u.deviceGroups?.editDescription||"修改分组名称。"})]}),o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"edit-group-name",children:u.deviceGroups?.groupNameLabel||"分组名称"}),o.jsx(dt,{id:"edit-group-name",value:k,onChange:A=>B(A.target.value),placeholder:u.deviceGroups?.groupNamePlaceholder||"请输入分组名称",maxLength:50,onKeyDown:A=>{A.key==="Enter"&&!Y&&Z()}})]})}),o.jsxs(wr,{children:[o.jsx(fe,{variant:"outline",onClick:()=>L(null),disabled:Y,children:u.common?.cancel||"取消"}),o.jsx(fe,{onClick:Z,disabled:!k.trim()||Y,children:Y?o.jsxs(o.Fragment,{children:[o.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),u.common?.loading||"加载中..."]}):u.common?.save||"保存"})]})]})}),o.jsx(ia,{isOpen:!!F,title:u.deviceGroups?.deleteTitle||"删除分组",content:u.deviceGroups?.deleteContent?.replace("{name}",F?.name||"")||`确定要删除分组 "${F?.name}" 吗?该分组内的设备将被移回默认分组。`,onConfirm:Q,onCancel:()=>z(null),confirmText:D?u.common?.loading||"加载中...":u.common?.delete||"删除",confirmVariant:"destructive",disabled:D})]})}function mE({message:s,type:n="info",onClose:r,duration:a=3e3}){x.useEffect(()=>{const m=setTimeout(()=>{r()},a);return()=>clearTimeout(m)},[a,r]);const u={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500",warning:"bg-amber-500"},l={success:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:o.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})};return o.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:o.jsxs("div",{className:`${u[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[l[n],o.jsx("span",{className:"font-medium",children:s}),o.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:o.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const $r=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{base_url:"https://api-inference.modelscope.cn/v1",model_name:"ZhipuAI/AutoGLM-Phone-9B"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b"}}],gE=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:R1,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:nd,defaultConfig:{history_n:3}}],xE=[{name:"bigmodel",config:{decision_base_url:"https://open.bigmodel.cn/api/paas/v4",decision_model_name:"glm-4.7"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{decision_base_url:"https://api-inference.modelscope.cn/v1",decision_model_name:"Qwen/Qwen3-235B-A22B-Instruct-2507"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{decision_base_url:"",decision_model_name:""}}];function kE(){const s=pn(),n=o1.useSearch(),r=a1(),[a,u]=x.useState([]),[l,m]=x.useState(""),[b,h]=x.useState(n.mode||"classic"),[d,p]=x.useState(!1),[_,y]=x.useState({message:"",type:"info",visible:!1}),w=(M,G="info")=>{y({message:M,type:G,visible:!0})},[S,P]=x.useState(null),[N,I]=x.useState(!1),[L,k]=x.useState(!1),[B,Y]=x.useState(!1),[T,F]=x.useState({base_url:$r[0].config.base_url,model_name:$r[0].config.model_name,api_key:"",agent_type:"glm",agent_config_params:{},default_max_steps:100,layered_max_turns:50,decision_base_url:"",decision_model_name:"",decision_api_key:""});x.useEffect(()=>{(async()=>{try{const G=await c1();P({base_url:G.base_url,model_name:G.model_name,api_key:G.api_key||void 0,agent_type:G.agent_type||"glm",agent_config_params:G.agent_config_params||void 0,default_max_steps:G.default_max_steps||100,layered_max_turns:G.layered_max_turns||50,decision_base_url:G.decision_base_url||void 0,decision_model_name:G.decision_model_name||void 0,decision_api_key:G.decision_api_key||void 0});const H=!G.base_url;F({base_url:H?$r[0].config.base_url:G.base_url,model_name:H?$r[0].config.model_name:G.model_name,api_key:G.api_key||"",agent_type:G.agent_type||"glm",agent_config_params:G.agent_config_params||{},default_max_steps:G.default_max_steps||100,layered_max_turns:G.layered_max_turns||50,decision_base_url:G.decision_base_url||"",decision_model_name:G.decision_model_name||"glm-4.7",decision_api_key:G.decision_api_key||""}),H&&I(!0)}catch(G){console.error("Failed to load config:",G),I(!0)}})()},[]);const z=x.useCallback(async()=>{try{const G=(await l1()).devices.filter(ee=>ee.state!=="disconnected"),H=new Map,Z=new Map;for(const ee of G)if(ee.serial){const ie=Z.get(ee.serial)||[];ie.push(ee),Z.set(ee.serial,ie)}else H.set(ee.id,ee);Array.from(Z.values()).forEach(ee=>{const ne=ee.find(A=>A.connection_type==="wifi")||ee[0];H.set(ne.id,ne)});const Q=Array.from(H.values());if(u(Q),Q.length>0&&!d){const ee=n.serial;if(ee){const ie=Q.find(ne=>ne.serial===ee);m(ie?ie.id:Q[0].id)}else l||m(Q[0].id);p(!0)}l&&!Q.find(ee=>ee.id===l)&&m(Q[0]?.id||"")}catch(M){console.error("Failed to load devices:",M)}},[l,d,n.serial]);x.useEffect(()=>{const M=setTimeout(()=>{z()},0),G=setInterval(z,3e3);return()=>{clearTimeout(M),clearInterval(G)}},[z]),x.useEffect(()=>{const G=a.find(Z=>Z.id===l)?.serial;if(!d)return;(G!==n.serial||b!==n.mode)&&r({to:"/chat",search:{serial:G,mode:b},replace:!0})},[l,b,a,d,r,n.serial,n.mode]);const D=async()=>{if(!T.base_url){w(s.chat.baseUrlRequired,"error");return}try{await u1({base_url:T.base_url,model_name:T.model_name||"autoglm-phone-9b",api_key:T.api_key||void 0,agent_type:T.agent_type,agent_config_params:Object.keys(T.agent_config_params).length>0?T.agent_config_params:void 0,default_max_steps:T.default_max_steps,layered_max_turns:T.layered_max_turns,decision_base_url:T.decision_base_url||void 0,decision_model_name:T.decision_model_name||void 0,decision_api_key:T.decision_api_key||void 0}),P({base_url:T.base_url,model_name:T.model_name,api_key:T.api_key||void 0,agent_type:T.agent_type,agent_config_params:Object.keys(T.agent_config_params).length>0?T.agent_config_params:void 0,default_max_steps:T.default_max_steps,layered_max_turns:T.layered_max_turns,decision_base_url:T.decision_base_url||void 0,decision_model_name:T.decision_model_name||void 0,decision_api_key:T.decision_api_key||void 0}),w(s.toasts.configSaved,"success");try{const M=await d1();if(M.total===0)console.log("No agents to reinitialize");else if(M.success)w(`Configuration applied to ${M.succeeded.length} device(s)`,"success");else{const G=Object.keys(M.failed).length;w(`Configuration partially applied: ${M.succeeded.length}/${M.total} succeeded, ${G} failed`,"warning")}}catch(M){console.error("Failed to reinitialize agents:",M),w("Configuration saved, but failed to update devices. Please reinitialize manually.","warning")}I(!1)}catch(M){console.error("Failed to save config:",M),w(`Failed to save: ${Ju(M)}`,"error")}},te=async M=>{try{const G=await h1({device_id:M});G.success&&G.device_id?(m(G.device_id),w(s.toasts.wifiConnected,"success")):G.success||w(G.message||G.error||s.toasts.connectionFailed,"error")}catch(G){w(s.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",G)}},U=async M=>{try{const G=await f1(M);G.success?w(s.toasts.wifiDisconnected,"success"):w(G.message||G.error||s.toasts.disconnectFailed,"error")}catch(G){w(s.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",G)}};return o.jsxs("div",{className:"h-full flex relative min-h-0",children:[_.visible&&o.jsx(mE,{message:_.message,type:_.type,onClose:()=>y(M=>({...M,visible:!1}))}),o.jsx(xr,{open:N,onOpenChange:I,children:o.jsxs(_r,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[o.jsxs(vr,{className:"flex-shrink-0",children:[o.jsxs(br,{className:"flex items-center gap-2",children:[o.jsx(ad,{className:"w-5 h-5 text-[#1d9bf0]"}),s.chat.configuration]}),o.jsx(yr,{children:s.chat.configureApi})]}),o.jsxs(vf,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[o.jsxs(bf,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[o.jsxs(Vr,{value:"vision",children:[o.jsx(Wo,{className:"w-4 h-4 mr-2"}),s.chat.visionModelTab]}),o.jsxs(Vr,{value:"decision",children:[o.jsx(nd,{className:"w-4 h-4 mr-2"}),s.chat.decisionModelTab]})]}),o.jsxs(Qr,{value:"vision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{className:"text-sm font-medium",children:s.chat.selectPreset}),o.jsx("div",{className:"grid grid-cols-1 gap-2",children:$r.map(M=>o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>F(G=>({...G,base_url:M.config.base_url,model_name:M.config.model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${T.base_url===M.config.base_url&&(M.name!=="custom"||M.name==="custom"&&T.base_url==="")?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(sa,{className:`w-4 h-4 ${T.base_url===M.config.base_url&&(M.name!=="custom"||M.name==="custom"&&T.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:s.presetConfigs[M.name].name})]}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:s.presetConfigs[M.name].description})]}),"apiKeyUrl"in M&&o.jsx("a",{href:M.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:G=>G.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:s.chat.getApiKey||"获取 API Key",children:o.jsx(mu,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},M.name))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(et,{htmlFor:"base_url",children:[s.chat.baseUrl," *"]}),o.jsx(dt,{id:"base_url",value:T.base_url,onChange:M=>F({...T,base_url:M.target.value}),placeholder:"http://localhost:8080/v1"}),!T.base_url&&o.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[o.jsx(dn,{className:"w-3 h-3"}),s.chat.baseUrlRequired]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"api_key",children:s.chat.apiKey}),o.jsxs("div",{className:"relative",children:[o.jsx(dt,{id:"api_key",type:B?"text":"password",value:T.api_key,onChange:M=>F({...T,api_key:M.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),o.jsx(fe,{type:"button",variant:"ghost",size:"icon",onClick:()=>Y(!B),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:B?o.jsx(gu,{className:"w-4 h-4 text-slate-400"}):o.jsx(Wo,{className:"w-4 h-4 text-slate-400"})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"model_name",children:s.chat.modelName}),o.jsx(dt,{id:"model_name",value:T.model_name,onChange:M=>F({...T,model_name:M.target.value}),placeholder:"autoglm-phone-9b"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{className:"text-sm font-medium",children:s.chat.agentType||"Agent 类型"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:gE.map(M=>o.jsxs("button",{type:"button",onClick:()=>F(G=>({...G,agent_type:M.name,agent_config_params:M.defaultConfig})),className:`text-left p-3 rounded-lg border transition-all ${T.agent_type===M.name?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(M.icon,{className:`w-4 h-4 ${T.agent_type===M.name?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:`font-medium text-sm ${T.agent_type===M.name?"text-[#1d9bf0]":"text-slate-900 dark:text-slate-100"}`,children:M.displayName})]}),o.jsx("p",{className:`text-xs mt-1 ml-6 ${T.agent_type===M.name?"text-[#1d9bf0]/70":"text-slate-500 dark:text-slate-400"}`,children:M.description})]},M.name))})]}),T.agent_type==="mai"&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"history_n",children:s.chat.history_n||"历史记录数量"}),o.jsx(dt,{id:"history_n",type:"number",min:1,max:10,value:T.agent_config_params?.history_n||3,onChange:M=>{const G=parseInt(M.target.value)||3;F(H=>({...H,agent_config_params:{...H.agent_config_params,history_n:G}}))},className:"w-full"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:s.chat.history_n_hint||"包含的历史截图数量(1-10)"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"default_max_steps",children:s.chat.maxSteps||"最大执行步数"}),o.jsx(dt,{id:"default_max_steps",type:"number",min:1,max:1e3,value:T.default_max_steps,onChange:M=>{const G=parseInt(M.target.value)||100;F(H=>({...H,default_max_steps:Math.min(1e3,Math.max(1,G))}))},className:"w-full"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:s.chat.maxStepsHint||"单次任务最大执行步数(1-1000)"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"layered_max_turns",children:"分层代理最大轮次"}),o.jsx(dt,{id:"layered_max_turns",type:"number",min:1,value:T.layered_max_turns,onChange:M=>{const G=parseInt(M.target.value)||50;F(H=>({...H,layered_max_turns:Math.max(1,G)}))},className:"w-full"}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"分层代理模式的最大轮次(最小值为1)"})]})]}),o.jsxs(Qr,{value:"decision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[o.jsx("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50 dark:border-indigo-900 dark:bg-indigo-950/30 p-3 text-sm text-indigo-900 dark:text-indigo-100",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(O1,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),o.jsx("div",{children:s.chat.decisionModelHint})]})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{className:"text-sm font-medium",children:s.chat.selectDecisionPreset}),o.jsx("div",{className:"grid grid-cols-1 gap-2",children:xE.map(M=>o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>F(G=>({...G,decision_base_url:M.config.decision_base_url,decision_model_name:M.config.decision_model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${T.decision_base_url===M.config.decision_base_url&&(M.name!=="custom"||M.name==="custom"&&T.decision_base_url==="")?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-slate-200 dark:border-slate-700 hover:border-indigo-500/50 hover:bg-indigo-50 dark:hover:bg-indigo-950/30"}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(sa,{className:`w-4 h-4 ${T.decision_base_url===M.config.decision_base_url&&(M.name!=="custom"||M.name==="custom"&&T.decision_base_url==="")?"text-indigo-600 dark:text-indigo-400":"text-slate-400 dark:text-slate-500"}`}),o.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:s.presetConfigs[M.name].name})]}),o.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:s.presetConfigs[M.name].description})]}),"apiKeyUrl"in M&&o.jsx("a",{href:M.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:G=>G.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:s.chat.getApiKey||"获取 API Key",children:o.jsx(mu,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-indigo-600 dark:group-hover:text-indigo-400 transition-colors"})})]},M.name))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(et,{htmlFor:"decision_base_url",children:[s.chat.decisionBaseUrl," *"]}),o.jsx(dt,{id:"decision_base_url",value:T.decision_base_url,onChange:M=>F({...T,decision_base_url:M.target.value}),placeholder:"http://localhost:8080/v1"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(et,{htmlFor:"decision_api_key",children:s.chat.decisionApiKey}),o.jsxs("div",{className:"relative",children:[o.jsx(dt,{id:"decision_api_key",type:B?"text":"password",value:T.decision_api_key,onChange:M=>F({...T,decision_api_key:M.target.value}),placeholder:"sk-...",className:"pr-10"}),o.jsx(fe,{type:"button",variant:"ghost",size:"icon",onClick:()=>Y(!B),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:B?o.jsx(gu,{className:"w-4 h-4 text-slate-400"}):o.jsx(Wo,{className:"w-4 h-4 text-slate-400"})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(et,{htmlFor:"decision_model_name",children:[s.chat.decisionModelName," *"]}),o.jsx(dt,{id:"decision_model_name",value:T.decision_model_name,onChange:M=>F({...T,decision_model_name:M.target.value}),placeholder:""})]})]})]}),o.jsxs(wr,{className:"sm:justify-between gap-2 flex-shrink-0",children:[o.jsx(fe,{variant:"outline",onClick:()=>{I(!1),S&&F({base_url:S.base_url,model_name:S.model_name,api_key:S.api_key||"",agent_type:S.agent_type||"glm",agent_config_params:S.agent_config_params||{},default_max_steps:S.default_max_steps||100,layered_max_turns:S.layered_max_turns||50,decision_base_url:S.decision_base_url||"",decision_model_name:S.decision_model_name||"glm-4.7",decision_api_key:S.decision_api_key||""})},children:s.chat.cancel}),o.jsxs(fe,{onClick:D,variant:"twitter",children:[o.jsx(ns,{className:"w-4 h-4 mr-2"}),s.chat.saveConfig]})]})]})}),o.jsx(Cw,{devices:a,currentDeviceId:l,onSelectDevice:m,onOpenConfig:()=>I(!0),onOpenGroupManager:()=>k(!0),onConnectWifi:te,onDisconnectWifi:U,onRefreshDevices:z,showToast:w}),o.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative",children:[o.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:o.jsxs("div",{className:"flex items-center gap-0.5 bg-white/95 dark:bg-slate-800/95 backdrop-blur-sm rounded-full p-1 shadow-lg border border-slate-200 dark:border-slate-700",children:[o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsxs("button",{onClick:()=>h("classic"),className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${b==="classic"?"bg-slate-900 dark:bg-white text-white dark:text-slate-900 shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[o.jsx(qr,{className:"w-4 h-4"}),s.chatkit?.classicMode||"经典模式"]})}),o.jsx(un,{side:"bottom",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:s.chatkit?.classicMode||"经典模式"}),o.jsx("p",{className:"text-xs opacity-80",children:s.chatkit?.classicModeDesc||"视觉模型直接执行任务"})]})})]}),o.jsxs(ln,{children:[o.jsx(cn,{asChild:!0,children:o.jsxs("button",{onClick:()=>{h("chatkit")},className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${b==="chatkit"?"bg-indigo-600 text-white shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[o.jsx(ra,{className:"w-4 h-4"}),s.chatkit?.layeredMode||"分层代理"]})}),o.jsx(un,{side:"bottom",sideOffset:8,className:"max-w-xs",children:o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"font-medium",children:s.chatkit?.layeredMode||"分层代理"}),o.jsx("p",{className:"text-xs opacity-80",children:s.chatkit?.layeredModeDesc||"规划层分解任务,执行层独立完成子任务"})]})})]})]})}),o.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4 pt-16",children:a.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mx-auto mb-4",children:o.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),o.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:s.chat.welcomeTitle}),o.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:s.chat.connectDevice})]})}):a.map(M=>o.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${M.id===l?"":"hidden"}`,children:b==="chatkit"?o.jsx("div",{className:"w-full flex items-stretch justify-center",children:o.jsx(hE,{deviceId:M.id,deviceSerial:M.serial,deviceName:M.model,deviceConnectionType:M.connection_type,isVisible:M.id===l})}):o.jsx("div",{className:"w-full flex items-stretch justify-center",children:o.jsx(fE,{deviceId:M.id,deviceSerial:M.serial,deviceName:M.model,deviceConnectionType:M.connection_type,isConfigured:!!S?.base_url,isVisible:M.id===l})})},M.serial))})]}),o.jsx(pE,{isOpen:L,onClose:()=>k(!1),onGroupsChanged:z,showToast:w})]})}export{kE as component};
|