autoglm-gui 1.5.1__py3-none-any.whl → 1.5.3__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/__init__.py +1 -1
- AutoGLM_GUI/__main__.py +11 -2
- AutoGLM_GUI/adb_plus/qr_pair.py +3 -3
- AutoGLM_GUI/agents/__init__.py +7 -2
- AutoGLM_GUI/agents/factory.py +46 -6
- AutoGLM_GUI/agents/glm/agent.py +2 -2
- AutoGLM_GUI/agents/glm/async_agent.py +515 -0
- AutoGLM_GUI/agents/glm/parser.py +4 -2
- AutoGLM_GUI/agents/protocols.py +111 -1
- AutoGLM_GUI/agents/stream_runner.py +4 -5
- AutoGLM_GUI/api/__init__.py +3 -1
- AutoGLM_GUI/api/agents.py +78 -37
- AutoGLM_GUI/api/devices.py +72 -0
- AutoGLM_GUI/api/layered_agent.py +9 -8
- AutoGLM_GUI/api/mcp.py +6 -4
- AutoGLM_GUI/config_manager.py +38 -1
- AutoGLM_GUI/device_manager.py +28 -4
- AutoGLM_GUI/device_metadata_manager.py +174 -0
- AutoGLM_GUI/devices/mock_device.py +8 -1
- AutoGLM_GUI/phone_agent_manager.py +145 -32
- AutoGLM_GUI/scheduler_manager.py +6 -6
- AutoGLM_GUI/schemas.py +89 -0
- AutoGLM_GUI/scrcpy_stream.py +2 -1
- AutoGLM_GUI/static/assets/{about-CfwX1Cmc.js → about-DTrVqEQH.js} +1 -1
- AutoGLM_GUI/static/assets/{alert-dialog-CtGlN2IJ.js → alert-dialog-B2KxPLtZ.js} +1 -1
- AutoGLM_GUI/static/assets/chat-BkrVbc3X.js +129 -0
- AutoGLM_GUI/static/assets/{circle-alert-t08bEMPO.js → circle-alert-vnNxOaxv.js} +1 -1
- AutoGLM_GUI/static/assets/{dialog-FNwZJFwk.js → dialog-Cuw3N8_F.js} +1 -1
- AutoGLM_GUI/static/assets/{eye-D0UPWCWC.js → eye-JD1jbm99.js} +1 -1
- AutoGLM_GUI/static/assets/{history-CRo95B7i.js → history-CobYdXju.js} +1 -1
- AutoGLM_GUI/static/assets/{index-CTHbFvKl.js → index-BzP-Te33.js} +5 -5
- AutoGLM_GUI/static/assets/index-y1vOOBHH.js +1 -0
- AutoGLM_GUI/static/assets/label-BpCMrXj_.js +1 -0
- AutoGLM_GUI/static/assets/{logs-RW09DyYY.js → logs-BcsSAeol.js} +1 -1
- AutoGLM_GUI/static/assets/{popover--JTJrE5v.js → popover-BHbCs5Wl.js} +1 -1
- AutoGLM_GUI/static/assets/scheduled-tasks-WvtmRsex.js +1 -0
- AutoGLM_GUI/static/assets/{textarea-PRmVnWq5.js → textarea-B84jf3cE.js} +1 -1
- AutoGLM_GUI/static/assets/workflows-DhBpqdz_.js +1 -0
- AutoGLM_GUI/static/index.html +1 -1
- {autoglm_gui-1.5.1.dist-info → autoglm_gui-1.5.3.dist-info}/METADATA +10 -1
- {autoglm_gui-1.5.1.dist-info → autoglm_gui-1.5.3.dist-info}/RECORD +44 -43
- AutoGLM_GUI/static/assets/chat-BYa-foUI.js +0 -129
- AutoGLM_GUI/static/assets/index-BaLMSqd3.js +0 -1
- AutoGLM_GUI/static/assets/label-DJFevVmr.js +0 -1
- AutoGLM_GUI/static/assets/scheduled-tasks-DTRKsQXF.js +0 -1
- AutoGLM_GUI/static/assets/square-pen-CPK_K680.js +0 -1
- AutoGLM_GUI/static/assets/workflows-CdcsAoaT.js +0 -1
- {autoglm_gui-1.5.1.dist-info → autoglm_gui-1.5.3.dist-info}/WHEEL +0 -0
- {autoglm_gui-1.5.1.dist-info → autoglm_gui-1.5.3.dist-info}/entry_points.txt +0 -0
- {autoglm_gui-1.5.1.dist-info → autoglm_gui-1.5.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BzP-Te33.js","assets/index-CV7jGxGm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as $e,j as a,u as An,r as E,T as en,t as tn,v as nn,B as Ee,f as Hn,w as _x,x as xx,y as Xs,R as Ye,z as _n,A as jc,D as uu,P as Vt,E as _t,G as du,H as Tn,I as Br,b as cr,J as As,K as vx,L as bx,M as yx,N as wx,O as Ex,S as Tr,Q as Pc,U as Sx,V as Nx,W as Cx,X as fu,Y as Tx,Z as Ic,_ as Lc,$ as Rx,a0 as kx,a1 as Ax,a2 as jx,a3 as Px,a4 as Fs,a5 as hu,p as pu,l as mu,q as gu,s as _u,a6 as xu,a7 as Ix,a8 as Lx,a9 as Mx,aa as Dx,ab as Ox,ac as Bx,ad as Fx,ae as Ux,af as Wx,ag as Hx}from"./index-BzP-Te33.js";import{L as Yt,T as vu,D as Fo,d as Uo,e as Wo,f as Ho,h as Go,g as zo,C as Ys}from"./dialog-Cuw3N8_F.js";import{S as Gx,L as nt,I as ht,P as bu}from"./label-BpCMrXj_.js";import{C as yu,E as mo}from"./eye-JD1jbm99.js";import{C as kn}from"./circle-alert-vnNxOaxv.js";import{C as Mc,a as Dc,P as Us,c as Ws,d as Hs,b as zx}from"./popover-BHbCs5Wl.js";import{T as wu}from"./textarea-B84jf3cE.js";const qx=[["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"}]],$x=$e("arrow-up-down",qx);const Xx=[["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"}]],Eu=$e("brain",Xx);const Yx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Su=$e("chevron-left",Yx);const Vx=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Kx=$e("chevron-up",Vx);const Qx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Fr=$e("circle-check",Qx);const Jx=[["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"}]],Zx=$e("cpu",Jx);const ev=[["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"}]],Oc=$e("external-link",ev);const tv=[["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"}]],Bc=$e("eye-off",tv);const nv=[["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"}]],rv=$e("fingerprint-pattern",nv);const sv=[["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"}]],Fc=$e("image",sv);const iv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ov=$e("info",iv);const av=[["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"}]],Ro=$e("layers",av);const lv=[["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"}]],cv=$e("maximize",lv);const uv=[["path",{d:"M5 12h14",key:"1ays0h"}]],dv=$e("minus",uv);const fv=[["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"}]],hv=$e("monitor-play",fv);const pv=[["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"}]],mv=$e("plug",pv);const gv=[["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"}]],Nu=$e("rotate-ccw",gv);const _v=[["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"}]],Cu=$e("send",_v);const xv=[["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"}]],ko=$e("server",xv);const vv=[["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"}]],Tu=$e("settings",vv);const bv=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Is=$e("smartphone",bv);const yv=[["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"}]],jr=$e("sparkles",yv);const wv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ru=$e("square",wv);const Ev=[["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"}]],Sv=$e("video",Ev);const Nv=[["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"}]],Cv=$e("wifi-off",Nv);const Tv=[["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"}]],Gs=$e("wifi",Tv);const Rv=[["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"}]],kv=$e("wrench",Rv);function Uc({isOpen:i,title:n,content:r,onConfirm:o,onCancel:d,confirmText:l="确认",cancelText:_="取消"}){return i?a.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:a.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:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"p-6",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),a.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[a.jsx("button",{onClick:v=>{v.stopPropagation(),d()},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",children:_}),a.jsx("button",{onClick:v=>{v.stopPropagation(),o()},className:"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",children:l})]})]})}):null}function Av({id:i,serial:n,model:r,status:o,connectionType:d,displayName:l,agent:_,isActive:v,onClick:u,onConnectWifi:m,onDisconnectWifi:p,onNameUpdated:x,showToast:y}){const b=An(),N=o==="device",I=d==="usb",A=d==="wifi",D=d==="remote",[M,P]=E.useState(!1),[j,z]=E.useState(!1),[J,q]=E.useState(!1),[$,O]=E.useState(!1),[C,R]=E.useState(""),[re,pe]=E.useState(!1),X=l||r||b.deviceCard.unknownDevice,Y=()=>{if(!N||!_)return"status-agent-none";switch(_.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"}},K=()=>{if(!N||!_)return b.deviceCard.statusTooltip.none;switch(_.state){case"idle":return b.deviceCard.statusTooltip.idle;case"busy":return b.deviceCard.statusTooltip.busy;case"error":return b.deviceCard.statusTooltip.error;case"initializing":return b.deviceCard.statusTooltip.initializing;default:return b.deviceCard.statusTooltip.none}},se=te=>{te.stopPropagation(),!(M||!m)&&z(!0)},oe=te=>{te.stopPropagation(),!(M||!p)&&q(!0)},Re=async()=>{z(!1),P(!0);try{m&&await m()}finally{P(!1)}},G=async()=>{q(!1),P(!0);try{p&&await p()}finally{P(!1)}},Q=te=>{te.stopPropagation(),R(l||r||""),O(!0)},ue=async()=>{try{pe(!0);const te=C.trim(),me=await xx(n,te||null);if(!me.success){y&&y(me.error||b.deviceCard.saveNameError,"error");return}O(!1),x&&x(),y&&y(b.deviceCard.saveNameSuccess,"success")}catch(te){console.error("Failed to update device name:",te),y&&y(b.deviceCard.saveNameError,"error")}finally{pe(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:u,role:"button",tabIndex:0,onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&u()},className:`
|
|
3
|
+
group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
|
|
4
|
+
border-2
|
|
5
|
+
${v?"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:[v&&a.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),a.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsx("div",{className:`relative flex-shrink-0 ${Y()} w-3 h-3 rounded-full transition-all cursor-help ${v?"scale-110":""}`})}),a.jsx(nn,{side:"right",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("p",{className:"font-medium",children:[b.deviceCard.statusTooltip.title,K()]}),a.jsxs("div",{className:"text-xs opacity-80 space-y-0.5",children:[a.jsx("p",{children:b.deviceCard.statusTooltip.legend.green}),a.jsx("p",{children:b.deviceCard.statusTooltip.legend.yellow}),a.jsx("p",{children:b.deviceCard.statusTooltip.legend.red}),a.jsx("p",{children:b.deviceCard.statusTooltip.legend.gray})]})]})})]}),a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Is,{className:`w-4 h-4 flex-shrink-0 ${v?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-semibold text-sm truncate ${v?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:X}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"icon",onClick:Q,className:"h-5 w-5 text-slate-400 hover:text-[#1d9bf0] opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(Gx,{className:"w-3 h-3"})})}),a.jsx(nn,{children:a.jsx("p",{children:b.deviceCard.editName})})]})]}),a.jsx("span",{className:`text-xs font-mono truncate ${v?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:n})]}),a.jsx("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:D?a.jsxs(Hn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[a.jsx(ko,{className:"w-2.5 h-2.5 mr-1"}),b.deviceCard.remote||"Remote"]}):A?a.jsxs(Hn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[a.jsx(Gs,{className:"w-2.5 h-2.5 mr-1"}),b.deviceCard.wifi||"WiFi"]}):I?a.jsx(Hn,{variant:"outline",className:"text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:"USB"}):null}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[m&&I&&a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"icon",onClick:se,disabled:M,className:"h-7 w-7 text-slate-400 hover:text-[#1d9bf0]",children:M?a.jsx(Yt,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(Gs,{className:"w-3.5 h-3.5"})})}),a.jsx(nn,{children:a.jsx("p",{children:b.deviceCard.connectViaWifi})})]}),p&&A&&a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"icon",onClick:oe,disabled:M,className:"h-7 w-7 text-slate-400 hover:text-orange-500",children:M?a.jsx(Yt,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(Cv,{className:"w-3.5 h-3.5"})})}),a.jsx(nn,{children:a.jsx("p",{children:b.deviceCard.disconnectWifi})})]}),D&&a.jsx(Ee,{variant:"ghost",size:"icon",onClick:async te=>{te.stopPropagation(),P(!0);try{await _x(n)}catch(me){console.error("Failed to remove remote device:",me)}finally{P(!1)}},disabled:M,className:"h-7 w-7 text-slate-400 hover:text-red-500",title:b.deviceCard.removeRemote||"移除远程设备",children:M?a.jsx(Yt,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(vu,{className:"w-3.5 h-3.5"})})]})]})]}),a.jsx(Uc,{isOpen:j,title:b.deviceCard.connectWifiTitle,content:b.deviceCard.connectWifiContent,onConfirm:Re,onCancel:()=>z(!1)}),a.jsx(Uc,{isOpen:J,title:b.deviceCard.disconnectWifiTitle,content:b.deviceCard.disconnectWifiContent,onConfirm:G,onCancel:()=>q(!1)}),a.jsx(Fo,{open:$,onOpenChange:O,children:a.jsxs(Uo,{className:"sm:max-w-md",children:[a.jsxs(Wo,{children:[a.jsx(Ho,{children:b.deviceCard.editNameDialogTitle}),a.jsx(Go,{children:b.deviceCard.editNameDialogDescription})]}),a.jsx("div",{className:"space-y-4 py-4",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"device-name",children:b.deviceCard.deviceNameLabel}),a.jsx(ht,{id:"device-name",value:C,onChange:te=>R(te.target.value),placeholder:b.deviceCard.deviceNamePlaceholder,maxLength:100,onKeyDown:te=>{te.key==="Enter"&&!re&&ue()}}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[b.deviceCard.deviceSerialLabel,": ",n]})]})}),a.jsxs(zo,{children:[a.jsx(Ee,{variant:"outline",onClick:()=>O(!1),disabled:re,children:b.common.cancel}),a.jsx(Ee,{onClick:ue,disabled:re,children:re?a.jsxs(a.Fragment,{children:[a.jsx(Yt,{className:"w-4 h-4 mr-2 animate-spin"}),b.common.loading]}):b.common.save})]})]})})]})}function jv(i){const n=i+"CollectionProvider",[r,o]=Xs(n),[d,l]=r(n,{collectionRef:{current:null},itemMap:new Map}),_=I=>{const{scope:A,children:D}=I,M=Ye.useRef(null),P=Ye.useRef(new Map).current;return a.jsx(d,{scope:A,itemMap:P,collectionRef:M,children:D})};_.displayName=n;const v=i+"CollectionSlot",u=jc(v),m=Ye.forwardRef((I,A)=>{const{scope:D,children:M}=I,P=l(v,D),j=_n(A,P.collectionRef);return a.jsx(u,{ref:j,children:M})});m.displayName=v;const p=i+"CollectionItemSlot",x="data-radix-collection-item",y=jc(p),b=Ye.forwardRef((I,A)=>{const{scope:D,children:M,...P}=I,j=Ye.useRef(null),z=_n(A,j),J=l(p,D);return Ye.useEffect(()=>(J.itemMap.set(j,{ref:j,...P}),()=>void J.itemMap.delete(j))),a.jsx(y,{[x]:"",ref:z,children:M})});b.displayName=p;function N(I){const A=l(i+"CollectionConsumer",I);return Ye.useCallback(()=>{const M=A.collectionRef.current;if(!M)return[];const P=Array.from(M.querySelectorAll(`[${x}]`));return Array.from(A.itemMap.values()).sort((J,q)=>P.indexOf(J.ref.current)-P.indexOf(q.ref.current))},[A.collectionRef,A.itemMap])}return[{Provider:_,Slot:m,ItemSlot:b},N,o]}var Pv=E.createContext(void 0);function qo(i){const n=E.useContext(Pv);return i||n||"ltr"}var go="rovingFocusGroup.onEntryFocus",Iv={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[Ao,ku,Lv]=jv(Ur),[Mv,Au]=Xs(Ur,[Lv]),[Dv,Ov]=Mv(Ur),ju=E.forwardRef((i,n)=>a.jsx(Ao.Provider,{scope:i.__scopeRovingFocusGroup,children:a.jsx(Ao.Slot,{scope:i.__scopeRovingFocusGroup,children:a.jsx(Bv,{...i,ref:n})})}));ju.displayName=Ur;var Bv=E.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,orientation:o,loop:d=!1,dir:l,currentTabStopId:_,defaultCurrentTabStopId:v,onCurrentTabStopIdChange:u,onEntryFocus:m,preventScrollOnEntryFocus:p=!1,...x}=i,y=E.useRef(null),b=_n(n,y),N=qo(l),[I,A]=du({prop:_,defaultProp:v??null,onChange:u,caller:Ur}),[D,M]=E.useState(!1),P=Tn(m),j=ku(r),z=E.useRef(!1),[J,q]=E.useState(0);return E.useEffect(()=>{const $=y.current;if($)return $.addEventListener(go,P),()=>$.removeEventListener(go,P)},[P]),a.jsx(Dv,{scope:r,orientation:o,dir:N,loop:d,currentTabStopId:I,onItemFocus:E.useCallback($=>A($),[A]),onItemShiftTab:E.useCallback(()=>M(!0),[]),onFocusableItemAdd:E.useCallback(()=>q($=>$+1),[]),onFocusableItemRemove:E.useCallback(()=>q($=>$-1),[]),children:a.jsx(Vt.div,{tabIndex:D||J===0?-1:0,"data-orientation":o,...x,ref:b,style:{outline:"none",...i.style},onMouseDown:_t(i.onMouseDown,()=>{z.current=!0}),onFocus:_t(i.onFocus,$=>{const O=!z.current;if($.target===$.currentTarget&&O&&!D){const C=new CustomEvent(go,Iv);if($.currentTarget.dispatchEvent(C),!C.defaultPrevented){const R=j().filter(K=>K.focusable),re=R.find(K=>K.active),pe=R.find(K=>K.id===I),Y=[re,pe,...R].filter(Boolean).map(K=>K.ref.current);Lu(Y,p)}}z.current=!1}),onBlur:_t(i.onBlur,()=>M(!1))})})}),Pu="RovingFocusGroupItem",Iu=E.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:d=!1,tabStopId:l,children:_,...v}=i,u=uu(),m=l||u,p=Ov(Pu,r),x=p.currentTabStopId===m,y=ku(r),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:I}=p;return E.useEffect(()=>{if(o)return b(),()=>N()},[o,b,N]),a.jsx(Ao.ItemSlot,{scope:r,id:m,focusable:o,active:d,children:a.jsx(Vt.span,{tabIndex:x?0:-1,"data-orientation":p.orientation,...v,ref:n,onMouseDown:_t(i.onMouseDown,A=>{o?p.onItemFocus(m):A.preventDefault()}),onFocus:_t(i.onFocus,()=>p.onItemFocus(m)),onKeyDown:_t(i.onKeyDown,A=>{if(A.key==="Tab"&&A.shiftKey){p.onItemShiftTab();return}if(A.target!==A.currentTarget)return;const D=Wv(A,p.orientation,p.dir);if(D!==void 0){if(A.metaKey||A.ctrlKey||A.altKey||A.shiftKey)return;A.preventDefault();let P=y().filter(j=>j.focusable).map(j=>j.ref.current);if(D==="last")P.reverse();else if(D==="prev"||D==="next"){D==="prev"&&P.reverse();const j=P.indexOf(A.currentTarget);P=p.loop?Hv(P,j+1):P.slice(j+1)}setTimeout(()=>Lu(P))}}),children:typeof _=="function"?_({isCurrentTabStop:x,hasTabStop:I!=null}):_})})});Iu.displayName=Pu;var Fv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Uv(i,n){return n!=="rtl"?i:i==="ArrowLeft"?"ArrowRight":i==="ArrowRight"?"ArrowLeft":i}function Wv(i,n,r){const o=Uv(i.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Fv[o]}function Lu(i,n=!1){const r=document.activeElement;for(const o of i)if(o===r||(o.focus({preventScroll:n}),document.activeElement!==r))return}function Hv(i,n){return i.map((r,o)=>i[(n+o)%i.length])}var Gv=ju,zv=Iu,Vs="Tabs",[qv]=Xs(Vs,[Au]),Mu=Au(),[$v,$o]=qv(Vs),Du=E.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,onValueChange:d,defaultValue:l,orientation:_="horizontal",dir:v,activationMode:u="automatic",...m}=i,p=qo(v),[x,y]=du({prop:o,onChange:d,defaultProp:l??"",caller:Vs});return a.jsx($v,{scope:r,baseId:uu(),value:x,onValueChange:y,orientation:_,dir:p,activationMode:u,children:a.jsx(Vt.div,{dir:p,"data-orientation":_,...m,ref:n})})});Du.displayName=Vs;var Ou="TabsList",Bu=E.forwardRef((i,n)=>{const{__scopeTabs:r,loop:o=!0,...d}=i,l=$o(Ou,r),_=Mu(r);return a.jsx(Gv,{asChild:!0,..._,orientation:l.orientation,dir:l.dir,loop:o,children:a.jsx(Vt.div,{role:"tablist","aria-orientation":l.orientation,...d,ref:n})})});Bu.displayName=Ou;var Fu="TabsTrigger",Uu=E.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,disabled:d=!1,...l}=i,_=$o(Fu,r),v=Mu(r),u=Gu(_.baseId,o),m=zu(_.baseId,o),p=o===_.value;return a.jsx(zv,{asChild:!0,...v,focusable:!d,active:p,children:a.jsx(Vt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":m,"data-state":p?"active":"inactive","data-disabled":d?"":void 0,disabled:d,id:u,...l,ref:n,onMouseDown:_t(i.onMouseDown,x=>{!d&&x.button===0&&x.ctrlKey===!1?_.onValueChange(o):x.preventDefault()}),onKeyDown:_t(i.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&_.onValueChange(o)}),onFocus:_t(i.onFocus,()=>{const x=_.activationMode!=="manual";!p&&!d&&x&&_.onValueChange(o)})})})});Uu.displayName=Fu;var Wu="TabsContent",Hu=E.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,forceMount:d,children:l,..._}=i,v=$o(Wu,r),u=Gu(v.baseId,o),m=zu(v.baseId,o),p=o===v.value,x=E.useRef(p);return E.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),a.jsx(Br,{present:d||p,children:({present:y})=>a.jsx(Vt.div,{"data-state":p?"active":"inactive","data-orientation":v.orientation,role:"tabpanel","aria-labelledby":u,hidden:!y,id:m,tabIndex:0,..._,ref:n,style:{...i.style,animationDuration:x.current?"0s":void 0},children:y&&l})})});Hu.displayName=Wu;function Gu(i,n){return`${i}-trigger-${n}`}function zu(i,n){return`${i}-content-${n}`}var Xv=Du,Yv=Bu,Vv=Uu,Kv=Hu;function qu({className:i,...n}){return a.jsx(Xv,{"data-slot":"tabs",className:cr("flex flex-col gap-2",i),...n})}function $u({className:i,...n}){return a.jsx(Yv,{"data-slot":"tabs-list",className:cr("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",i),...n})}function Lr({className:i,...n}){return a.jsx(Vv,{"data-slot":"tabs-trigger",className:cr("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",i),...n})}function Mr({className:i,...n}){return a.jsx(Kv,{"data-slot":"tabs-content",className:cr("flex-1 outline-none",i),...n})}var Qv=Object.defineProperty,zs=Object.getOwnPropertySymbols,Xu=Object.prototype.hasOwnProperty,Yu=Object.prototype.propertyIsEnumerable,Wc=(i,n,r)=>n in i?Qv(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,jo=(i,n)=>{for(var r in n||(n={}))Xu.call(n,r)&&Wc(i,r,n[r]);if(zs)for(var r of zs(n))Yu.call(n,r)&&Wc(i,r,n[r]);return i},Po=(i,n)=>{var r={};for(var o in i)Xu.call(i,o)&&n.indexOf(o)<0&&(r[o]=i[o]);if(i!=null&&zs)for(var o of zs(i))n.indexOf(o)<0&&Yu.call(i,o)&&(r[o]=i[o]);return r};var Gn;(i=>{const n=class Ie{constructor(u,m,p,x){if(this.version=u,this.errorCorrectionLevel=m,this.modules=[],this.isFunction=[],u<Ie.MIN_VERSION||u>Ie.MAX_VERSION)throw new RangeError("Version value out of range");if(x<-1||x>7)throw new RangeError("Mask value out of range");this.size=u*4+17;let y=[];for(let N=0;N<this.size;N++)y.push(!1);for(let N=0;N<this.size;N++)this.modules.push(y.slice()),this.isFunction.push(y.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(p);if(this.drawCodewords(b),x==-1){let N=1e9;for(let I=0;I<8;I++){this.applyMask(I),this.drawFormatBits(I);const A=this.getPenaltyScore();A<N&&(x=I,N=A),this.applyMask(I)}}d(0<=x&&x<=7),this.mask=x,this.applyMask(x),this.drawFormatBits(x),this.isFunction=[]}static encodeText(u,m){const p=i.QrSegment.makeSegments(u);return Ie.encodeSegments(p,m)}static encodeBinary(u,m){const p=i.QrSegment.makeBytes(u);return Ie.encodeSegments([p],m)}static encodeSegments(u,m,p=1,x=40,y=-1,b=!0){if(!(Ie.MIN_VERSION<=p&&p<=x&&x<=Ie.MAX_VERSION)||y<-1||y>7)throw new RangeError("Invalid value");let N,I;for(N=p;;N++){const P=Ie.getNumDataCodewords(N,m)*8,j=_.getTotalBits(u,N);if(j<=P){I=j;break}if(N>=x)throw new RangeError("Data too long")}for(const P of[Ie.Ecc.MEDIUM,Ie.Ecc.QUARTILE,Ie.Ecc.HIGH])b&&I<=Ie.getNumDataCodewords(N,P)*8&&(m=P);let A=[];for(const P of u){r(P.mode.modeBits,4,A),r(P.numChars,P.mode.numCharCountBits(N),A);for(const j of P.getData())A.push(j)}d(A.length==I);const D=Ie.getNumDataCodewords(N,m)*8;d(A.length<=D),r(0,Math.min(4,D-A.length),A),r(0,(8-A.length%8)%8,A),d(A.length%8==0);for(let P=236;A.length<D;P^=253)r(P,8,A);let M=[];for(;M.length*8<A.length;)M.push(0);return A.forEach((P,j)=>M[j>>>3]|=P<<7-(j&7)),new Ie(N,m,M,y)}getModule(u,m){return 0<=u&&u<this.size&&0<=m&&m<this.size&&this.modules[m][u]}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 u=this.getAlignmentPatternPositions(),m=u.length;for(let p=0;p<m;p++)for(let x=0;x<m;x++)p==0&&x==0||p==0&&x==m-1||p==m-1&&x==0||this.drawAlignmentPattern(u[p],u[x]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(u){const m=this.errorCorrectionLevel.formatBits<<3|u;let p=m;for(let y=0;y<10;y++)p=p<<1^(p>>>9)*1335;const x=(m<<10|p)^21522;d(x>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,o(x,y));this.setFunctionModule(8,7,o(x,6)),this.setFunctionModule(8,8,o(x,7)),this.setFunctionModule(7,8,o(x,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,o(x,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,o(x,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,o(x,y));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let u=this.version;for(let p=0;p<12;p++)u=u<<1^(u>>>11)*7973;const m=this.version<<12|u;d(m>>>18==0);for(let p=0;p<18;p++){const x=o(m,p),y=this.size-11+p%3,b=Math.floor(p/3);this.setFunctionModule(y,b,x),this.setFunctionModule(b,y,x)}}drawFinderPattern(u,m){for(let p=-4;p<=4;p++)for(let x=-4;x<=4;x++){const y=Math.max(Math.abs(x),Math.abs(p)),b=u+x,N=m+p;0<=b&&b<this.size&&0<=N&&N<this.size&&this.setFunctionModule(b,N,y!=2&&y!=4)}}drawAlignmentPattern(u,m){for(let p=-2;p<=2;p++)for(let x=-2;x<=2;x++)this.setFunctionModule(u+x,m+p,Math.max(Math.abs(x),Math.abs(p))!=1)}setFunctionModule(u,m,p){this.modules[m][u]=p,this.isFunction[m][u]=!0}addEccAndInterleave(u){const m=this.version,p=this.errorCorrectionLevel;if(u.length!=Ie.getNumDataCodewords(m,p))throw new RangeError("Invalid argument");const x=Ie.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][m],y=Ie.ECC_CODEWORDS_PER_BLOCK[p.ordinal][m],b=Math.floor(Ie.getNumRawDataModules(m)/8),N=x-b%x,I=Math.floor(b/x);let A=[];const D=Ie.reedSolomonComputeDivisor(y);for(let P=0,j=0;P<x;P++){let z=u.slice(j,j+I-y+(P<N?0:1));j+=z.length;const J=Ie.reedSolomonComputeRemainder(z,D);P<N&&z.push(0),A.push(z.concat(J))}let M=[];for(let P=0;P<A[0].length;P++)A.forEach((j,z)=>{(P!=I-y||z>=N)&&M.push(j[P])});return d(M.length==b),M}drawCodewords(u){if(u.length!=Math.floor(Ie.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let m=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let x=0;x<this.size;x++)for(let y=0;y<2;y++){const b=p-y,I=(p+1&2)==0?this.size-1-x:x;!this.isFunction[I][b]&&m<u.length*8&&(this.modules[I][b]=o(u[m>>>3],7-(m&7)),m++)}}d(m==u.length*8)}applyMask(u){if(u<0||u>7)throw new RangeError("Mask value out of range");for(let m=0;m<this.size;m++)for(let p=0;p<this.size;p++){let x;switch(u){case 0:x=(p+m)%2==0;break;case 1:x=m%2==0;break;case 2:x=p%3==0;break;case 3:x=(p+m)%3==0;break;case 4:x=(Math.floor(p/3)+Math.floor(m/2))%2==0;break;case 5:x=p*m%2+p*m%3==0;break;case 6:x=(p*m%2+p*m%3)%2==0;break;case 7:x=((p+m)%2+p*m%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[m][p]&&x&&(this.modules[m][p]=!this.modules[m][p])}}getPenaltyScore(){let u=0;for(let y=0;y<this.size;y++){let b=!1,N=0,I=[0,0,0,0,0,0,0];for(let A=0;A<this.size;A++)this.modules[y][A]==b?(N++,N==5?u+=Ie.PENALTY_N1:N>5&&u++):(this.finderPenaltyAddHistory(N,I),b||(u+=this.finderPenaltyCountPatterns(I)*Ie.PENALTY_N3),b=this.modules[y][A],N=1);u+=this.finderPenaltyTerminateAndCount(b,N,I)*Ie.PENALTY_N3}for(let y=0;y<this.size;y++){let b=!1,N=0,I=[0,0,0,0,0,0,0];for(let A=0;A<this.size;A++)this.modules[A][y]==b?(N++,N==5?u+=Ie.PENALTY_N1:N>5&&u++):(this.finderPenaltyAddHistory(N,I),b||(u+=this.finderPenaltyCountPatterns(I)*Ie.PENALTY_N3),b=this.modules[A][y],N=1);u+=this.finderPenaltyTerminateAndCount(b,N,I)*Ie.PENALTY_N3}for(let y=0;y<this.size-1;y++)for(let b=0;b<this.size-1;b++){const N=this.modules[y][b];N==this.modules[y][b+1]&&N==this.modules[y+1][b]&&N==this.modules[y+1][b+1]&&(u+=Ie.PENALTY_N2)}let m=0;for(const y of this.modules)m=y.reduce((b,N)=>b+(N?1:0),m);const p=this.size*this.size,x=Math.ceil(Math.abs(m*20-p*10)/p)-1;return d(0<=x&&x<=9),u+=x*Ie.PENALTY_N4,d(0<=u&&u<=2568888),u}getAlignmentPatternPositions(){if(this.version==1)return[];{const u=Math.floor(this.version/7)+2,m=this.version==32?26:Math.ceil((this.version*4+4)/(u*2-2))*2;let p=[6];for(let x=this.size-7;p.length<u;x-=m)p.splice(1,0,x);return p}}static getNumRawDataModules(u){if(u<Ie.MIN_VERSION||u>Ie.MAX_VERSION)throw new RangeError("Version number out of range");let m=(16*u+128)*u+64;if(u>=2){const p=Math.floor(u/7)+2;m-=(25*p-10)*p-55,u>=7&&(m-=36)}return d(208<=m&&m<=29648),m}static getNumDataCodewords(u,m){return Math.floor(Ie.getNumRawDataModules(u)/8)-Ie.ECC_CODEWORDS_PER_BLOCK[m.ordinal][u]*Ie.NUM_ERROR_CORRECTION_BLOCKS[m.ordinal][u]}static reedSolomonComputeDivisor(u){if(u<1||u>255)throw new RangeError("Degree out of range");let m=[];for(let x=0;x<u-1;x++)m.push(0);m.push(1);let p=1;for(let x=0;x<u;x++){for(let y=0;y<m.length;y++)m[y]=Ie.reedSolomonMultiply(m[y],p),y+1<m.length&&(m[y]^=m[y+1]);p=Ie.reedSolomonMultiply(p,2)}return m}static reedSolomonComputeRemainder(u,m){let p=m.map(x=>0);for(const x of u){const y=x^p.shift();p.push(0),m.forEach((b,N)=>p[N]^=Ie.reedSolomonMultiply(b,y))}return p}static reedSolomonMultiply(u,m){if(u>>>8||m>>>8)throw new RangeError("Byte out of range");let p=0;for(let x=7;x>=0;x--)p=p<<1^(p>>>7)*285,p^=(m>>>x&1)*u;return d(p>>>8==0),p}finderPenaltyCountPatterns(u){const m=u[1];d(m<=this.size*3);const p=m>0&&u[2]==m&&u[3]==m*3&&u[4]==m&&u[5]==m;return(p&&u[0]>=m*4&&u[6]>=m?1:0)+(p&&u[6]>=m*4&&u[0]>=m?1:0)}finderPenaltyTerminateAndCount(u,m,p){return u&&(this.finderPenaltyAddHistory(m,p),m=0),m+=this.size,this.finderPenaltyAddHistory(m,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(u,m){m[0]==0&&(u+=this.size),m.pop(),m.unshift(u)}};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]],i.QrCode=n;function r(v,u,m){if(u<0||u>31||v>>>u)throw new RangeError("Value out of range");for(let p=u-1;p>=0;p--)m.push(v>>>p&1)}function o(v,u){return(v>>>u&1)!=0}function d(v){if(!v)throw new Error("Assertion error")}const l=class tt{constructor(u,m,p){if(this.mode=u,this.numChars=m,this.bitData=p,m<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(u){let m=[];for(const p of u)r(p,8,m);return new tt(tt.Mode.BYTE,u.length,m)}static makeNumeric(u){if(!tt.isNumeric(u))throw new RangeError("String contains non-numeric characters");let m=[];for(let p=0;p<u.length;){const x=Math.min(u.length-p,3);r(parseInt(u.substring(p,p+x),10),x*3+1,m),p+=x}return new tt(tt.Mode.NUMERIC,u.length,m)}static makeAlphanumeric(u){if(!tt.isAlphanumeric(u))throw new RangeError("String contains unencodable characters in alphanumeric mode");let m=[],p;for(p=0;p+2<=u.length;p+=2){let x=tt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p))*45;x+=tt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p+1)),r(x,11,m)}return p<u.length&&r(tt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p)),6,m),new tt(tt.Mode.ALPHANUMERIC,u.length,m)}static makeSegments(u){return u==""?[]:tt.isNumeric(u)?[tt.makeNumeric(u)]:tt.isAlphanumeric(u)?[tt.makeAlphanumeric(u)]:[tt.makeBytes(tt.toUtf8ByteArray(u))]}static makeEci(u){let m=[];if(u<0)throw new RangeError("ECI assignment value out of range");if(u<128)r(u,8,m);else if(u<16384)r(2,2,m),r(u,14,m);else if(u<1e6)r(6,3,m),r(u,21,m);else throw new RangeError("ECI assignment value out of range");return new tt(tt.Mode.ECI,0,m)}static isNumeric(u){return tt.NUMERIC_REGEX.test(u)}static isAlphanumeric(u){return tt.ALPHANUMERIC_REGEX.test(u)}getData(){return this.bitData.slice()}static getTotalBits(u,m){let p=0;for(const x of u){const y=x.mode.numCharCountBits(m);if(x.numChars>=1<<y)return 1/0;p+=4+y+x.bitData.length}return p}static toUtf8ByteArray(u){u=encodeURI(u);let m=[];for(let p=0;p<u.length;p++)u.charAt(p)!="%"?m.push(u.charCodeAt(p)):(m.push(parseInt(u.substring(p+1,p+3),16)),p+=2);return m}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let _=l;i.QrSegment=l})(Gn||(Gn={}));(i=>{(n=>{const r=class{constructor(d,l){this.ordinal=d,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})(i.QrCode||(i.QrCode={}))})(Gn||(Gn={}));(i=>{(n=>{const r=class{constructor(d,l){this.modeBits=d,this.numBitsCharCount=l}numCharCountBits(d){return this.numBitsCharCount[Math.floor((d+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})(i.QrSegment||(i.QrSegment={}))})(Gn||(Gn={}));var ar=Gn;var Jv={L:ar.QrCode.Ecc.LOW,M:ar.QrCode.Ecc.MEDIUM,Q:ar.QrCode.Ecc.QUARTILE,H:ar.QrCode.Ecc.HIGH},Vu=128,Ku="L",Qu="#FFFFFF",Ju="#000000",Zu=!1,ed=1,Zv=4,e1=0,t1=.1;function td(i,n=0){const r=[];return i.forEach(function(o,d){let l=null;o.forEach(function(_,v){if(!_&&l!==null){r.push(`M${l+n} ${d+n}h${v-l}v1H${l+n}z`),l=null;return}if(v===o.length-1){if(!_)return;l===null?r.push(`M${v+n},${d+n} h1v1H${v+n}z`):r.push(`M${l+n},${d+n} h${v+1-l}v1H${l+n}z`);return}_&&l===null&&(l=v)})}),r.join("")}function nd(i,n){return i.slice().map((r,o)=>o<n.y||o>=n.y+n.h?r:r.map((d,l)=>l<n.x||l>=n.x+n.w?d:!1))}function n1(i,n,r,o){if(o==null)return null;const d=i.length+r*2,l=Math.floor(n*t1),_=d/n,v=(o.width||l)*_,u=(o.height||l)*_,m=o.x==null?i.length/2-v/2:o.x*_,p=o.y==null?i.length/2-u/2:o.y*_,x=o.opacity==null?1:o.opacity;let y=null;if(o.excavate){let N=Math.floor(m),I=Math.floor(p),A=Math.ceil(v+m-N),D=Math.ceil(u+p-I);y={x:N,y:I,w:A,h:D}}const b=o.crossOrigin;return{x:m,y:p,h:u,w:v,excavation:y,opacity:x,crossOrigin:b}}function r1(i,n){return n!=null?Math.max(Math.floor(n),0):i?Zv:e1}function rd({value:i,level:n,minVersion:r,includeMargin:o,marginSize:d,imageSettings:l,size:_,boostLevel:v}){let u=Ye.useMemo(()=>{const N=(Array.isArray(i)?i:[i]).reduce((I,A)=>(I.push(...ar.QrSegment.makeSegments(A)),I),[]);return ar.QrCode.encodeSegments(N,Jv[n],r,void 0,void 0,v)},[i,n,r,v]);const{cells:m,margin:p,numCells:x,calculatedImageSettings:y}=Ye.useMemo(()=>{let b=u.getModules();const N=r1(o,d),I=b.length+N*2,A=n1(b,_,N,l);return{cells:b,margin:N,numCells:I,calculatedImageSettings:A}},[u,_,l,o,d]);return{qrcode:u,margin:p,cells:m,numCells:x,calculatedImageSettings:y}}var s1=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),i1=Ye.forwardRef(function(n,r){const o=n,{value:d,size:l=Vu,level:_=Ku,bgColor:v=Qu,fgColor:u=Ju,includeMargin:m=Zu,minVersion:p=ed,boostLevel:x,marginSize:y,imageSettings:b}=o,I=Po(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:A}=I,D=Po(I,["style"]),M=b?.src,P=Ye.useRef(null),j=Ye.useRef(null),z=Ye.useCallback(X=>{P.current=X,typeof r=="function"?r(X):r&&(r.current=X)},[r]),[J,q]=Ye.useState(!1),{margin:$,cells:O,numCells:C,calculatedImageSettings:R}=rd({value:d,level:_,minVersion:p,boostLevel:x,includeMargin:m,marginSize:y,imageSettings:b,size:l});Ye.useEffect(()=>{if(P.current!=null){const X=P.current,Y=X.getContext("2d");if(!Y)return;let K=O;const se=j.current,oe=R!=null&&se!==null&&se.complete&&se.naturalHeight!==0&&se.naturalWidth!==0;oe&&R.excavation!=null&&(K=nd(O,R.excavation));const Re=window.devicePixelRatio||1;X.height=X.width=l*Re;const G=l/C*Re;Y.scale(G,G),Y.fillStyle=v,Y.fillRect(0,0,C,C),Y.fillStyle=u,s1?Y.fill(new Path2D(td(K,$))):O.forEach(function(Q,ue){Q.forEach(function(te,me){te&&Y.fillRect(me+$,ue+$,1,1)})}),R&&(Y.globalAlpha=R.opacity),oe&&Y.drawImage(se,R.x+$,R.y+$,R.w,R.h)}}),Ye.useEffect(()=>{q(!1)},[M]);const re=jo({height:l,width:l},A);let pe=null;return M!=null&&(pe=Ye.createElement("img",{src:M,key:M,style:{display:"none"},onLoad:()=>{q(!0)},ref:j,crossOrigin:R?.crossOrigin})),Ye.createElement(Ye.Fragment,null,Ye.createElement("canvas",jo({style:re,height:l,width:l,ref:z,role:"img"},D)),pe)});i1.displayName="QRCodeCanvas";var sd=Ye.forwardRef(function(n,r){const o=n,{value:d,size:l=Vu,level:_=Ku,bgColor:v=Qu,fgColor:u=Ju,includeMargin:m=Zu,minVersion:p=ed,boostLevel:x,title:y,marginSize:b,imageSettings:N}=o,I=Po(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:A,cells:D,numCells:M,calculatedImageSettings:P}=rd({value:d,level:_,minVersion:p,boostLevel:x,includeMargin:m,marginSize:b,imageSettings:N,size:l});let j=D,z=null;N!=null&&P!=null&&(P.excavation!=null&&(j=nd(D,P.excavation)),z=Ye.createElement("image",{href:N.src,height:P.h,width:P.w,x:P.x+A,y:P.y+A,preserveAspectRatio:"none",opacity:P.opacity,crossOrigin:P.crossOrigin}));const J=td(j,A);return Ye.createElement("svg",jo({height:l,width:l,viewBox:`0 0 ${M} ${M}`,ref:r,role:"img"},I),!!y&&Ye.createElement("title",null,y),Ye.createElement("path",{fill:v,d:`M0,0 h${M}v${M}H0z`,shapeRendering:"crispEdges"}),Ye.createElement("path",{fill:u,d:J,shapeRendering:"crispEdges"}),z)});sd.displayName="QRCodeSVG";var Pr={exports:{}};var o1=Pr.exports,Hc;function a1(){return Hc||(Hc=1,(function(i,n){(function(){var r,o="4.17.21",d=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",_="Expected a function",v="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",m=500,p="__lodash_placeholder__",x=1,y=2,b=4,N=1,I=2,A=1,D=2,M=4,P=8,j=16,z=32,J=64,q=128,$=256,O=512,C=30,R="...",re=800,pe=16,X=1,Y=2,K=3,se=1/0,oe=9007199254740991,Re=17976931348623157e292,G=NaN,Q=4294967295,ue=Q-1,te=Q>>>1,me=[["ary",q],["bind",A],["bindKey",D],["curry",P],["curryRight",j],["flip",O],["partial",z],["partialRight",J],["rearg",$]],ae="[object Arguments]",Ue="[object Array]",Ze="[object AsyncFunction]",Ge="[object Boolean]",B="[object Date]",ce="[object DOMException]",ye="[object Error]",Be="[object Function]",We="[object GeneratorFunction]",de="[object Map]",Se="[object Number]",ee="[object Null]",Z="[object Object]",we="[object Promise]",Le="[object Proxy]",fe="[object RegExp]",_e="[object Set]",Ne="[object String]",he="[object Symbol]",ct="[object Undefined]",yt="[object WeakMap]",wt="[object WeakSet]",it="[object ArrayBuffer]",Ve="[object DataView]",zn="[object Float32Array]",jn="[object Float64Array]",Pn="[object Int8Array]",qn="[object Int16Array]",dr="[object Int32Array]",an="[object Uint8Array]",$n="[object Uint8ClampedArray]",U="[object Uint16Array]",xe="[object Uint32Array]",Kt=/\b__p \+= '';/g,ti=/\b(__p \+=) '' \+/g,Wr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,na=/&(?:amp|lt|gt|quot|#39);/g,ra=/[&<>"']/g,Ud=RegExp(na.source),Wd=RegExp(ra.source),Hd=/<%-([\s\S]+?)%>/g,Gd=/<%([\s\S]+?)%>/g,sa=/<%=([\s\S]+?)%>/g,zd=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qd=/^\w*$/,$d=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ni=/[\\^$.*+?()[\]{}|]/g,Xd=RegExp(ni.source),ri=/^\s+/,Yd=/\s/,Vd=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Kd=/\{\n\/\* \[wrapped with (.+)\] \*/,Qd=/,? & /,Jd=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Zd=/[()=,{}\[\]\/\s]/,ef=/\\(\\)?/g,tf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ia=/\w*$/,nf=/^[-+]0x[0-9a-f]+$/i,rf=/^0b[01]+$/i,sf=/^\[object .+?Constructor\]$/,of=/^0o[0-7]+$/i,af=/^(?:0|[1-9]\d*)$/,lf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Hr=/($^)/,cf=/['\n\r\u2028\u2029\\]/g,Gr="\\ud800-\\udfff",uf="\\u0300-\\u036f",df="\\ufe20-\\ufe2f",ff="\\u20d0-\\u20ff",oa=uf+df+ff,aa="\\u2700-\\u27bf",la="a-z\\xdf-\\xf6\\xf8-\\xff",hf="\\xac\\xb1\\xd7\\xf7",pf="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",mf="\\u2000-\\u206f",gf=" \\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",ca="A-Z\\xc0-\\xd6\\xd8-\\xde",ua="\\ufe0e\\ufe0f",da=hf+pf+mf+gf,si="['’]",_f="["+Gr+"]",fa="["+da+"]",zr="["+oa+"]",ha="\\d+",xf="["+aa+"]",pa="["+la+"]",ma="[^"+Gr+da+ha+aa+la+ca+"]",ii="\\ud83c[\\udffb-\\udfff]",vf="(?:"+zr+"|"+ii+")",ga="[^"+Gr+"]",oi="(?:\\ud83c[\\udde6-\\uddff]){2}",ai="[\\ud800-\\udbff][\\udc00-\\udfff]",Xn="["+ca+"]",_a="\\u200d",xa="(?:"+pa+"|"+ma+")",bf="(?:"+Xn+"|"+ma+")",va="(?:"+si+"(?:d|ll|m|re|s|t|ve))?",ba="(?:"+si+"(?:D|LL|M|RE|S|T|VE))?",ya=vf+"?",wa="["+ua+"]?",yf="(?:"+_a+"(?:"+[ga,oi,ai].join("|")+")"+wa+ya+")*",wf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ef="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ea=wa+ya+yf,Sf="(?:"+[xf,oi,ai].join("|")+")"+Ea,Nf="(?:"+[ga+zr+"?",zr,oi,ai,_f].join("|")+")",Cf=RegExp(si,"g"),Tf=RegExp(zr,"g"),li=RegExp(ii+"(?="+ii+")|"+Nf+Ea,"g"),Rf=RegExp([Xn+"?"+pa+"+"+va+"(?="+[fa,Xn,"$"].join("|")+")",bf+"+"+ba+"(?="+[fa,Xn+xa,"$"].join("|")+")",Xn+"?"+xa+"+"+va,Xn+"+"+ba,Ef,wf,ha,Sf].join("|"),"g"),kf=RegExp("["+_a+Gr+oa+ua+"]"),Af=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,jf=["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"],Pf=-1,Ke={};Ke[zn]=Ke[jn]=Ke[Pn]=Ke[qn]=Ke[dr]=Ke[an]=Ke[$n]=Ke[U]=Ke[xe]=!0,Ke[ae]=Ke[Ue]=Ke[it]=Ke[Ge]=Ke[Ve]=Ke[B]=Ke[ye]=Ke[Be]=Ke[de]=Ke[Se]=Ke[Z]=Ke[fe]=Ke[_e]=Ke[Ne]=Ke[yt]=!1;var Xe={};Xe[ae]=Xe[Ue]=Xe[it]=Xe[Ve]=Xe[Ge]=Xe[B]=Xe[zn]=Xe[jn]=Xe[Pn]=Xe[qn]=Xe[dr]=Xe[de]=Xe[Se]=Xe[Z]=Xe[fe]=Xe[_e]=Xe[Ne]=Xe[he]=Xe[an]=Xe[$n]=Xe[U]=Xe[xe]=!0,Xe[ye]=Xe[Be]=Xe[yt]=!1;var If={À:"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"},Lf={"&":"&","<":"<",">":">",'"':""","'":"'"},Mf={"&":"&","<":"<",">":">",""":'"',"'":"'"},Df={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Of=parseFloat,Bf=parseInt,Sa=typeof As=="object"&&As&&As.Object===Object&&As,Ff=typeof self=="object"&&self&&self.Object===Object&&self,dt=Sa||Ff||Function("return this")(),ci=n&&!n.nodeType&&n,In=ci&&!0&&i&&!i.nodeType&&i,Na=In&&In.exports===ci,ui=Na&&Sa.process,It=(function(){try{var T=In&&In.require&&In.require("util").types;return T||ui&&ui.binding&&ui.binding("util")}catch{}})(),Ca=It&&It.isArrayBuffer,Ta=It&&It.isDate,Ra=It&&It.isMap,ka=It&&It.isRegExp,Aa=It&&It.isSet,ja=It&&It.isTypedArray;function Tt(T,F,L){switch(L.length){case 0:return T.call(F);case 1:return T.call(F,L[0]);case 2:return T.call(F,L[0],L[1]);case 3:return T.call(F,L[0],L[1],L[2])}return T.apply(F,L)}function Uf(T,F,L,ie){for(var Ce=-1,Fe=T==null?0:T.length;++Ce<Fe;){var at=T[Ce];F(ie,at,L(at),T)}return ie}function Lt(T,F){for(var L=-1,ie=T==null?0:T.length;++L<ie&&F(T[L],L,T)!==!1;);return T}function Wf(T,F){for(var L=T==null?0:T.length;L--&&F(T[L],L,T)!==!1;);return T}function Pa(T,F){for(var L=-1,ie=T==null?0:T.length;++L<ie;)if(!F(T[L],L,T))return!1;return!0}function xn(T,F){for(var L=-1,ie=T==null?0:T.length,Ce=0,Fe=[];++L<ie;){var at=T[L];F(at,L,T)&&(Fe[Ce++]=at)}return Fe}function qr(T,F){var L=T==null?0:T.length;return!!L&&Yn(T,F,0)>-1}function di(T,F,L){for(var ie=-1,Ce=T==null?0:T.length;++ie<Ce;)if(L(F,T[ie]))return!0;return!1}function Qe(T,F){for(var L=-1,ie=T==null?0:T.length,Ce=Array(ie);++L<ie;)Ce[L]=F(T[L],L,T);return Ce}function vn(T,F){for(var L=-1,ie=F.length,Ce=T.length;++L<ie;)T[Ce+L]=F[L];return T}function fi(T,F,L,ie){var Ce=-1,Fe=T==null?0:T.length;for(ie&&Fe&&(L=T[++Ce]);++Ce<Fe;)L=F(L,T[Ce],Ce,T);return L}function Hf(T,F,L,ie){var Ce=T==null?0:T.length;for(ie&&Ce&&(L=T[--Ce]);Ce--;)L=F(L,T[Ce],Ce,T);return L}function hi(T,F){for(var L=-1,ie=T==null?0:T.length;++L<ie;)if(F(T[L],L,T))return!0;return!1}var Gf=pi("length");function zf(T){return T.split("")}function qf(T){return T.match(Jd)||[]}function Ia(T,F,L){var ie;return L(T,function(Ce,Fe,at){if(F(Ce,Fe,at))return ie=Fe,!1}),ie}function $r(T,F,L,ie){for(var Ce=T.length,Fe=L+(ie?1:-1);ie?Fe--:++Fe<Ce;)if(F(T[Fe],Fe,T))return Fe;return-1}function Yn(T,F,L){return F===F?rh(T,F,L):$r(T,La,L)}function $f(T,F,L,ie){for(var Ce=L-1,Fe=T.length;++Ce<Fe;)if(ie(T[Ce],F))return Ce;return-1}function La(T){return T!==T}function Ma(T,F){var L=T==null?0:T.length;return L?gi(T,F)/L:G}function pi(T){return function(F){return F==null?r:F[T]}}function mi(T){return function(F){return T==null?r:T[F]}}function Da(T,F,L,ie,Ce){return Ce(T,function(Fe,at,qe){L=ie?(ie=!1,Fe):F(L,Fe,at,qe)}),L}function Xf(T,F){var L=T.length;for(T.sort(F);L--;)T[L]=T[L].value;return T}function gi(T,F){for(var L,ie=-1,Ce=T.length;++ie<Ce;){var Fe=F(T[ie]);Fe!==r&&(L=L===r?Fe:L+Fe)}return L}function _i(T,F){for(var L=-1,ie=Array(T);++L<T;)ie[L]=F(L);return ie}function Yf(T,F){return Qe(F,function(L){return[L,T[L]]})}function Oa(T){return T&&T.slice(0,Wa(T)+1).replace(ri,"")}function Rt(T){return function(F){return T(F)}}function xi(T,F){return Qe(F,function(L){return T[L]})}function fr(T,F){return T.has(F)}function Ba(T,F){for(var L=-1,ie=T.length;++L<ie&&Yn(F,T[L],0)>-1;);return L}function Fa(T,F){for(var L=T.length;L--&&Yn(F,T[L],0)>-1;);return L}function Vf(T,F){for(var L=T.length,ie=0;L--;)T[L]===F&&++ie;return ie}var Kf=mi(If),Qf=mi(Lf);function Jf(T){return"\\"+Df[T]}function Zf(T,F){return T==null?r:T[F]}function Vn(T){return kf.test(T)}function eh(T){return Af.test(T)}function th(T){for(var F,L=[];!(F=T.next()).done;)L.push(F.value);return L}function vi(T){var F=-1,L=Array(T.size);return T.forEach(function(ie,Ce){L[++F]=[Ce,ie]}),L}function Ua(T,F){return function(L){return T(F(L))}}function bn(T,F){for(var L=-1,ie=T.length,Ce=0,Fe=[];++L<ie;){var at=T[L];(at===F||at===p)&&(T[L]=p,Fe[Ce++]=L)}return Fe}function Xr(T){var F=-1,L=Array(T.size);return T.forEach(function(ie){L[++F]=ie}),L}function nh(T){var F=-1,L=Array(T.size);return T.forEach(function(ie){L[++F]=[ie,ie]}),L}function rh(T,F,L){for(var ie=L-1,Ce=T.length;++ie<Ce;)if(T[ie]===F)return ie;return-1}function sh(T,F,L){for(var ie=L+1;ie--;)if(T[ie]===F)return ie;return ie}function Kn(T){return Vn(T)?oh(T):Gf(T)}function Gt(T){return Vn(T)?ah(T):zf(T)}function Wa(T){for(var F=T.length;F--&&Yd.test(T.charAt(F)););return F}var ih=mi(Mf);function oh(T){for(var F=li.lastIndex=0;li.test(T);)++F;return F}function ah(T){return T.match(li)||[]}function lh(T){return T.match(Rf)||[]}var ch=(function T(F){F=F==null?dt:Qn.defaults(dt.Object(),F,Qn.pick(dt,jf));var L=F.Array,ie=F.Date,Ce=F.Error,Fe=F.Function,at=F.Math,qe=F.Object,bi=F.RegExp,uh=F.String,Mt=F.TypeError,Yr=L.prototype,dh=Fe.prototype,Jn=qe.prototype,Vr=F["__core-js_shared__"],Kr=dh.toString,ze=Jn.hasOwnProperty,fh=0,Ha=(function(){var e=/[^.]+$/.exec(Vr&&Vr.keys&&Vr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),Qr=Jn.toString,hh=Kr.call(qe),ph=dt._,mh=bi("^"+Kr.call(ze).replace(ni,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Jr=Na?F.Buffer:r,yn=F.Symbol,Zr=F.Uint8Array,Ga=Jr?Jr.allocUnsafe:r,es=Ua(qe.getPrototypeOf,qe),za=qe.create,qa=Jn.propertyIsEnumerable,ts=Yr.splice,$a=yn?yn.isConcatSpreadable:r,hr=yn?yn.iterator:r,Ln=yn?yn.toStringTag:r,ns=(function(){try{var e=Fn(qe,"defineProperty");return e({},"",{}),e}catch{}})(),gh=F.clearTimeout!==dt.clearTimeout&&F.clearTimeout,_h=ie&&ie.now!==dt.Date.now&&ie.now,xh=F.setTimeout!==dt.setTimeout&&F.setTimeout,rs=at.ceil,ss=at.floor,yi=qe.getOwnPropertySymbols,vh=Jr?Jr.isBuffer:r,Xa=F.isFinite,bh=Yr.join,yh=Ua(qe.keys,qe),lt=at.max,pt=at.min,wh=ie.now,Eh=F.parseInt,Ya=at.random,Sh=Yr.reverse,wi=Fn(F,"DataView"),pr=Fn(F,"Map"),Ei=Fn(F,"Promise"),Zn=Fn(F,"Set"),mr=Fn(F,"WeakMap"),gr=Fn(qe,"create"),is=mr&&new mr,er={},Nh=Un(wi),Ch=Un(pr),Th=Un(Ei),Rh=Un(Zn),kh=Un(mr),os=yn?yn.prototype:r,_r=os?os.valueOf:r,Va=os?os.toString:r;function h(e){if(et(e)&&!Te(e)&&!(e instanceof Me)){if(e instanceof Dt)return e;if(ze.call(e,"__wrapped__"))return Kl(e)}return new Dt(e)}var tr=(function(){function e(){}return function(t){if(!Je(t))return{};if(za)return za(t);e.prototype=t;var s=new e;return e.prototype=r,s}})();function as(){}function Dt(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}h.templateSettings={escape:Hd,evaluate:Gd,interpolate:sa,variable:"",imports:{_:h}},h.prototype=as.prototype,h.prototype.constructor=h,Dt.prototype=tr(as.prototype),Dt.prototype.constructor=Dt;function Me(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Q,this.__views__=[]}function Ah(){var e=new Me(this.__wrapped__);return e.__actions__=Et(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Et(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Et(this.__views__),e}function jh(){if(this.__filtered__){var e=new Me(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Ph(){var e=this.__wrapped__.value(),t=this.__dir__,s=Te(e),c=t<0,f=s?e.length:0,g=zp(0,f,this.__views__),w=g.start,S=g.end,k=S-w,W=c?S:w-1,H=this.__iteratees__,V=H.length,ne=0,le=pt(k,this.__takeCount__);if(!s||!c&&f==k&&le==k)return vl(e,this.__actions__);var ve=[];e:for(;k--&&ne<le;){W+=t;for(var Ae=-1,be=e[W];++Ae<V;){var Pe=H[Ae],De=Pe.iteratee,jt=Pe.type,bt=De(be);if(jt==Y)be=bt;else if(!bt){if(jt==X)continue e;break e}}ve[ne++]=be}return ve}Me.prototype=tr(as.prototype),Me.prototype.constructor=Me;function Mn(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var c=e[t];this.set(c[0],c[1])}}function Ih(){this.__data__=gr?gr(null):{},this.size=0}function Lh(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Mh(e){var t=this.__data__;if(gr){var s=t[e];return s===u?r:s}return ze.call(t,e)?t[e]:r}function Dh(e){var t=this.__data__;return gr?t[e]!==r:ze.call(t,e)}function Oh(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=gr&&t===r?u:t,this}Mn.prototype.clear=Ih,Mn.prototype.delete=Lh,Mn.prototype.get=Mh,Mn.prototype.has=Dh,Mn.prototype.set=Oh;function ln(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var c=e[t];this.set(c[0],c[1])}}function Bh(){this.__data__=[],this.size=0}function Fh(e){var t=this.__data__,s=ls(t,e);if(s<0)return!1;var c=t.length-1;return s==c?t.pop():ts.call(t,s,1),--this.size,!0}function Uh(e){var t=this.__data__,s=ls(t,e);return s<0?r:t[s][1]}function Wh(e){return ls(this.__data__,e)>-1}function Hh(e,t){var s=this.__data__,c=ls(s,e);return c<0?(++this.size,s.push([e,t])):s[c][1]=t,this}ln.prototype.clear=Bh,ln.prototype.delete=Fh,ln.prototype.get=Uh,ln.prototype.has=Wh,ln.prototype.set=Hh;function cn(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var c=e[t];this.set(c[0],c[1])}}function Gh(){this.size=0,this.__data__={hash:new Mn,map:new(pr||ln),string:new Mn}}function zh(e){var t=bs(this,e).delete(e);return this.size-=t?1:0,t}function qh(e){return bs(this,e).get(e)}function $h(e){return bs(this,e).has(e)}function Xh(e,t){var s=bs(this,e),c=s.size;return s.set(e,t),this.size+=s.size==c?0:1,this}cn.prototype.clear=Gh,cn.prototype.delete=zh,cn.prototype.get=qh,cn.prototype.has=$h,cn.prototype.set=Xh;function Dn(e){var t=-1,s=e==null?0:e.length;for(this.__data__=new cn;++t<s;)this.add(e[t])}function Yh(e){return this.__data__.set(e,u),this}function Vh(e){return this.__data__.has(e)}Dn.prototype.add=Dn.prototype.push=Yh,Dn.prototype.has=Vh;function zt(e){var t=this.__data__=new ln(e);this.size=t.size}function Kh(){this.__data__=new ln,this.size=0}function Qh(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s}function Jh(e){return this.__data__.get(e)}function Zh(e){return this.__data__.has(e)}function ep(e,t){var s=this.__data__;if(s instanceof ln){var c=s.__data__;if(!pr||c.length<d-1)return c.push([e,t]),this.size=++s.size,this;s=this.__data__=new cn(c)}return s.set(e,t),this.size=s.size,this}zt.prototype.clear=Kh,zt.prototype.delete=Qh,zt.prototype.get=Jh,zt.prototype.has=Zh,zt.prototype.set=ep;function Ka(e,t){var s=Te(e),c=!s&&Wn(e),f=!s&&!c&&Cn(e),g=!s&&!c&&!f&&ir(e),w=s||c||f||g,S=w?_i(e.length,uh):[],k=S.length;for(var W in e)(t||ze.call(e,W))&&!(w&&(W=="length"||f&&(W=="offset"||W=="parent")||g&&(W=="buffer"||W=="byteLength"||W=="byteOffset")||hn(W,k)))&&S.push(W);return S}function Qa(e){var t=e.length;return t?e[Li(0,t-1)]:r}function tp(e,t){return ys(Et(e),On(t,0,e.length))}function np(e){return ys(Et(e))}function Si(e,t,s){(s!==r&&!qt(e[t],s)||s===r&&!(t in e))&&un(e,t,s)}function xr(e,t,s){var c=e[t];(!(ze.call(e,t)&&qt(c,s))||s===r&&!(t in e))&&un(e,t,s)}function ls(e,t){for(var s=e.length;s--;)if(qt(e[s][0],t))return s;return-1}function rp(e,t,s,c){return wn(e,function(f,g,w){t(c,f,s(f),w)}),c}function Ja(e,t){return e&&Jt(t,ut(t),e)}function sp(e,t){return e&&Jt(t,Nt(t),e)}function un(e,t,s){t=="__proto__"&&ns?ns(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function Ni(e,t){for(var s=-1,c=t.length,f=L(c),g=e==null;++s<c;)f[s]=g?r:io(e,t[s]);return f}function On(e,t,s){return e===e&&(s!==r&&(e=e<=s?e:s),t!==r&&(e=e>=t?e:t)),e}function Ot(e,t,s,c,f,g){var w,S=t&x,k=t&y,W=t&b;if(s&&(w=f?s(e,c,f,g):s(e)),w!==r)return w;if(!Je(e))return e;var H=Te(e);if(H){if(w=$p(e),!S)return Et(e,w)}else{var V=mt(e),ne=V==Be||V==We;if(Cn(e))return wl(e,S);if(V==Z||V==ae||ne&&!f){if(w=k||ne?{}:Wl(e),!S)return k?Mp(e,sp(w,e)):Lp(e,Ja(w,e))}else{if(!Xe[V])return f?e:{};w=Xp(e,V,S)}}g||(g=new zt);var le=g.get(e);if(le)return le;g.set(e,w),gc(e)?e.forEach(function(be){w.add(Ot(be,t,s,be,e,g))}):pc(e)&&e.forEach(function(be,Pe){w.set(Pe,Ot(be,t,s,Pe,e,g))});var ve=W?k?qi:zi:k?Nt:ut,Ae=H?r:ve(e);return Lt(Ae||e,function(be,Pe){Ae&&(Pe=be,be=e[Pe]),xr(w,Pe,Ot(be,t,s,Pe,e,g))}),w}function ip(e){var t=ut(e);return function(s){return Za(s,e,t)}}function Za(e,t,s){var c=s.length;if(e==null)return!c;for(e=qe(e);c--;){var f=s[c],g=t[f],w=e[f];if(w===r&&!(f in e)||!g(w))return!1}return!0}function el(e,t,s){if(typeof e!="function")throw new Mt(_);return Nr(function(){e.apply(r,s)},t)}function vr(e,t,s,c){var f=-1,g=qr,w=!0,S=e.length,k=[],W=t.length;if(!S)return k;s&&(t=Qe(t,Rt(s))),c?(g=di,w=!1):t.length>=d&&(g=fr,w=!1,t=new Dn(t));e:for(;++f<S;){var H=e[f],V=s==null?H:s(H);if(H=c||H!==0?H:0,w&&V===V){for(var ne=W;ne--;)if(t[ne]===V)continue e;k.push(H)}else g(t,V,c)||k.push(H)}return k}var wn=Tl(Qt),tl=Tl(Ti,!0);function op(e,t){var s=!0;return wn(e,function(c,f,g){return s=!!t(c,f,g),s}),s}function cs(e,t,s){for(var c=-1,f=e.length;++c<f;){var g=e[c],w=t(g);if(w!=null&&(S===r?w===w&&!At(w):s(w,S)))var S=w,k=g}return k}function ap(e,t,s,c){var f=e.length;for(s=ke(s),s<0&&(s=-s>f?0:f+s),c=c===r||c>f?f:ke(c),c<0&&(c+=f),c=s>c?0:xc(c);s<c;)e[s++]=t;return e}function nl(e,t){var s=[];return wn(e,function(c,f,g){t(c,f,g)&&s.push(c)}),s}function ft(e,t,s,c,f){var g=-1,w=e.length;for(s||(s=Vp),f||(f=[]);++g<w;){var S=e[g];t>0&&s(S)?t>1?ft(S,t-1,s,c,f):vn(f,S):c||(f[f.length]=S)}return f}var Ci=Rl(),rl=Rl(!0);function Qt(e,t){return e&&Ci(e,t,ut)}function Ti(e,t){return e&&rl(e,t,ut)}function us(e,t){return xn(t,function(s){return pn(e[s])})}function Bn(e,t){t=Sn(t,e);for(var s=0,c=t.length;e!=null&&s<c;)e=e[Zt(t[s++])];return s&&s==c?e:r}function sl(e,t,s){var c=t(e);return Te(e)?c:vn(c,s(e))}function xt(e){return e==null?e===r?ct:ee:Ln&&Ln in qe(e)?Gp(e):nm(e)}function Ri(e,t){return e>t}function lp(e,t){return e!=null&&ze.call(e,t)}function cp(e,t){return e!=null&&t in qe(e)}function up(e,t,s){return e>=pt(t,s)&&e<lt(t,s)}function ki(e,t,s){for(var c=s?di:qr,f=e[0].length,g=e.length,w=g,S=L(g),k=1/0,W=[];w--;){var H=e[w];w&&t&&(H=Qe(H,Rt(t))),k=pt(H.length,k),S[w]=!s&&(t||f>=120&&H.length>=120)?new Dn(w&&H):r}H=e[0];var V=-1,ne=S[0];e:for(;++V<f&&W.length<k;){var le=H[V],ve=t?t(le):le;if(le=s||le!==0?le:0,!(ne?fr(ne,ve):c(W,ve,s))){for(w=g;--w;){var Ae=S[w];if(!(Ae?fr(Ae,ve):c(e[w],ve,s)))continue e}ne&&ne.push(ve),W.push(le)}}return W}function dp(e,t,s,c){return Qt(e,function(f,g,w){t(c,s(f),g,w)}),c}function br(e,t,s){t=Sn(t,e),e=ql(e,t);var c=e==null?e:e[Zt(Ft(t))];return c==null?r:Tt(c,e,s)}function il(e){return et(e)&&xt(e)==ae}function fp(e){return et(e)&&xt(e)==it}function hp(e){return et(e)&&xt(e)==B}function yr(e,t,s,c,f){return e===t?!0:e==null||t==null||!et(e)&&!et(t)?e!==e&&t!==t:pp(e,t,s,c,yr,f)}function pp(e,t,s,c,f,g){var w=Te(e),S=Te(t),k=w?Ue:mt(e),W=S?Ue:mt(t);k=k==ae?Z:k,W=W==ae?Z:W;var H=k==Z,V=W==Z,ne=k==W;if(ne&&Cn(e)){if(!Cn(t))return!1;w=!0,H=!1}if(ne&&!H)return g||(g=new zt),w||ir(e)?Bl(e,t,s,c,f,g):Wp(e,t,k,s,c,f,g);if(!(s&N)){var le=H&&ze.call(e,"__wrapped__"),ve=V&&ze.call(t,"__wrapped__");if(le||ve){var Ae=le?e.value():e,be=ve?t.value():t;return g||(g=new zt),f(Ae,be,s,c,g)}}return ne?(g||(g=new zt),Hp(e,t,s,c,f,g)):!1}function mp(e){return et(e)&&mt(e)==de}function Ai(e,t,s,c){var f=s.length,g=f,w=!c;if(e==null)return!g;for(e=qe(e);f--;){var S=s[f];if(w&&S[2]?S[1]!==e[S[0]]:!(S[0]in e))return!1}for(;++f<g;){S=s[f];var k=S[0],W=e[k],H=S[1];if(w&&S[2]){if(W===r&&!(k in e))return!1}else{var V=new zt;if(c)var ne=c(W,H,k,e,t,V);if(!(ne===r?yr(H,W,N|I,c,V):ne))return!1}}return!0}function ol(e){if(!Je(e)||Qp(e))return!1;var t=pn(e)?mh:sf;return t.test(Un(e))}function gp(e){return et(e)&&xt(e)==fe}function _p(e){return et(e)&&mt(e)==_e}function xp(e){return et(e)&&Ts(e.length)&&!!Ke[xt(e)]}function al(e){return typeof e=="function"?e:e==null?Ct:typeof e=="object"?Te(e)?ul(e[0],e[1]):cl(e):kc(e)}function ji(e){if(!Sr(e))return yh(e);var t=[];for(var s in qe(e))ze.call(e,s)&&s!="constructor"&&t.push(s);return t}function vp(e){if(!Je(e))return tm(e);var t=Sr(e),s=[];for(var c in e)c=="constructor"&&(t||!ze.call(e,c))||s.push(c);return s}function Pi(e,t){return e<t}function ll(e,t){var s=-1,c=St(e)?L(e.length):[];return wn(e,function(f,g,w){c[++s]=t(f,g,w)}),c}function cl(e){var t=Xi(e);return t.length==1&&t[0][2]?Gl(t[0][0],t[0][1]):function(s){return s===e||Ai(s,e,t)}}function ul(e,t){return Vi(e)&&Hl(t)?Gl(Zt(e),t):function(s){var c=io(s,e);return c===r&&c===t?oo(s,e):yr(t,c,N|I)}}function ds(e,t,s,c,f){e!==t&&Ci(t,function(g,w){if(f||(f=new zt),Je(g))bp(e,t,w,s,ds,c,f);else{var S=c?c(Qi(e,w),g,w+"",e,t,f):r;S===r&&(S=g),Si(e,w,S)}},Nt)}function bp(e,t,s,c,f,g,w){var S=Qi(e,s),k=Qi(t,s),W=w.get(k);if(W){Si(e,s,W);return}var H=g?g(S,k,s+"",e,t,w):r,V=H===r;if(V){var ne=Te(k),le=!ne&&Cn(k),ve=!ne&&!le&&ir(k);H=k,ne||le||ve?Te(S)?H=S:rt(S)?H=Et(S):le?(V=!1,H=wl(k,!0)):ve?(V=!1,H=El(k,!0)):H=[]:Cr(k)||Wn(k)?(H=S,Wn(S)?H=vc(S):(!Je(S)||pn(S))&&(H=Wl(k))):V=!1}V&&(w.set(k,H),f(H,k,c,g,w),w.delete(k)),Si(e,s,H)}function dl(e,t){var s=e.length;if(s)return t+=t<0?s:0,hn(t,s)?e[t]:r}function fl(e,t,s){t.length?t=Qe(t,function(g){return Te(g)?function(w){return Bn(w,g.length===1?g[0]:g)}:g}):t=[Ct];var c=-1;t=Qe(t,Rt(ge()));var f=ll(e,function(g,w,S){var k=Qe(t,function(W){return W(g)});return{criteria:k,index:++c,value:g}});return Xf(f,function(g,w){return Ip(g,w,s)})}function yp(e,t){return hl(e,t,function(s,c){return oo(e,c)})}function hl(e,t,s){for(var c=-1,f=t.length,g={};++c<f;){var w=t[c],S=Bn(e,w);s(S,w)&&wr(g,Sn(w,e),S)}return g}function wp(e){return function(t){return Bn(t,e)}}function Ii(e,t,s,c){var f=c?$f:Yn,g=-1,w=t.length,S=e;for(e===t&&(t=Et(t)),s&&(S=Qe(e,Rt(s)));++g<w;)for(var k=0,W=t[g],H=s?s(W):W;(k=f(S,H,k,c))>-1;)S!==e&&ts.call(S,k,1),ts.call(e,k,1);return e}function pl(e,t){for(var s=e?t.length:0,c=s-1;s--;){var f=t[s];if(s==c||f!==g){var g=f;hn(f)?ts.call(e,f,1):Oi(e,f)}}return e}function Li(e,t){return e+ss(Ya()*(t-e+1))}function Ep(e,t,s,c){for(var f=-1,g=lt(rs((t-e)/(s||1)),0),w=L(g);g--;)w[c?g:++f]=e,e+=s;return w}function Mi(e,t){var s="";if(!e||t<1||t>oe)return s;do t%2&&(s+=e),t=ss(t/2),t&&(e+=e);while(t);return s}function je(e,t){return Ji(zl(e,t,Ct),e+"")}function Sp(e){return Qa(or(e))}function Np(e,t){var s=or(e);return ys(s,On(t,0,s.length))}function wr(e,t,s,c){if(!Je(e))return e;t=Sn(t,e);for(var f=-1,g=t.length,w=g-1,S=e;S!=null&&++f<g;){var k=Zt(t[f]),W=s;if(k==="__proto__"||k==="constructor"||k==="prototype")return e;if(f!=w){var H=S[k];W=c?c(H,k,S):r,W===r&&(W=Je(H)?H:hn(t[f+1])?[]:{})}xr(S,k,W),S=S[k]}return e}var ml=is?function(e,t){return is.set(e,t),e}:Ct,Cp=ns?function(e,t){return ns(e,"toString",{configurable:!0,enumerable:!1,value:lo(t),writable:!0})}:Ct;function Tp(e){return ys(or(e))}function Bt(e,t,s){var c=-1,f=e.length;t<0&&(t=-t>f?0:f+t),s=s>f?f:s,s<0&&(s+=f),f=t>s?0:s-t>>>0,t>>>=0;for(var g=L(f);++c<f;)g[c]=e[c+t];return g}function Rp(e,t){var s;return wn(e,function(c,f,g){return s=t(c,f,g),!s}),!!s}function fs(e,t,s){var c=0,f=e==null?c:e.length;if(typeof t=="number"&&t===t&&f<=te){for(;c<f;){var g=c+f>>>1,w=e[g];w!==null&&!At(w)&&(s?w<=t:w<t)?c=g+1:f=g}return f}return Di(e,t,Ct,s)}function Di(e,t,s,c){var f=0,g=e==null?0:e.length;if(g===0)return 0;t=s(t);for(var w=t!==t,S=t===null,k=At(t),W=t===r;f<g;){var H=ss((f+g)/2),V=s(e[H]),ne=V!==r,le=V===null,ve=V===V,Ae=At(V);if(w)var be=c||ve;else W?be=ve&&(c||ne):S?be=ve&&ne&&(c||!le):k?be=ve&&ne&&!le&&(c||!Ae):le||Ae?be=!1:be=c?V<=t:V<t;be?f=H+1:g=H}return pt(g,ue)}function gl(e,t){for(var s=-1,c=e.length,f=0,g=[];++s<c;){var w=e[s],S=t?t(w):w;if(!s||!qt(S,k)){var k=S;g[f++]=w===0?0:w}}return g}function _l(e){return typeof e=="number"?e:At(e)?G:+e}function kt(e){if(typeof e=="string")return e;if(Te(e))return Qe(e,kt)+"";if(At(e))return Va?Va.call(e):"";var t=e+"";return t=="0"&&1/e==-se?"-0":t}function En(e,t,s){var c=-1,f=qr,g=e.length,w=!0,S=[],k=S;if(s)w=!1,f=di;else if(g>=d){var W=t?null:Fp(e);if(W)return Xr(W);w=!1,f=fr,k=new Dn}else k=t?[]:S;e:for(;++c<g;){var H=e[c],V=t?t(H):H;if(H=s||H!==0?H:0,w&&V===V){for(var ne=k.length;ne--;)if(k[ne]===V)continue e;t&&k.push(V),S.push(H)}else f(k,V,s)||(k!==S&&k.push(V),S.push(H))}return S}function Oi(e,t){return t=Sn(t,e),e=ql(e,t),e==null||delete e[Zt(Ft(t))]}function xl(e,t,s,c){return wr(e,t,s(Bn(e,t)),c)}function hs(e,t,s,c){for(var f=e.length,g=c?f:-1;(c?g--:++g<f)&&t(e[g],g,e););return s?Bt(e,c?0:g,c?g+1:f):Bt(e,c?g+1:0,c?f:g)}function vl(e,t){var s=e;return s instanceof Me&&(s=s.value()),fi(t,function(c,f){return f.func.apply(f.thisArg,vn([c],f.args))},s)}function Bi(e,t,s){var c=e.length;if(c<2)return c?En(e[0]):[];for(var f=-1,g=L(c);++f<c;)for(var w=e[f],S=-1;++S<c;)S!=f&&(g[f]=vr(g[f]||w,e[S],t,s));return En(ft(g,1),t,s)}function bl(e,t,s){for(var c=-1,f=e.length,g=t.length,w={};++c<f;){var S=c<g?t[c]:r;s(w,e[c],S)}return w}function Fi(e){return rt(e)?e:[]}function Ui(e){return typeof e=="function"?e:Ct}function Sn(e,t){return Te(e)?e:Vi(e,t)?[e]:Vl(He(e))}var kp=je;function Nn(e,t,s){var c=e.length;return s=s===r?c:s,!t&&s>=c?e:Bt(e,t,s)}var yl=gh||function(e){return dt.clearTimeout(e)};function wl(e,t){if(t)return e.slice();var s=e.length,c=Ga?Ga(s):new e.constructor(s);return e.copy(c),c}function Wi(e){var t=new e.constructor(e.byteLength);return new Zr(t).set(new Zr(e)),t}function Ap(e,t){var s=t?Wi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function jp(e){var t=new e.constructor(e.source,ia.exec(e));return t.lastIndex=e.lastIndex,t}function Pp(e){return _r?qe(_r.call(e)):{}}function El(e,t){var s=t?Wi(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function Sl(e,t){if(e!==t){var s=e!==r,c=e===null,f=e===e,g=At(e),w=t!==r,S=t===null,k=t===t,W=At(t);if(!S&&!W&&!g&&e>t||g&&w&&k&&!S&&!W||c&&w&&k||!s&&k||!f)return 1;if(!c&&!g&&!W&&e<t||W&&s&&f&&!c&&!g||S&&s&&f||!w&&f||!k)return-1}return 0}function Ip(e,t,s){for(var c=-1,f=e.criteria,g=t.criteria,w=f.length,S=s.length;++c<w;){var k=Sl(f[c],g[c]);if(k){if(c>=S)return k;var W=s[c];return k*(W=="desc"?-1:1)}}return e.index-t.index}function Nl(e,t,s,c){for(var f=-1,g=e.length,w=s.length,S=-1,k=t.length,W=lt(g-w,0),H=L(k+W),V=!c;++S<k;)H[S]=t[S];for(;++f<w;)(V||f<g)&&(H[s[f]]=e[f]);for(;W--;)H[S++]=e[f++];return H}function Cl(e,t,s,c){for(var f=-1,g=e.length,w=-1,S=s.length,k=-1,W=t.length,H=lt(g-S,0),V=L(H+W),ne=!c;++f<H;)V[f]=e[f];for(var le=f;++k<W;)V[le+k]=t[k];for(;++w<S;)(ne||f<g)&&(V[le+s[w]]=e[f++]);return V}function Et(e,t){var s=-1,c=e.length;for(t||(t=L(c));++s<c;)t[s]=e[s];return t}function Jt(e,t,s,c){var f=!s;s||(s={});for(var g=-1,w=t.length;++g<w;){var S=t[g],k=c?c(s[S],e[S],S,s,e):r;k===r&&(k=e[S]),f?un(s,S,k):xr(s,S,k)}return s}function Lp(e,t){return Jt(e,Yi(e),t)}function Mp(e,t){return Jt(e,Fl(e),t)}function ps(e,t){return function(s,c){var f=Te(s)?Uf:rp,g=t?t():{};return f(s,e,ge(c,2),g)}}function nr(e){return je(function(t,s){var c=-1,f=s.length,g=f>1?s[f-1]:r,w=f>2?s[2]:r;for(g=e.length>3&&typeof g=="function"?(f--,g):r,w&&vt(s[0],s[1],w)&&(g=f<3?r:g,f=1),t=qe(t);++c<f;){var S=s[c];S&&e(t,S,c,g)}return t})}function Tl(e,t){return function(s,c){if(s==null)return s;if(!St(s))return e(s,c);for(var f=s.length,g=t?f:-1,w=qe(s);(t?g--:++g<f)&&c(w[g],g,w)!==!1;);return s}}function Rl(e){return function(t,s,c){for(var f=-1,g=qe(t),w=c(t),S=w.length;S--;){var k=w[e?S:++f];if(s(g[k],k,g)===!1)break}return t}}function Dp(e,t,s){var c=t&A,f=Er(e);function g(){var w=this&&this!==dt&&this instanceof g?f:e;return w.apply(c?s:this,arguments)}return g}function kl(e){return function(t){t=He(t);var s=Vn(t)?Gt(t):r,c=s?s[0]:t.charAt(0),f=s?Nn(s,1).join(""):t.slice(1);return c[e]()+f}}function rr(e){return function(t){return fi(Tc(Cc(t).replace(Cf,"")),e,"")}}function Er(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 s=tr(e.prototype),c=e.apply(s,t);return Je(c)?c:s}}function Op(e,t,s){var c=Er(e);function f(){for(var g=arguments.length,w=L(g),S=g,k=sr(f);S--;)w[S]=arguments[S];var W=g<3&&w[0]!==k&&w[g-1]!==k?[]:bn(w,k);if(g-=W.length,g<s)return Ll(e,t,ms,f.placeholder,r,w,W,r,r,s-g);var H=this&&this!==dt&&this instanceof f?c:e;return Tt(H,this,w)}return f}function Al(e){return function(t,s,c){var f=qe(t);if(!St(t)){var g=ge(s,3);t=ut(t),s=function(S){return g(f[S],S,f)}}var w=e(t,s,c);return w>-1?f[g?t[w]:w]:r}}function jl(e){return fn(function(t){var s=t.length,c=s,f=Dt.prototype.thru;for(e&&t.reverse();c--;){var g=t[c];if(typeof g!="function")throw new Mt(_);if(f&&!w&&vs(g)=="wrapper")var w=new Dt([],!0)}for(c=w?c:s;++c<s;){g=t[c];var S=vs(g),k=S=="wrapper"?$i(g):r;k&&Ki(k[0])&&k[1]==(q|P|z|$)&&!k[4].length&&k[9]==1?w=w[vs(k[0])].apply(w,k[3]):w=g.length==1&&Ki(g)?w[S]():w.thru(g)}return function(){var W=arguments,H=W[0];if(w&&W.length==1&&Te(H))return w.plant(H).value();for(var V=0,ne=s?t[V].apply(this,W):H;++V<s;)ne=t[V].call(this,ne);return ne}})}function ms(e,t,s,c,f,g,w,S,k,W){var H=t&q,V=t&A,ne=t&D,le=t&(P|j),ve=t&O,Ae=ne?r:Er(e);function be(){for(var Pe=arguments.length,De=L(Pe),jt=Pe;jt--;)De[jt]=arguments[jt];if(le)var bt=sr(be),Pt=Vf(De,bt);if(c&&(De=Nl(De,c,f,le)),g&&(De=Cl(De,g,w,le)),Pe-=Pt,le&&Pe<W){var st=bn(De,bt);return Ll(e,t,ms,be.placeholder,s,De,st,S,k,W-Pe)}var $t=V?s:this,gn=ne?$t[e]:e;return Pe=De.length,S?De=rm(De,S):ve&&Pe>1&&De.reverse(),H&&k<Pe&&(De.length=k),this&&this!==dt&&this instanceof be&&(gn=Ae||Er(gn)),gn.apply($t,De)}return be}function Pl(e,t){return function(s,c){return dp(s,e,t(c),{})}}function gs(e,t){return function(s,c){var f;if(s===r&&c===r)return t;if(s!==r&&(f=s),c!==r){if(f===r)return c;typeof s=="string"||typeof c=="string"?(s=kt(s),c=kt(c)):(s=_l(s),c=_l(c)),f=e(s,c)}return f}}function Hi(e){return fn(function(t){return t=Qe(t,Rt(ge())),je(function(s){var c=this;return e(t,function(f){return Tt(f,c,s)})})})}function _s(e,t){t=t===r?" ":kt(t);var s=t.length;if(s<2)return s?Mi(t,e):t;var c=Mi(t,rs(e/Kn(t)));return Vn(t)?Nn(Gt(c),0,e).join(""):c.slice(0,e)}function Bp(e,t,s,c){var f=t&A,g=Er(e);function w(){for(var S=-1,k=arguments.length,W=-1,H=c.length,V=L(H+k),ne=this&&this!==dt&&this instanceof w?g:e;++W<H;)V[W]=c[W];for(;k--;)V[W++]=arguments[++S];return Tt(ne,f?s:this,V)}return w}function Il(e){return function(t,s,c){return c&&typeof c!="number"&&vt(t,s,c)&&(s=c=r),t=mn(t),s===r?(s=t,t=0):s=mn(s),c=c===r?t<s?1:-1:mn(c),Ep(t,s,c,e)}}function xs(e){return function(t,s){return typeof t=="string"&&typeof s=="string"||(t=Ut(t),s=Ut(s)),e(t,s)}}function Ll(e,t,s,c,f,g,w,S,k,W){var H=t&P,V=H?w:r,ne=H?r:w,le=H?g:r,ve=H?r:g;t|=H?z:J,t&=~(H?J:z),t&M||(t&=-4);var Ae=[e,t,f,le,V,ve,ne,S,k,W],be=s.apply(r,Ae);return Ki(e)&&$l(be,Ae),be.placeholder=c,Xl(be,e,t)}function Gi(e){var t=at[e];return function(s,c){if(s=Ut(s),c=c==null?0:pt(ke(c),292),c&&Xa(s)){var f=(He(s)+"e").split("e"),g=t(f[0]+"e"+(+f[1]+c));return f=(He(g)+"e").split("e"),+(f[0]+"e"+(+f[1]-c))}return t(s)}}var Fp=Zn&&1/Xr(new Zn([,-0]))[1]==se?function(e){return new Zn(e)}:fo;function Ml(e){return function(t){var s=mt(t);return s==de?vi(t):s==_e?nh(t):Yf(t,e(t))}}function dn(e,t,s,c,f,g,w,S){var k=t&D;if(!k&&typeof e!="function")throw new Mt(_);var W=c?c.length:0;if(W||(t&=-97,c=f=r),w=w===r?w:lt(ke(w),0),S=S===r?S:ke(S),W-=f?f.length:0,t&J){var H=c,V=f;c=f=r}var ne=k?r:$i(e),le=[e,t,s,c,f,H,V,g,w,S];if(ne&&em(le,ne),e=le[0],t=le[1],s=le[2],c=le[3],f=le[4],S=le[9]=le[9]===r?k?0:e.length:lt(le[9]-W,0),!S&&t&(P|j)&&(t&=-25),!t||t==A)var ve=Dp(e,t,s);else t==P||t==j?ve=Op(e,t,S):(t==z||t==(A|z))&&!f.length?ve=Bp(e,t,s,c):ve=ms.apply(r,le);var Ae=ne?ml:$l;return Xl(Ae(ve,le),e,t)}function Dl(e,t,s,c){return e===r||qt(e,Jn[s])&&!ze.call(c,s)?t:e}function Ol(e,t,s,c,f,g){return Je(e)&&Je(t)&&(g.set(t,e),ds(e,t,r,Ol,g),g.delete(t)),e}function Up(e){return Cr(e)?r:e}function Bl(e,t,s,c,f,g){var w=s&N,S=e.length,k=t.length;if(S!=k&&!(w&&k>S))return!1;var W=g.get(e),H=g.get(t);if(W&&H)return W==t&&H==e;var V=-1,ne=!0,le=s&I?new Dn:r;for(g.set(e,t),g.set(t,e);++V<S;){var ve=e[V],Ae=t[V];if(c)var be=w?c(Ae,ve,V,t,e,g):c(ve,Ae,V,e,t,g);if(be!==r){if(be)continue;ne=!1;break}if(le){if(!hi(t,function(Pe,De){if(!fr(le,De)&&(ve===Pe||f(ve,Pe,s,c,g)))return le.push(De)})){ne=!1;break}}else if(!(ve===Ae||f(ve,Ae,s,c,g))){ne=!1;break}}return g.delete(e),g.delete(t),ne}function Wp(e,t,s,c,f,g,w){switch(s){case Ve:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case it:return!(e.byteLength!=t.byteLength||!g(new Zr(e),new Zr(t)));case Ge:case B:case Se:return qt(+e,+t);case ye:return e.name==t.name&&e.message==t.message;case fe:case Ne:return e==t+"";case de:var S=vi;case _e:var k=c&N;if(S||(S=Xr),e.size!=t.size&&!k)return!1;var W=w.get(e);if(W)return W==t;c|=I,w.set(e,t);var H=Bl(S(e),S(t),c,f,g,w);return w.delete(e),H;case he:if(_r)return _r.call(e)==_r.call(t)}return!1}function Hp(e,t,s,c,f,g){var w=s&N,S=zi(e),k=S.length,W=zi(t),H=W.length;if(k!=H&&!w)return!1;for(var V=k;V--;){var ne=S[V];if(!(w?ne in t:ze.call(t,ne)))return!1}var le=g.get(e),ve=g.get(t);if(le&&ve)return le==t&&ve==e;var Ae=!0;g.set(e,t),g.set(t,e);for(var be=w;++V<k;){ne=S[V];var Pe=e[ne],De=t[ne];if(c)var jt=w?c(De,Pe,ne,t,e,g):c(Pe,De,ne,e,t,g);if(!(jt===r?Pe===De||f(Pe,De,s,c,g):jt)){Ae=!1;break}be||(be=ne=="constructor")}if(Ae&&!be){var bt=e.constructor,Pt=t.constructor;bt!=Pt&&"constructor"in e&&"constructor"in t&&!(typeof bt=="function"&&bt instanceof bt&&typeof Pt=="function"&&Pt instanceof Pt)&&(Ae=!1)}return g.delete(e),g.delete(t),Ae}function fn(e){return Ji(zl(e,r,Zl),e+"")}function zi(e){return sl(e,ut,Yi)}function qi(e){return sl(e,Nt,Fl)}var $i=is?function(e){return is.get(e)}:fo;function vs(e){for(var t=e.name+"",s=er[t],c=ze.call(er,t)?s.length:0;c--;){var f=s[c],g=f.func;if(g==null||g==e)return f.name}return t}function sr(e){var t=ze.call(h,"placeholder")?h:e;return t.placeholder}function ge(){var e=h.iteratee||co;return e=e===co?al:e,arguments.length?e(arguments[0],arguments[1]):e}function bs(e,t){var s=e.__data__;return Kp(t)?s[typeof t=="string"?"string":"hash"]:s.map}function Xi(e){for(var t=ut(e),s=t.length;s--;){var c=t[s],f=e[c];t[s]=[c,f,Hl(f)]}return t}function Fn(e,t){var s=Zf(e,t);return ol(s)?s:r}function Gp(e){var t=ze.call(e,Ln),s=e[Ln];try{e[Ln]=r;var c=!0}catch{}var f=Qr.call(e);return c&&(t?e[Ln]=s:delete e[Ln]),f}var Yi=yi?function(e){return e==null?[]:(e=qe(e),xn(yi(e),function(t){return qa.call(e,t)}))}:ho,Fl=yi?function(e){for(var t=[];e;)vn(t,Yi(e)),e=es(e);return t}:ho,mt=xt;(wi&&mt(new wi(new ArrayBuffer(1)))!=Ve||pr&&mt(new pr)!=de||Ei&&mt(Ei.resolve())!=we||Zn&&mt(new Zn)!=_e||mr&&mt(new mr)!=yt)&&(mt=function(e){var t=xt(e),s=t==Z?e.constructor:r,c=s?Un(s):"";if(c)switch(c){case Nh:return Ve;case Ch:return de;case Th:return we;case Rh:return _e;case kh:return yt}return t});function zp(e,t,s){for(var c=-1,f=s.length;++c<f;){var g=s[c],w=g.size;switch(g.type){case"drop":e+=w;break;case"dropRight":t-=w;break;case"take":t=pt(t,e+w);break;case"takeRight":e=lt(e,t-w);break}}return{start:e,end:t}}function qp(e){var t=e.match(Kd);return t?t[1].split(Qd):[]}function Ul(e,t,s){t=Sn(t,e);for(var c=-1,f=t.length,g=!1;++c<f;){var w=Zt(t[c]);if(!(g=e!=null&&s(e,w)))break;e=e[w]}return g||++c!=f?g:(f=e==null?0:e.length,!!f&&Ts(f)&&hn(w,f)&&(Te(e)||Wn(e)))}function $p(e){var t=e.length,s=new e.constructor(t);return t&&typeof e[0]=="string"&&ze.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function Wl(e){return typeof e.constructor=="function"&&!Sr(e)?tr(es(e)):{}}function Xp(e,t,s){var c=e.constructor;switch(t){case it:return Wi(e);case Ge:case B:return new c(+e);case Ve:return Ap(e,s);case zn:case jn:case Pn:case qn:case dr:case an:case $n:case U:case xe:return El(e,s);case de:return new c;case Se:case Ne:return new c(e);case fe:return jp(e);case _e:return new c;case he:return Pp(e)}}function Yp(e,t){var s=t.length;if(!s)return e;var c=s-1;return t[c]=(s>1?"& ":"")+t[c],t=t.join(s>2?", ":" "),e.replace(Vd,`{
|
|
7
|
+
/* [wrapped with `+t+`] */
|
|
8
|
+
`)}function Vp(e){return Te(e)||Wn(e)||!!($a&&e&&e[$a])}function hn(e,t){var s=typeof e;return t=t??oe,!!t&&(s=="number"||s!="symbol"&&af.test(e))&&e>-1&&e%1==0&&e<t}function vt(e,t,s){if(!Je(s))return!1;var c=typeof t;return(c=="number"?St(s)&&hn(t,s.length):c=="string"&&t in s)?qt(s[t],e):!1}function Vi(e,t){if(Te(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||At(e)?!0:qd.test(e)||!zd.test(e)||t!=null&&e in qe(t)}function Kp(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ki(e){var t=vs(e),s=h[t];if(typeof s!="function"||!(t in Me.prototype))return!1;if(e===s)return!0;var c=$i(s);return!!c&&e===c[0]}function Qp(e){return!!Ha&&Ha in e}var Jp=Vr?pn:po;function Sr(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||Jn;return e===s}function Hl(e){return e===e&&!Je(e)}function Gl(e,t){return function(s){return s==null?!1:s[e]===t&&(t!==r||e in qe(s))}}function Zp(e){var t=Ns(e,function(c){return s.size===m&&s.clear(),c}),s=t.cache;return t}function em(e,t){var s=e[1],c=t[1],f=s|c,g=f<(A|D|q),w=c==q&&s==P||c==q&&s==$&&e[7].length<=t[8]||c==(q|$)&&t[7].length<=t[8]&&s==P;if(!(g||w))return e;c&A&&(e[2]=t[2],f|=s&A?0:M);var S=t[3];if(S){var k=e[3];e[3]=k?Nl(k,S,t[4]):S,e[4]=k?bn(e[3],p):t[4]}return S=t[5],S&&(k=e[5],e[5]=k?Cl(k,S,t[6]):S,e[6]=k?bn(e[5],p):t[6]),S=t[7],S&&(e[7]=S),c&q&&(e[8]=e[8]==null?t[8]:pt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=f,e}function tm(e){var t=[];if(e!=null)for(var s in qe(e))t.push(s);return t}function nm(e){return Qr.call(e)}function zl(e,t,s){return t=lt(t===r?e.length-1:t,0),function(){for(var c=arguments,f=-1,g=lt(c.length-t,0),w=L(g);++f<g;)w[f]=c[t+f];f=-1;for(var S=L(t+1);++f<t;)S[f]=c[f];return S[t]=s(w),Tt(e,this,S)}}function ql(e,t){return t.length<2?e:Bn(e,Bt(t,0,-1))}function rm(e,t){for(var s=e.length,c=pt(t.length,s),f=Et(e);c--;){var g=t[c];e[c]=hn(g,s)?f[g]:r}return e}function Qi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var $l=Yl(ml),Nr=xh||function(e,t){return dt.setTimeout(e,t)},Ji=Yl(Cp);function Xl(e,t,s){var c=t+"";return Ji(e,Yp(c,sm(qp(c),s)))}function Yl(e){var t=0,s=0;return function(){var c=wh(),f=pe-(c-s);if(s=c,f>0){if(++t>=re)return arguments[0]}else t=0;return e.apply(r,arguments)}}function ys(e,t){var s=-1,c=e.length,f=c-1;for(t=t===r?c:t;++s<t;){var g=Li(s,f),w=e[g];e[g]=e[s],e[s]=w}return e.length=t,e}var Vl=Zp(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace($d,function(s,c,f,g){t.push(f?g.replace(ef,"$1"):c||s)}),t});function Zt(e){if(typeof e=="string"||At(e))return e;var t=e+"";return t=="0"&&1/e==-se?"-0":t}function Un(e){if(e!=null){try{return Kr.call(e)}catch{}try{return e+""}catch{}}return""}function sm(e,t){return Lt(me,function(s){var c="_."+s[0];t&s[1]&&!qr(e,c)&&e.push(c)}),e.sort()}function Kl(e){if(e instanceof Me)return e.clone();var t=new Dt(e.__wrapped__,e.__chain__);return t.__actions__=Et(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function im(e,t,s){(s?vt(e,t,s):t===r)?t=1:t=lt(ke(t),0);var c=e==null?0:e.length;if(!c||t<1)return[];for(var f=0,g=0,w=L(rs(c/t));f<c;)w[g++]=Bt(e,f,f+=t);return w}function om(e){for(var t=-1,s=e==null?0:e.length,c=0,f=[];++t<s;){var g=e[t];g&&(f[c++]=g)}return f}function am(){var e=arguments.length;if(!e)return[];for(var t=L(e-1),s=arguments[0],c=e;c--;)t[c-1]=arguments[c];return vn(Te(s)?Et(s):[s],ft(t,1))}var lm=je(function(e,t){return rt(e)?vr(e,ft(t,1,rt,!0)):[]}),cm=je(function(e,t){var s=Ft(t);return rt(s)&&(s=r),rt(e)?vr(e,ft(t,1,rt,!0),ge(s,2)):[]}),um=je(function(e,t){var s=Ft(t);return rt(s)&&(s=r),rt(e)?vr(e,ft(t,1,rt,!0),r,s):[]});function dm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:ke(t),Bt(e,t<0?0:t,c)):[]}function fm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:ke(t),t=c-t,Bt(e,0,t<0?0:t)):[]}function hm(e,t){return e&&e.length?hs(e,ge(t,3),!0,!0):[]}function pm(e,t){return e&&e.length?hs(e,ge(t,3),!0):[]}function mm(e,t,s,c){var f=e==null?0:e.length;return f?(s&&typeof s!="number"&&vt(e,t,s)&&(s=0,c=f),ap(e,t,s,c)):[]}function Ql(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:ke(s);return f<0&&(f=lt(c+f,0)),$r(e,ge(t,3),f)}function Jl(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return s!==r&&(f=ke(s),f=s<0?lt(c+f,0):pt(f,c-1)),$r(e,ge(t,3),f,!0)}function Zl(e){var t=e==null?0:e.length;return t?ft(e,1):[]}function gm(e){var t=e==null?0:e.length;return t?ft(e,se):[]}function _m(e,t){var s=e==null?0:e.length;return s?(t=t===r?1:ke(t),ft(e,t)):[]}function xm(e){for(var t=-1,s=e==null?0:e.length,c={};++t<s;){var f=e[t];c[f[0]]=f[1]}return c}function ec(e){return e&&e.length?e[0]:r}function vm(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:ke(s);return f<0&&(f=lt(c+f,0)),Yn(e,t,f)}function bm(e){var t=e==null?0:e.length;return t?Bt(e,0,-1):[]}var ym=je(function(e){var t=Qe(e,Fi);return t.length&&t[0]===e[0]?ki(t):[]}),wm=je(function(e){var t=Ft(e),s=Qe(e,Fi);return t===Ft(s)?t=r:s.pop(),s.length&&s[0]===e[0]?ki(s,ge(t,2)):[]}),Em=je(function(e){var t=Ft(e),s=Qe(e,Fi);return t=typeof t=="function"?t:r,t&&s.pop(),s.length&&s[0]===e[0]?ki(s,r,t):[]});function Sm(e,t){return e==null?"":bh.call(e,t)}function Ft(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Nm(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c;return s!==r&&(f=ke(s),f=f<0?lt(c+f,0):pt(f,c-1)),t===t?sh(e,t,f):$r(e,La,f,!0)}function Cm(e,t){return e&&e.length?dl(e,ke(t)):r}var Tm=je(tc);function tc(e,t){return e&&e.length&&t&&t.length?Ii(e,t):e}function Rm(e,t,s){return e&&e.length&&t&&t.length?Ii(e,t,ge(s,2)):e}function km(e,t,s){return e&&e.length&&t&&t.length?Ii(e,t,r,s):e}var Am=fn(function(e,t){var s=e==null?0:e.length,c=Ni(e,t);return pl(e,Qe(t,function(f){return hn(f,s)?+f:f}).sort(Sl)),c});function jm(e,t){var s=[];if(!(e&&e.length))return s;var c=-1,f=[],g=e.length;for(t=ge(t,3);++c<g;){var w=e[c];t(w,c,e)&&(s.push(w),f.push(c))}return pl(e,f),s}function Zi(e){return e==null?e:Sh.call(e)}function Pm(e,t,s){var c=e==null?0:e.length;return c?(s&&typeof s!="number"&&vt(e,t,s)?(t=0,s=c):(t=t==null?0:ke(t),s=s===r?c:ke(s)),Bt(e,t,s)):[]}function Im(e,t){return fs(e,t)}function Lm(e,t,s){return Di(e,t,ge(s,2))}function Mm(e,t){var s=e==null?0:e.length;if(s){var c=fs(e,t);if(c<s&&qt(e[c],t))return c}return-1}function Dm(e,t){return fs(e,t,!0)}function Om(e,t,s){return Di(e,t,ge(s,2),!0)}function Bm(e,t){var s=e==null?0:e.length;if(s){var c=fs(e,t,!0)-1;if(qt(e[c],t))return c}return-1}function Fm(e){return e&&e.length?gl(e):[]}function Um(e,t){return e&&e.length?gl(e,ge(t,2)):[]}function Wm(e){var t=e==null?0:e.length;return t?Bt(e,1,t):[]}function Hm(e,t,s){return e&&e.length?(t=s||t===r?1:ke(t),Bt(e,0,t<0?0:t)):[]}function Gm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:ke(t),t=c-t,Bt(e,t<0?0:t,c)):[]}function zm(e,t){return e&&e.length?hs(e,ge(t,3),!1,!0):[]}function qm(e,t){return e&&e.length?hs(e,ge(t,3)):[]}var $m=je(function(e){return En(ft(e,1,rt,!0))}),Xm=je(function(e){var t=Ft(e);return rt(t)&&(t=r),En(ft(e,1,rt,!0),ge(t,2))}),Ym=je(function(e){var t=Ft(e);return t=typeof t=="function"?t:r,En(ft(e,1,rt,!0),r,t)});function Vm(e){return e&&e.length?En(e):[]}function Km(e,t){return e&&e.length?En(e,ge(t,2)):[]}function Qm(e,t){return t=typeof t=="function"?t:r,e&&e.length?En(e,r,t):[]}function eo(e){if(!(e&&e.length))return[];var t=0;return e=xn(e,function(s){if(rt(s))return t=lt(s.length,t),!0}),_i(t,function(s){return Qe(e,pi(s))})}function nc(e,t){if(!(e&&e.length))return[];var s=eo(e);return t==null?s:Qe(s,function(c){return Tt(t,r,c)})}var Jm=je(function(e,t){return rt(e)?vr(e,t):[]}),Zm=je(function(e){return Bi(xn(e,rt))}),e0=je(function(e){var t=Ft(e);return rt(t)&&(t=r),Bi(xn(e,rt),ge(t,2))}),t0=je(function(e){var t=Ft(e);return t=typeof t=="function"?t:r,Bi(xn(e,rt),r,t)}),n0=je(eo);function r0(e,t){return bl(e||[],t||[],xr)}function s0(e,t){return bl(e||[],t||[],wr)}var i0=je(function(e){var t=e.length,s=t>1?e[t-1]:r;return s=typeof s=="function"?(e.pop(),s):r,nc(e,s)});function rc(e){var t=h(e);return t.__chain__=!0,t}function o0(e,t){return t(e),e}function ws(e,t){return t(e)}var a0=fn(function(e){var t=e.length,s=t?e[0]:0,c=this.__wrapped__,f=function(g){return Ni(g,e)};return t>1||this.__actions__.length||!(c instanceof Me)||!hn(s)?this.thru(f):(c=c.slice(s,+s+(t?1:0)),c.__actions__.push({func:ws,args:[f],thisArg:r}),new Dt(c,this.__chain__).thru(function(g){return t&&!g.length&&g.push(r),g}))});function l0(){return rc(this)}function c0(){return new Dt(this.value(),this.__chain__)}function u0(){this.__values__===r&&(this.__values__=_c(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function d0(){return this}function f0(e){for(var t,s=this;s instanceof as;){var c=Kl(s);c.__index__=0,c.__values__=r,t?f.__wrapped__=c:t=c;var f=c;s=s.__wrapped__}return f.__wrapped__=e,t}function h0(){var e=this.__wrapped__;if(e instanceof Me){var t=e;return this.__actions__.length&&(t=new Me(this)),t=t.reverse(),t.__actions__.push({func:ws,args:[Zi],thisArg:r}),new Dt(t,this.__chain__)}return this.thru(Zi)}function p0(){return vl(this.__wrapped__,this.__actions__)}var m0=ps(function(e,t,s){ze.call(e,s)?++e[s]:un(e,s,1)});function g0(e,t,s){var c=Te(e)?Pa:op;return s&&vt(e,t,s)&&(t=r),c(e,ge(t,3))}function _0(e,t){var s=Te(e)?xn:nl;return s(e,ge(t,3))}var x0=Al(Ql),v0=Al(Jl);function b0(e,t){return ft(Es(e,t),1)}function y0(e,t){return ft(Es(e,t),se)}function w0(e,t,s){return s=s===r?1:ke(s),ft(Es(e,t),s)}function sc(e,t){var s=Te(e)?Lt:wn;return s(e,ge(t,3))}function ic(e,t){var s=Te(e)?Wf:tl;return s(e,ge(t,3))}var E0=ps(function(e,t,s){ze.call(e,s)?e[s].push(t):un(e,s,[t])});function S0(e,t,s,c){e=St(e)?e:or(e),s=s&&!c?ke(s):0;var f=e.length;return s<0&&(s=lt(f+s,0)),Rs(e)?s<=f&&e.indexOf(t,s)>-1:!!f&&Yn(e,t,s)>-1}var N0=je(function(e,t,s){var c=-1,f=typeof t=="function",g=St(e)?L(e.length):[];return wn(e,function(w){g[++c]=f?Tt(t,w,s):br(w,t,s)}),g}),C0=ps(function(e,t,s){un(e,s,t)});function Es(e,t){var s=Te(e)?Qe:ll;return s(e,ge(t,3))}function T0(e,t,s,c){return e==null?[]:(Te(t)||(t=t==null?[]:[t]),s=c?r:s,Te(s)||(s=s==null?[]:[s]),fl(e,t,s))}var R0=ps(function(e,t,s){e[s?0:1].push(t)},function(){return[[],[]]});function k0(e,t,s){var c=Te(e)?fi:Da,f=arguments.length<3;return c(e,ge(t,4),s,f,wn)}function A0(e,t,s){var c=Te(e)?Hf:Da,f=arguments.length<3;return c(e,ge(t,4),s,f,tl)}function j0(e,t){var s=Te(e)?xn:nl;return s(e,Cs(ge(t,3)))}function P0(e){var t=Te(e)?Qa:Sp;return t(e)}function I0(e,t,s){(s?vt(e,t,s):t===r)?t=1:t=ke(t);var c=Te(e)?tp:Np;return c(e,t)}function L0(e){var t=Te(e)?np:Tp;return t(e)}function M0(e){if(e==null)return 0;if(St(e))return Rs(e)?Kn(e):e.length;var t=mt(e);return t==de||t==_e?e.size:ji(e).length}function D0(e,t,s){var c=Te(e)?hi:Rp;return s&&vt(e,t,s)&&(t=r),c(e,ge(t,3))}var O0=je(function(e,t){if(e==null)return[];var s=t.length;return s>1&&vt(e,t[0],t[1])?t=[]:s>2&&vt(t[0],t[1],t[2])&&(t=[t[0]]),fl(e,ft(t,1),[])}),Ss=_h||function(){return dt.Date.now()};function B0(e,t){if(typeof t!="function")throw new Mt(_);return e=ke(e),function(){if(--e<1)return t.apply(this,arguments)}}function oc(e,t,s){return t=s?r:t,t=e&&t==null?e.length:t,dn(e,q,r,r,r,r,t)}function ac(e,t){var s;if(typeof t!="function")throw new Mt(_);return e=ke(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=r),s}}var to=je(function(e,t,s){var c=A;if(s.length){var f=bn(s,sr(to));c|=z}return dn(e,c,t,s,f)}),lc=je(function(e,t,s){var c=A|D;if(s.length){var f=bn(s,sr(lc));c|=z}return dn(t,c,e,s,f)});function cc(e,t,s){t=s?r:t;var c=dn(e,P,r,r,r,r,r,t);return c.placeholder=cc.placeholder,c}function uc(e,t,s){t=s?r:t;var c=dn(e,j,r,r,r,r,r,t);return c.placeholder=uc.placeholder,c}function dc(e,t,s){var c,f,g,w,S,k,W=0,H=!1,V=!1,ne=!0;if(typeof e!="function")throw new Mt(_);t=Ut(t)||0,Je(s)&&(H=!!s.leading,V="maxWait"in s,g=V?lt(Ut(s.maxWait)||0,t):g,ne="trailing"in s?!!s.trailing:ne);function le(st){var $t=c,gn=f;return c=f=r,W=st,w=e.apply(gn,$t),w}function ve(st){return W=st,S=Nr(Pe,t),H?le(st):w}function Ae(st){var $t=st-k,gn=st-W,Ac=t-$t;return V?pt(Ac,g-gn):Ac}function be(st){var $t=st-k,gn=st-W;return k===r||$t>=t||$t<0||V&&gn>=g}function Pe(){var st=Ss();if(be(st))return De(st);S=Nr(Pe,Ae(st))}function De(st){return S=r,ne&&c?le(st):(c=f=r,w)}function jt(){S!==r&&yl(S),W=0,c=k=f=S=r}function bt(){return S===r?w:De(Ss())}function Pt(){var st=Ss(),$t=be(st);if(c=arguments,f=this,k=st,$t){if(S===r)return ve(k);if(V)return yl(S),S=Nr(Pe,t),le(k)}return S===r&&(S=Nr(Pe,t)),w}return Pt.cancel=jt,Pt.flush=bt,Pt}var F0=je(function(e,t){return el(e,1,t)}),U0=je(function(e,t,s){return el(e,Ut(t)||0,s)});function W0(e){return dn(e,O)}function Ns(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Mt(_);var s=function(){var c=arguments,f=t?t.apply(this,c):c[0],g=s.cache;if(g.has(f))return g.get(f);var w=e.apply(this,c);return s.cache=g.set(f,w)||g,w};return s.cache=new(Ns.Cache||cn),s}Ns.Cache=cn;function Cs(e){if(typeof e!="function")throw new Mt(_);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 H0(e){return ac(2,e)}var G0=kp(function(e,t){t=t.length==1&&Te(t[0])?Qe(t[0],Rt(ge())):Qe(ft(t,1),Rt(ge()));var s=t.length;return je(function(c){for(var f=-1,g=pt(c.length,s);++f<g;)c[f]=t[f].call(this,c[f]);return Tt(e,this,c)})}),no=je(function(e,t){var s=bn(t,sr(no));return dn(e,z,r,t,s)}),fc=je(function(e,t){var s=bn(t,sr(fc));return dn(e,J,r,t,s)}),z0=fn(function(e,t){return dn(e,$,r,r,r,t)});function q0(e,t){if(typeof e!="function")throw new Mt(_);return t=t===r?t:ke(t),je(e,t)}function $0(e,t){if(typeof e!="function")throw new Mt(_);return t=t==null?0:lt(ke(t),0),je(function(s){var c=s[t],f=Nn(s,0,t);return c&&vn(f,c),Tt(e,this,f)})}function X0(e,t,s){var c=!0,f=!0;if(typeof e!="function")throw new Mt(_);return Je(s)&&(c="leading"in s?!!s.leading:c,f="trailing"in s?!!s.trailing:f),dc(e,t,{leading:c,maxWait:t,trailing:f})}function Y0(e){return oc(e,1)}function V0(e,t){return no(Ui(t),e)}function K0(){if(!arguments.length)return[];var e=arguments[0];return Te(e)?e:[e]}function Q0(e){return Ot(e,b)}function J0(e,t){return t=typeof t=="function"?t:r,Ot(e,b,t)}function Z0(e){return Ot(e,x|b)}function eg(e,t){return t=typeof t=="function"?t:r,Ot(e,x|b,t)}function tg(e,t){return t==null||Za(e,t,ut(t))}function qt(e,t){return e===t||e!==e&&t!==t}var ng=xs(Ri),rg=xs(function(e,t){return e>=t}),Wn=il((function(){return arguments})())?il:function(e){return et(e)&&ze.call(e,"callee")&&!qa.call(e,"callee")},Te=L.isArray,sg=Ca?Rt(Ca):fp;function St(e){return e!=null&&Ts(e.length)&&!pn(e)}function rt(e){return et(e)&&St(e)}function ig(e){return e===!0||e===!1||et(e)&&xt(e)==Ge}var Cn=vh||po,og=Ta?Rt(Ta):hp;function ag(e){return et(e)&&e.nodeType===1&&!Cr(e)}function lg(e){if(e==null)return!0;if(St(e)&&(Te(e)||typeof e=="string"||typeof e.splice=="function"||Cn(e)||ir(e)||Wn(e)))return!e.length;var t=mt(e);if(t==de||t==_e)return!e.size;if(Sr(e))return!ji(e).length;for(var s in e)if(ze.call(e,s))return!1;return!0}function cg(e,t){return yr(e,t)}function ug(e,t,s){s=typeof s=="function"?s:r;var c=s?s(e,t):r;return c===r?yr(e,t,r,s):!!c}function ro(e){if(!et(e))return!1;var t=xt(e);return t==ye||t==ce||typeof e.message=="string"&&typeof e.name=="string"&&!Cr(e)}function dg(e){return typeof e=="number"&&Xa(e)}function pn(e){if(!Je(e))return!1;var t=xt(e);return t==Be||t==We||t==Ze||t==Le}function hc(e){return typeof e=="number"&&e==ke(e)}function Ts(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=oe}function Je(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function et(e){return e!=null&&typeof e=="object"}var pc=Ra?Rt(Ra):mp;function fg(e,t){return e===t||Ai(e,t,Xi(t))}function hg(e,t,s){return s=typeof s=="function"?s:r,Ai(e,t,Xi(t),s)}function pg(e){return mc(e)&&e!=+e}function mg(e){if(Jp(e))throw new Ce(l);return ol(e)}function gg(e){return e===null}function _g(e){return e==null}function mc(e){return typeof e=="number"||et(e)&&xt(e)==Se}function Cr(e){if(!et(e)||xt(e)!=Z)return!1;var t=es(e);if(t===null)return!0;var s=ze.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&Kr.call(s)==hh}var so=ka?Rt(ka):gp;function xg(e){return hc(e)&&e>=-oe&&e<=oe}var gc=Aa?Rt(Aa):_p;function Rs(e){return typeof e=="string"||!Te(e)&&et(e)&&xt(e)==Ne}function At(e){return typeof e=="symbol"||et(e)&&xt(e)==he}var ir=ja?Rt(ja):xp;function vg(e){return e===r}function bg(e){return et(e)&&mt(e)==yt}function yg(e){return et(e)&&xt(e)==wt}var wg=xs(Pi),Eg=xs(function(e,t){return e<=t});function _c(e){if(!e)return[];if(St(e))return Rs(e)?Gt(e):Et(e);if(hr&&e[hr])return th(e[hr]());var t=mt(e),s=t==de?vi:t==_e?Xr:or;return s(e)}function mn(e){if(!e)return e===0?e:0;if(e=Ut(e),e===se||e===-se){var t=e<0?-1:1;return t*Re}return e===e?e:0}function ke(e){var t=mn(e),s=t%1;return t===t?s?t-s:t:0}function xc(e){return e?On(ke(e),0,Q):0}function Ut(e){if(typeof e=="number")return e;if(At(e))return G;if(Je(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Je(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Oa(e);var s=rf.test(e);return s||of.test(e)?Bf(e.slice(2),s?2:8):nf.test(e)?G:+e}function vc(e){return Jt(e,Nt(e))}function Sg(e){return e?On(ke(e),-oe,oe):e===0?e:0}function He(e){return e==null?"":kt(e)}var Ng=nr(function(e,t){if(Sr(t)||St(t)){Jt(t,ut(t),e);return}for(var s in t)ze.call(t,s)&&xr(e,s,t[s])}),bc=nr(function(e,t){Jt(t,Nt(t),e)}),ks=nr(function(e,t,s,c){Jt(t,Nt(t),e,c)}),Cg=nr(function(e,t,s,c){Jt(t,ut(t),e,c)}),Tg=fn(Ni);function Rg(e,t){var s=tr(e);return t==null?s:Ja(s,t)}var kg=je(function(e,t){e=qe(e);var s=-1,c=t.length,f=c>2?t[2]:r;for(f&&vt(t[0],t[1],f)&&(c=1);++s<c;)for(var g=t[s],w=Nt(g),S=-1,k=w.length;++S<k;){var W=w[S],H=e[W];(H===r||qt(H,Jn[W])&&!ze.call(e,W))&&(e[W]=g[W])}return e}),Ag=je(function(e){return e.push(r,Ol),Tt(yc,r,e)});function jg(e,t){return Ia(e,ge(t,3),Qt)}function Pg(e,t){return Ia(e,ge(t,3),Ti)}function Ig(e,t){return e==null?e:Ci(e,ge(t,3),Nt)}function Lg(e,t){return e==null?e:rl(e,ge(t,3),Nt)}function Mg(e,t){return e&&Qt(e,ge(t,3))}function Dg(e,t){return e&&Ti(e,ge(t,3))}function Og(e){return e==null?[]:us(e,ut(e))}function Bg(e){return e==null?[]:us(e,Nt(e))}function io(e,t,s){var c=e==null?r:Bn(e,t);return c===r?s:c}function Fg(e,t){return e!=null&&Ul(e,t,lp)}function oo(e,t){return e!=null&&Ul(e,t,cp)}var Ug=Pl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Qr.call(t)),e[t]=s},lo(Ct)),Wg=Pl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=Qr.call(t)),ze.call(e,t)?e[t].push(s):e[t]=[s]},ge),Hg=je(br);function ut(e){return St(e)?Ka(e):ji(e)}function Nt(e){return St(e)?Ka(e,!0):vp(e)}function Gg(e,t){var s={};return t=ge(t,3),Qt(e,function(c,f,g){un(s,t(c,f,g),c)}),s}function zg(e,t){var s={};return t=ge(t,3),Qt(e,function(c,f,g){un(s,f,t(c,f,g))}),s}var qg=nr(function(e,t,s){ds(e,t,s)}),yc=nr(function(e,t,s,c){ds(e,t,s,c)}),$g=fn(function(e,t){var s={};if(e==null)return s;var c=!1;t=Qe(t,function(g){return g=Sn(g,e),c||(c=g.length>1),g}),Jt(e,qi(e),s),c&&(s=Ot(s,x|y|b,Up));for(var f=t.length;f--;)Oi(s,t[f]);return s});function Xg(e,t){return wc(e,Cs(ge(t)))}var Yg=fn(function(e,t){return e==null?{}:yp(e,t)});function wc(e,t){if(e==null)return{};var s=Qe(qi(e),function(c){return[c]});return t=ge(t),hl(e,s,function(c,f){return t(c,f[0])})}function Vg(e,t,s){t=Sn(t,e);var c=-1,f=t.length;for(f||(f=1,e=r);++c<f;){var g=e==null?r:e[Zt(t[c])];g===r&&(c=f,g=s),e=pn(g)?g.call(e):g}return e}function Kg(e,t,s){return e==null?e:wr(e,t,s)}function Qg(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:wr(e,t,s,c)}var Ec=Ml(ut),Sc=Ml(Nt);function Jg(e,t,s){var c=Te(e),f=c||Cn(e)||ir(e);if(t=ge(t,4),s==null){var g=e&&e.constructor;f?s=c?new g:[]:Je(e)?s=pn(g)?tr(es(e)):{}:s={}}return(f?Lt:Qt)(e,function(w,S,k){return t(s,w,S,k)}),s}function Zg(e,t){return e==null?!0:Oi(e,t)}function e_(e,t,s){return e==null?e:xl(e,t,Ui(s))}function t_(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:xl(e,t,Ui(s),c)}function or(e){return e==null?[]:xi(e,ut(e))}function n_(e){return e==null?[]:xi(e,Nt(e))}function r_(e,t,s){return s===r&&(s=t,t=r),s!==r&&(s=Ut(s),s=s===s?s:0),t!==r&&(t=Ut(t),t=t===t?t:0),On(Ut(e),t,s)}function s_(e,t,s){return t=mn(t),s===r?(s=t,t=0):s=mn(s),e=Ut(e),up(e,t,s)}function i_(e,t,s){if(s&&typeof s!="boolean"&&vt(e,t,s)&&(t=s=r),s===r&&(typeof t=="boolean"?(s=t,t=r):typeof e=="boolean"&&(s=e,e=r)),e===r&&t===r?(e=0,t=1):(e=mn(e),t===r?(t=e,e=0):t=mn(t)),e>t){var c=e;e=t,t=c}if(s||e%1||t%1){var f=Ya();return pt(e+f*(t-e+Of("1e-"+((f+"").length-1))),t)}return Li(e,t)}var o_=rr(function(e,t,s){return t=t.toLowerCase(),e+(s?Nc(t):t)});function Nc(e){return ao(He(e).toLowerCase())}function Cc(e){return e=He(e),e&&e.replace(lf,Kf).replace(Tf,"")}function a_(e,t,s){e=He(e),t=kt(t);var c=e.length;s=s===r?c:On(ke(s),0,c);var f=s;return s-=t.length,s>=0&&e.slice(s,f)==t}function l_(e){return e=He(e),e&&Wd.test(e)?e.replace(ra,Qf):e}function c_(e){return e=He(e),e&&Xd.test(e)?e.replace(ni,"\\$&"):e}var u_=rr(function(e,t,s){return e+(s?"-":"")+t.toLowerCase()}),d_=rr(function(e,t,s){return e+(s?" ":"")+t.toLowerCase()}),f_=kl("toLowerCase");function h_(e,t,s){e=He(e),t=ke(t);var c=t?Kn(e):0;if(!t||c>=t)return e;var f=(t-c)/2;return _s(ss(f),s)+e+_s(rs(f),s)}function p_(e,t,s){e=He(e),t=ke(t);var c=t?Kn(e):0;return t&&c<t?e+_s(t-c,s):e}function m_(e,t,s){e=He(e),t=ke(t);var c=t?Kn(e):0;return t&&c<t?_s(t-c,s)+e:e}function g_(e,t,s){return s||t==null?t=0:t&&(t=+t),Eh(He(e).replace(ri,""),t||0)}function __(e,t,s){return(s?vt(e,t,s):t===r)?t=1:t=ke(t),Mi(He(e),t)}function x_(){var e=arguments,t=He(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var v_=rr(function(e,t,s){return e+(s?"_":"")+t.toLowerCase()});function b_(e,t,s){return s&&typeof s!="number"&&vt(e,t,s)&&(t=s=r),s=s===r?Q:s>>>0,s?(e=He(e),e&&(typeof t=="string"||t!=null&&!so(t))&&(t=kt(t),!t&&Vn(e))?Nn(Gt(e),0,s):e.split(t,s)):[]}var y_=rr(function(e,t,s){return e+(s?" ":"")+ao(t)});function w_(e,t,s){return e=He(e),s=s==null?0:On(ke(s),0,e.length),t=kt(t),e.slice(s,s+t.length)==t}function E_(e,t,s){var c=h.templateSettings;s&&vt(e,t,s)&&(t=r),e=He(e),t=ks({},t,c,Dl);var f=ks({},t.imports,c.imports,Dl),g=ut(f),w=xi(f,g),S,k,W=0,H=t.interpolate||Hr,V="__p += '",ne=bi((t.escape||Hr).source+"|"+H.source+"|"+(H===sa?tf:Hr).source+"|"+(t.evaluate||Hr).source+"|$","g"),le="//# sourceURL="+(ze.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Pf+"]")+`
|
|
9
|
+
`;e.replace(ne,function(be,Pe,De,jt,bt,Pt){return De||(De=jt),V+=e.slice(W,Pt).replace(cf,Jf),Pe&&(S=!0,V+=`' +
|
|
10
|
+
__e(`+Pe+`) +
|
|
11
|
+
'`),bt&&(k=!0,V+=`';
|
|
12
|
+
`+bt+`;
|
|
13
|
+
__p += '`),De&&(V+=`' +
|
|
14
|
+
((__t = (`+De+`)) == null ? '' : __t) +
|
|
15
|
+
'`),W=Pt+be.length,be}),V+=`';
|
|
16
|
+
`;var ve=ze.call(t,"variable")&&t.variable;if(!ve)V=`with (obj) {
|
|
17
|
+
`+V+`
|
|
18
|
+
}
|
|
19
|
+
`;else if(Zd.test(ve))throw new Ce(v);V=(k?V.replace(Kt,""):V).replace(ti,"$1").replace(Wr,"$1;"),V="function("+(ve||"obj")+`) {
|
|
20
|
+
`+(ve?"":`obj || (obj = {});
|
|
21
|
+
`)+"var __t, __p = ''"+(S?", __e = _.escape":"")+(k?`, __j = Array.prototype.join;
|
|
22
|
+
function print() { __p += __j.call(arguments, '') }
|
|
23
|
+
`:`;
|
|
24
|
+
`)+V+`return __p
|
|
25
|
+
}`;var Ae=Rc(function(){return Fe(g,le+"return "+V).apply(r,w)});if(Ae.source=V,ro(Ae))throw Ae;return Ae}function S_(e){return He(e).toLowerCase()}function N_(e){return He(e).toUpperCase()}function C_(e,t,s){if(e=He(e),e&&(s||t===r))return Oa(e);if(!e||!(t=kt(t)))return e;var c=Gt(e),f=Gt(t),g=Ba(c,f),w=Fa(c,f)+1;return Nn(c,g,w).join("")}function T_(e,t,s){if(e=He(e),e&&(s||t===r))return e.slice(0,Wa(e)+1);if(!e||!(t=kt(t)))return e;var c=Gt(e),f=Fa(c,Gt(t))+1;return Nn(c,0,f).join("")}function R_(e,t,s){if(e=He(e),e&&(s||t===r))return e.replace(ri,"");if(!e||!(t=kt(t)))return e;var c=Gt(e),f=Ba(c,Gt(t));return Nn(c,f).join("")}function k_(e,t){var s=C,c=R;if(Je(t)){var f="separator"in t?t.separator:f;s="length"in t?ke(t.length):s,c="omission"in t?kt(t.omission):c}e=He(e);var g=e.length;if(Vn(e)){var w=Gt(e);g=w.length}if(s>=g)return e;var S=s-Kn(c);if(S<1)return c;var k=w?Nn(w,0,S).join(""):e.slice(0,S);if(f===r)return k+c;if(w&&(S+=k.length-S),so(f)){if(e.slice(S).search(f)){var W,H=k;for(f.global||(f=bi(f.source,He(ia.exec(f))+"g")),f.lastIndex=0;W=f.exec(H);)var V=W.index;k=k.slice(0,V===r?S:V)}}else if(e.indexOf(kt(f),S)!=S){var ne=k.lastIndexOf(f);ne>-1&&(k=k.slice(0,ne))}return k+c}function A_(e){return e=He(e),e&&Ud.test(e)?e.replace(na,ih):e}var j_=rr(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),ao=kl("toUpperCase");function Tc(e,t,s){return e=He(e),t=s?r:t,t===r?eh(e)?lh(e):qf(e):e.match(t)||[]}var Rc=je(function(e,t){try{return Tt(e,r,t)}catch(s){return ro(s)?s:new Ce(s)}}),P_=fn(function(e,t){return Lt(t,function(s){s=Zt(s),un(e,s,to(e[s],e))}),e});function I_(e){var t=e==null?0:e.length,s=ge();return e=t?Qe(e,function(c){if(typeof c[1]!="function")throw new Mt(_);return[s(c[0]),c[1]]}):[],je(function(c){for(var f=-1;++f<t;){var g=e[f];if(Tt(g[0],this,c))return Tt(g[1],this,c)}})}function L_(e){return ip(Ot(e,x))}function lo(e){return function(){return e}}function M_(e,t){return e==null||e!==e?t:e}var D_=jl(),O_=jl(!0);function Ct(e){return e}function co(e){return al(typeof e=="function"?e:Ot(e,x))}function B_(e){return cl(Ot(e,x))}function F_(e,t){return ul(e,Ot(t,x))}var U_=je(function(e,t){return function(s){return br(s,e,t)}}),W_=je(function(e,t){return function(s){return br(e,s,t)}});function uo(e,t,s){var c=ut(t),f=us(t,c);s==null&&!(Je(t)&&(f.length||!c.length))&&(s=t,t=e,e=this,f=us(t,ut(t)));var g=!(Je(s)&&"chain"in s)||!!s.chain,w=pn(e);return Lt(f,function(S){var k=t[S];e[S]=k,w&&(e.prototype[S]=function(){var W=this.__chain__;if(g||W){var H=e(this.__wrapped__),V=H.__actions__=Et(this.__actions__);return V.push({func:k,args:arguments,thisArg:e}),H.__chain__=W,H}return k.apply(e,vn([this.value()],arguments))})}),e}function H_(){return dt._===this&&(dt._=ph),this}function fo(){}function G_(e){return e=ke(e),je(function(t){return dl(t,e)})}var z_=Hi(Qe),q_=Hi(Pa),$_=Hi(hi);function kc(e){return Vi(e)?pi(Zt(e)):wp(e)}function X_(e){return function(t){return e==null?r:Bn(e,t)}}var Y_=Il(),V_=Il(!0);function ho(){return[]}function po(){return!1}function K_(){return{}}function Q_(){return""}function J_(){return!0}function Z_(e,t){if(e=ke(e),e<1||e>oe)return[];var s=Q,c=pt(e,Q);t=ge(t),e-=Q;for(var f=_i(c,t);++s<e;)t(s);return f}function ex(e){return Te(e)?Qe(e,Zt):At(e)?[e]:Et(Vl(He(e)))}function tx(e){var t=++fh;return He(e)+t}var nx=gs(function(e,t){return e+t},0),rx=Gi("ceil"),sx=gs(function(e,t){return e/t},1),ix=Gi("floor");function ox(e){return e&&e.length?cs(e,Ct,Ri):r}function ax(e,t){return e&&e.length?cs(e,ge(t,2),Ri):r}function lx(e){return Ma(e,Ct)}function cx(e,t){return Ma(e,ge(t,2))}function ux(e){return e&&e.length?cs(e,Ct,Pi):r}function dx(e,t){return e&&e.length?cs(e,ge(t,2),Pi):r}var fx=gs(function(e,t){return e*t},1),hx=Gi("round"),px=gs(function(e,t){return e-t},0);function mx(e){return e&&e.length?gi(e,Ct):0}function gx(e,t){return e&&e.length?gi(e,ge(t,2)):0}return h.after=B0,h.ary=oc,h.assign=Ng,h.assignIn=bc,h.assignInWith=ks,h.assignWith=Cg,h.at=Tg,h.before=ac,h.bind=to,h.bindAll=P_,h.bindKey=lc,h.castArray=K0,h.chain=rc,h.chunk=im,h.compact=om,h.concat=am,h.cond=I_,h.conforms=L_,h.constant=lo,h.countBy=m0,h.create=Rg,h.curry=cc,h.curryRight=uc,h.debounce=dc,h.defaults=kg,h.defaultsDeep=Ag,h.defer=F0,h.delay=U0,h.difference=lm,h.differenceBy=cm,h.differenceWith=um,h.drop=dm,h.dropRight=fm,h.dropRightWhile=hm,h.dropWhile=pm,h.fill=mm,h.filter=_0,h.flatMap=b0,h.flatMapDeep=y0,h.flatMapDepth=w0,h.flatten=Zl,h.flattenDeep=gm,h.flattenDepth=_m,h.flip=W0,h.flow=D_,h.flowRight=O_,h.fromPairs=xm,h.functions=Og,h.functionsIn=Bg,h.groupBy=E0,h.initial=bm,h.intersection=ym,h.intersectionBy=wm,h.intersectionWith=Em,h.invert=Ug,h.invertBy=Wg,h.invokeMap=N0,h.iteratee=co,h.keyBy=C0,h.keys=ut,h.keysIn=Nt,h.map=Es,h.mapKeys=Gg,h.mapValues=zg,h.matches=B_,h.matchesProperty=F_,h.memoize=Ns,h.merge=qg,h.mergeWith=yc,h.method=U_,h.methodOf=W_,h.mixin=uo,h.negate=Cs,h.nthArg=G_,h.omit=$g,h.omitBy=Xg,h.once=H0,h.orderBy=T0,h.over=z_,h.overArgs=G0,h.overEvery=q_,h.overSome=$_,h.partial=no,h.partialRight=fc,h.partition=R0,h.pick=Yg,h.pickBy=wc,h.property=kc,h.propertyOf=X_,h.pull=Tm,h.pullAll=tc,h.pullAllBy=Rm,h.pullAllWith=km,h.pullAt=Am,h.range=Y_,h.rangeRight=V_,h.rearg=z0,h.reject=j0,h.remove=jm,h.rest=q0,h.reverse=Zi,h.sampleSize=I0,h.set=Kg,h.setWith=Qg,h.shuffle=L0,h.slice=Pm,h.sortBy=O0,h.sortedUniq=Fm,h.sortedUniqBy=Um,h.split=b_,h.spread=$0,h.tail=Wm,h.take=Hm,h.takeRight=Gm,h.takeRightWhile=zm,h.takeWhile=qm,h.tap=o0,h.throttle=X0,h.thru=ws,h.toArray=_c,h.toPairs=Ec,h.toPairsIn=Sc,h.toPath=ex,h.toPlainObject=vc,h.transform=Jg,h.unary=Y0,h.union=$m,h.unionBy=Xm,h.unionWith=Ym,h.uniq=Vm,h.uniqBy=Km,h.uniqWith=Qm,h.unset=Zg,h.unzip=eo,h.unzipWith=nc,h.update=e_,h.updateWith=t_,h.values=or,h.valuesIn=n_,h.without=Jm,h.words=Tc,h.wrap=V0,h.xor=Zm,h.xorBy=e0,h.xorWith=t0,h.zip=n0,h.zipObject=r0,h.zipObjectDeep=s0,h.zipWith=i0,h.entries=Ec,h.entriesIn=Sc,h.extend=bc,h.extendWith=ks,uo(h,h),h.add=nx,h.attempt=Rc,h.camelCase=o_,h.capitalize=Nc,h.ceil=rx,h.clamp=r_,h.clone=Q0,h.cloneDeep=Z0,h.cloneDeepWith=eg,h.cloneWith=J0,h.conformsTo=tg,h.deburr=Cc,h.defaultTo=M_,h.divide=sx,h.endsWith=a_,h.eq=qt,h.escape=l_,h.escapeRegExp=c_,h.every=g0,h.find=x0,h.findIndex=Ql,h.findKey=jg,h.findLast=v0,h.findLastIndex=Jl,h.findLastKey=Pg,h.floor=ix,h.forEach=sc,h.forEachRight=ic,h.forIn=Ig,h.forInRight=Lg,h.forOwn=Mg,h.forOwnRight=Dg,h.get=io,h.gt=ng,h.gte=rg,h.has=Fg,h.hasIn=oo,h.head=ec,h.identity=Ct,h.includes=S0,h.indexOf=vm,h.inRange=s_,h.invoke=Hg,h.isArguments=Wn,h.isArray=Te,h.isArrayBuffer=sg,h.isArrayLike=St,h.isArrayLikeObject=rt,h.isBoolean=ig,h.isBuffer=Cn,h.isDate=og,h.isElement=ag,h.isEmpty=lg,h.isEqual=cg,h.isEqualWith=ug,h.isError=ro,h.isFinite=dg,h.isFunction=pn,h.isInteger=hc,h.isLength=Ts,h.isMap=pc,h.isMatch=fg,h.isMatchWith=hg,h.isNaN=pg,h.isNative=mg,h.isNil=_g,h.isNull=gg,h.isNumber=mc,h.isObject=Je,h.isObjectLike=et,h.isPlainObject=Cr,h.isRegExp=so,h.isSafeInteger=xg,h.isSet=gc,h.isString=Rs,h.isSymbol=At,h.isTypedArray=ir,h.isUndefined=vg,h.isWeakMap=bg,h.isWeakSet=yg,h.join=Sm,h.kebabCase=u_,h.last=Ft,h.lastIndexOf=Nm,h.lowerCase=d_,h.lowerFirst=f_,h.lt=wg,h.lte=Eg,h.max=ox,h.maxBy=ax,h.mean=lx,h.meanBy=cx,h.min=ux,h.minBy=dx,h.stubArray=ho,h.stubFalse=po,h.stubObject=K_,h.stubString=Q_,h.stubTrue=J_,h.multiply=fx,h.nth=Cm,h.noConflict=H_,h.noop=fo,h.now=Ss,h.pad=h_,h.padEnd=p_,h.padStart=m_,h.parseInt=g_,h.random=i_,h.reduce=k0,h.reduceRight=A0,h.repeat=__,h.replace=x_,h.result=Vg,h.round=hx,h.runInContext=T,h.sample=P0,h.size=M0,h.snakeCase=v_,h.some=D0,h.sortedIndex=Im,h.sortedIndexBy=Lm,h.sortedIndexOf=Mm,h.sortedLastIndex=Dm,h.sortedLastIndexBy=Om,h.sortedLastIndexOf=Bm,h.startCase=y_,h.startsWith=w_,h.subtract=px,h.sum=mx,h.sumBy=gx,h.template=E_,h.times=Z_,h.toFinite=mn,h.toInteger=ke,h.toLength=xc,h.toLower=S_,h.toNumber=Ut,h.toSafeInteger=Sg,h.toString=He,h.toUpper=N_,h.trim=C_,h.trimEnd=T_,h.trimStart=R_,h.truncate=k_,h.unescape=A_,h.uniqueId=tx,h.upperCase=j_,h.upperFirst=ao,h.each=sc,h.eachRight=ic,h.first=ec,uo(h,(function(){var e={};return Qt(h,function(t,s){ze.call(h.prototype,s)||(e[s]=t)}),e})(),{chain:!1}),h.VERSION=o,Lt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){h[e].placeholder=h}),Lt(["drop","take"],function(e,t){Me.prototype[e]=function(s){s=s===r?1:lt(ke(s),0);var c=this.__filtered__&&!t?new Me(this):this.clone();return c.__filtered__?c.__takeCount__=pt(s,c.__takeCount__):c.__views__.push({size:pt(s,Q),type:e+(c.__dir__<0?"Right":"")}),c},Me.prototype[e+"Right"]=function(s){return this.reverse()[e](s).reverse()}}),Lt(["filter","map","takeWhile"],function(e,t){var s=t+1,c=s==X||s==K;Me.prototype[e]=function(f){var g=this.clone();return g.__iteratees__.push({iteratee:ge(f,3),type:s}),g.__filtered__=g.__filtered__||c,g}}),Lt(["head","last"],function(e,t){var s="take"+(t?"Right":"");Me.prototype[e]=function(){return this[s](1).value()[0]}}),Lt(["initial","tail"],function(e,t){var s="drop"+(t?"":"Right");Me.prototype[e]=function(){return this.__filtered__?new Me(this):this[s](1)}}),Me.prototype.compact=function(){return this.filter(Ct)},Me.prototype.find=function(e){return this.filter(e).head()},Me.prototype.findLast=function(e){return this.reverse().find(e)},Me.prototype.invokeMap=je(function(e,t){return typeof e=="function"?new Me(this):this.map(function(s){return br(s,e,t)})}),Me.prototype.reject=function(e){return this.filter(Cs(ge(e)))},Me.prototype.slice=function(e,t){e=ke(e);var s=this;return s.__filtered__&&(e>0||t<0)?new Me(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==r&&(t=ke(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Me.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Me.prototype.toArray=function(){return this.take(Q)},Qt(Me.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),c=/^(?:head|last)$/.test(t),f=h[c?"take"+(t=="last"?"Right":""):t],g=c||/^find/.test(t);f&&(h.prototype[t]=function(){var w=this.__wrapped__,S=c?[1]:arguments,k=w instanceof Me,W=S[0],H=k||Te(w),V=function(Pe){var De=f.apply(h,vn([Pe],S));return c&&ne?De[0]:De};H&&s&&typeof W=="function"&&W.length!=1&&(k=H=!1);var ne=this.__chain__,le=!!this.__actions__.length,ve=g&&!ne,Ae=k&&!le;if(!g&&H){w=Ae?w:new Me(this);var be=e.apply(w,S);return be.__actions__.push({func:ws,args:[V],thisArg:r}),new Dt(be,ne)}return ve&&Ae?e.apply(this,S):(be=this.thru(V),ve?c?be.value()[0]:be.value():be)})}),Lt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Yr[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);h.prototype[e]=function(){var f=arguments;if(c&&!this.__chain__){var g=this.value();return t.apply(Te(g)?g:[],f)}return this[s](function(w){return t.apply(Te(w)?w:[],f)})}}),Qt(Me.prototype,function(e,t){var s=h[t];if(s){var c=s.name+"";ze.call(er,c)||(er[c]=[]),er[c].push({name:t,func:s})}}),er[ms(r,D).name]=[{name:"wrapper",func:r}],Me.prototype.clone=Ah,Me.prototype.reverse=jh,Me.prototype.value=Ph,h.prototype.at=a0,h.prototype.chain=l0,h.prototype.commit=c0,h.prototype.next=u0,h.prototype.plant=f0,h.prototype.reverse=h0,h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=p0,h.prototype.first=h.prototype.head,hr&&(h.prototype[hr]=d0),h}),Qn=ch();In?((In.exports=Qn)._=Qn,ci._=Qn):dt._=Qn}).call(o1)})(Pr,Pr.exports)),Pr.exports}var id=a1();const l1=vx(id);function c1(i,n){const[r,o]=E.useState(i),d=E.useRef(l1.debounce(o,n)),l=E.useCallback(_=>{d.current(_)},[]);return[r,l]}const u1=[{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}],d1=()=>{try{const i=localStorage.getItem("sidebar-collapsed");return i!==null?JSON.parse(i):!1}catch(i){return console.warn("Failed to load sidebar collapsed state:",i),!1}};function f1({devices:i,currentDeviceId:n,onSelectDevice:r,onOpenConfig:o,onConnectWifi:d,onDisconnectWifi:l,onRefreshDevices:_,showToast:v}){const u=An(),[m,p]=E.useState(d1),[x,y]=E.useState(!1),[b,N]=E.useState(""),[I,A]=E.useState("5555"),[D,M]=E.useState(""),[P,j]=E.useState(""),[z,J]=E.useState("custom"),[q,$]=E.useState("direct"),[O,C]=E.useState(""),[R,re]=E.useState(""),[pe,X]=E.useState("5555"),[Y,K]=E.useState(""),[se,oe]=E.useState(!1),[Re,G]=E.useState([]),[Q,ue]=c1(!1,300),[te,me]=E.useState(""),[ae,Ue]=E.useState(null),[Ze,Ge]=E.useState(!1),B=E.useRef(null),[ce,ye]=E.useState(""),[Be,We]=E.useState(""),[de,Se]=E.useState(!1),[ee,Z]=E.useState([]),[we,Le]=E.useState(null),[fe,_e]=E.useState(!1);E.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(m))},[m]),E.useEffect(()=>{const U=xe=>{(xe.metaKey||xe.ctrlKey)&&xe.key==="b"&&(xe.preventDefault(),p(!m))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[m]);const Ne=()=>{p(!m)},he=U=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(U)?U.split(".").every(ti=>{const Wr=parseInt(ti,10);return Wr>=0&&Wr<=255}):!1,ct=U=>{const xe=parseInt(U,10);return!isNaN(xe)&&xe>=1&&xe<=65535},yt=U=>/^\d{6}$/.test(U),wt=async()=>{M(""),j("");let U=!1;if(he(b)||(M(u.deviceSidebar.invalidIpError),U=!0),ct(I)||(j(u.deviceSidebar.invalidPortError),U=!0),!U){oe(!0);try{const xe=await Pc({ip:b,port:parseInt(I,10)});xe.success?(y(!1),N(""),A("5555")):M(xe.message||u.toasts.wifiManualConnectError)}catch{M(u.toasts.wifiManualConnectError)}finally{oe(!1)}}},it=async()=>{K(""),M(""),j("");let U=!1;if(he(b)||(M(u.deviceSidebar.invalidIpError),U=!0),ct(R)||(j(u.deviceSidebar.invalidPortError),U=!0),ct(pe)||(j(u.deviceSidebar.invalidPortError),U=!0),yt(O)||(K(u.deviceSidebar.invalidPairingCodeError),U=!0),!U){oe(!0);try{const xe=await Sx({ip:b,pairing_port:parseInt(R,10),pairing_code:O,connection_port:parseInt(pe,10)});xe.success?(y(!1),N(""),A("5555"),C(""),re(""),X("5555"),$("direct")):xe.error==="invalid_pairing_code"?K(xe.message):xe.error==="invalid_ip"?M(xe.message):M(xe.message||u.toasts.wifiPairError)}catch{M(u.toasts.wifiPairError)}finally{oe(!1)}}},Ve=E.useCallback(()=>{B.current!==null&&(clearInterval(B.current),B.current=null)},[]),zn=E.useCallback(U=>{Ve(),B.current=window.setInterval(async()=>{try{const xe=await bx(U);Ue(Kt=>Kt?{...Kt,status:xe.status}:null),["connected","timeout","error"].includes(xe.status)&&(Ve(),xe.status==="connected"&&setTimeout(()=>{y(!1),Ue(null)},2e3))}catch(xe){console.error("[QR Pairing] Status poll failed:",xe)}},1e3)},[Ve]),jn=E.useCallback(async()=>{Ge(!0);try{const U=await yx();U.success&&U.qr_payload&&U.session_id&&(Ue({sessionId:U.session_id,payload:U.qr_payload,status:"listening",expiresAt:U.expires_at??Date.now()+12e4}),zn(U.session_id))}catch(U){console.error("[QR Pairing] Generation failed:",U)}finally{Ge(!1)}},[zn]),Pn=E.useCallback(async()=>{if(ae)try{await wx(ae.sessionId),Ue(null),Ve()}catch(U){console.error("[QR Pairing] Cancel failed:",U)}},[ae,Ve]),qn=async()=>{if(We(""),!ce.trim()){We(u.deviceSidebar.remoteUrlRequired||"请输入远程服务器地址");return}if(!ce.startsWith("http://")&&!ce.startsWith("https://")){We(u.deviceSidebar.remoteUrlInvalid||"地址必须以 http:// 或 https:// 开头");return}Se(!0);try{const U=await Nx({base_url:ce,timeout:5});U.success?(Z(U.devices),Le(null)):(We(U.message||"发现设备失败"),Z([]))}catch{We("连接失败,请检查地址是否正确"),Z([])}finally{Se(!1)}},dr=async()=>{if(we){_e(!0);try{const U=await Cx({base_url:ce,device_id:we});U.success?(y(!1),ye(""),Z([]),Le(null)):We(U.message||u.toasts.remoteDeviceAddError)}catch{We(u.toasts.remoteDeviceAddError)}finally{_e(!1)}}};E.useEffect(()=>{(!x||q!=="pair")&&(ae&&ae.status==="listening"&&Pn(),Ve())},[x,q,ae,Ve,Pn]),E.useEffect(()=>()=>{Ve()},[Ve]),E.useEffect(()=>{x&&q==="pair"&&!ae&&!Ze&&jn()},[x,q,ae,Ze,jn]);const an=E.useCallback(async()=>{ue(!0),me("");try{const U=await Ex();U.success?G(U.devices):(me(U.error||u.deviceSidebar.scanError.replace("{error}","Unknown error")),G([]))}catch(U){me(u.deviceSidebar.scanError.replace("{error}",String(U))),G([])}finally{ue(!1)}},[u.deviceSidebar.scanError,ue]),$n=async(U,xe)=>{if(!xe&&!U.has_pairing){oe(!0),M("");try{const Kt=await Pc({ip:U.ip,port:U.port});Kt.success?y(!1):M(Kt.message||u.toasts.wifiManualConnectError)}catch(Kt){M(u.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",Kt)}finally{oe(!1)}}else xe&&U.has_pairing&&(N(U.ip),re(U.pairing_port?String(U.pairing_port):""),X(String(U.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return E.useEffect(()=>{if(x){an();const U=setInterval(()=>{an()},5e3);return()=>{clearInterval(U)}}},[x,an]),a.jsxs(a.Fragment,{children:[m&&a.jsx(Ee,{variant:"outline",size:"icon",onClick:Ne,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:a.jsx(yu,{className:"h-4 w-4"})}),a.jsxs("div",{className:`
|
|
26
|
+
${m?"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:[a.jsxs("div",{className:"flex items-center justify-between p-4",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[i.length," ",(i.length===1,u.deviceSidebar.devices)]})]})}),a.jsx(Ee,{variant:"ghost",size:"icon",onClick:Ne,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:a.jsx(Su,{className:"h-4 w-4"})})]}),a.jsx(Tr,{className:"mx-4"}),a.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:i.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:a.jsx(mv,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:u.deviceSidebar.noDevicesConnected}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:u.deviceSidebar.clickToRefresh})]}):i.map(U=>a.jsx(Av,{id:U.id,serial:U.serial,model:U.model,displayName:U.display_name,status:U.status,connectionType:U.connection_type,agent:U.agent,isActive:n===U.id,onClick:()=>r(U.id),onConnectWifi:async()=>{await d(U.id)},onDisconnectWifi:async()=>{await l(U.id)},onNameUpdated:()=>{_&&_()},showToast:v},U.id))}),a.jsx(Tr,{className:"mx-4"}),a.jsxs("div",{className:"p-3 space-y-2",children:[a.jsxs(Ee,{variant:"outline",onClick:()=>y(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(bu,{className:"h-4 w-4"}),u.deviceSidebar.addDevice]}),a.jsxs(Ee,{variant:"outline",onClick:o,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(Tu,{className:"h-4 w-4"}),u.deviceSidebar.settings]})]}),a.jsx(Fo,{open:x,onOpenChange:y,children:a.jsxs(Uo,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[a.jsxs(Wo,{children:[a.jsx(Ho,{children:u.deviceSidebar.manualConnectTitle}),a.jsx(Go,{children:u.deviceSidebar.manualConnectDescription})]}),a.jsxs(qu,{value:q,onValueChange:$,className:"w-full",children:[a.jsxs($u,{className:"grid w-full grid-cols-3",children:[a.jsx(Lr,{value:"direct",children:u.deviceSidebar.directConnectTab}),a.jsx(Lr,{value:"pair",children:u.deviceSidebar.pairTab}),a.jsx(Lr,{value:"remote",children:u.deviceSidebar.remoteTab||"远程设备"})]}),a.jsxs(Mr,{value:"direct",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:u.deviceSidebar.discoveredDevices}),a.jsx(Ee,{variant:"outline",size:"sm",onClick:an,disabled:Q,className:"h-8",children:Q?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),u.deviceSidebar.scanning]}):u.deviceSidebar.scanAgain})]}),te&&a.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:a.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:te})}),(()=>{const U=Re.filter(xe=>!xe.has_pairing);return!Q&&U.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(Gs,{className:"mx-auto h-8 w-8 text-slate-400"}),a.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:u.deviceSidebar.noDirectDevices})]}):U.length>0?a.jsx("div",{className:"space-y-2",children:U.map(xe=>a.jsx("button",{onClick:()=>$n(xe,!1),disabled:se,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:a.jsx("div",{className:"flex items-start justify-between",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Is,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:xe.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[xe.ip,":",xe.port]})]})})},`${xe.ip}:${xe.port}`))}):null})(),D&&q==="direct"&&a.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:a.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:D})}),a.jsxs("div",{className:"relative my-4",children:[a.jsx(Tr,{}),a.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:u.deviceSidebar.orManualConnect})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{children:u.deviceSidebar.emulatorPreset}),a.jsx("div",{className:"grid grid-cols-3 gap-2",children:u1.map(U=>a.jsx("button",{onClick:()=>{J(U.id),U.id!=="custom"&&(N(U.ip),A(String(U.port))),M(""),j("")},className:`rounded-lg border p-2 text-xs text-center transition-colors ${z===U.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:u.deviceSidebar[U.nameKey]||U.nameKey},U.id))})]}),a.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:a.jsx("p",{className:"text-blue-800 dark:text-blue-200",children:u.deviceSidebar.emulatorNote})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"ip",children:u.deviceSidebar.ipAddress}),a.jsx(ht,{id:"ip",placeholder:"192.168.1.100",value:b,onChange:U=>{N(U.target.value),z!=="custom"&&J("custom")},onKeyDown:U=>U.key==="Enter"&&wt(),className:D?"border-red-500":""})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"port",children:u.deviceSidebar.port}),a.jsx(ht,{id:"port",type:"number",value:I,onChange:U=>{A(U.target.value),z!=="custom"&&J("custom")},onKeyDown:U=>U.key==="Enter"&&wt(),className:P?"border-red-500":""}),P&&a.jsx("p",{className:"text-sm text-red-500",children:P})]}),a.jsx(Ee,{onClick:wt,disabled:se,className:"w-full",children:se?u.common.loading:u.deviceSidebar.connect})]})]}),a.jsxs(Mr,{value:"pair",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:u.deviceSidebar.discoveredDevices}),a.jsx(Ee,{variant:"outline",size:"sm",onClick:an,disabled:Q,className:"h-8",children:Q?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),u.deviceSidebar.scanning]}):u.deviceSidebar.scanAgain})]}),te&&a.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:a.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:te})}),(()=>{const U=Re.filter(xe=>xe.has_pairing);return!Q&&U.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(Gs,{className:"mx-auto h-8 w-8 text-slate-400"}),a.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:u.deviceSidebar.noPairingDevices})]}):U.length>0?a.jsx("div",{className:"space-y-2",children:U.map(xe=>a.jsx("button",{onClick:()=>$n(xe,!0),disabled:se,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:a.jsx("div",{className:"flex items-start justify-between",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Is,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:xe.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[xe.ip,":",xe.port]}),a.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[a.jsx(kn,{className:"h-3 w-3"}),a.jsx("span",{children:u.deviceSidebar.pairingRequired})]})]})})},`${xe.ip}:${xe.port}`))}):null})(),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"relative my-4",children:[a.jsx(Tr,{}),a.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:u.deviceSidebar.orQrPair})]}),a.jsxs("div",{className:"rounded-lg bg-purple-50 dark:bg-purple-950/20 p-3 text-sm",children:[a.jsx("p",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:u.deviceSidebar.qrPairingTitle}),a.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[a.jsx("li",{children:u.deviceSidebar.qrStep1}),a.jsx("li",{children:u.deviceSidebar.qrStep2}),a.jsx("li",{children:u.deviceSidebar.qrStep3})]})]}),ae&&a.jsx("div",{className:"rounded-lg border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900",children:a.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[a.jsx("div",{className:"bg-white p-4 rounded-lg",children:a.jsx(sd,{value:ae.payload,size:200,level:"M"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[ae.status==="listening"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse"}),a.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:u.deviceSidebar.qrWaitingForScan})]}),ae.status==="pairing"&&a.jsxs(a.Fragment,{children:[a.jsx(Yt,{className:"h-4 w-4 animate-spin text-blue-500"}),a.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:u.deviceSidebar.qrPairing})]}),ae.status==="connected"&&a.jsxs(a.Fragment,{children:[a.jsx(Mc,{className:"h-4 w-4 text-green-500"}),a.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:u.deviceSidebar.qrConnected})]}),ae.status==="timeout"&&a.jsxs(a.Fragment,{children:[a.jsx(Dc,{className:"h-4 w-4 text-amber-500"}),a.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:u.deviceSidebar.qrTimeout})]}),ae.status==="error"&&a.jsxs(a.Fragment,{children:[a.jsx(Dc,{className:"h-4 w-4 text-red-500"}),a.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:u.deviceSidebar.qrError})]})]}),a.jsxs("div",{className:"flex gap-2 w-full",children:[(ae.status==="timeout"||ae.status==="error")&&a.jsx(Ee,{variant:"outline",onClick:jn,className:"flex-1",children:u.deviceSidebar.qrRegenerate}),ae.status==="listening"&&a.jsx(Ee,{variant:"outline",onClick:Pn,className:"flex-1",children:u.common.cancel}),ae.status==="connected"&&a.jsx(Ee,{onClick:()=>y(!1),className:"flex-1",children:u.common.confirm})]})]})}),!ae&&Ze&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[a.jsx(Yt,{className:"h-4 w-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:u.common.loading})]})]}),a.jsxs("div",{className:"relative my-4",children:[a.jsx(Tr,{}),a.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:u.deviceSidebar.orManualPair})]}),a.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:[a.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:u.deviceSidebar.pairingInstructions}),a.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[a.jsx("li",{children:u.deviceSidebar.pairingStep1}),a.jsx("li",{children:u.deviceSidebar.pairingStep2}),a.jsx("li",{children:u.deviceSidebar.pairingStep3}),a.jsx("li",{children:u.deviceSidebar.pairingStep4})]}),a.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:u.deviceSidebar.pairingNote})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"pair-ip",children:u.deviceSidebar.ipAddress}),a.jsx(ht,{id:"pair-ip",placeholder:"192.168.1.100",value:b,onChange:U=>N(U.target.value),className:D?"border-red-500":""}),D&&q==="pair"&&a.jsx("p",{className:"text-sm text-red-500",children:D})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"pairing-port",children:u.deviceSidebar.pairingPort}),a.jsx(ht,{id:"pairing-port",type:"number",placeholder:"37831",value:R,onChange:U=>re(U.target.value),className:P?"border-red-500":""}),P&&a.jsx("p",{className:"text-sm text-red-500",children:P})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"pairing-code",children:u.deviceSidebar.pairingCode}),a.jsx(ht,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:O,onChange:U=>C(U.target.value.replace(/\D/g,"")),onKeyDown:U=>U.key==="Enter"&&it(),className:Y?"border-red-500":""}),Y&&a.jsx("p",{className:"text-sm text-red-500",children:Y})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"connection-port",children:u.deviceSidebar.connectionPort}),a.jsx(ht,{id:"connection-port",type:"number",value:pe,onChange:U=>X(U.target.value),onKeyDown:U=>U.key==="Enter"&&it()})]}),a.jsx(Ee,{onClick:it,disabled:se,className:"w-full",children:se?u.common.loading:u.deviceSidebar.pairAndConnect})]})]}),a.jsxs(Mr,{value:"remote",className:"space-y-4 mt-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"remote-url",children:u.deviceSidebar.remoteUrl||"远程服务器地址"}),a.jsx(ht,{id:"remote-url",placeholder:"http://192.168.1.100:8001",value:ce,onChange:U=>{ye(U.target.value),We("")},disabled:de,onKeyDown:U=>U.key==="Enter"&&qn(),className:Be?"border-red-500":""}),Be&&a.jsx("p",{className:"text-sm text-red-500",children:Be}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:u.deviceSidebar.remoteUrlHint||"运行 Device Agent Server 的地址"}),a.jsx(Ee,{onClick:qn,disabled:de||!ce,className:"w-full",children:de?"正在发现...":"发现设备"})]}),ee.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{children:"可用设备"}),a.jsx("div",{className:"space-y-2",children:ee.map(U=>a.jsx("button",{onClick:()=>Le(U.device_id),className:`
|
|
34
|
+
w-full rounded-lg border p-3 text-left transition-colors
|
|
35
|
+
${we===U.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:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Is,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"font-medium text-sm",children:U.device_id}),a.jsxs("p",{className:"text-xs text-slate-500",children:[U.model," · ",U.platform]})]}),we===U.device_id&&a.jsx(Mc,{className:"h-4 w-4 text-[#1d9bf0]"})]})},U.device_id))})]}),we&&a.jsx(Ee,{onClick:dr,disabled:fe,className:"w-full",children:fe?"正在连接...":"连接远程设备"})]})]}),a.jsx(zo,{children:a.jsx(Ee,{variant:"outline",onClick:()=>{y(!1),M(""),j(""),K(""),me(""),N(""),A("5555"),C(""),re(""),X("5555"),$("direct"),G([])},children:u.common.cancel})})]})})]})]})}const sn=Object.create(null);sn.open="0";sn.close="1";sn.ping="2";sn.pong="3";sn.message="4";sn.upgrade="5";sn.noop="6";const Ls=Object.create(null);Object.keys(sn).forEach(i=>{Ls[sn[i]]=i});const Io={type:"error",data:"parser error"},od=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ad=typeof ArrayBuffer=="function",ld=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,Xo=({type:i,data:n},r,o)=>od&&n instanceof Blob?r?o(n):Gc(n,o):ad&&(n instanceof ArrayBuffer||ld(n))?r?o(n):Gc(new Blob([n]),o):o(sn[i]+(n||"")),Gc=(i,n)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];n("b"+(o||""))},r.readAsDataURL(i)};function zc(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let _o;function h1(i,n){if(od&&i.data instanceof Blob)return i.data.arrayBuffer().then(zc).then(n);if(ad&&(i.data instanceof ArrayBuffer||ld(i.data)))return n(zc(i.data));Xo(i,!1,r=>{_o||(_o=new TextEncoder),n(_o.encode(r))})}const qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ir=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<qc.length;i++)Ir[qc.charCodeAt(i)]=i;const p1=i=>{let n=i.length*.75,r=i.length,o,d=0,l,_,v,u;i[i.length-1]==="="&&(n--,i[i.length-2]==="="&&n--);const m=new ArrayBuffer(n),p=new Uint8Array(m);for(o=0;o<r;o+=4)l=Ir[i.charCodeAt(o)],_=Ir[i.charCodeAt(o+1)],v=Ir[i.charCodeAt(o+2)],u=Ir[i.charCodeAt(o+3)],p[d++]=l<<2|_>>4,p[d++]=(_&15)<<4|v>>2,p[d++]=(v&3)<<6|u&63;return m},m1=typeof ArrayBuffer=="function",Yo=(i,n)=>{if(typeof i!="string")return{type:"message",data:cd(i,n)};const r=i.charAt(0);return r==="b"?{type:"message",data:g1(i.substring(1),n)}:Ls[r]?i.length>1?{type:Ls[r],data:i.substring(1)}:{type:Ls[r]}:Io},g1=(i,n)=>{if(m1){const r=p1(i);return cd(r,n)}else return{base64:!0,data:i}},cd=(i,n)=>{switch(n){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},ud="",_1=(i,n)=>{const r=i.length,o=new Array(r);let d=0;i.forEach((l,_)=>{Xo(l,!1,v=>{o[_]=v,++d===r&&n(o.join(ud))})})},x1=(i,n)=>{const r=i.split(ud),o=[];for(let d=0;d<r.length;d++){const l=Yo(r[d],n);if(o.push(l),l.type==="error")break}return o};function v1(){return new TransformStream({transform(i,n){h1(i,r=>{const o=r.length;let d;if(o<126)d=new Uint8Array(1),new DataView(d.buffer).setUint8(0,o);else if(o<65536){d=new Uint8Array(3);const l=new DataView(d.buffer);l.setUint8(0,126),l.setUint16(1,o)}else{d=new Uint8Array(9);const l=new DataView(d.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(o))}i.data&&typeof i.data!="string"&&(d[0]|=128),n.enqueue(d),n.enqueue(r)})}})}let xo;function js(i){return i.reduce((n,r)=>n+r.length,0)}function Ps(i,n){if(i[0].length===n)return i.shift();const r=new Uint8Array(n);let o=0;for(let d=0;d<n;d++)r[d]=i[0][o++],o===i[0].length&&(i.shift(),o=0);return i.length&&o<i[0].length&&(i[0]=i[0].slice(o)),r}function b1(i,n){xo||(xo=new TextDecoder);const r=[];let o=0,d=-1,l=!1;return new TransformStream({transform(_,v){for(r.push(_);;){if(o===0){if(js(r)<1)break;const u=Ps(r,1);l=(u[0]&128)===128,d=u[0]&127,d<126?o=3:d===126?o=1:o=2}else if(o===1){if(js(r)<2)break;const u=Ps(r,2);d=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),o=3}else if(o===2){if(js(r)<8)break;const u=Ps(r,8),m=new DataView(u.buffer,u.byteOffset,u.length),p=m.getUint32(0);if(p>Math.pow(2,21)-1){v.enqueue(Io);break}d=p*Math.pow(2,32)+m.getUint32(4),o=3}else{if(js(r)<d)break;const u=Ps(r,d);v.enqueue(Yo(l?u:xo.decode(u),n)),o=0}if(d===0||d>i){v.enqueue(Io);break}}}})}const dd=4;function ot(i){if(i)return y1(i)}function y1(i){for(var n in ot.prototype)i[n]=ot.prototype[n];return i}ot.prototype.on=ot.prototype.addEventListener=function(i,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(n),this};ot.prototype.once=function(i,n){function r(){this.off(i,r),n.apply(this,arguments)}return r.fn=n,this.on(i,r),this};ot.prototype.off=ot.prototype.removeListener=ot.prototype.removeAllListeners=ot.prototype.removeEventListener=function(i,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+i];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var o,d=0;d<r.length;d++)if(o=r[d],o===n||o.fn===n){r.splice(d,1);break}return r.length===0&&delete this._callbacks["$"+i],this};ot.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),r=this._callbacks["$"+i],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,d=r.length;o<d;++o)r[o].apply(this,n)}return this};ot.prototype.emitReserved=ot.prototype.emit;ot.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};ot.prototype.hasListeners=function(i){return!!this.listeners(i).length};const Ks=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,r)=>r(n,0),Wt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),w1="arraybuffer";function fd(i,...n){return n.reduce((r,o)=>(i.hasOwnProperty(o)&&(r[o]=i[o]),r),{})}const E1=Wt.setTimeout,S1=Wt.clearTimeout;function Qs(i,n){n.useNativeTimers?(i.setTimeoutFn=E1.bind(Wt),i.clearTimeoutFn=S1.bind(Wt)):(i.setTimeoutFn=Wt.setTimeout.bind(Wt),i.clearTimeoutFn=Wt.clearTimeout.bind(Wt))}const N1=1.33;function C1(i){return typeof i=="string"?T1(i):Math.ceil((i.byteLength||i.size)*N1)}function T1(i){let n=0,r=0;for(let o=0,d=i.length;o<d;o++)n=i.charCodeAt(o),n<128?r+=1:n<2048?r+=2:n<55296||n>=57344?r+=3:(o++,r+=4);return r}function hd(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function R1(i){let n="";for(let r in i)i.hasOwnProperty(r)&&(n.length&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(i[r]));return n}function k1(i){let n={},r=i.split("&");for(let o=0,d=r.length;o<d;o++){let l=r[o].split("=");n[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return n}class A1 extends Error{constructor(n,r,o){super(n),this.description=r,this.context=o,this.type="TransportError"}}class Vo extends ot{constructor(n){super(),this.writable=!1,Qs(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,r,o){return super.emitReserved("error",new A1(n,r,o)),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=Yo(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=R1(n);return r.length?"?"+r:""}}class j1 extends Vo{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 o=0;this._polling&&(o++,this.once("pollComplete",function(){--o||r()})),this.writable||(o++,this.once("drain",function(){--o||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(n){const r=o=>{if(this.readyState==="opening"&&o.type==="open"&&this.onOpen(),o.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(o)};x1(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,_1(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]=hd()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let pd=!1;try{pd=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const P1=pd;function I1(){}class L1 extends j1{constructor(n){if(super(n),typeof location<"u"){const r=location.protocol==="https:";let o=location.port;o||(o=r?"443":"80"),this.xd=typeof location<"u"&&n.hostname!==location.hostname||o!==n.port}}doWrite(n,r){const o=this.request({method:"POST",data:n});o.on("success",r),o.on("error",(d,l)=>{this.onError("xhr post error",d,l)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=n}}class rn extends ot{constructor(n,r,o){super(),this.createRequest=n,Qs(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var n;const r=fd(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let d in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(d)&&o.setRequestHeader(d,this._opts.extraHeaders[d])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(n=this._opts.cookieJar)===null||n===void 0||n.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var d;o.readyState===3&&((d=this._opts.cookieJar)===null||d===void 0||d.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(d){this.setTimeoutFn(()=>{this._onError(d)},0);return}typeof document<"u"&&(this._index=rn.requestsCount++,rn.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=I1,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete rn.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()}}rn.requestsCount=0;rn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",$c);else if(typeof addEventListener=="function"){const i="onpagehide"in Wt?"pagehide":"unload";addEventListener(i,$c,!1)}}function $c(){for(let i in rn.requests)rn.requests.hasOwnProperty(i)&&rn.requests[i].abort()}const M1=(function(){const i=md({xdomain:!1});return i&&i.responseType!==null})();class D1 extends L1{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=M1&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new rn(md,this.uri(),n)}}function md(i){const n=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||P1))return new XMLHttpRequest}catch{}if(!n)try{return new Wt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const gd=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class O1 extends Vo{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,o=gd?{}:fd(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(o.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(n,r,o)}catch(d){return this.emitReserved("error",d)}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 o=n[r],d=r===n.length-1;Xo(o,this.supportsBinary,l=>{try{this.doWrite(o,l)}catch{}d&&Ks(()=>{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]=hd()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const vo=Wt.WebSocket||Wt.MozWebSocket;class B1 extends O1{createSocket(n,r,o){return gd?new vo(n,r,o):r?new vo(n,r):new vo(n)}doWrite(n,r){this.ws.send(r)}}class F1 extends Vo{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=b1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=n.readable.pipeThrough(r).getReader(),d=v1();d.readable.pipeTo(n.writable),this._writer=d.writable.getWriter();const l=()=>{o.read().then(({done:v,value:u})=>{v||(this.onPacket(u),l())}).catch(v=>{})};l();const _={type:"open"};this.query.sid&&(_.data=`{"sid":"${this.query.sid}"}`),this._writer.write(_).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const o=n[r],d=r===n.length-1;this._writer.write(o).then(()=>{d&&Ks(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const U1={websocket:B1,webtransport:F1,polling:D1},W1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,H1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Lo(i){if(i.length>8e3)throw"URI too long";const n=i,r=i.indexOf("["),o=i.indexOf("]");r!=-1&&o!=-1&&(i=i.substring(0,r)+i.substring(r,o).replace(/:/g,";")+i.substring(o,i.length));let d=W1.exec(i||""),l={},_=14;for(;_--;)l[H1[_]]=d[_]||"";return r!=-1&&o!=-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=G1(l,l.path),l.queryKey=z1(l,l.query),l}function G1(i,n){const r=/\/{2,9}/g,o=n.replace(r,"/").split("/");return(n.slice(0,1)=="/"||n.length===0)&&o.splice(0,1),n.slice(-1)=="/"&&o.splice(o.length-1,1),o}function z1(i,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,d,l){d&&(r[d]=l)}),r}const Mo=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ms=[];Mo&&addEventListener("offline",()=>{Ms.forEach(i=>i())},!1);class Rn extends ot{constructor(n,r){if(super(),this.binaryType=w1,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 o=Lo(n);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Lo(r.host).host);Qs(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(o=>{const d=o.prototype.name;this.transports.push(d),this._transportsByName[d]=o}),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=k1(this.opts.query)),Mo&&(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"})},Ms.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const r=Object.assign({},this.opts.query);r.EIO=dd,r.transport=n,this.id&&(r.sid=this.id);const o=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](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const n=this.opts.rememberUpgrade&&Rn.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",Rn.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 o=0;o<this.writeBuffer.length;o++){const d=this.writeBuffer[o].data;if(d&&(r+=C1(d)),o>0&&r>this._maxPayload)return this.writeBuffer.slice(0,o);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const n=Date.now()>this._pingTimeoutTime;return n&&(this._pingTimeoutTime=0,Ks(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),n}write(n,r,o){return this._sendPacket("message",n,r,o),this}send(n,r,o){return this._sendPacket("message",n,r,o),this}_sendPacket(n,r,o,d){if(typeof r=="function"&&(d=r,r=void 0),typeof o=="function"&&(d=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;const l={type:n,data:r,options:o};this.emitReserved("packetCreate",l),this.writeBuffer.push(l),d&&this.once("flush",d),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),n()},o=()=>{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?o():n()}):this.upgrading?o():n()),this}_onError(n){if(Rn.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(),Mo&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=Ms.indexOf(this._offlineEventListener);o!==-1&&Ms.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}Rn.protocol=dd;class q1 extends Rn{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),o=!1;Rn.priorWebsocketSuccess=!1;const d=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",x=>{if(!o)if(x.type==="pong"&&x.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Rn.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||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(){o||(o=!0,p(),r.close(),r=null)}const _=x=>{const y=new Error("probe error: "+x);y.transport=r.name,l(),this.emitReserved("upgradeError",y)};function v(){_("transport closed")}function u(){_("socket closed")}function m(x){r&&x.name!==r.name&&l()}const p=()=>{r.removeListener("open",d),r.removeListener("error",_),r.removeListener("close",v),this.off("close",u),this.off("upgrading",m)};r.once("open",d),r.once("error",_),r.once("close",v),this.once("close",u),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&n!=="webtransport"?this.setTimeoutFn(()=>{o||r.open()},200):r.open()}onHandshake(n){this._upgrades=this._filterUpgrades(n.upgrades),super.onHandshake(n)}_filterUpgrades(n){const r=[];for(let o=0;o<n.length;o++)~this.transports.indexOf(n[o])&&r.push(n[o]);return r}}let $1=class extends q1{constructor(n,r={}){const o=typeof n=="object"?n:r;(!o.transports||o.transports&&typeof o.transports[0]=="string")&&(o.transports=(o.transports||["polling","websocket","webtransport"]).map(d=>U1[d]).filter(d=>!!d)),super(n,o)}};function X1(i,n="",r){let o=i;r=r||typeof location<"u"&&location,i==null&&(i=r.protocol+"//"+r.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=r.protocol+i:i=r.host+i),/^(https?|wss?):\/\//.test(i)||(typeof r<"u"?i=r.protocol+"//"+i:i="https://"+i),o=Lo(i)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const l=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+l+":"+o.port+n,o.href=o.protocol+"://"+l+(r&&r.port===o.port?"":":"+o.port),o}const Y1=typeof ArrayBuffer=="function",V1=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,_d=Object.prototype.toString,K1=typeof Blob=="function"||typeof Blob<"u"&&_d.call(Blob)==="[object BlobConstructor]",Q1=typeof File=="function"||typeof File<"u"&&_d.call(File)==="[object FileConstructor]";function Ko(i){return Y1&&(i instanceof ArrayBuffer||V1(i))||K1&&i instanceof Blob||Q1&&i instanceof File}function Ds(i,n){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let r=0,o=i.length;r<o;r++)if(Ds(i[r]))return!0;return!1}if(Ko(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ds(i.toJSON(),!0);for(const r in i)if(Object.prototype.hasOwnProperty.call(i,r)&&Ds(i[r]))return!0;return!1}function J1(i){const n=[],r=i.data,o=i;return o.data=Do(r,n),o.attachments=n.length,{packet:o,buffers:n}}function Do(i,n){if(!i)return i;if(Ko(i)){const r={_placeholder:!0,num:n.length};return n.push(i),r}else if(Array.isArray(i)){const r=new Array(i.length);for(let o=0;o<i.length;o++)r[o]=Do(i[o],n);return r}else if(typeof i=="object"&&!(i instanceof Date)){const r={};for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&(r[o]=Do(i[o],n));return r}return i}function Z1(i,n){return i.data=Oo(i.data,n),delete i.attachments,i}function Oo(i,n){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<n.length)return n[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let r=0;r<i.length;r++)i[r]=Oo(i[r],n);else if(typeof i=="object")for(const r in i)Object.prototype.hasOwnProperty.call(i,r)&&(i[r]=Oo(i[r],n));return i}const eb=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],tb=5;var Oe;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(Oe||(Oe={}));class nb{constructor(n){this.replacer=n}encode(n){return(n.type===Oe.EVENT||n.type===Oe.ACK)&&Ds(n)?this.encodeAsBinary({type:n.type===Oe.EVENT?Oe.BINARY_EVENT:Oe.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let r=""+n.type;return(n.type===Oe.BINARY_EVENT||n.type===Oe.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=J1(n),o=this.encodeAsString(r.packet),d=r.buffers;return d.unshift(o),d}}function Xc(i){return Object.prototype.toString.call(i)==="[object Object]"}class Qo extends ot{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 o=r.type===Oe.BINARY_EVENT;o||r.type===Oe.BINARY_ACK?(r.type=o?Oe.EVENT:Oe.ACK,this.reconstructor=new rb(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Ko(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 o={type:Number(n.charAt(0))};if(Oe[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Oe.BINARY_EVENT||o.type===Oe.BINARY_ACK){const l=r+1;for(;n.charAt(++r)!=="-"&&r!=n.length;);const _=n.substring(l,r);if(_!=Number(_)||n.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(_)}if(n.charAt(r+1)==="/"){const l=r+1;for(;++r&&!(n.charAt(r)===","||r===n.length););o.nsp=n.substring(l,r)}else o.nsp="/";const d=n.charAt(r+1);if(d!==""&&Number(d)==d){const l=r+1;for(;++r;){const _=n.charAt(r);if(_==null||Number(_)!=_){--r;break}if(r===n.length)break}o.id=Number(n.substring(l,r+1))}if(n.charAt(++r)){const l=this.tryParse(n.substr(r));if(Qo.isPayloadValid(o.type,l))o.data=l;else throw new Error("invalid payload")}return o}tryParse(n){try{return JSON.parse(n,this.reviver)}catch{return!1}}static isPayloadValid(n,r){switch(n){case Oe.CONNECT:return Xc(r);case Oe.DISCONNECT:return r===void 0;case Oe.CONNECT_ERROR:return typeof r=="string"||Xc(r);case Oe.EVENT:case Oe.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&eb.indexOf(r[0])===-1);case Oe.ACK:case Oe.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class rb{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=Z1(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const sb=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Qo,Encoder:nb,get PacketType(){return Oe},protocol:tb},Symbol.toStringTag,{value:"Module"}));function Xt(i,n,r){return i.on(n,r),function(){i.off(n,r)}}const ib=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class xd extends ot{constructor(n,r,o){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,o&&o.auth&&(this.auth=o.auth),this._opts=Object.assign({},o),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const n=this.io;this.subs=[Xt(n,"open",this.onopen.bind(this)),Xt(n,"packet",this.onpacket.bind(this)),Xt(n,"error",this.onerror.bind(this)),Xt(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 o,d,l;if(ib.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 _={type:Oe.EVENT,data:r};if(_.options={},_.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const p=this.ids++,x=r.pop();this._registerAckCallback(p,x),_.id=p}const v=(d=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||d===void 0?void 0:d.writable,u=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!v||(u?(this.notifyOutgoingListeners(_),this.packet(_)):this.sendBuffer.push(_)),this.flags={},this}_registerAckCallback(n,r){var o;const d=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(d===void 0){this.acks[n]=r;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let v=0;v<this.sendBuffer.length;v++)this.sendBuffer[v].id===n&&this.sendBuffer.splice(v,1);r.call(this,new Error("operation has timed out"))},d),_=(...v)=>{this.io.clearTimeoutFn(l),r.apply(this,v)};_.withError=!0,this.acks[n]=_}emitWithAck(n,...r){return new Promise((o,d)=>{const l=(_,v)=>_?d(_):o(v);l.withError=!0,r.push(l),this.emit(n,...r)})}_addToQueue(n){let r;typeof n[n.length-1]=="function"&&(r=n.pop());const o={id:this._queueSeq++,tryCount:0,pending:!1,args:n,flags:Object.assign({fromQueue:!0},this.flags)};n.push((d,...l)=>o!==this._queue[0]?void 0:(d!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(d)):(this._queue.shift(),r&&r(null,...l)),o.pending=!1,this._drainQueue())),this._queue.push(o),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:Oe.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(o=>String(o.id)===n)){const o=this.acks[n];delete this.acks[n],o.withError&&o.call(this,new Error("socket has been disconnected"))}})}onpacket(n){if(n.nsp===this.nsp)switch(n.type){case Oe.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 Oe.EVENT:case Oe.BINARY_EVENT:this.onevent(n);break;case Oe.ACK:case Oe.BINARY_ACK:this.onack(n);break;case Oe.DISCONNECT:this.ondisconnect();break;case Oe.CONNECT_ERROR:this.destroy();const o=new Error(n.data.message);o.data=n.data.data,this.emitReserved("connect_error",o);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 o of r)o.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 o=!1;return function(...d){o||(o=!0,r.packet({type:Oe.ACK,id:n,data:d}))}}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:Oe.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 o=0;o<r.length;o++)if(n===r[o])return r.splice(o,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 o=0;o<r.length;o++)if(n===r[o])return r.splice(o,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 o of r)o.apply(this,n.data)}}}function ur(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}ur.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),r=Math.floor(n*this.jitter*i);i=(Math.floor(n*10)&1)==0?i-r:i+r}return Math.min(i,this.max)|0};ur.prototype.reset=function(){this.attempts=0};ur.prototype.setMin=function(i){this.ms=i};ur.prototype.setMax=function(i){this.max=i};ur.prototype.setJitter=function(i){this.jitter=i};class Bo extends ot{constructor(n,r){var o;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,Qs(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((o=r.randomizationFactor)!==null&&o!==void 0?o:.5),this.backoff=new ur({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=n;const d=r.parser||sb;this.encoder=new d.Encoder,this.decoder=new d.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 $1(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const d=Xt(r,"open",function(){o.onopen(),n&&n()}),l=v=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",v),n?n(v):this.maybeReconnectOnOpen()},_=Xt(r,"error",l);if(this._timeout!==!1){const v=this._timeout,u=this.setTimeoutFn(()=>{d(),l(new Error("timeout")),r.close()},v);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(d),this.subs.push(_),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(Xt(n,"ping",this.onping.bind(this)),Xt(n,"data",this.ondata.bind(this)),Xt(n,"error",this.onerror.bind(this)),Xt(n,"close",this.onclose.bind(this)),Xt(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){Ks(()=>{this.emitReserved("packet",n)},this.setTimeoutFn)}onerror(n){this.emitReserved("error",n)}socket(n,r){let o=this.nsps[n];return o?this._autoConnect&&!o.active&&o.connect():(o=new xd(this,n,r),this.nsps[n]=o),o}_destroy(n){const r=Object.keys(this.nsps);for(const o of r)if(this.nsps[o].active)return;this._close()}_packet(n){const r=this.encoder.encode(n);for(let o=0;o<r.length;o++)this.engine.write(r[o],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 o;this.cleanup(),(o=this.engine)===null||o===void 0||o.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 o=this.setTimeoutFn(()=>{n.skipReconnect||(this.emitReserved("reconnect_attempt",n.backoff.attempts),!n.skipReconnect&&n.open(d=>{d?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",d)):n.onreconnect()}))},r);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}}onreconnect(){const n=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",n)}}const Rr={};function Os(i,n){typeof i=="object"&&(n=i,i=void 0),n=n||{};const r=X1(i,n.path||"/socket.io"),o=r.source,d=r.id,l=r.path,_=Rr[d]&&l in Rr[d].nsps,v=n.forceNew||n["force new connection"]||n.multiplex===!1||_;let u;return v?u=new Bo(o,n):(Rr[d]||(Rr[d]=new Bo(o,n)),u=Rr[d]),r.query&&!n.query&&(n.query=r.queryKey),u.socket(r.path,n)}Object.assign(Os,{Manager:Bo,Socket:xd,io:Os,connect:Os});function ob(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}const Bs={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:ab}=globalThis;class lb{#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 cb={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},ub={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},db={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},fb={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 gt extends lb{static ObuType=cb;static ColorPrimaries=ub;static TransferCharacteristics=db;static MatrixCoefficients=fb;#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 o=this.f(8);if(n|=BigInt(o&127)<<7n*r,this.#e+=1,(o&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 o=this.openBitstreamUnit(r);o&&(yield o),n-=r}}#t=0;openBitstreamUnit(n){const r=this.obuHeader();let o;if(r.obu_has_size_field)o=this.leb128();else if(n!==void 0)o=n-1n-(r.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const d=this.getPosition();if(r.obu_type!==gt.ObuType.SequenceHeader&&r.obu_type!==gt.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const u=!!(this.#t&1<<r.obu_extension_header.temporal_id),m=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!u||!m){this.skip(Number(o));return}}let l;switch(r.obu_type){case gt.ObuType.SequenceHeader:l=this.sequenceHeaderObu();break}const _=this.getPosition(),v=(_[0]-d[0])*8+(d[1]-_[1]);return o>0&&this.skip(Number(o)*8-v),{obu_header:r,obu_size:o,sequence_header_obu:l}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const r=this.f(4),o=!!this.f1(),d=!!this.f1();this.f1();let l;return o&&(l=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:o,obu_has_size_field:d,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(),o=!!this.f1();let d=!1,l,_=!1,v,u=!1,m=0;const p=[],x=[],y=[],b=[],N=[];let I,A;if(o)p[0]=0,x[0]=this.f(5),y[0]=0,b[0]=!1,N[0]=!1;else{d=!!this.f1(),d&&(l=this.timingInfo(),_=!!this.f1(),_&&(v=this.decoderModelInfo(),I=[])),u=!!this.f1(),u&&(A=[]),m=this.f(5);for(let B=0;B<=m;B+=1)p[B]=this.f(12),x[B]=this.f(5),x[B]>7?y[B]=this.f1():y[B]=0,_?(b[B]=!!this.f1(),b[B]&&(I[B]=this.operatingParametersInfo(v))):b[B]=!1,u&&(N[B]=!!this.f1(),N[B]&&(A[B]=this.f(4)))}const D=this.chooseOperatingPoint();this.#t=p[D];const M=this.f(4),P=this.f(4),j=this.f(M+1),z=this.f(P+1);let J=!1,q,$;o||(J=!!this.f1(),J&&(q=this.f(4),$=this.f(3)));const O=!!this.f1(),C=!!this.f1(),R=!!this.f1();let re=!1,pe=!1,X=!1,Y=!1,K=!1,se=!1,oe=!1,Re=!1,G=gt.SelectScreenContentTools,Q=!1,ue=gt.SelectIntegerMv,te;o||(re=!!this.f1(),pe=!!this.f1(),X=!!this.f1(),Y=!!this.f1(),K=!!this.f1(),K&&(se=!!this.f1(),oe=!!this.f1()),Re=!!this.f1(),Re||(G=this.f1()),G>0&&(Q=!!this.f1(),Q||(ue=this.f1())),K&&(te=this.f(3)));const me=!!this.f1(),ae=!!this.f1(),Ue=!!this.f1(),Ze=this.colorConfig(n),Ge=!!this.f1();return{seq_profile:n,still_picture:r,reduced_still_picture_header:o,timing_info_present_flag:d,timing_info:l,decoder_model_info_present_flag:_,decoder_model_info:v,initial_display_delay_present_flag:u,initial_display_delay_minus_1:A,operating_points_cnt_minus_1:m,operating_point_idc:p,seq_level_idx:x,seq_tier:y,decoder_model_present_for_this_op:b,operating_parameters_info:I,initial_display_delay_present_for_this_op:N,frame_width_bits_minus_1:M,frame_height_bits_minus_1:P,max_frame_width_minus_1:j,max_frame_height_minus_1:z,frame_id_numbers_present_flag:J,delta_frame_id_length_minus_2:q,additional_frame_id_length_minus_1:$,use_128x128_superblock:O,enable_filter_intra:C,enable_intra_edge_filter:R,enable_interintra_compound:re,enable_masked_compound:pe,enable_warped_motion:X,enable_dual_filter:Y,enable_order_hint:K,enable_jnt_comp:se,enable_ref_frame_mvs:oe,seq_choose_screen_content_tools:Re,seq_force_screen_content_tools:G,seq_choose_integer_mv:Q,seq_force_integer_mv:ue,order_hint_bits_minus_1:te,enable_superres:me,enable_cdef:ae,enable_restoration:Ue,color_config:Ze,film_grain_params_present:Ge}}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),o=!!this.f1();let d;return o&&(d=this.uvlc()),{num_units_in_display_tick:n,time_scale:r,equal_picture_interval:o,num_ticks_per_picture_minus_1:d}}decoderModelInfo(){const n=this.f(5),r=this.f(32),o=this.f(5),d=this.f(5);return{buffer_delay_length_minus_1:n,num_units_in_decoding_tick:r,buffer_removal_time_length_minus_1:o,frame_presentation_time_length_minus_1:d}}operatingParametersInfo(n){const r=n.buffer_delay_length_minus_1+1,o=this.f(r),d=this.f(r),l=!!this.f1();return{decoder_buffer_delay:o,encoder_buffer_delay:d,low_delay_mode_flag:l}}chooseOperatingPoint(){return 0}colorConfig(n){const r=!!this.f1();let o=!1,d=8;n===2&&r?(o=!!this.f1(),d=o?12:10):n<=2&&(d=r?10:8);let l=!1;n===1&&(l=!!this.f1());const _=!!this.f1();let v=gt.ColorPrimaries.Unspecified,u=gt.TransferCharacteristics.Unspecified,m=gt.MatrixCoefficients.Unspecified;_&&(v=this.f(8),u=this.f(8),m=this.f(8));let p=!1,x,y,b=0,N=!1;if(l)p=!!this.f1(),x=!0,y=!0;else{if(v===gt.ColorPrimaries.Bt709&&u===gt.TransferCharacteristics.Srgb&&m===gt.MatrixCoefficients.Identity)p=!0,x=!1,y=!1;else{switch(p=!!this.f1(),n){case 0:x=!0,y=!0;break;case 1:x=!1,y=!1;break;default:d==12?(x=!!this.f1(),x?y=!!this.f1():y=!1):(x=!0,y=!1);break}x&&y&&(b=this.f(2))}N=!!this.f1()}return{high_bitdepth:r,twelve_bit:o,BitDepth:d,mono_chrome:l,color_description_present_flag:_,color_primaries:v,transfer_characteristics:u,matrix_coefficients:m,color_range:p,subsampling_x:x,subsampling_y:y,chroma_sample_position:b,separate_uv_delta_q:N}}}function*vd(i){let n=-1,r=0,o=!1;for(let d=0;d<i.length;d+=1){const l=i[d];if(o){if(l>3)throw new Error("Invalid data");o=!1;continue}if(l===0){r+=1;continue}const _=r;if(r=0,n===-1){if(_>=2&&l===1){n=d+1;continue}throw new Error("Invalid data")}if(!(_<2)){if(l===1){yield i.subarray(n,d-_),n=d+1;continue}if(_>2)throw new Error("Invalid data");switch(l){case 2:throw new Error("Invalid data");case 3:o=!0;break}}}if(o)throw new Error("Invalid data");yield i.subarray(n,i.length)}class Js{#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 o=n[r];for(let d=0;d<8;d+=1)if((o>>d&1)===1){this.#t=r,this.#n=d,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 o=0;o<n;o+=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(),o=this.read(n);return this.#a(r),o}readBytes(n){const r=new Uint8Array(n);for(let o=0;o<n;o+=1)r[o]=this.read(8);return r}peekBytes(n){const r=this.#d(),o=this.readBytes(n);return this.#a(r),o}}function hb(i){const n=new Js(i);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 d=n.read(8),l=n.peek(8),_=!!n.next(),v=!!n.next(),u=!!n.next(),m=!!n.next(),p=!!n.next(),x=!!n.next();if(n.read(2)!==0)throw new Error("Invalid data");const y=n.read(8),b=n.decodeExponentialGolombNumber();if(d===100||d===110||d===122||d===244||d===44||d===83||d===86||d===118||d===128||d===138||d===139||d===134){const q=n.decodeExponentialGolombNumber();if(q===3&&n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber(),n.next(),!!n.next())for(let O=0;O<(q!==3?8:12);O+=1)n.next()}n.decodeExponentialGolombNumber();const N=n.decodeExponentialGolombNumber();if(N===0)n.decodeExponentialGolombNumber();else if(N===1){n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber();const q=n.decodeExponentialGolombNumber();for(let $=0;$<q;$+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const I=n.decodeExponentialGolombNumber(),A=n.decodeExponentialGolombNumber(),D=n.next();D||n.next(),n.next();const M=!!n.next();let P,j,z,J;return M?(P=n.decodeExponentialGolombNumber(),j=n.decodeExponentialGolombNumber(),z=n.decodeExponentialGolombNumber(),J=n.decodeExponentialGolombNumber()):(P=0,j=0,z=0,J=0),n.next(),{profile_idc:d,constraint_set:l,constraint_set0_flag:_,constraint_set1_flag:v,constraint_set2_flag:u,constraint_set3_flag:m,constraint_set4_flag:p,constraint_set5_flag:x,level_idc:y,seq_parameter_set_id:b,pic_width_in_mbs_minus1:I,pic_height_in_map_units_minus1:A,frame_mbs_only_flag:D,frame_cropping_flag:M,frame_crop_left_offset:P,frame_crop_right_offset:j,frame_crop_top_offset:z,frame_crop_bottom_offset:J}}function pb(i){let n,r;for(const o of vd(i))switch(o[0]&31){case 7:if(n=o,r)return{sequenceParameterSet:n,pictureParameterSet:r};break;case 8:if(r=o,n)return{sequenceParameterSet:n,pictureParameterSet:r};break}throw new Error("Invalid data")}function mb(i){const{sequenceParameterSet:n,pictureParameterSet:r}=pb(i),{profile_idc:o,constraint_set:d,level_idc:l,pic_width_in_mbs_minus1:_,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:u,frame_crop_left_offset:m,frame_crop_right_offset:p,frame_crop_top_offset:x,frame_crop_bottom_offset:y}=hb(n),b=(_+1)*16,N=(v+1)*(2-u)*16,I=m*2,A=p*2,D=x*2,M=y*2,P=b-I-A,j=N-D-M;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:d,levelIndex:l,encodedWidth:b,encodedHeight:N,cropLeft:I,cropRight:A,cropTop:D,cropBottom:M,croppedWidth:P,croppedHeight:j}}function gb(i){switch(i){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function _b(i){switch(i){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function xb(i){const n=new Js(i);if(n.next()!==0)throw new Error("Invalid NALU header");const r=n.read(6),o=n.read(6),d=n.read(3);return{nal_unit_type:r,nuh_layer_id:o,nuh_temporal_id_plus1:d}}function vb(i){const n=new Js(i),r=n.read(4),o=!!n.next(),d=!!n.next(),l=n.read(6),_=n.read(3),v=!!n.next();n.skip(16);const u=bd(n,!0,_),m=!!n.next(),p=[],x=[],y=[];for(let C=m?0:_;C<=_;C+=1)p[C]=n.decodeExponentialGolombNumber(),x[C]=n.decodeExponentialGolombNumber(),y[C]=n.decodeExponentialGolombNumber();const b=n.read(6),N=n.decodeExponentialGolombNumber(),I=[];for(let C=1;C<=N;C+=1){I[C]=[];for(let R=0;R<=b;R+=1)I[C][R]=!!n.next()}const A=!!n.next();let D,M,P,j,z,J,q,$;if(A){D=n.read(32),M=n.read(32),P=!!n.next(),P&&(j=n.decodeExponentialGolombNumber()),z=n.decodeExponentialGolombNumber(),J=[],q=[!0],$=[];for(let C=0;C<z;C+=1)J[C]=n.decodeExponentialGolombNumber(),C>0&&(q[C]=!!n.next()),$[C]=yd(n,q[C],_)}const O=!!n.next();return{vps_video_parameter_set_id:r,vps_base_layer_internal_flag:o,vps_base_layer_available_flag:d,vps_max_layers_minus1:l,vps_max_sub_layers_minus1:_,vps_temporal_id_nesting_flag:v,profileTierLevel:u,vps_sub_layer_ordering_info_present_flag:m,vps_max_dec_pic_buffering_minus1:p,vps_max_num_reorder_pics:x,vps_max_latency_increase_plus1:y,vps_max_layer_id:b,vps_num_layer_sets_minus1:N,layer_id_included_flag:I,vps_timing_info_present_flag:A,vps_num_units_in_tick:D,vps_time_scale:M,vps_poc_proportional_to_timing_flag:P,vps_num_ticks_poc_diff_one_minus1:j,vps_num_hrd_parameters:z,hrd_layer_set_idx:J,cprms_present_flag:q,hrdParameters:$,vps_extension_flag:O}}function bb(i){const n=new Js(i),r=n.read(4),o=n.read(3),d=!!n.next(),l=bd(n,!0,o),_=n.decodeExponentialGolombNumber(),v=n.decodeExponentialGolombNumber();let u;v===3&&(u=!!n.next());const m=n.decodeExponentialGolombNumber(),p=n.decodeExponentialGolombNumber(),x=!!n.next();let y,b,N,I;x&&(y=n.decodeExponentialGolombNumber(),b=n.decodeExponentialGolombNumber(),N=n.decodeExponentialGolombNumber(),I=n.decodeExponentialGolombNumber());const A=n.decodeExponentialGolombNumber(),D=n.decodeExponentialGolombNumber(),M=n.decodeExponentialGolombNumber(),P=[],j=[],z=[],J=!!n.next();for(let he=J?0:o;he<=o;he+=1)P[he]=n.decodeExponentialGolombNumber(),j[he]=n.decodeExponentialGolombNumber(),z[he]=n.decodeExponentialGolombNumber();const q=n.decodeExponentialGolombNumber(),$=n.decodeExponentialGolombNumber(),O=n.decodeExponentialGolombNumber(),C=n.decodeExponentialGolombNumber(),R=n.decodeExponentialGolombNumber(),re=n.decodeExponentialGolombNumber(),pe=!!n.next();let X,Y;pe&&(X=!!n.next(),X&&(Y=yb(n)));const K=!!n.next(),se=!!n.next(),oe=!!n.next();let Re,G,Q,ue,te;oe&&(Re=n.read(4),G=n.read(4),Q=n.read(4),ue=n.read(4),te=!!n.next());const me=n.decodeExponentialGolombNumber(),ae=[];for(let he=0;he<me;he+=1)ae[he]=wb(n,he,me,ae);const Ue=!!n.next();let Ze,Ge,B;if(Ue){Ze=n.decodeExponentialGolombNumber(),Ge=[],B=[];for(let he=0;he<Ze;he+=1)Ge[he]=n.read(M+4),B[he]=!!n.next()}const ce=!!n.next(),ye=!!n.next(),Be=!!n.next();let We;Be&&(We=Eb(n,o));const de=!!n.next();let Se,ee,Z,we,Le;if(de&&(Se=!!n.next(),ee=!!n.next(),Z=!!n.next(),we=!!n.next(),Le=n.read(4)),Se)throw new Error("Not implemented");let fe;ee&&(fe=Nb(n));let _e;if(Z&&(_e=Cb(n)),we)throw new Error("Not implemented");let Ne;if(Le){Ne=[];let he=0;for(;!n.ended;)Ne[he]=!!n.next(),he+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:o,sps_temporal_id_nesting_flag:d,profileTierLevel:l,sps_seq_parameter_set_id:_,chroma_format_idc:v,separate_colour_plane_flag:u,pic_width_in_luma_samples:m,pic_height_in_luma_samples:p,conformance_window_flag:x,conf_win_left_offset:y,conf_win_right_offset:b,conf_win_top_offset:N,conf_win_bottom_offset:I,bit_depth_luma_minus8:A,bit_depth_chroma_minus8:D,log2_max_pic_order_cnt_lsb_minus4:M,sps_sub_layer_ordering_info_present_flag:J,sps_max_dec_pic_buffering_minus1:P,sps_max_num_reorder_pics:j,sps_max_latency_increase_plus1:z,log2_min_luma_coding_block_size_minus3:q,log2_diff_max_min_luma_coding_block_size:$,log2_min_luma_transform_block_size_minus2:O,log2_diff_max_min_luma_transform_block_size:C,max_transform_hierarchy_depth_inter:R,max_transform_hierarchy_depth_intra:re,scaling_list_enabled_flag:pe,sps_scaling_list_data_present_flag:X,scalingListData:Y,amp_enabled_flag:K,sample_adaptive_offset_enabled_flag:se,pcm_enabled_flag:oe,pcm_sample_bit_depth_luma_minus1:Re,pcm_sample_bit_depth_chroma_minus1:G,log2_min_pcm_luma_coding_block_size_minus3:Q,log2_diff_max_min_pcm_luma_coding_block_size:ue,pcm_loop_filter_disabled_flag:te,num_short_term_ref_pic_sets:me,shortTermRefPicSets:ae,long_term_ref_pics_present_flag:Ue,num_long_term_ref_pics_sps:Ze,lt_ref_pic_poc_lsb_sps:Ge,used_by_curr_pic_lt_sps_flag:B,sps_temporal_mvp_enabled_flag:ce,strong_intra_smoothing_enabled_flag:ye,vui_parameters_present_flag:Be,vuiParameters:We,sps_extension_present_flag:de,sps_range_extension_flag:Se,sps_multilayer_extension_flag:ee,sps_3d_extension_flag:Z,sps_scc_extension_flag:we,sps_extension_4bits:Le,spsMultilayerExtension:fe,sps3dExtension:_e,sps_extension_data_flag:Ne}}function Yc(i){const n=i.read(2),r=!!i.next(),o=i.read(5),d=i.peekBytes(4),l=[];for(let J=0;J<32;J+=1)l[J]=!!i.next();const _=i.peekBytes(6),v=!!i.next(),u=!!i.next(),m=!!i.next(),p=!!i.next();let x,y,b,N,I,A,D,M,P,j;o===4||l[4]||o===5||l[5]||o===6||l[6]||o===7||l[7]||o===8||l[8]||o===9||l[9]||o===10||l[10]||o===11||l[11]?(x=!!i.next(),y=!!i.next(),b=!!i.next(),N=!!i.next(),I=!!i.next(),A=!!i.next(),D=!!i.next(),M=!!i.next(),P=!!i.next(),o===5||l[5]||o===9||l[9]||o===10||l[10]||o===11||l[11]?(j=!!i.next(),i.skip(33)):i.skip(34)):o===2||l[2]?(i.skip(7),M=!!i.next(),i.skip(35)):i.skip(43);let z;return o===1||l[1]||o===2||l[2]||o===3||l[3]||o===4||l[4]||o===5||l[5]||o===9||l[9]||o===11||l[11]?z=!!i.next():i.skip(1),{profile_space:n,tier_flag:r,profile_idc:o,profileCompatibilitySet:d,profile_compatibility_flag:l,constraintSet:_,progressive_source_flag:v,interlaced_source_flag:u,non_packed_constraint_flag:m,frame_only_constraint_flag:p,max_12bit_constraint_flag:x,max_10bit_constraint_flag:y,max_8bit_constraint_flag:b,max_422chroma_constraint_flag:N,max_420chroma_constraint_flag:I,max_monochrome_constraint_flag:A,intra_constraint_flag:D,one_picture_only_constraint_flag:M,lower_bit_rate_constraint_flag:P,max_14bit_constraint_flag:j,inbld_flag:z}}function bd(i,n,r){let o;o=Yc(i);const d=i.read(8),l=[],_=[];for(let m=0;m<r;m+=1)l[m]=!!i.next(),_[m]=!!i.next();if(r>0)for(let m=r;m<8;m+=1)i.read(2);const v=[],u=[];for(let m=0;m<r;m+=1)l[m]&&(v[m]=Yc(i)),_[m]&&(u[m]=i.read(8));return{generalProfileTier:o,general_level_idc:d,sub_layer_profile_present_flag:l,sub_layer_level_present_flag:_,subLayerProfileTier:v,sub_layer_level_idc:u}}function yb(i){const n=[];for(let r=0;r<4;r+=1){n[r]=[];for(let o=0;o<6;o+=r===3?3:1)if(!!!i.next())i.decodeExponentialGolombNumber();else{let l=8;const _=Math.min(64,1<<4+(r<<1));r>1&&(l=i.decodeExponentialGolombNumber()+8),n[r][o]=[];for(let v=0;v<_;v+=1){const u=i.decodeExponentialGolombNumber();l=(l+u+256)%256,n[r][o][v]=l}}}return n}function wb(i,n,r,o){let d=!1;n!==0&&(d=!!i.next());let l=0,_=!1,v=0;const u=[],m=[];let p=0,x=0;const y=[],b=[],N=[],I=[];if(d){n===r&&(l=i.decodeExponentialGolombNumber()),_=!!i.next(),v=i.decodeExponentialGolombNumber();const A=n-(l+1),D=o[A],M=D.num_negative_pics+D.num_positive_pics;for(let R=0;R<=M;R+=1)u[R]=!!i.next(),u[R]?m[R]=!0:m[R]=!!i.next();const P=(1-2*Number(_))*(v+1),j=[],z=[],J=[],q=[];let $=0;for(let R=0;R<D.num_negative_pics;R+=1)$-=D.delta_poc_s0_minus1[R]+1,j[R]=$;$=0;for(let R=0;R<D.num_positive_pics;R+=1)$+=D.delta_poc_s1_minus1[R]+1,z[R]=$;let O=0;if(D.num_positive_pics>0)for(let R=D.num_positive_pics-1;R>=0;R-=1)$=z[R]+P,$<0&&m[D.num_negative_pics+R]&&(J[O]=$,b[O]=u[D.num_negative_pics+R],O+=1);P<0&&m[M]&&(J[O]=P,b[O]=u[M],O+=1);for(let R=0;R<D.num_negative_pics;R+=1)$=j[R]+P,$<0&&m[R]&&(J[O]=$,b[O]=u[R],O+=1);p=O;let C=0;for(O=0;O<p;O+=1){const R=J[O];y[O]=-(R-C-1),C=R}if(O=0,D.num_negative_pics>0)for(let R=D.num_negative_pics-1;R>=0;R-=1)$=j[R]+P,$>0&&m[R]&&(q[O]=$,I[O]=u[R],O+=1);P>0&&m[M]&&(q[O]=P,I[O]=u[M],O+=1);for(let R=0;R<D.num_positive_pics;R+=1)$=z[R]+P,$>0&&m[D.num_negative_pics+R]&&(q[O]=$,I[O]=u[D.num_negative_pics+R],O+=1);for(x=O,C=0,O=0;O<x;O+=1){const R=q[O];N[O]=R-C-1,C=R}}else{p=i.decodeExponentialGolombNumber(),x=i.decodeExponentialGolombNumber();for(let A=0;A<p;A+=1)y[A]=i.decodeExponentialGolombNumber(),b[A]=!!i.next();for(let A=0;A<x;A+=1)N[A]=i.decodeExponentialGolombNumber(),I[A]=!!i.next()}return{stRpsIdx:n,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:d,delta_idx_minus1:l,delta_rps_sign:_,abs_delta_rps_minus1:v,used_by_curr_pic_flag:u,use_delta_flag:m,num_negative_pics:p,num_positive_pics:x,delta_poc_s0_minus1:y,used_by_curr_pic_s0_flag:b,delta_poc_s1_minus1:N,used_by_curr_pic_s1_flag:I}}function Eb(i,n){const r=!!i.next();let o,d,l;r&&(o=i.read(8),o===255&&(d=i.read(16),l=i.read(16)));const _=!!i.next();let v;_&&(v=!!i.next());const u=!!i.next();let m,p,x,y,b,N;u&&(m=i.read(3),p=!!i.next(),x=!!i.next(),x&&(y=i.read(8),b=i.read(8),N=i.read(8)));const I=!!i.next();let A,D;I&&(A=i.decodeExponentialGolombNumber(),D=i.decodeExponentialGolombNumber());const M=!!i.next(),P=!!i.next(),j=!!i.next(),z=!!i.next();let J,q,$,O;z&&(J=i.decodeExponentialGolombNumber(),q=i.decodeExponentialGolombNumber(),$=i.decodeExponentialGolombNumber(),O=i.decodeExponentialGolombNumber());const C=!!i.next();let R,re,pe,X,Y,K;C&&(R=i.read(32),re=i.read(32),pe=!!i.next(),pe&&(X=i.decodeExponentialGolombNumber()),Y=!!i.next(),Y&&(K=yd(i,!0,n)));const se=!!i.next();let oe,Re,G,Q,ue,te,me,ae;return se&&(oe=!!i.next(),Re=!!i.next(),G=!!i.next(),Q=i.decodeExponentialGolombNumber(),ue=i.decodeExponentialGolombNumber(),te=i.decodeExponentialGolombNumber(),me=i.decodeExponentialGolombNumber(),ae=i.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:o,sar_width:d,sar_height:l,overscan_info_present_flag:_,overscan_appropriate_flag:v,video_signal_type_present_flag:u,video_format:m,video_full_range_flag:p,colour_description_present_flag:x,colour_primaries:y,transfer_characteristics:b,matrix_coeffs:N,chroma_loc_info_present_flag:I,chroma_sample_loc_type_top_field:A,chroma_sample_loc_type_bottom_field:D,neutral_chroma_indication_flag:M,field_seq_flag:P,frame_field_info_present_flag:j,default_display_window_flag:z,def_disp_win_left_offset:J,def_disp_win_right_offset:q,def_disp_win_top_offset:$,def_disp_win_bottom_offset:O,vui_timing_info_present_flag:C,vui_num_units_in_tick:R,vui_time_scale:re,vui_poc_proportional_to_timing_flag:pe,vui_num_ticks_poc_diff_one_minus1:X,vui_hrd_parameters_present_flag:Y,vui_hrd_parameters:K,bitstream_restriction_flag:se,tiles_fixed_structure_flag:oe,motion_vectors_over_pic_boundaries_flag:Re,restricted_ref_pic_lists_flag:G,min_spatial_segmentation_idc:Q,max_bytes_per_pic_denom:ue,max_bits_per_min_cu_denom:te,log2_max_mv_length_horizontal:me,log2_max_mv_length_vertical:ae}}function yd(i,n,r){let o,d,l,_,v,u,m,p,x,y,b,N,I;n&&(o=!!i.next(),d=!!i.next(),(o||d)&&(l=!!i.next(),l&&(_=i.read(8),v=i.read(5),u=!!i.next(),m=i.read(5)),p=i.read(4),x=i.read(4),l&&(y=i.read(4)),b=i.read(5),N=i.read(5),I=i.read(5)));const A=[],D=[],M=[],P=[],j=[],z=[],J=[];for(let q=0;q<=r;q+=1)A[q]=!!i.next(),A[q]||(D[q]=!!i.next()),D[q]?M[q]=i.decodeExponentialGolombNumber():P[q]=!!i.next(),P[q]||(j[q]=i.decodeExponentialGolombNumber()),o&&(z[q]=Vc(i,q,Kc(j[q]))),d&&(J[q]=Vc(i,q,Kc(j[q])));return{nal_hrd_parameters_present_flag:o,vcl_hrd_parameters_present_flag:d,sub_pic_hrd_params_present_flag:l,tick_divisor_minus2:_,du_cpb_removal_delay_increment_length_minus1:v,sub_pic_cpb_params_in_pic_timing_sei_flag:u,dpb_output_delay_du_length_minus1:m,bit_rate_scale:p,cpb_size_scale:x,cpb_size_du_scale:y,initial_cpb_removal_delay_length_minus1:b,au_cpb_removal_delay_length_minus1:N,dpb_output_delay_length_minus1:I,fixed_pic_rate_general_flag:A,fixed_pic_rate_within_cvs_flag:D,elemental_duration_in_tc_minus1:M,low_delay_hrd_flag:P,cpb_cnt_minus1:j,nalHrdParameters:z,vclHrdParameters:J}}function Vc(i,n,r){const o=[],d=[],l=[],_=[],v=[];for(let u=0;u<r;u+=1)o[u]=i.decodeExponentialGolombNumber(),d[u]=i.decodeExponentialGolombNumber(),n>0&&(v[u]=!!i.next());return{bit_rate_value_minus1:o,cpb_size_value_minus1:d,cpb_size_du_value_minus1:l,bit_rate_du_value_minus1:_,cbr_flag:v}}function Kc(i){return i+1}function Sb(i){let n,r,o,d=0;for(const l of vd(i)){const _=xb(l),v={..._,data:l,rbsp:l.subarray(2)};switch(_.nal_unit_type){case 32:n=v;break;case 33:r=v;break;case 34:o=v;break;default:continue}if(d+=1,d===3)return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}}throw new Error("Invalid data")}function Nb(i){return{inter_view_mv_vert_constraint_flag:!!i.next()}}function Cb(i){const n=[],r=[];n[0]=!!i.next(),r[0]=!!i.next();const o=i.decodeExponentialGolombNumber(),d=!!i.next(),l=!!i.next(),_=!!i.next(),v=!!i.next();n[1]=!!i.next(),r[1]=!!i.next();const u=!!i.next(),m=i.decodeExponentialGolombNumber(),p=!!i.next(),x=!!i.next(),y=!!i.next(),b=!!i.next(),N=!!i.next();return{iv_di_mc_enabled_flag:n,iv_mv_scal_enabled_flag:r,log2_ivmc_sub_pb_size_minus3:o,iv_res_pred_enabled_flag:d,depth_ref_enabled_flag:l,vsp_mc_enabled_flag:_,dbbp_enabled_flag:v,tex_mc_enabled_flag:u,log2_texmc_sub_pb_size_minus3:m,intra_contour_enabled_flag:p,intra_dc_only_wedge_enabled_flag:x,cqt_cu_part_pred_enabled_flag:y,inter_dc_only_enabled_flag:b,skip_intra_enabled_flag:N}}function Tb(i){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}=Sb(i),{profileTierLevel:{generalProfileTier:{profile_space:d,tier_flag:l,profile_idc:_,profileCompatibilitySet:v,constraintSet:u},general_level_idc:m}}=vb(n.rbsp),{chroma_format_idc:p,pic_width_in_luma_samples:x,pic_height_in_luma_samples:y,conf_win_left_offset:b=0,conf_win_right_offset:N=0,conf_win_top_offset:I=0,conf_win_bottom_offset:A=0}=bb(r.rbsp),D=gb(p),M=_b(p),P=x-D*(b+N),j=y-M*(I+A);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o,generalProfileSpace:d,generalProfileIndex:_,generalProfileCompatibilitySet:v,generalTierFlag:l,generalLevelIndex:m,generalConstraintSet:u,encodedWidth:x,encodedHeight:y,cropLeft:b,cropRight:N,cropTop:I,cropBottom:A,croppedWidth:P,croppedHeight:j}}function Qc(i){return i.toString(16).toUpperCase()}function bo(i){return i.toString(16).toUpperCase().padStart(2,"0")}function kr(i){return i.toString(10).padStart(2,"0")}class Rb{#e;#t;constructor(n,r){this.#e=n,this.#t=r}#n(n){const o=new gt(n).searchSequenceHeaderObu();if(!o)return;const{seq_profile:d,seq_level_idx:[l=0],max_frame_width_minus_1:_,max_frame_height_minus_1:v,color_config:{BitDepth:u,mono_chrome:m,subsampling_x:p,subsampling_y:x,chroma_sample_position:y,color_description_present_flag:b}}=o;let N,I,A,D;b?{color_primaries:N,transfer_characteristics:I,matrix_coefficients:A,color_range:D}=o.color_config:(N=gt.ColorPrimaries.Bt709,I=gt.TransferCharacteristics.Bt709,A=gt.MatrixCoefficients.Bt709,D=!1);const M=_+1,P=v+1;this.#t(M,P);const j=["av01",d.toString(16),kr(l)+(o.seq_tier[0]?"H":"M"),kr(u),m?"1":"0",(p?"1":"0")+(x?"1":"0")+y.toString(),kr(N),kr(I),kr(A),D?"1":"0"].join(".");this.#e.configure({codec:j,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 wd{#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 kb extends wd{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{profileIndex:r,constraintSet:o,levelIndex:d,croppedWidth:l,croppedHeight:_}=mb(n);this.#t(l,_);const v="avc1."+bo(r)+bo(o)+bo(d);this.#e.configure({codec:v,optimizeForLatency:!0})}}class Ab extends wd{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{generalProfileSpace:r,generalProfileIndex:o,generalProfileCompatibilitySet:d,generalTierFlag:l,generalLevelIndex:_,generalConstraintSet:v,croppedWidth:u,croppedHeight:m}=Tb(n);this.#t(u,m);const p=["hev1",["","A","B","C"][r]+o.toString(),Qc(ob(d,0)),(l?"H":"L")+_.toString(),...Array.from(v,Qc)].join(".");this.#e.configure({codec:p,codedWidth:u,codedHeight:m,optimizeForLatency:!0})}}class jb{listeners=[];constructor(){this.event=this.event.bind(this)}addEventListener(n){this.listeners.push(n);const r=()=>{const o=this.listeners.indexOf(n);o!==-1&&this.listeners.splice(o,1)};return r.dispose=r,r}event=(n,r,...o)=>{const d={listener:n,thisArg:r,args:o};return this.addEventListener(d)};fire(n){for(const r of this.listeners.slice())r.listener.apply(r.thisArg,[n,...r.args])}dispose(){this.listeners.length=0}}class Pb{#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 Ib{#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((o,d)=>{this.#e.toBlob(l=>{l?o(l):d(new Error("Failed to convert canvas to blob"))},"image/png")})}}const Jc=new Pb(()=>new Ib,4);class Zc{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 jb;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:o=>{if(this.#f?.close(),this.#f=o.clone(),this.#p){this.#u&&(this.#u.close(),this.#c+=1),this.#u=o;return}this.#_(o)},error:o=>{this.#g(o)}}),this.#e){case Bs.H264:this.#t=new kb(this.#a,this.#h);break;case Bs.H265:this.#t=new Ab(this.#a,this.#h);break;case Bs.AV1:this.#t=new Rb(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new ab({start:o=>{this.#r?o.error(this.#r):this.#i=o},write:o=>{this.#t.decode(o)}}),this.#x()}#g(n){if(this.#i)try{this.#i.error(n)}catch{}else this.#r=n}async#_(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.#_(r)}this.#p=!1}catch(r){this.#g(r)}}#h=(n,r)=>{this.#s.setSize(n,r),this.#d.fire({width:n,height:r})};#x=()=>{this.#o>0&&(this.#l+=1,this.#c+=this.#o-1,this.#o=0),this.#m=requestAnimationFrame(this.#x)};async snapshot(){const n=this.#f;if(!n)return;const r=await Jc.borrow(),o=await r.capture(n);return Jc.return(r),o}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#f?.close()}}var yo={exports:{}},wo={exports:{}},eu;function Jo(){return eu||(eu=1,(function(){function i(n,r){throw new Error("abstract")}i.prototype.drawFrame=function(n){throw new Error("abstract")},i.prototype.clear=function(){throw new Error("abstract")},wo.exports=i})()),wo.exports}var Eo={exports:{}},So={exports:{}},No={exports:{}},tu;function Lb(){return tu||(tu=1,(function(){function i(n){for(var r=0,o=n>>1;o!=0;)o=o>>1,r++;if(n!==1<<r)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+n;return r}No.exports=i})()),No.exports}var nu;function Mb(){return nu||(nu=1,(function(){var i=Lb();function n(r,o){var d=r.format.width|0,l=r.format.height|0,_=i(r.format.width/r.format.chromaWidth)|0,v=i(r.format.height/r.format.chromaHeight)|0,u=r.y.bytes,m=r.u.bytes,p=r.v.bytes,x=r.y.stride|0,y=r.u.stride|0,b=r.v.stride|0,N=d<<2,I=0,A=0,D=0,M=0,P=0,j=0,z=0,J=0,q=0,$=0,O=0,C=0,R=0,re=0,pe=0,X=0,Y=0,K=0;if(_==1&&v==1)for(z=0,J=N,K=0,X=0;X<l;X+=2){for(A=X*x|0,D=A+x|0,M=K*y|0,P=K*b|0,pe=0;pe<d;pe+=2)q=m[M++]|0,$=p[P++]|0,C=(409*$|0)-57088|0,R=(100*q|0)+(208*$|0)-34816|0,re=(516*q|0)-70912|0,O=298*u[A++]|0,o[z]=O+C>>8,o[z+1]=O-R>>8,o[z+2]=O+re>>8,z+=4,O=298*u[A++]|0,o[z]=O+C>>8,o[z+1]=O-R>>8,o[z+2]=O+re>>8,z+=4,O=298*u[D++]|0,o[J]=O+C>>8,o[J+1]=O-R>>8,o[J+2]=O+re>>8,J+=4,O=298*u[D++]|0,o[J]=O+C>>8,o[J+1]=O-R>>8,o[J+2]=O+re>>8,J+=4;z+=N,J+=N,K++}else for(j=0,X=0;X<l;X++)for(Y=0,K=X>>v,I=X*x|0,M=K*y|0,P=K*b|0,pe=0;pe<d;pe++)Y=pe>>_,q=m[M+Y]|0,$=p[P+Y]|0,C=(409*$|0)-57088|0,R=(100*q|0)+(208*$|0)-34816|0,re=(516*q|0)-70912|0,O=298*u[I++]|0,o[j]=O+C>>8,o[j+1]=O-R>>8,o[j+2]=O+re>>8,j+=4}So.exports={convertYCbCr:n}})()),So.exports}var ru;function Db(){return ru||(ru=1,(function(){var i=Jo(),n=Mb();function r(o){var d=this,l=o.getContext("2d"),_=null,v=null,u=null;function m(x,y){_=l.createImageData(x,y);for(var b=_.data,N=x*y*4,I=0;I<N;I+=4)b[I+3]=255}function p(x,y){v=document.createElement("canvas"),v.width=x,v.height=y,u=v.getContext("2d")}return d.drawFrame=function(y){var b=y.format;(o.width!==b.displayWidth||o.height!==b.displayHeight)&&(o.width=b.displayWidth,o.height=b.displayHeight),(_===null||_.width!=b.width||_.height!=b.height)&&m(b.width,b.height),n.convertYCbCr(y,_.data);var N=b.cropWidth!=b.displayWidth||b.cropHeight!=b.displayHeight,I;N?(v||p(b.cropWidth,b.cropHeight),I=u):I=l,I.putImageData(_,-b.cropLeft,-b.cropTop,b.cropLeft,b.cropTop,b.cropWidth,b.cropHeight),N&&l.drawImage(v,0,0,b.displayWidth,b.displayHeight)},d.clear=function(){l.clearRect(0,0,o.width,o.height)},d}r.prototype=Object.create(i.prototype),Eo.exports=r})()),Eo.exports}var Co={exports:{}},To,su;function Ob(){return su||(su=1,To={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
|
+
`}),To}var iu;function Bb(){return iu||(iu=1,(function(){var i=Jo(),n=Ob();function r(o){var d=this,l=r.contextForCanvas(o);if(l===null)throw new Error("WebGL unavailable");function _(X,Y){var K=l.createShader(X);if(l.shaderSource(K,Y),l.compileShader(K),!l.getShaderParameter(K,l.COMPILE_STATUS)){var se=l.getShaderInfoLog(K);throw l.deleteShader(K),new Error("GL shader compilation for "+X+" failed: "+se)}return K}var v,u,m=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),p={},x={},y={},b,N,I,A,D,M,P,j,z,J;function q(X,Y){return(!p[X]||Y)&&(p[X]=l.createTexture()),p[X]}function $(X,Y,K,se,oe){var Re=!p[X]||Y,G=q(X,Y);if(l.activeTexture(l.TEXTURE0),r.stripe){var Q=!p[X+"_temp"]||Y,ue=q(X+"_temp",Y);l.bindTexture(l.TEXTURE_2D,ue),Q?(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,K/4,se,0,l.RGBA,l.UNSIGNED_BYTE,oe)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K/4,se,l.RGBA,l.UNSIGNED_BYTE,oe);var te=p[X+"_stripe"],me=!te||Y;me&&(te=q(X+"_stripe",Y)),l.bindTexture(l.TEXTURE_2D,te),me&&(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,K,1,0,l.RGBA,l.UNSIGNED_BYTE,R(K)))}else l.bindTexture(l.TEXTURE_2D,G),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.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texImage2D(l.TEXTURE_2D,0,l.ALPHA,K,se,0,l.ALPHA,l.UNSIGNED_BYTE,oe)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K,se,l.ALPHA,l.UNSIGNED_BYTE,oe)}function O(X,Y,K,se){var oe=p[X];l.useProgram(u);var Re=x[X];(!Re||Y)&&(l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,oe),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,K,se,0,l.RGBA,l.UNSIGNED_BYTE,null),Re=x[X]=l.createFramebuffer()),l.bindFramebuffer(l.FRAMEBUFFER,Re),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,oe,0);var G=p[X+"_temp"];l.activeTexture(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,G),l.uniform1i(M,1);var Q=p[X+"_stripe"];l.activeTexture(l.TEXTURE2),l.bindTexture(l.TEXTURE_2D,Q),l.uniform1i(D,2),l.bindBuffer(l.ARRAY_BUFFER,b),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,I),l.enableVertexAttribArray(A),l.vertexAttribPointer(A,2,l.FLOAT,!1,0,0),l.viewport(0,0,K,se),l.drawArrays(l.TRIANGLES,0,m.length/2),l.bindFramebuffer(l.FRAMEBUFFER,null)}function C(X,Y,K){l.activeTexture(Y),l.bindTexture(l.TEXTURE_2D,p[X]),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(v,X),K)}function R(X){if(y[X])return y[X];for(var Y=X,K=new Uint32Array(Y),se=0;se<Y;se+=4)K[se]=255,K[se+1]=65280,K[se+2]=16711680,K[se+3]=4278190080;return y[X]=new Uint8Array(K.buffer)}function re(X,Y){var K=_(l.VERTEX_SHADER,X),se=_(l.FRAGMENT_SHADER,Y),oe=l.createProgram();if(l.attachShader(oe,K),l.attachShader(oe,se),l.linkProgram(oe),!l.getProgramParameter(oe,l.LINK_STATUS)){var Re=l.getProgramInfoLog(oe);throw l.deleteProgram(oe),new Error("GL program linking failed: "+Re)}return oe}function pe(){if(r.stripe){u=re(n.vertexStripe,n.fragmentStripe),l.getAttribLocation(u,"aPosition"),I=l.createBuffer();var X=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);l.bindBuffer(l.ARRAY_BUFFER,I),l.bufferData(l.ARRAY_BUFFER,X,l.STATIC_DRAW),A=l.getAttribLocation(u,"aTexturePosition"),D=l.getUniformLocation(u,"uStripe"),M=l.getUniformLocation(u,"uTexture")}v=re(n.vertex,n.fragment),b=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,b),l.bufferData(l.ARRAY_BUFFER,m,l.STATIC_DRAW),N=l.getAttribLocation(v,"aPosition"),P=l.createBuffer(),j=l.getAttribLocation(v,"aLumaPosition"),z=l.createBuffer(),J=l.getAttribLocation(v,"aChromaPosition")}return d.drawFrame=function(X){var Y=X.format,K=!v||o.width!==Y.displayWidth||o.height!==Y.displayHeight;if(K&&(o.width=Y.displayWidth,o.height=Y.displayHeight,d.clear()),v||pe(),K){var se=function(oe,Re,G){var Q=Y.cropLeft/G,ue=(Y.cropLeft+Y.cropWidth)/G,te=(Y.cropTop+Y.cropHeight)/Y.height,me=Y.cropTop/Y.height,ae=new Float32Array([Q,te,ue,te,Q,me,Q,me,ue,te,ue,me]);l.bindBuffer(l.ARRAY_BUFFER,oe),l.bufferData(l.ARRAY_BUFFER,ae,l.STATIC_DRAW)};se(P,j,X.y.stride),se(z,J,X.u.stride*Y.width/Y.chromaWidth)}$("uTextureY",K,X.y.stride,Y.height,X.y.bytes),$("uTextureCb",K,X.u.stride,Y.chromaHeight,X.u.bytes),$("uTextureCr",K,X.v.stride,Y.chromaHeight,X.v.bytes),r.stripe&&(O("uTextureY",K,X.y.stride,Y.height),O("uTextureCb",K,X.u.stride,Y.chromaHeight),O("uTextureCr",K,X.v.stride,Y.chromaHeight)),l.useProgram(v),l.viewport(0,0,o.width,o.height),C("uTextureY",l.TEXTURE0,0),C("uTextureCb",l.TEXTURE1,1),C("uTextureCr",l.TEXTURE2,2),l.bindBuffer(l.ARRAY_BUFFER,b),l.enableVertexAttribArray(N),l.vertexAttribPointer(N,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,P),l.enableVertexAttribArray(j),l.vertexAttribPointer(j,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,z),l.enableVertexAttribArray(J),l.vertexAttribPointer(J,2,l.FLOAT,!1,0,0),l.drawArrays(l.TRIANGLES,0,m.length/2)},d.clear=function(){l.viewport(0,0,o.width,o.height),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT)},d.clear(),d}r.stripe=!1,r.contextForCanvas=function(o){var d={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return o.getContext("webgl",d)||o.getContext("experimental-webgl",d)},r.isAvailable=function(){var o=document.createElement("canvas"),d;o.width=1,o.height=1;try{d=r.contextForCanvas(o)}catch{return!1}if(d){var l=d.TEXTURE0,_=4,v=4,u=d.createTexture(),m=new Uint8Array(_*v),p=r.stripe?_/4:_,x=r.stripe?d.RGBA:d.ALPHA,y=r.stripe?d.NEAREST:d.LINEAR;d.activeTexture(l),d.bindTexture(d.TEXTURE_2D,u),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,y),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,y),d.texImage2D(d.TEXTURE_2D,0,x,p,v,0,x,d.UNSIGNED_BYTE,m);var b=d.getError();return!b}else return!1},r.prototype=Object.create(i.prototype),Co.exports=r})()),Co.exports}var ou;function Fb(){return ou||(ou=1,(function(){var i=Jo(),n=Db(),r=Bb(),o={FrameSink:i,SoftwareFrameSink:n,WebGLFrameSink:r,attach:function(d,l){l=l||{};var _="webGL"in l?l.webGL:r.isAvailable();return _?new r(d,l):new n(d,l)}};yo.exports=o})()),yo.exports}Fb();function Ed(){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 Sd{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=Ed()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class Ub extends Sd{#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 Wb=Promise.resolve();function au(i,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return i.getContext("webgl2",r)||i.getContext("webgl",r)}class Or extends Sd{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=Ed();return!!au(n)}#e;constructor(n,r){super(n);const o=au(this.canvas,r);if(!o)throw new Error("WebGL not supported");this.#e=o;const d=o.createShader(o.VERTEX_SHADER);if(o.shaderSource(d,Or.vertexShaderSource),o.compileShader(d),!o.getShaderParameter(d,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(d));const l=o.createShader(o.FRAGMENT_SHADER);if(o.shaderSource(l,Or.fragmentShaderSource),o.compileShader(l),!o.getShaderParameter(l,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(l));const _=o.createProgram();if(o.attachShader(_,d),o.attachShader(_,l),o.linkProgram(_),!o.getProgramParameter(_,o.LINK_STATUS))throw new Error(o.getProgramInfoLog(_));o.useProgram(_);const v=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,v),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),o.STATIC_DRAW);const u=o.getAttribLocation(_,"xy");o.vertexAttribPointer(u,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(u);const m=o.createTexture();o.bindTexture(o.TEXTURE_2D,m),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.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),Wb}}const lu=50,Hb=300;function Gb({deviceId:i,className:n,onFallback:r,fallbackTimeout:o=2e4,enableControl:d=!1,onTapSuccess:l,onTapError:_,onSwipeSuccess:v,onSwipeError:u,onStreamReady:m}){const p=E.useRef(null),x=E.useRef(null),y=E.useRef(null),b=E.useRef(null),N=E.useRef(null),I=E.useRef(null),A=E.useRef(null),D=E.useRef(!1),M=E.useRef(!1),P=E.useRef(r),j=E.useRef(o),z=E.useRef(m),[J,q]=E.useState("connecting"),[$,O]=E.useState(null),[C,R]=E.useState(null),[re,pe]=E.useState(null),X=E.useRef(!1),Y=E.useRef(null),K=E.useRef(!1),se=E.useRef(0),oe=E.useRef(null),Re=E.useRef(null),G=E.useRef(null),Q=E.useRef(null);E.useEffect(()=>{P.current=r,j.current=o,z.current=m},[r,o,m]),E.useEffect(()=>{(async()=>{try{const Z=await fu(i);Z.success&&pe({width:Z.width,height:Z.height})}catch(Z){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",Z)}})()},[i]);const ue=E.useCallback(()=>{const ee=b.current,Z=y.current;if(!ee||!Z||!C)return;const we=Z.clientWidth,Le=Z.clientHeight,{width:fe,height:_e}=C,Ne=fe/_e;let he=we,ct=we/Ne;ct>Le&&(ct=Le,he=Le*Ne),ee.width=fe,ee.height=_e,ee.style.width=`${he}px`,ee.style.height=`${ct}px`},[C]);E.useEffect(()=>{const ee=()=>ue();return window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[ue]),E.useEffect(()=>{ue()},[C,ue]);const te=E.useCallback(async()=>{if(Or.isSupported){const Z=new Or;return{renderer:Z,element:Z.canvas}}const ee=new Ub;return{renderer:ee,element:ee.canvas}},[]),me=E.useCallback(async ee=>{if(!Zc.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:Z,element:we}=await te();return b.current=we,y.current&&!we.parentElement&&y.current.appendChild(we),new Zc({codec:ee,renderer:Z})},[te]),ae=E.useCallback(()=>{D.current||(D.current=!0,N.current&&(clearTimeout(N.current),N.current=null))},[]),Ue=E.useCallback(ee=>{let Z=!1,we=[];const Le=new TransformStream({transform(_e,Ne){if(_e.type==="configuration"){Ne.enqueue(_e),Z=!0,we.length>0&&(we.forEach(he=>Ne.enqueue(he)),we=[]);return}if(_e.type==="data"&&!Z){we.push(_e);return}Ne.enqueue(_e)}});return new ReadableStream({start(_e){let Ne=!1;const he=it=>{if(!Ne)try{ae();const Ve={...it,data:it.data instanceof Uint8Array?it.data:new Uint8Array(it.data)};_e.enqueue(Ve)}catch(Ve){console.error("[ScrcpyPlayer] Video enqueue error:",Ve),Ne=!0,wt()}},ct=it=>{Ne||(_e.error(new Error(it?.message||"Socket error")),Ne=!0,wt())},yt=()=>{Ne||(_e.close(),Ne=!0,wt())},wt=()=>{p.current?.off("video-data",he),p.current?.off("error",ct),p.current?.off("disconnect",yt)};return p.current?.on("video-data",he),p.current?.on("error",ct),p.current?.on("disconnect",yt),()=>{Ne=!0,wt()}}}).pipeThrough(Le)},[ae]),Ze=E.useCallback((ee=!1)=>{if(ee&&(M.current=!0),x.current){try{x.current.dispose()}catch(Z){console.error("[ScrcpyPlayer] Failed to dispose decoder:",Z)}x.current=null}b.current=null,p.current&&(p.current.disconnect(),p.current=null),z.current?.(null),I.current&&(clearTimeout(I.current),I.current=null),N.current&&(clearTimeout(N.current),N.current=null),q("disconnected"),R(null),O(null)},[]),Ge=E.useCallback(()=>{Ze(!0),D.current=!1,q("connecting"),O(null);const ee=Os({path:"/socket.io",transports:["websocket"],timeout:1e4});p.current=ee,ee.on("connect",()=>{ee.emit("connect-device",{device_id:i,maxSize:1280,bitRate:4e6}),N.current=setTimeout(()=>{D.current||(q("error"),O("Video stream timeout"),M.current=!0,ee.close(),P.current?.())},j.current)}),ee.on("video-metadata",async Z=>{try{x.current&&(x.current.dispose(),x.current=null);const we=Z?.codec?Z.codec:Bs.H264;x.current=await me(we),x.current.sizeChanged(({width:fe,height:_e})=>{R({width:fe,height:_e})}),Ue(Z).pipeTo(x.current.writable).catch(fe=>{console.error("[ScrcpyPlayer] Video stream error:",fe)}),q("connected"),z.current?.({close:()=>ee.close()})}catch(we){console.error("[ScrcpyPlayer] Decoder initialization failed:",we),q("error"),O("Decoder initialization failed"),M.current=!0,ee.close(),P.current?.()}}),ee.on("error",Z=>{console.error("[ScrcpyPlayer] Socket error:",Z),q("error"),O(Z?.message||"Socket error"),!M.current&&(z.current?.(null),I.current||(I.current=setTimeout(()=>{I.current=null,A.current?.()},3e3)))}),ee.on("disconnect",()=>{if(M.current){M.current=!1;return}q("disconnected"),z.current?.(null),I.current||(I.current=setTimeout(()=>{I.current=null,A.current?.()},3e3))})},[i,Ze,me,Ue]);E.useEffect(()=>{A.current=Ge},[Ge]),E.useEffect(()=>(queueMicrotask(()=>{Ge()}),()=>{Re.current&&(clearTimeout(Re.current),Re.current=null),G.current&&(clearTimeout(G.current),G.current=null),Ze(!0)}),[Ge,Ze]);const B=()=>{if(C)return{width:C.width,height:C.height};const ee=b.current;return ee?{width:ee.width,height:ee.height}:null},ce=(ee,Z)=>{const we=b.current,Le=B();if(!we||!Le)return null;const fe=we.getBoundingClientRect();if(ee<fe.left||ee>fe.right||Z<fe.top||Z>fe.bottom)return null;const _e=ee-fe.left,Ne=Z-fe.top,he=Math.round(_e/fe.width*Le.width),ct=Math.round(Ne/fe.height*Le.height),yt=re?re.width/Le.width:1,wt=re?re.height/Le.height:1;return{x:Math.round(he*yt),y:Math.round(ct*wt)}},ye=async ee=>{if(!d||J!=="connected")return;const Z=ce(ee.clientX,ee.clientY);if(Z){X.current=!0,K.current=!1,Y.current={x:ee.clientX,y:ee.clientY};try{await Rx(Z.x,Z.y,i)}catch(we){console.error("[ScrcpyPlayer] Touch down failed:",we)}}},Be=ee=>{if(!X.current||J!=="connected")return;const Z=Date.now(),we=ce(ee.clientX,ee.clientY);if(we){if(Y.current){const Le=ee.clientX-Y.current.x,fe=ee.clientY-Y.current.y;Math.hypot(Le,fe)>4&&(K.current=!0)}if(oe.current=we,Z-se.current<lu){Re.current||(Re.current=setTimeout(()=>{Re.current=null,oe.current&&(Lc(oe.current.x,oe.current.y,i).catch(Le=>{console.error("[ScrcpyPlayer] Touch move failed:",Le)}),oe.current=null,se.current=Date.now())},lu));return}se.current=Z,Lc(we.x,we.y,i).catch(Le=>{console.error("[ScrcpyPlayer] Touch move failed:",Le)})}},We=async ee=>{if(!X.current||J!=="connected")return;const Z=ce(ee.clientX,ee.clientY);if(X.current=!1,Y.current=null,!!Z)try{await Ic(Z.x,Z.y,i),K.current?v?.():l?.()}catch(we){const Le=String(we);K.current?u?.(Le):_?.(Le)}},de=async ee=>{if(!X.current||J!=="connected")return;const Z=ce(ee.clientX,ee.clientY);if(X.current=!1,Y.current=null,!!Z)try{await Ic(Z.x,Z.y,i)}catch(we){console.error("[ScrcpyPlayer] Touch cancel failed:",we)}},Se=ee=>{if(!d||J!=="connected")return;ee.preventDefault();const Z=ee.deltaY;Q.current||(Q.current={deltaY:0}),Q.current.deltaY+=Z,G.current&&clearTimeout(G.current),G.current=setTimeout(async()=>{const we=Q.current;if(Q.current=null,!we)return;const Le=b.current,fe=B();if(!Le||!fe)return;const _e=Le.getBoundingClientRect(),Ne=_e.left+_e.width/2,he=_e.top+_e.height/2,ct=ce(Ne,he);if(!ct)return;const yt=Math.max(Math.min(we.deltaY,600),-600),wt=he+yt,it=ce(Ne,wt);if(it)try{const Ve=await Tx(ct.x,ct.y,it.x,it.y,300,i);Ve.success?v?.():u?.(Ve.error||"Scroll failed")}catch(Ve){u?.(String(Ve))}},Hb)};return a.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${n||""}`,children:a.jsx("div",{ref:y,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:ye,onMouseMove:Be,onMouseUp:We,onMouseLeave:de,onWheel:Se,children:J!=="connected"&&a.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[J==="connecting"&&"Connecting...",J==="error"&&($||"Connection error"),J==="disconnected"&&"Disconnected"]})})})}const zb={compact:320,standard:400,wide:480,auto:"auto"};function qb({currentWidth:i,onWidthChange:n}){const r=An(),o=_=>{n(zb[_])},d=()=>{if(typeof i!="number")return;const _=Math.max(240,i-40);n(_)},l=()=>{if(typeof i!="number")return;const _=Math.min(640,i+40);n(_)};return a.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[typeof i=="number"&&a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"sm",onClick:d,className:"h-7 w-7 p-0 rounded-lg",disabled:i<=240,children:a.jsx(dv,{className:"w-3 h-3"})})}),a.jsx(nn,{children:a.jsx("p",{children:r.deviceMonitor?.decreaseWidth||"Decrease width"})})]}),a.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>o("compact"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i===320?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.compact||"Compact"}),a.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>o("standard"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i===400?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.standard||"Standard"}),a.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>o("wide"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i===480?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:r.deviceMonitor?.wide||"Wide"}),a.jsxs(Ee,{variant:"ghost",size:"sm",onClick:()=>o("auto"),className:`h-7 px-2 text-xs rounded-lg transition-colors ${i==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(cv,{className:"w-3 h-3 mr-1"}),r.deviceMonitor?.auto||"Auto"]}),typeof i=="number"&&a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0 rounded-lg",disabled:i>=640,children:a.jsx(bu,{className:"w-3 h-3"})})}),a.jsx(nn,{children:a.jsx("p",{children:r.deviceMonitor?.increaseWidth||"Increase width"})})]})]})}function $b({onResize:i,onResizeStart:n,onResizeEnd:r,minWidth:o=240,maxWidth:d=640,className:l=""}){const[_,v]=E.useState(!1),u=E.useRef(0),m=E.useRef(0),p=E.useRef(null),x=y=>{if(y.preventDefault(),v(!0),u.current=y.clientX,p.current?.parentElement){const b=p.current.parentElement.getBoundingClientRect();m.current=b.width}n?.()};return E.useEffect(()=>{if(!_)return;const y=N=>{const I=N.clientX-u.current,A=Math.min(d,Math.max(o,m.current+I));i(A-m.current)},b=()=>{v(!1),r?.()};return document.addEventListener("mousemove",y),document.addEventListener("mouseup",b),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",b)}},[_,o,d,i,r]),a.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 ${_?"bg-primary":""} ${l}`,onMouseDown:x,children:a.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("div",{className:"w-1 h-8 bg-primary rounded-full"})})})}function Xb(i,n){const[r,o]=E.useState(()=>{if(typeof window>"u")return n;try{const l=window.localStorage.getItem(i);return l?JSON.parse(l):n}catch(l){return console.error(`Error loading localStorage key "${i}":`,l),n}});return[r,l=>{try{const _=l instanceof Function?l(r):l;o(_),typeof window<"u"&&window.localStorage.setItem(i,JSON.stringify(_))}catch(_){console.error(`Error setting localStorage key "${i}":`,_)}}]}function Nd({deviceId:i,serial:n,connectionType:r,isVisible:o=!0,className:d=""}){const l=An(),_=r==="remote",[v,u]=E.useState(null),[m,p]=E.useState(!_),[x,y]=E.useState(!1),[b,N]=E.useState(_?"screenshot":"auto"),[I,A]=E.useState(null),[D,M]=E.useState("success"),[P,j]=E.useState(!1),[z,J]=E.useState(!1),[q,$]=Xb("device-monitor-width",320),O=E.useRef(null),C=E.useRef(!1),R=E.useRef(null),re=E.useRef(null),pe=(te,me=2e3,ae="success")=>{R.current&&clearTimeout(R.current),M(ae),A(te),R.current=setTimeout(()=>{A(null)},me)},X=()=>{re.current&&clearTimeout(re.current),j(!0)},Y=()=>{re.current=setTimeout(()=>{j(!1)},500)},K=()=>{J(te=>!te)},se=te=>{$(te)},oe=te=>{if(typeof q!="number")return;const me=Math.min(640,Math.max(240,q+te));$(me)},Re=E.useCallback(te=>{O.current=te},[]),G=E.useCallback(()=>{y(!0),p(!1)},[]),Q=te=>{N(te)};E.useEffect(()=>()=>{R.current&&clearTimeout(R.current),re.current&&clearTimeout(re.current),O.current&&O.current.close()},[]),E.useEffect(()=>{if(!i||!o||!(b==="screenshot"||b==="auto"&&x))return;const me=async()=>{if(!C.current){C.current=!0;try{const Ue=await fu(i);Ue.success&&u(Ue)}catch(Ue){console.error("Failed to fetch screenshot:",Ue)}finally{C.current=!1}}};me();const ae=setInterval(me,500);return()=>clearInterval(ae)},[i,x,b,o]);const ue=typeof q=="number"?`${q}px`:"auto";return a.jsxs(Ys,{className:`flex-shrink-0 relative min-h-0 overflow-hidden bg-background ${d}`,style:{width:ue,minWidth:typeof q=="number"?void 0:"240px",maxWidth:typeof q=="number"?void 0:"640px"},onMouseEnter:X,onMouseLeave:Y,children:[typeof q=="number"&&a.jsx($b,{onResize:oe,minWidth:240,maxWidth:640,className:"z-20"}),a.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${P?"opacity-100":"opacity-0 pointer-events-none"}`,children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsxs("div",{className:`flex flex-col items-end gap-2 transition-all duration-300 ${z?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[a.jsxs("div",{className:"flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border",children:[!_&&a.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>Q("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${b==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:l.devicePanel?.auto||"Auto"}),!_&&a.jsxs(Ee,{variant:"ghost",size:"sm",onClick:()=>Q("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${b==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(Sv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),a.jsxs(Ee,{variant:"ghost",size:"sm",onClick:()=>Q("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${b==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(Fc,{className:"w-3 h-3 mr-1"}),l.devicePanel?.image||"Image"]})]}),a.jsx(qb,{currentWidth:q,onWidthChange:se})]}),a.jsx(Ee,{variant:"ghost",size:"icon",onClick:K,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:z?"Hide controls":"Show controls",children:z?a.jsx(yu,{className:"w-4 h-4"}):a.jsx(Su,{className:"w-4 h-4"})})]})}),a.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:a.jsxs(Hn,{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:[b==="auto"&&(l.devicePanel?.auto||"Auto"),b==="video"&&a.jsxs(a.Fragment,{children:[a.jsx(hv,{className:"w-3 h-3 mr-1"}),l.devicePanel?.video||"Video"]}),b==="screenshot"&&a.jsxs(a.Fragment,{children:[a.jsx(Fc,{className:"w-3 h-3 mr-1"}),l.devicePanel?.imageRefresh||"Screenshot"]})]})}),I&&a.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:[D==="error"&&a.jsx(kn,{className:"w-4 h-4"}),D==="tap"&&a.jsx(rv,{className:"w-4 h-4"}),D==="swipe"&&a.jsx($x,{className:"w-4 h-4"}),D==="success"&&a.jsx(Fr,{className:"w-4 h-4"}),a.jsx("span",{children:I})]}),b==="video"||b==="auto"&&m&&!x?a.jsx(Gb,{deviceId:i,className:"w-full h-full",enableControl:!0,onFallback:G,onTapSuccess:()=>pe(l.devicePanel?.tapped||"Tapped",2e3,"tap"),onTapError:te=>pe((l.devicePanel?.tapError||"Tap error: {error}").replace("{error}",te),3e3,"error"),onSwipeSuccess:()=>pe(l.devicePanel?.swiped||"Swiped",2e3,"swipe"),onSwipeError:te=>pe((l.devicePanel?.swipeError||"Swipe error: {error}").replace("{error}",te),3e3,"error"),onStreamReady:Re,fallbackTimeout:2e4}):a.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:v&&v.success?a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[a.jsx("img",{src:`data:image/png;base64,${v.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:v.width>v.height?"100%":"auto",height:v.width>v.height?"auto":"100%"}}),v.is_sensitive&&a.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"})]}):v?.error?a.jsxs("div",{className:"text-center text-destructive",children:[a.jsx(kn,{className:"w-8 h-8 mx-auto mb-2"}),a.jsx("p",{className:"font-medium",children:l.devicePanel?.screenshotFailed||"Screenshot Failed"}),a.jsx("p",{className:"text-xs mt-1 opacity-60",children:v.error})]}):a.jsxs("div",{className:"text-center text-muted-foreground",children:[a.jsx(Yt,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),a.jsx("p",{className:"text-sm",children:l.devicePanel?.loading||"Loading..."})]})})]})}function Yb(i,[n,r]){return Math.min(r,Math.max(n,i))}function Vb(i,n){return E.useReducer((r,o)=>n[r][o]??r,i)}var Zo="ScrollArea",[Cd]=Xs(Zo),[Kb,Ht]=Cd(Zo),Td=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,type:o="hover",dir:d,scrollHideDelay:l=600,..._}=i,[v,u]=E.useState(null),[m,p]=E.useState(null),[x,y]=E.useState(null),[b,N]=E.useState(null),[I,A]=E.useState(null),[D,M]=E.useState(0),[P,j]=E.useState(0),[z,J]=E.useState(!1),[q,$]=E.useState(!1),O=_n(n,R=>u(R)),C=qo(d);return a.jsx(Kb,{scope:r,type:o,dir:C,scrollHideDelay:l,scrollArea:v,viewport:m,onViewportChange:p,content:x,onContentChange:y,scrollbarX:b,onScrollbarXChange:N,scrollbarXEnabled:z,onScrollbarXEnabledChange:J,scrollbarY:I,onScrollbarYChange:A,scrollbarYEnabled:q,onScrollbarYEnabledChange:$,onCornerWidthChange:M,onCornerHeightChange:j,children:a.jsx(Vt.div,{dir:C,..._,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":D+"px","--radix-scroll-area-corner-height":P+"px",...i.style}})})});Td.displayName=Zo;var Rd="ScrollAreaViewport",kd=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,children:o,nonce:d,...l}=i,_=Ht(Rd,r),v=E.useRef(null),u=_n(n,v,_.onViewportChange);return a.jsxs(a.Fragment,{children:[a.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:d}),a.jsx(Vt.div,{"data-radix-scroll-area-viewport":"",...l,ref:u,style:{overflowX:_.scrollbarXEnabled?"scroll":"hidden",overflowY:_.scrollbarYEnabled?"scroll":"hidden",...i.style},children:a.jsx("div",{ref:_.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});kd.displayName=Rd;var on="ScrollAreaScrollbar",Ad=E.forwardRef((i,n)=>{const{forceMount:r,...o}=i,d=Ht(on,i.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:_}=d,v=i.orientation==="horizontal";return E.useEffect(()=>(v?l(!0):_(!0),()=>{v?l(!1):_(!1)}),[v,l,_]),d.type==="hover"?a.jsx(Qb,{...o,ref:n,forceMount:r}):d.type==="scroll"?a.jsx(Jb,{...o,ref:n,forceMount:r}):d.type==="auto"?a.jsx(jd,{...o,ref:n,forceMount:r}):d.type==="always"?a.jsx(ea,{...o,ref:n}):null});Ad.displayName=on;var Qb=E.forwardRef((i,n)=>{const{forceMount:r,...o}=i,d=Ht(on,i.__scopeScrollArea),[l,_]=E.useState(!1);return E.useEffect(()=>{const v=d.scrollArea;let u=0;if(v){const m=()=>{window.clearTimeout(u),_(!0)},p=()=>{u=window.setTimeout(()=>_(!1),d.scrollHideDelay)};return v.addEventListener("pointerenter",m),v.addEventListener("pointerleave",p),()=>{window.clearTimeout(u),v.removeEventListener("pointerenter",m),v.removeEventListener("pointerleave",p)}}},[d.scrollArea,d.scrollHideDelay]),a.jsx(Br,{present:r||l,children:a.jsx(jd,{"data-state":l?"visible":"hidden",...o,ref:n})})}),Jb=E.forwardRef((i,n)=>{const{forceMount:r,...o}=i,d=Ht(on,i.__scopeScrollArea),l=i.orientation==="horizontal",_=ei(()=>u("SCROLL_END"),100),[v,u]=Vb("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 E.useEffect(()=>{if(v==="idle"){const m=window.setTimeout(()=>u("HIDE"),d.scrollHideDelay);return()=>window.clearTimeout(m)}},[v,d.scrollHideDelay,u]),E.useEffect(()=>{const m=d.viewport,p=l?"scrollLeft":"scrollTop";if(m){let x=m[p];const y=()=>{const b=m[p];x!==b&&(u("SCROLL"),_()),x=b};return m.addEventListener("scroll",y),()=>m.removeEventListener("scroll",y)}},[d.viewport,l,u,_]),a.jsx(Br,{present:r||v!=="hidden",children:a.jsx(ea,{"data-state":v==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:_t(i.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:_t(i.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),jd=E.forwardRef((i,n)=>{const r=Ht(on,i.__scopeScrollArea),{forceMount:o,...d}=i,[l,_]=E.useState(!1),v=i.orientation==="horizontal",u=ei(()=>{if(r.viewport){const m=r.viewport.offsetWidth<r.viewport.scrollWidth,p=r.viewport.offsetHeight<r.viewport.scrollHeight;_(v?m:p)}},10);return lr(r.viewport,u),lr(r.content,u),a.jsx(Br,{present:o||l,children:a.jsx(ea,{"data-state":l?"visible":"hidden",...d,ref:n})})}),ea=E.forwardRef((i,n)=>{const{orientation:r="vertical",...o}=i,d=Ht(on,i.__scopeScrollArea),l=E.useRef(null),_=E.useRef(0),[v,u]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=Dd(v.viewport,v.content),p={...o,sizes:v,onSizesChange:u,hasThumb:m>0&&m<1,onThumbChange:y=>l.current=y,onThumbPointerUp:()=>_.current=0,onThumbPointerDown:y=>_.current=y};function x(y,b){return sy(y,_.current,v,b)}return r==="horizontal"?a.jsx(Zb,{...p,ref:n,onThumbPositionChange:()=>{if(d.viewport&&l.current){const y=d.viewport.scrollLeft,b=cu(y,v,d.dir);l.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:y=>{d.viewport&&(d.viewport.scrollLeft=y)},onDragScroll:y=>{d.viewport&&(d.viewport.scrollLeft=x(y,d.dir))}}):r==="vertical"?a.jsx(ey,{...p,ref:n,onThumbPositionChange:()=>{if(d.viewport&&l.current){const y=d.viewport.scrollTop,b=cu(y,v);l.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:y=>{d.viewport&&(d.viewport.scrollTop=y)},onDragScroll:y=>{d.viewport&&(d.viewport.scrollTop=x(y))}}):null}),Zb=E.forwardRef((i,n)=>{const{sizes:r,onSizesChange:o,...d}=i,l=Ht(on,i.__scopeScrollArea),[_,v]=E.useState(),u=E.useRef(null),m=_n(n,u,l.onScrollbarXChange);return E.useEffect(()=>{u.current&&v(getComputedStyle(u.current))},[u]),a.jsx(Id,{"data-orientation":"horizontal",...d,ref:m,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":Zs(r)+"px",...i.style},onThumbPointerDown:p=>i.onThumbPointerDown(p.x),onDragScroll:p=>i.onDragScroll(p.x),onWheelScroll:(p,x)=>{if(l.viewport){const y=l.viewport.scrollLeft+p.deltaX;i.onWheelScroll(y),Bd(y,x)&&p.preventDefault()}},onResize:()=>{u.current&&l.viewport&&_&&o({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:$s(_.paddingLeft),paddingEnd:$s(_.paddingRight)}})}})}),ey=E.forwardRef((i,n)=>{const{sizes:r,onSizesChange:o,...d}=i,l=Ht(on,i.__scopeScrollArea),[_,v]=E.useState(),u=E.useRef(null),m=_n(n,u,l.onScrollbarYChange);return E.useEffect(()=>{u.current&&v(getComputedStyle(u.current))},[u]),a.jsx(Id,{"data-orientation":"vertical",...d,ref:m,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":Zs(r)+"px",...i.style},onThumbPointerDown:p=>i.onThumbPointerDown(p.y),onDragScroll:p=>i.onDragScroll(p.y),onWheelScroll:(p,x)=>{if(l.viewport){const y=l.viewport.scrollTop+p.deltaY;i.onWheelScroll(y),Bd(y,x)&&p.preventDefault()}},onResize:()=>{u.current&&l.viewport&&_&&o({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:$s(_.paddingTop),paddingEnd:$s(_.paddingBottom)}})}})}),[ty,Pd]=Cd(on),Id=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:d,onThumbChange:l,onThumbPointerUp:_,onThumbPointerDown:v,onThumbPositionChange:u,onDragScroll:m,onWheelScroll:p,onResize:x,...y}=i,b=Ht(on,r),[N,I]=E.useState(null),A=_n(n,O=>I(O)),D=E.useRef(null),M=E.useRef(""),P=b.viewport,j=o.content-o.viewport,z=Tn(p),J=Tn(u),q=ei(x,10);function $(O){if(D.current){const C=O.clientX-D.current.left,R=O.clientY-D.current.top;m({x:C,y:R})}}return E.useEffect(()=>{const O=C=>{const R=C.target;N?.contains(R)&&z(C,j)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[P,N,j,z]),E.useEffect(J,[o,J]),lr(N,q),lr(b.content,q),a.jsx(ty,{scope:r,scrollbar:N,hasThumb:d,onThumbChange:Tn(l),onThumbPointerUp:Tn(_),onThumbPositionChange:J,onThumbPointerDown:Tn(v),children:a.jsx(Vt.div,{...y,ref:A,style:{position:"absolute",...y.style},onPointerDown:_t(i.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),D.current=N.getBoundingClientRect(),M.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),$(O))}),onPointerMove:_t(i.onPointerMove,$),onPointerUp:_t(i.onPointerUp,O=>{const C=O.target;C.hasPointerCapture(O.pointerId)&&C.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=M.current,b.viewport&&(b.viewport.style.scrollBehavior=""),D.current=null})})})}),qs="ScrollAreaThumb",Ld=E.forwardRef((i,n)=>{const{forceMount:r,...o}=i,d=Pd(qs,i.__scopeScrollArea);return a.jsx(Br,{present:r||d.hasThumb,children:a.jsx(ny,{ref:n,...o})})}),ny=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,style:o,...d}=i,l=Ht(qs,r),_=Pd(qs,r),{onThumbPositionChange:v}=_,u=_n(n,x=>_.onThumbChange(x)),m=E.useRef(void 0),p=ei(()=>{m.current&&(m.current(),m.current=void 0)},100);return E.useEffect(()=>{const x=l.viewport;if(x){const y=()=>{if(p(),!m.current){const b=iy(x,v);m.current=b,v()}};return v(),x.addEventListener("scroll",y),()=>x.removeEventListener("scroll",y)}},[l.viewport,p,v]),a.jsx(Vt.div,{"data-state":_.hasThumb?"visible":"hidden",...d,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:_t(i.onPointerDownCapture,x=>{const b=x.target.getBoundingClientRect(),N=x.clientX-b.left,I=x.clientY-b.top;_.onThumbPointerDown({x:N,y:I})}),onPointerUp:_t(i.onPointerUp,_.onThumbPointerUp)})});Ld.displayName=qs;var ta="ScrollAreaCorner",Md=E.forwardRef((i,n)=>{const r=Ht(ta,i.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?a.jsx(ry,{...i,ref:n}):null});Md.displayName=ta;var ry=E.forwardRef((i,n)=>{const{__scopeScrollArea:r,...o}=i,d=Ht(ta,r),[l,_]=E.useState(0),[v,u]=E.useState(0),m=!!(l&&v);return lr(d.scrollbarX,()=>{const p=d.scrollbarX?.offsetHeight||0;d.onCornerHeightChange(p),u(p)}),lr(d.scrollbarY,()=>{const p=d.scrollbarY?.offsetWidth||0;d.onCornerWidthChange(p),_(p)}),m?a.jsx(Vt.div,{...o,ref:n,style:{width:l,height:v,position:"absolute",right:d.dir==="ltr"?0:void 0,left:d.dir==="rtl"?0:void 0,bottom:0,...i.style}}):null});function $s(i){return i?parseInt(i,10):0}function Dd(i,n){const r=i/n;return isNaN(r)?0:r}function Zs(i){const n=Dd(i.viewport,i.content),r=i.scrollbar.paddingStart+i.scrollbar.paddingEnd,o=(i.scrollbar.size-r)*n;return Math.max(o,18)}function sy(i,n,r,o="ltr"){const d=Zs(r),l=d/2,_=n||l,v=d-_,u=r.scrollbar.paddingStart+_,m=r.scrollbar.size-r.scrollbar.paddingEnd-v,p=r.content-r.viewport,x=o==="ltr"?[0,p]:[p*-1,0];return Od([u,m],x)(i)}function cu(i,n,r="ltr"){const o=Zs(n),d=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,l=n.scrollbar.size-d,_=n.content-n.viewport,v=l-o,u=r==="ltr"?[0,_]:[_*-1,0],m=Yb(i,u);return Od([0,_],[0,v])(m)}function Od(i,n){return r=>{if(i[0]===i[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(i[1]-i[0]);return n[0]+o*(r-i[0])}}function Bd(i,n){return i>0&&i<n}var iy=(i,n=()=>{})=>{let r={left:i.scrollLeft,top:i.scrollTop},o=0;return(function d(){const l={left:i.scrollLeft,top:i.scrollTop},_=r.left!==l.left,v=r.top!==l.top;(_||v)&&n(),r=l,o=window.requestAnimationFrame(d)})(),()=>window.cancelAnimationFrame(o)};function ei(i,n){const r=Tn(i),o=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(o.current),[]),E.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,n)},[r,n])}function lr(i,n){const r=Tn(n);kx(()=>{let o=0;if(i){const d=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return d.observe(i),()=>{window.cancelAnimationFrame(o),d.unobserve(i)}}},[i,r])}var oy=Td,ay=kd,ly=Md;function Dr({className:i,children:n,...r}){return a.jsxs(oy,{"data-slot":"scroll-area",className:cr("relative",i),...r,children:[a.jsx(ay,{"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}),a.jsx(cy,{}),a.jsx(ly,{})]})}function cy({className:i,orientation:n="vertical",...r}){return a.jsx(Ad,{"data-slot":"scroll-area-scrollbar",orientation:n,className:cr("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",i),...r,children:a.jsx(Ld,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function uy(i){const n=new Date(i),o=new Date().getTime()-n.getTime(),d=Math.floor(o/6e4),l=Math.floor(o/36e5),_=Math.floor(o/864e5);return d<1?"Just now":d<60?`${d}m ago`:l<24?`${l}h ago`:_<7?`${_}d ago`:n.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function dy(i){const n=Math.floor(i/1e3),r=Math.floor(n/60),o=n%60;return r===0?`${o}s`:`${r}m ${o}s`}function Fd({item:i,onSelect:n,onDelete:r}){const o=An(),d=l=>{l.stopPropagation(),confirm(o.history.deleteConfirm)&&r(i.id)};return a.jsx(Ys,{className:"hover:bg-slate-50 dark:hover:bg-slate-800/50 transition-colors cursor-pointer group",onClick:()=>n(i),children:a.jsxs("div",{className:"p-3 space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2",children:i.task_text}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[a.jsx("span",{children:uy(i.start_time)}),a.jsx("span",{children:"•"}),a.jsxs("span",{children:[i.steps," ",i.steps===1?"step":"steps"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:dy(i.duration_ms)})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hn,{variant:i.success?"success":"destructive",className:"shrink-0",children:i.success?a.jsxs(a.Fragment,{children:[a.jsx(Fr,{className:"w-3 h-3 mr-1"}),o.history.success]}):a.jsxs(a.Fragment,{children:[a.jsx(kn,{className:"w-3 h-3 mr-1"}),o.history.failed]})}),a.jsx(Ee,{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:d,title:o.history.deleteItem,children:a.jsx(vu,{className:"w-3 h-3"})})]})]})]})})}function fy({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:o,isConfigured:d}){const l=An(),[_,v]=E.useState([]),[u,m]=E.useState(""),[p,x]=E.useState(!1),[y,b]=E.useState(!1),[N,I]=E.useState(null),[A,D]=E.useState(!1),[M,P]=E.useState([]),[j,z]=E.useState([]),[J,q]=E.useState(!1),$=E.useRef(null),O=E.useRef(null),C=E.useRef(null),R=E.useRef(0),re=E.useRef(null),[pe,X]=E.useState(!0),[Y,K]=E.useState(!1),se=E.useRef(id.throttle(()=>{const B=C.current;if(!B)return;const ce=80,ye=B.scrollHeight-B.scrollTop-B.clientHeight,Be=ye<=1;X(Be),ye<=ce&&K(!1)},100));E.useEffect(()=>{const B=se.current;return()=>{B.cancel()}},[]),E.useEffect(()=>{A&&(async()=>{try{const ce=await pu(n,20,0);P(ce.records)}catch(ce){console.error("Failed to load history:",ce),P([])}})()},[A,n]);const oe=B=>{const ce=[],ye=B.messages.find(Se=>Se.role==="user");ye?ce.push({id:`${B.id}-user`,role:"user",content:ye.content||B.task_text,timestamp:new Date(ye.timestamp)}):ce.push({id:`${B.id}-user`,role:"user",content:B.task_text,timestamp:new Date(B.start_time)});const Be=[],We=[];B.messages.filter(Se=>Se.role==="assistant").forEach(Se=>{Se.thinking&&Be.push(Se.thinking),Se.action&&We.push(Se.action)});const de={id:`${B.id}-agent`,role:"assistant",content:B.final_message,timestamp:B.end_time?new Date(B.end_time):new Date(B.start_time),steps:B.steps,success:B.success,thinking:Be,actions:We,isStreaming:!1};ce.push(de),v(ce),R.current=ce.length,re.current=[de.id,de.content?.length??0,de.currentThinking?.length??0,de.thinking?JSON.stringify(de.thinking).length:0,de.steps??"",de.isStreaming?1:0].join("|"),K(!1),X(!0),D(!1)},Re=async()=>{if(confirm(l.history.clearAllConfirm))try{await gu(n),P([])}catch(B){console.error("Failed to clear history:",B)}},G=async B=>{try{await _u(n,B),P(ce=>ce.filter(ye=>ye.id!==B))}catch(ce){console.error("Failed to delete history item:",ce)}},Q=E.useCallback(async()=>{const B=u.trim();if(!B||p)return;const ce={id:Date.now().toString(),role:"user",content:B,timestamp:new Date};v(fe=>[...fe,ce]),m(""),x(!0),I(null);const ye=[],Be=[];let We="";const de=[];let Se=null;const ee=(Date.now()+1).toString(),Z={id:ee,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};v(fe=>[...fe,Z]);const we=()=>{if(de.length>0){const fe=de.join("");de.length=0,We+=fe,v(_e=>_e.map(Ne=>Ne.id===ee?{...Ne,currentThinking:We}:Ne))}Se=null},Le=Ax(ce.content,i,fe=>{de.push(fe.chunk),Se===null&&(Se=setTimeout(we,50))},fe=>{Se!==null&&(clearTimeout(Se),we());const _e=fe.thinking&&fe.thinking.length>0?fe.thinking:We;_e&&ye.push(_e),We="",Be.push(fe.action),v(Ne=>Ne.map(he=>he.id===ee?{...he,thinking:[...ye],actions:[...Be],steps:fe.step,currentThinking:""}:he))},fe=>{Se!==null&&clearTimeout(Se);const _e={...Z,content:fe.message,success:fe.success,isStreaming:!1,steps:fe.steps,thinking:[...ye],actions:[...Be],timestamp:new Date,currentThinking:void 0};v(Ne=>Ne.map(he=>he.id===ee?_e:he)),x(!1),$.current=null},fe=>{Se!==null&&clearTimeout(Se);const _e={...Z,content:`Error: ${fe.message}`,success:!1,isStreaming:!1,thinking:[...ye],actions:[...Be],timestamp:new Date,currentThinking:void 0};v(Ne=>Ne.map(he=>he.id===ee?_e:he)),x(!1),I(fe.message),$.current=null},fe=>{Se!==null&&clearTimeout(Se);const _e={...Z,content:fe.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...ye],actions:[...Be],timestamp:new Date,currentThinking:void 0};v(Ne=>Ne.map(he=>he.id===ee?_e:he)),x(!1),$.current=null});$.current=Le},[u,p,i]),ue=E.useCallback(async()=>{$.current&&$.current.close(),v([]),x(!1),I(null),K(!1),X(!0),$.current=null,R.current=0,re.current=null,await jx(i)},[i]),te=E.useCallback(async()=>{if($.current){b(!0);try{$.current&&($.current.close(),$.current=null),v(B=>{const ce=B[B.length-1];return ce&&ce.role==="assistant"&&ce.isStreaming?B.map((ye,Be)=>Be===B.length-1?{...ye,content:ye.content||l.chat.aborted,isStreaming:!1,success:!1,currentThinking:void 0}:ye):B}),Px(i).catch(B=>console.error("Backend abort failed:",B))}catch(B){console.error("Failed to abort chat:",B)}finally{x(!1),b(!1)}}},[i,l]),me=E.useCallback(()=>{O.current?.scrollIntoView({behavior:"smooth"})},[]);E.useEffect(()=>{const B=_[_.length-1],ce=B?.thinking?JSON.stringify(B.thinking).length:0,ye=B?[B.id,B.content?.length??0,B.currentThinking?.length??0,ce,B.steps??"",B.isStreaming?1:0].join("|"):null,Be=_.length>R.current,We=ye!==re.current&&_.length>0;if(R.current=_.length,re.current=ye,pe){me(),K(!1);return}if(_.length===0){K(!1);return}(Be||We)&&K(!0)},[_,pe,me]),E.useEffect(()=>()=>{$.current&&$.current.close()},[i]),E.useEffect(()=>{(async()=>{try{const ce=await mu();z(ce.workflows)}catch(ce){console.error("Failed to load workflows:",ce)}})()},[]);const ae=B=>{m(B.text),q(!1)},Ue=()=>{se.current()},Ze=()=>{me(),K(!1),X(!0)},Ge=B=>{(B.metaKey||B.ctrlKey)&&B.key==="Enter"&&(B.preventDefault(),Q())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Ys,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(jr,{className:"h-5 w-5 text-[#1d9bf0]"})}),a.jsxs("div",{className:"group",children:[a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:r})}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:i})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Us,{open:A,onOpenChange:D,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{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,children:a.jsx(Fs,{className:"h-4 w-4"})})}),a.jsxs(Hs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history.title}),M.length>0&&a.jsx(Ee,{variant:"ghost",size:"sm",onClick:Re,className:"h-7 text-xs",children:l.history.clearAll})]}),a.jsx(Dr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:M.length>0?M.map(B=>a.jsx(Fd,{item:B,onSelect:oe,onDelete:G},B.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Fs,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history.noHistory}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history.noHistoryDescription})]})})})]})]}),!d&&a.jsxs(Hn,{variant:"warning",children:[a.jsx(kn,{className:"w-3 h-3 mr-1"}),l.devicePanel.noConfig]}),a.jsx(Ee,{variant:"ghost",size:"icon",onClick:ue,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:a.jsx(Nu,{className:"h-4 w-4"})})]})]}),N&&a.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:[a.jsx(kn,{className:"w-4 h-4 flex-shrink-0"}),N]}),a.jsxs("div",{className:"flex-1 min-h-0 relative",children:[a.jsxs("div",{className:"h-full overflow-y-auto p-4",ref:C,onScroll:Ue,children:[_.length===0?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:a.jsx(jr,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.devicePanel.readyToHelp}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:l.devicePanel.describeTask})]}):_.map(B=>a.jsx("div",{className:`flex ${B.role==="user"?"justify-end":"justify-start"}`,children:B.role==="assistant"?a.jsxs("div",{className:"max-w-[85%] space-y-3",children:[B.thinking?.map((ce,ye)=>a.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(jr,{className:"h-3 w-3 text-[#1d9bf0]"})}),a.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",ye+1]})]}),a.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:ce}),B.actions?.[ye]&&a.jsxs("details",{className:"mt-2 text-xs",children:[a.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),a.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(B.actions[ye],null,2)})]})]},ye)),B.currentThinking&&a.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:a.jsx(jr,{className:"h-3 w-3 text-[#1d9bf0] animate-pulse"})}),a.jsx("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Thinking..."})]}),a.jsxs("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:[B.currentThinking,a.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),B.content&&a.jsxs("div",{className:`
|
|
126
|
+
rounded-2xl px-4 py-3 flex items-start gap-2
|
|
127
|
+
${B.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:[a.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${B.success===!1?"text-red-500":"text-green-500"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"whitespace-pre-wrap",children:B.content}),B.steps!==void 0&&a.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[B.steps," steps completed"]})]})]}),B.isStreaming&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[a.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):a.jsxs("div",{className:"max-w-[75%]",children:[a.jsx("div",{className:"chat-bubble-user px-4 py-3",children:a.jsx("p",{className:"whitespace-pre-wrap",children:B.content})}),a.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:B.timestamp.toLocaleTimeString()})]})},B.id)),a.jsx("div",{ref:O})]}),Y&&a.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:a.jsx(Ee,{onClick:Ze,size:"sm",className:"pointer-events-auto shadow-lg bg-[#1d9bf0] text-white hover:bg-[#1a8cd8]","aria-label":l.devicePanel.newMessages,children:l.devicePanel.newMessages})})]}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(wu,{value:u,onChange:B=>m(B.target.value),onKeyDown:Ge,placeholder:d?l.devicePanel.whatToDo:l.devicePanel.configureFirst,disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs(Us,{open:J,onOpenChange:q,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(hu,{className:"w-4 h-4"})})}),a.jsx(Hs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows.selectWorkflow}),j.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows.empty}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Dr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:j.map(B=>a.jsxs("button",{onClick:()=>ae(B),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:B.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:B.text})]},B.uuid))})})]})})]})}),a.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel.tooltips.workflowButton}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel.tooltips.workflowButtonDesc})]})})]}),p&&a.jsx(Ee,{onClick:te,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat.abortChat,children:y?a.jsx(Yt,{className:"h-4 w-4 animate-spin"}):a.jsx(Ru,{className:"h-4 w-4"})}),!p&&a.jsx(Ee,{onClick:Q,disabled:!u.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:a.jsx(Cu,{className:"h-4 w-4"})})]})})]}),a.jsx(Nd,{deviceId:i,serial:n,connectionType:o,isVisible:!0})]})}function hy({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:o,isVisible:d}){const l=An(),[_,v]=E.useState([]),[u,m]=E.useState(""),[p,x]=E.useState(!1),[y,b]=E.useState(!1),[N,I]=E.useState(null),A=E.useRef(null),D=E.useRef(null),M=E.useRef(null),[P,j]=E.useState([]),[z,J]=E.useState(!1),[q,$]=E.useState([]),[O,C]=E.useState(!1);E.useEffect(()=>{A.current?.scrollIntoView({behavior:"smooth"})},[_]),E.useEffect(()=>()=>{D.current&&D.current.close()},[]),E.useEffect(()=>{(async()=>{try{const Q=await mu();j(Q.workflows)}catch(Q){console.error("Failed to load workflows:",Q)}})()},[]),E.useEffect(()=>{O&&(async()=>{try{const Q=await pu(n,20,0);$(Q.records)}catch(Q){console.error("Failed to load history:",Q),$([])}})()},[O,n]);const R=G=>{m(G.text),J(!1)},re=G=>{const Q={id:`${G.id}-user`,role:"user",content:G.task_text,timestamp:new Date(G.start_time)},ue={id:`${G.id}-agent`,role:"assistant",content:G.final_message,timestamp:G.end_time?new Date(G.end_time):new Date(G.start_time),steps:[],success:G.success,isStreaming:!1};v([Q,ue]),C(!1)},pe=async()=>{if(confirm(l.history?.clearAllConfirm||"Clear all history?"))try{await gu(n),$([])}catch(G){console.error("Failed to clear history:",G)}},X=async G=>{try{await _u(n,G),$(Q=>Q.filter(ue=>ue.id!==G))}catch(Q){console.error("Failed to delete history item:",Q)}},Y=(G,Q)=>{v(ue=>ue.map(te=>te.id===G?{...te,steps:te.steps?.map(me=>me.id===Q?{...me,isExpanded:!me.isExpanded}:me)}:te))},K=E.useCallback(async()=>{const G=u.trim();if(!G||p)return;const Q={id:Date.now().toString(),role:"user",content:G,timestamp:new Date};v(ae=>[...ae,Q]),m(""),x(!0),I(null);const ue=(Date.now()+1).toString(),te={id:ue,role:"assistant",content:"",timestamp:new Date,steps:[],isStreaming:!0};v(ae=>[...ae,te]);const me=new AbortController;M.current=me;try{const ae=await fetch("/api/layered-agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:G,device_id:i,session_id:i}),signal:me.signal});if(!ae.ok){let ce=`HTTP error! status: ${ae.status}`;try{const ye=await ae.json();ye.detail&&(ce=ye.detail)}catch{}throw new Error(ce)}const Ue=ae.body?.getReader();if(!Ue)throw new Error("No response body");const Ze=new TextDecoder;let Ge="";const B=[];for(;;){const{done:ce,value:ye}=await Ue.read();if(ce)break;Ge+=Ze.decode(ye,{stream:!0});const Be=Ge.split(`
|
|
129
|
+
`);Ge=Be.pop()||"";for(const We of Be)if(We.startsWith("data: "))try{const de=JSON.parse(We.slice(6));if(de.type==="tool_call"){const Se={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:de.tool_name==="chat"?"发送指令给 Phone Agent":de.tool_name==="list_devices"?"获取设备列表":`调用工具: ${de.tool_name}`,toolName:de.tool_name,toolArgs:de.tool_args||{},timestamp:new Date,isExpanded:!0};B.push(Se),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...B]}:Z))}else if(de.type==="tool_result"){const Se={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:de.tool_name==="chat"?"Phone Agent 执行结果":`${de.tool_name} 结果`,toolResult:de.result,timestamp:new Date,isExpanded:!0};B.push(Se),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...B]}:Z))}else if(de.type==="message")v(Se=>Se.map(ee=>ee.id===ue?{...ee,content:de.content}:ee));else if(de.type==="done"){const Se={...te,content:de.content||"",isStreaming:!1,success:de.success,steps:[...B],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Se:Z))}else if(de.type==="error"){const Se={...te,content:`错误: ${de.message}`,isStreaming:!1,success:!1,steps:[...B],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Se:Z)),I(de.message)}}catch(de){console.error("Failed to parse SSE data:",de,We)}}v(ce=>ce.map(ye=>ye.id===ue&&ye.isStreaming?{...ye,isStreaming:!1,success:!0}:ye))}catch(ae){if(ae instanceof Error&&ae.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",ae);const Ue=xu(ae);I(Ue),v(Ze=>Ze.map(Ge=>Ge.id===ue?{...Ge,content:`错误: ${Ue}`,isStreaming:!1,success:!1}:Ge))}finally{x(!1),M.current=null}},[u,p,i]),se=E.useCallback(()=>{if(M.current){b(!0);try{M.current.abort(),M.current=null,v(G=>{const Q=G[G.length-1];return Q&&Q.role==="assistant"&&Q.isStreaming?G.map((ue,te)=>te===G.length-1?{...ue,content:ue.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:ue):G}),Ix(async()=>{const{abortLayeredAgentChat:G}=await import("./index-BzP-Te33.js").then(Q=>Q.aq);return{abortLayeredAgentChat:G}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:G})=>{G(i).catch(Q=>console.error("Backend abort failed:",Q))})}catch(G){console.error("Failed to abort chat:",G)}finally{x(!1),b(!1)}}},[l,i]),oe=E.useCallback(async()=>{M.current&&(M.current.abort(),M.current=null),v([]),I(null),D.current&&(D.current.close(),D.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i})})}catch(G){console.warn("Failed to reset backend session:",G)}},[i]),Re=G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),K())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Ys,{className:"flex-1 flex flex-col min-h-0 max-w-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-purple-500/10",children:a.jsx(Ro,{className:"h-5 w-5 text-purple-500"})}),a.jsxs("div",{children:[a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"AI Agent"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[r," • ",l.chatkit?.layeredAgent||"分层代理模式"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hn,{variant:"secondary",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",children:l.chatkit?.layeredAgent||"分层代理模式"}),a.jsxs(Us,{open:O,onOpenChange:C,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{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:a.jsx(Fs,{className:"h-4 w-4"})})}),a.jsxs(Hs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history?.title||"History"}),q.length>0&&a.jsx(Ee,{variant:"ghost",size:"sm",onClick:pe,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),a.jsx(Dr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:q.length>0?q.map(G=>a.jsx(Fd,{item:G,onSelect:re,onDelete:X},G.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Fs,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history?.noHistory||"No history yet"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history?.noHistoryDescription||"Your completed tasks will appear here"})]})})})]})]}),a.jsx(Ee,{variant:"ghost",size:"icon",onClick:oe,className:"h-8 w-8 rounded-full",title:"重置对话",children:a.jsx(Nu,{className:"h-4 w-4"})})]})]}),N&&a.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:[a.jsx(kn,{className:"w-4 h-4 flex-shrink-0"}),N]}),a.jsx(Dr,{className:"flex-1 min-h-0",children:a.jsxs("div",{className:"p-4 space-y-4",children:[_.length===0?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-12",children:[a.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:a.jsx(Ro,{className:"h-8 w-8 text-purple-500"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"分层代理模式"}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400 max-w-xs",children:l.chatkit?.layeredAgentDesc||"决策模型负责规划任务,视觉模型负责执行。你可以看到每一步的执行过程。"})]}):_.map(G=>a.jsx("div",{className:"space-y-2",children:G.role==="user"?a.jsx("div",{className:"flex justify-end",children:a.jsxs("div",{className:"max-w-[80%]",children:[a.jsx("div",{className:"bg-purple-600 text-white px-4 py-2 rounded-2xl rounded-br-sm",children:a.jsx("p",{className:"whitespace-pre-wrap",children:G.content})}),a.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:G.timestamp.toLocaleTimeString()})]})}):a.jsxs("div",{className:"space-y-3",children:[G.steps&&G.steps.length>0&&a.jsx("div",{className:"space-y-2",children:G.steps.map((Q,ue)=>a.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[a.jsxs("button",{onClick:()=>Y(G.id,Q.id),className:"w-full flex items-center justify-between p-3 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium ${Q.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:Q.type==="tool_call"?a.jsx(kv,{className:"w-3 h-3"}):a.jsx(Lx,{className:"w-3 h-3"})}),a.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",ue+1,": ",Q.content]})]}),Q.isExpanded?a.jsx(Kx,{className:"w-4 h-4 text-slate-400"}):a.jsx(zx,{className:"w-4 h-4 text-slate-400"})]}),Q.isExpanded&&a.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[Q.type==="tool_call"&&Q.toolArgs&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:Q.toolName==="chat"?"发送给 Phone Agent 的指令:":"工具参数:"}),Q.toolName==="chat"?a.jsx("p",{className:"text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:Q.toolArgs.message||JSON.stringify(Q.toolArgs,null,2)}):a.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto",children:JSON.stringify(Q.toolArgs,null,2)})]}),Q.type==="tool_result"&&Q.toolResult&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:"执行结果:"}),a.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto whitespace-pre-wrap",children:typeof Q.toolResult=="string"?Q.toolResult:JSON.stringify(Q.toolResult,null,2)})]})]})]},Q.id))}),G.content&&a.jsx("div",{className:"flex justify-start",children:a.jsx("div",{className:`max-w-[85%] rounded-2xl rounded-tl-sm px-4 py-3 ${G.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:a.jsxs("div",{className:"flex items-start gap-2",children:[G.success!==void 0&&a.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${G.success?"text-green-500":"text-red-500"}`}),a.jsx("p",{className:"whitespace-pre-wrap",children:G.content})]})})}),G.isStreaming&&!G.content&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[a.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"正在思考和执行..."]})]})},G.id)),a.jsx("div",{ref:A})]})}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(wu,{value:u,onChange:G=>m(G.target.value),onKeyDown:Re,placeholder:"描述你想要完成的任务... (Cmd+Enter 发送)",disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs(Us,{open:z,onOpenChange:J,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(hu,{className:"w-4 h-4"})})}),a.jsx(Hs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows?.selectWorkflow||"Select Workflow"}),P.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows?.empty||"No workflows yet"}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Dr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:P.map(G=>a.jsxs("button",{onClick:()=>R(G),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:G.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:G.text})]},G.uuid))})})]})})]})}),a.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel?.tooltips?.workflowButton||"Quick Workflow"}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel?.tooltips?.workflowButtonDesc||"Select a workflow to quickly fill in the task"})]})})]}),p&&a.jsx(Ee,{onClick:se,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat?.abortChat||"中断任务",children:y?a.jsx(Yt,{className:"h-4 w-4 animate-spin"}):a.jsx(Ru,{className:"h-4 w-4"})}),!p&&a.jsx(Ee,{onClick:K,disabled:!u.trim(),size:"icon",className:"h-10 w-10 rounded-full flex-shrink-0 bg-purple-600 hover:bg-purple-700",children:a.jsx(Cu,{className:"h-4 w-4"})})]})})]}),a.jsx(Nd,{deviceId:i,serial:n,connectionType:o,isVisible:d})]})}function py({message:i,type:n="info",onClose:r,duration:o=3e3}){E.useEffect(()=>{const _=setTimeout(()=>{r()},o);return()=>clearTimeout(_)},[o,r]);const d={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500",warning:"bg-amber-500"},l={success:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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 a.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:a.jsxs("div",{className:`${d[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[l[n],a.jsx("span",{className:"font-medium",children:i}),a.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const Ar=[{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"}}],my=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:Zx,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:Eu,defaultConfig:{history_n:3}}],gy=[{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 Ty(){const i=An(),n=Mx.useSearch(),r=Dx(),[o,d]=E.useState([]),[l,_]=E.useState(""),[v,u]=E.useState(n.mode||"classic"),[m,p]=E.useState(!1),[x,y]=E.useState({message:"",type:"info",visible:!1}),b=(C,R="info")=>{y({message:C,type:R,visible:!0})},[N,I]=E.useState(null),[A,D]=E.useState(!1),[M,P]=E.useState(!1),[j,z]=E.useState({base_url:Ar[0].config.base_url,model_name:Ar[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:""});E.useEffect(()=>{(async()=>{try{const R=await Bx();I({base_url:R.base_url,model_name:R.model_name,api_key:R.api_key||void 0,agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||void 0,default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||void 0,decision_model_name:R.decision_model_name||void 0,decision_api_key:R.decision_api_key||void 0});const re=!R.base_url;z({base_url:re?Ar[0].config.base_url:R.base_url,model_name:re?Ar[0].config.model_name:R.model_name,api_key:R.api_key||"",agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||{},default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||"",decision_model_name:R.decision_model_name||"glm-4.7",decision_api_key:R.decision_api_key||""}),re&&D(!0)}catch(R){console.error("Failed to load config:",R),D(!0)}})()},[]);const J=E.useCallback(async()=>{try{const R=(await Ox()).devices.filter(Y=>Y.state!=="disconnected"),re=new Map,pe=new Map;for(const Y of R)if(Y.serial){const K=pe.get(Y.serial)||[];K.push(Y),pe.set(Y.serial,K)}else re.set(Y.id,Y);Array.from(pe.values()).forEach(Y=>{const se=Y.find(oe=>oe.connection_type==="wifi")||Y[0];re.set(se.id,se)});const X=Array.from(re.values());if(d(X),X.length>0&&!m){const Y=n.serial;if(Y){const K=X.find(se=>se.serial===Y);_(K?K.id:X[0].id)}else l||_(X[0].id);p(!0)}l&&!X.find(Y=>Y.id===l)&&_(X[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}},[l,m,n.serial]);E.useEffect(()=>{const C=setTimeout(()=>{J()},0),R=setInterval(J,3e3);return()=>{clearTimeout(C),clearInterval(R)}},[J]),E.useEffect(()=>{const R=o.find(pe=>pe.id===l)?.serial;if(!m)return;(R!==n.serial||v!==n.mode)&&r({to:"/chat",search:{serial:R,mode:v},replace:!0})},[l,v,o,m,r,n.serial,n.mode]);const q=async()=>{if(!j.base_url){b(i.chat.baseUrlRequired,"error");return}try{await Fx({base_url:j.base_url,model_name:j.model_name||"autoglm-phone-9b",api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),I({base_url:j.base_url,model_name:j.model_name,api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),b(i.toasts.configSaved,"success");try{const C=await Ux();if(C.total===0)console.log("No agents to reinitialize");else if(C.success)b(`Configuration applied to ${C.succeeded.length} device(s)`,"success");else{const R=Object.keys(C.failed).length;b(`Configuration partially applied: ${C.succeeded.length}/${C.total} succeeded, ${R} failed`,"warning")}}catch(C){console.error("Failed to reinitialize agents:",C),b("Configuration saved, but failed to update devices. Please reinitialize manually.","warning")}D(!1)}catch(C){console.error("Failed to save config:",C),b(`Failed to save: ${xu(C)}`,"error")}},$=async C=>{try{const R=await Hx({device_id:C});R.success&&R.device_id?(_(R.device_id),b(i.toasts.wifiConnected,"success")):R.success||b(R.message||R.error||i.toasts.connectionFailed,"error")}catch(R){b(i.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",R)}},O=async C=>{try{const R=await Wx(C);R.success?b(i.toasts.wifiDisconnected,"success"):b(R.message||R.error||i.toasts.disconnectFailed,"error")}catch(R){b(i.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",R)}};return a.jsxs("div",{className:"h-full flex relative min-h-0",children:[x.visible&&a.jsx(py,{message:x.message,type:x.type,onClose:()=>y(C=>({...C,visible:!1}))}),a.jsx(Fo,{open:A,onOpenChange:D,children:a.jsxs(Uo,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[a.jsxs(Wo,{className:"flex-shrink-0",children:[a.jsxs(Ho,{className:"flex items-center gap-2",children:[a.jsx(Tu,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),a.jsx(Go,{children:i.chat.configureApi})]}),a.jsxs(qu,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[a.jsxs($u,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[a.jsxs(Lr,{value:"vision",children:[a.jsx(mo,{className:"w-4 h-4 mr-2"}),i.chat.visionModelTab]}),a.jsxs(Lr,{value:"decision",children:[a.jsx(Eu,{className:"w-4 h-4 mr-2"}),i.chat.decisionModelTab]})]}),a.jsxs(Mr,{value:"vision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ar.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,base_url:C.config.base_url,model_name:C.config.model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.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:i.chat.getApiKey||"获取 API Key",children:a.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"base_url",children:[i.chat.baseUrl," *"]}),a.jsx(ht,{id:"base_url",value:j.base_url,onChange:C=>z({...j,base_url:C.target.value}),placeholder:"http://localhost:8080/v1"}),!j.base_url&&a.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[a.jsx(kn,{className:"w-3 h-3"}),i.chat.baseUrlRequired]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"api_key",children:i.chat.apiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(ht,{id:"api_key",type:M?"text":"password",value:j.api_key,onChange:C=>z({...j,api_key:C.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!M),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:M?a.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"model_name",children:i.chat.modelName}),a.jsx(ht,{id:"model_name",value:j.model_name,onChange:C=>z({...j,model_name:C.target.value}),placeholder:"autoglm-phone-9b"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.agentType||"Agent 类型"}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:my.map(C=>a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,agent_type:C.name,agent_config_params:C.defaultConfig})),className:`text-left p-3 rounded-lg border transition-all ${j.agent_type===C.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(C.icon,{className:`w-4 h-4 ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-medium text-sm ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-900 dark:text-slate-100"}`,children:C.displayName})]}),a.jsx("p",{className:`text-xs mt-1 ml-6 ${j.agent_type===C.name?"text-[#1d9bf0]/70":"text-slate-500 dark:text-slate-400"}`,children:C.description})]},C.name))})]}),j.agent_type==="mai"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"history_n",children:i.chat.history_n||"历史记录数量"}),a.jsx(ht,{id:"history_n",type:"number",min:1,max:10,value:j.agent_config_params?.history_n||3,onChange:C=>{const R=parseInt(C.target.value)||3;z(re=>({...re,agent_config_params:{...re.agent_config_params,history_n:R}}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.history_n_hint||"包含的历史截图数量(1-10)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"default_max_steps",children:i.chat.maxSteps||"最大执行步数"}),a.jsx(ht,{id:"default_max_steps",type:"number",min:1,max:1e3,value:j.default_max_steps,onChange:C=>{const R=parseInt(C.target.value)||100;z(re=>({...re,default_max_steps:Math.min(1e3,Math.max(1,R))}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.maxStepsHint||"单次任务最大执行步数(1-1000)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"layered_max_turns",children:"分层代理最大轮次"}),a.jsx(ht,{id:"layered_max_turns",type:"number",min:1,value:j.layered_max_turns,onChange:C=>{const R=parseInt(C.target.value)||50;z(re=>({...re,layered_max_turns:Math.max(1,R)}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"分层代理模式的最大轮次(最小值为1)"})]})]}),a.jsxs(Mr,{value:"decision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.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:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(ov,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),a.jsx("div",{children:i.chat.decisionModelHint})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectDecisionPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:gy.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,decision_base_url:C.config.decision_base_url,decision_model_name:C.config.decision_model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.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:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"text-indigo-600 dark:text-indigo-400":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.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:i.chat.getApiKey||"获取 API Key",children:a.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-indigo-600 dark:group-hover:text-indigo-400 transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"decision_base_url",children:[i.chat.decisionBaseUrl," *"]}),a.jsx(ht,{id:"decision_base_url",value:j.decision_base_url,onChange:C=>z({...j,decision_base_url:C.target.value}),placeholder:"http://localhost:8080/v1"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"decision_api_key",children:i.chat.decisionApiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(ht,{id:"decision_api_key",type:M?"text":"password",value:j.decision_api_key,onChange:C=>z({...j,decision_api_key:C.target.value}),placeholder:"sk-...",className:"pr-10"}),a.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!M),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:M?a.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"decision_model_name",children:[i.chat.decisionModelName," *"]}),a.jsx(ht,{id:"decision_model_name",value:j.decision_model_name,onChange:C=>z({...j,decision_model_name:C.target.value}),placeholder:""})]})]})]}),a.jsxs(zo,{className:"sm:justify-between gap-2 flex-shrink-0",children:[a.jsx(Ee,{variant:"outline",onClick:()=>{D(!1),N&&z({base_url:N.base_url,model_name:N.model_name,api_key:N.api_key||"",agent_type:N.agent_type||"glm",agent_config_params:N.agent_config_params||{},default_max_steps:N.default_max_steps||100,layered_max_turns:N.layered_max_turns||50,decision_base_url:N.decision_base_url||"",decision_model_name:N.decision_model_name||"glm-4.7",decision_api_key:N.decision_api_key||""})},children:i.chat.cancel}),a.jsxs(Ee,{onClick:q,variant:"twitter",children:[a.jsx(Fr,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),a.jsx(f1,{devices:o,currentDeviceId:l,onSelectDevice:_,onOpenConfig:()=>D(!0),onConnectWifi:$,onDisconnectWifi:O,onRefreshDevices:J,showToast:b}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative",children:[a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:a.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:[a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs("button",{onClick:()=>u("classic"),className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="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:[a.jsx(jr,{className:"w-4 h-4"}),i.chatkit?.classicMode||"经典模式"]})}),a.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.classicMode||"经典模式"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.classicModeDesc||"视觉模型直接执行任务"})]})})]}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs("button",{onClick:()=>{u("chatkit")},className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="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:[a.jsx(Ro,{className:"w-4 h-4"}),i.chatkit?.layeredMode||"分层代理"]})}),a.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.layeredMode||"分层代理"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.layeredModeDesc||"规划层分解任务,执行层独立完成子任务"})]})})]})]})}),a.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4 pt-16",children:o.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:a.jsxs("div",{className:"text-center",children:[a.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:a.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.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"})})}),a.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:i.chat.welcomeTitle}),a.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:i.chat.connectDevice})]})}):o.map(C=>a.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${C.id===l?"":"hidden"}`,children:v==="chatkit"?a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(hy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isVisible:C.id===l})}):a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(fy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isConfigured:!!N?.base_url})})},C.serial))})]})]})}export{Ty as component};
|