autoglm-gui 1.2.1__py3-none-any.whl → 1.3.1__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.
Files changed (34) hide show
  1. AutoGLM_GUI/adb_plus/__init__.py +6 -6
  2. AutoGLM_GUI/api/__init__.py +54 -16
  3. AutoGLM_GUI/api/agents.py +163 -209
  4. AutoGLM_GUI/api/dual_model.py +310 -0
  5. AutoGLM_GUI/api/mcp.py +134 -0
  6. AutoGLM_GUI/api/metrics.py +36 -0
  7. AutoGLM_GUI/config_manager.py +110 -6
  8. AutoGLM_GUI/dual_model/__init__.py +53 -0
  9. AutoGLM_GUI/dual_model/decision_model.py +664 -0
  10. AutoGLM_GUI/dual_model/dual_agent.py +917 -0
  11. AutoGLM_GUI/dual_model/protocols.py +354 -0
  12. AutoGLM_GUI/dual_model/vision_model.py +442 -0
  13. AutoGLM_GUI/exceptions.py +75 -3
  14. AutoGLM_GUI/metrics.py +283 -0
  15. AutoGLM_GUI/phone_agent_manager.py +264 -14
  16. AutoGLM_GUI/prompts.py +97 -0
  17. AutoGLM_GUI/schemas.py +40 -9
  18. AutoGLM_GUI/static/assets/{about-BtBH1xKN.js → about-Cj6QXqMf.js} +1 -1
  19. AutoGLM_GUI/static/assets/chat-BJeomZgh.js +124 -0
  20. AutoGLM_GUI/static/assets/dialog-CxJlnjzH.js +45 -0
  21. AutoGLM_GUI/static/assets/{index-B_AaKuOT.js → index-C_B-Arvf.js} +1 -1
  22. AutoGLM_GUI/static/assets/index-CxJQuE4y.js +12 -0
  23. AutoGLM_GUI/static/assets/index-Z0uYCPOO.css +1 -0
  24. AutoGLM_GUI/static/assets/{workflows-xX_QH-wI.js → workflows-BTiGCNI0.js} +1 -1
  25. AutoGLM_GUI/static/index.html +2 -2
  26. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.1.dist-info}/METADATA +90 -5
  27. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.1.dist-info}/RECORD +30 -20
  28. AutoGLM_GUI/static/assets/chat-DPzFNNGu.js +0 -124
  29. AutoGLM_GUI/static/assets/dialog-Dwuk2Hgl.js +0 -45
  30. AutoGLM_GUI/static/assets/index-BjYIY--m.css +0 -1
  31. AutoGLM_GUI/static/assets/index-CvQkCi2d.js +0 -11
  32. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.1.dist-info}/WHEEL +0 -0
  33. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.1.dist-info}/entry_points.txt +0 -0
  34. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,124 @@
1
+ import{c as Ie,j as a,u as Jr,r as w,e as Qt,B as Ae,f as Zr,R as Oe,g as cn,h as Qo,i as ua,P as Wt,k as rt,m as fa,n as Un,o as rr,p as Hn,q as Xs,s as yx,t as wx,v as Ex,w as Sx,x as Cx,S as $r,y as Qc,z as Nx,A as Ou,C as Tx,D as Jc,E as Zc,F as Rx,M as kx,G as Fu,H as Ax,I as Bu,J as Px,K as jx,L as Ix,N as Lx,O as Mx,Q as Dx,T as Ox,U as Fx,V as Bx,W as Ux,X as Wx,Y as Gx,Z as Hx,_ as Ys,$ as Vs,a0 as Ks,a1 as zx,l as qx,a2 as $x,a3 as Xx,a4 as Yx,a5 as Vx,a6 as Kx}from"./index-CxJQuE4y.js";import{L as pn,P as Qx,D as Uu,d as Wu,e as Gu,f as Hu,j as zu,g as It,I as Jt,i as qu,C as wr,k as Jx,R as Zx,u as ev,F as tv,T as nv,h as rv}from"./dialog-CxJlnjzH.js";const sv=[["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"}]],iv=Ie("arrow-up-down",sv);const ov=[["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"}]],da=Ie("brain",ov);const av=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Jo=Ie("chevron-down",av);const lv=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],$u=Ie("chevron-left",lv);const cv=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ha=Ie("chevron-right",cv);const uv=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],eu=Ie("chevron-up",uv);const fv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],tr=Ie("circle-alert",fv);const dv=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hv=Ie("circle-check-big",dv);const pv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Wn=Ie("circle-check",pv);const mv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ii=Ie("circle-x",mv);const gv=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_v=Ie("clock",gv);const xv=[["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"}]],vv=Ie("external-link",xv);const bv=[["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"}]],tu=Ie("eye-off",bv);const yv=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],oi=Ie("eye",yv);const wv=[["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"}]],Ev=Ie("fingerprint-pattern",wv);const Sv=[["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"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],nu=Ie("history",Sv);const Cv=[["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"}]],ru=Ie("image",Cv);const Nv=[["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"}]],Tv=Ie("monitor-play",Nv);const Rv=[["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"}]],kv=Ie("plug",Rv);const Av=[["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"}]],Pv=Ie("rotate-ccw",Av);const jv=[["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"}]],Iv=Ie("send",jv);const Lv=[["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"}]],Mv=Ie("server",Lv);const Dv=[["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"}]],Xu=Ie("settings",Dv);const Ov=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Zo=Ie("smartphone",Ov);const Fv=[["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"}]],Qs=Ie("sparkles",Fv);const Bv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Uv=Ie("square",Bv);const Wv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Yu=Ie("target",Wv);const Gv=[["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"}]],Hv=Ie("video",Gv);const zv=[["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"}]],su=Ie("wifi-off",zv);const qv=[["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"}]],ea=Ie("wifi",qv);const $v=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ai=Ie("zap",$v);function iu({isOpen:i,title:n,content:r,onConfirm:o,onCancel:u,confirmText:l="确认",cancelText:p="取消"}){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:x=>x.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:x=>{x.stopPropagation(),u()},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:p}),a.jsx("button",{onClick:x=>{x.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 Xv({id:i,serial:n,model:r,status:o,connectionType:u,agent:l,isActive:p,onClick:x,onConnectWifi:d,onDisconnectWifi:m}){const h=Jr(),v=o==="device",b=u==="usb",S=u==="remote",[T,L]=w.useState(!1),[R,D]=w.useState(!1),[G,I]=w.useState(!1),k=r||h.deviceCard.unknownDevice,q=F=>{F.stopPropagation(),!(T||!d)&&D(!0)},$=F=>{F.stopPropagation(),!(T||!m)&&I(!0)},X=async()=>{D(!1),L(!0);try{d&&await d()}finally{L(!1)}},Y=async()=>{I(!1),L(!0);try{m&&await m()}finally{L(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:x,role:"button",tabIndex:0,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&x()},className:`
2
+ group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
3
+ border-2
4
+ ${p?"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"}
5
+ `,children:[p&&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.jsx("div",{className:`relative flex-shrink-0 ${v?"status-online":"status-offline"} w-3 h-3 rounded-full transition-all ${p?"scale-110":""}`}),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(Zo,{className:`w-4 h-4 flex-shrink-0 ${p?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-semibold text-sm truncate ${p?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:k})]}),a.jsx("span",{className:`text-xs font-mono truncate ${p?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:r||i}),l&&a.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[l.state==="busy"&&a.jsxs(Qt,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-[#1d9bf0]/10 text-[#1d9bf0] hover:bg-[#1d9bf0]/20",children:[a.jsx(pn,{className:"w-2.5 h-2.5 animate-spin mr-1"}),h.deviceCard.agentBusy]}),l.state==="idle"&&a.jsxs(Qt,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-400",children:[a.jsx(Wn,{className:"w-2.5 h-2.5 mr-1"}),h.deviceCard.agentIdle]}),l.state==="error"&&a.jsxs(Qt,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-red-50 text-red-700 dark:bg-red-900/20 dark:text-red-400",children:[a.jsx(ii,{className:"w-2.5 h-2.5 mr-1"}),h.deviceCard.agentError]}),l.state==="initializing"&&a.jsxs(Qt,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400",children:[a.jsx(_v,{className:"w-2.5 h-2.5 mr-1"}),h.deviceCard.agentInitializing]})]})]}),b&&a.jsx(Qt,{variant:"outline",className:"flex-shrink-0 text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:"USB"}),S&&a.jsxs(Qt,{variant:"outline",className:"flex-shrink-0 text-xs border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",children:[a.jsx(su,{className:"w-2.5 h-2.5 mr-1"}),"Remote"]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[d&&b&&a.jsx(Ae,{variant:"ghost",size:"icon",onClick:q,disabled:T,className:"h-7 w-7 text-slate-400 hover:text-[#1d9bf0]",title:h.deviceCard.connectViaWifi,children:T?a.jsx(pn,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(ea,{className:"w-3.5 h-3.5"})}),m&&S&&a.jsx(Ae,{variant:"ghost",size:"icon",onClick:$,disabled:T,className:"h-7 w-7 text-slate-400 hover:text-orange-500",title:h.deviceCard.disconnectWifi,children:T?a.jsx(pn,{className:"w-3.5 h-3.5 animate-spin"}):a.jsx(su,{className:"w-3.5 h-3.5"})})]})]})]}),a.jsx(iu,{isOpen:R,title:h.deviceCard.connectWifiTitle,content:h.deviceCard.connectWifiContent,onConfirm:X,onCancel:()=>D(!1)}),a.jsx(iu,{isOpen:G,title:h.deviceCard.disconnectWifiTitle,content:h.deviceCard.disconnectWifiContent,onConfirm:Y,onCancel:()=>I(!1)})]})}function Yv(i){const n=i+"CollectionProvider",[r,o]=Zr(n),[u,l]=r(n,{collectionRef:{current:null},itemMap:new Map}),p=L=>{const{scope:R,children:D}=L,G=Oe.useRef(null),I=Oe.useRef(new Map).current;return a.jsx(u,{scope:R,itemMap:I,collectionRef:G,children:D})};p.displayName=n;const x=i+"CollectionSlot",d=Qo(x),m=Oe.forwardRef((L,R)=>{const{scope:D,children:G}=L,I=l(x,D),k=cn(R,I.collectionRef);return a.jsx(d,{ref:k,children:G})});m.displayName=x;const h=i+"CollectionItemSlot",v="data-radix-collection-item",b=Qo(h),S=Oe.forwardRef((L,R)=>{const{scope:D,children:G,...I}=L,k=Oe.useRef(null),q=cn(R,k),$=l(h,D);return Oe.useEffect(()=>($.itemMap.set(k,{ref:k,...I}),()=>void $.itemMap.delete(k))),a.jsx(b,{[v]:"",ref:q,children:G})});S.displayName=h;function T(L){const R=l(i+"CollectionConsumer",L);return Oe.useCallback(()=>{const G=R.collectionRef.current;if(!G)return[];const I=Array.from(G.querySelectorAll(`[${v}]`));return Array.from(R.itemMap.values()).sort(($,X)=>I.indexOf($.ref.current)-I.indexOf(X.ref.current))},[R.collectionRef,R.itemMap])}return[{Provider:p,Slot:m,ItemSlot:S},T,o]}var Vv=w.createContext(void 0);function pa(i){const n=w.useContext(Vv);return i||n||"ltr"}var Bo="rovingFocusGroup.onEntryFocus",Kv={bubbles:!1,cancelable:!0},es="RovingFocusGroup",[ta,Vu,Qv]=Yv(es),[Jv,Ku]=Zr(es,[Qv]),[Zv,e1]=Jv(es),Qu=w.forwardRef((i,n)=>a.jsx(ta.Provider,{scope:i.__scopeRovingFocusGroup,children:a.jsx(ta.Slot,{scope:i.__scopeRovingFocusGroup,children:a.jsx(t1,{...i,ref:n})})}));Qu.displayName=es;var t1=w.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,orientation:o,loop:u=!1,dir:l,currentTabStopId:p,defaultCurrentTabStopId:x,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...v}=i,b=w.useRef(null),S=cn(n,b),T=pa(l),[L,R]=fa({prop:p,defaultProp:x??null,onChange:d,caller:es}),[D,G]=w.useState(!1),I=Un(m),k=Vu(r),q=w.useRef(!1),[$,X]=w.useState(0);return w.useEffect(()=>{const Y=b.current;if(Y)return Y.addEventListener(Bo,I),()=>Y.removeEventListener(Bo,I)},[I]),a.jsx(Zv,{scope:r,orientation:o,dir:T,loop:u,currentTabStopId:L,onItemFocus:w.useCallback(Y=>R(Y),[R]),onItemShiftTab:w.useCallback(()=>G(!0),[]),onFocusableItemAdd:w.useCallback(()=>X(Y=>Y+1),[]),onFocusableItemRemove:w.useCallback(()=>X(Y=>Y-1),[]),children:a.jsx(Wt.div,{tabIndex:D||$===0?-1:0,"data-orientation":o,...v,ref:S,style:{outline:"none",...i.style},onMouseDown:rt(i.onMouseDown,()=>{q.current=!0}),onFocus:rt(i.onFocus,Y=>{const F=!q.current;if(Y.target===Y.currentTarget&&F&&!D){const P=new CustomEvent(Bo,Kv);if(Y.currentTarget.dispatchEvent(P),!P.defaultPrevented){const A=k().filter(K=>K.focusable),de=A.find(K=>K.active),ae=A.find(K=>K.id===L),V=[de,ae,...A].filter(Boolean).map(K=>K.ref.current);ef(V,h)}}q.current=!1}),onBlur:rt(i.onBlur,()=>G(!1))})})}),Ju="RovingFocusGroupItem",Zu=w.forwardRef((i,n)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:u=!1,tabStopId:l,children:p,...x}=i,d=ua(),m=l||d,h=e1(Ju,r),v=h.currentTabStopId===m,b=Vu(r),{onFocusableItemAdd:S,onFocusableItemRemove:T,currentTabStopId:L}=h;return w.useEffect(()=>{if(o)return S(),()=>T()},[o,S,T]),a.jsx(ta.ItemSlot,{scope:r,id:m,focusable:o,active:u,children:a.jsx(Wt.span,{tabIndex:v?0:-1,"data-orientation":h.orientation,...x,ref:n,onMouseDown:rt(i.onMouseDown,R=>{o?h.onItemFocus(m):R.preventDefault()}),onFocus:rt(i.onFocus,()=>h.onItemFocus(m)),onKeyDown:rt(i.onKeyDown,R=>{if(R.key==="Tab"&&R.shiftKey){h.onItemShiftTab();return}if(R.target!==R.currentTarget)return;const D=s1(R,h.orientation,h.dir);if(D!==void 0){if(R.metaKey||R.ctrlKey||R.altKey||R.shiftKey)return;R.preventDefault();let I=b().filter(k=>k.focusable).map(k=>k.ref.current);if(D==="last")I.reverse();else if(D==="prev"||D==="next"){D==="prev"&&I.reverse();const k=I.indexOf(R.currentTarget);I=h.loop?i1(I,k+1):I.slice(k+1)}setTimeout(()=>ef(I))}}),children:typeof p=="function"?p({isCurrentTabStop:v,hasTabStop:L!=null}):p})})});Zu.displayName=Ju;var n1={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function r1(i,n){return n!=="rtl"?i:i==="ArrowLeft"?"ArrowRight":i==="ArrowRight"?"ArrowLeft":i}function s1(i,n,r){const o=r1(i.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return n1[o]}function ef(i,n=!1){const r=document.activeElement;for(const o of i)if(o===r||(o.focus({preventScroll:n}),document.activeElement!==r))return}function i1(i,n){return i.map((r,o)=>i[(n+o)%i.length])}var o1=Qu,a1=Zu,fi="Tabs",[l1]=Zr(fi,[Ku]),tf=Ku(),[c1,ma]=l1(fi),nf=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,onValueChange:u,defaultValue:l,orientation:p="horizontal",dir:x,activationMode:d="automatic",...m}=i,h=pa(x),[v,b]=fa({prop:o,onChange:u,defaultProp:l??"",caller:fi});return a.jsx(c1,{scope:r,baseId:ua(),value:v,onValueChange:b,orientation:p,dir:h,activationMode:d,children:a.jsx(Wt.div,{dir:h,"data-orientation":p,...m,ref:n})})});nf.displayName=fi;var rf="TabsList",sf=w.forwardRef((i,n)=>{const{__scopeTabs:r,loop:o=!0,...u}=i,l=ma(rf,r),p=tf(r);return a.jsx(o1,{asChild:!0,...p,orientation:l.orientation,dir:l.dir,loop:o,children:a.jsx(Wt.div,{role:"tablist","aria-orientation":l.orientation,...u,ref:n})})});sf.displayName=rf;var of="TabsTrigger",af=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,disabled:u=!1,...l}=i,p=ma(of,r),x=tf(r),d=uf(p.baseId,o),m=ff(p.baseId,o),h=o===p.value;return a.jsx(a1,{asChild:!0,...x,focusable:!u,active:h,children:a.jsx(Wt.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":u?"":void 0,disabled:u,id:d,...l,ref:n,onMouseDown:rt(i.onMouseDown,v=>{!u&&v.button===0&&v.ctrlKey===!1?p.onValueChange(o):v.preventDefault()}),onKeyDown:rt(i.onKeyDown,v=>{[" ","Enter"].includes(v.key)&&p.onValueChange(o)}),onFocus:rt(i.onFocus,()=>{const v=p.activationMode!=="manual";!h&&!u&&v&&p.onValueChange(o)})})})});af.displayName=of;var lf="TabsContent",cf=w.forwardRef((i,n)=>{const{__scopeTabs:r,value:o,forceMount:u,children:l,...p}=i,x=ma(lf,r),d=uf(x.baseId,o),m=ff(x.baseId,o),h=o===x.value,v=w.useRef(h);return w.useEffect(()=>{const b=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(b)},[]),a.jsx(rr,{present:u||h,children:({present:b})=>a.jsx(Wt.div,{"data-state":h?"active":"inactive","data-orientation":x.orientation,role:"tabpanel","aria-labelledby":d,hidden:!b,id:m,tabIndex:0,...p,ref:n,style:{...i.style,animationDuration:v.current?"0s":void 0},children:b&&l})})});cf.displayName=lf;function uf(i,n){return`${i}-trigger-${n}`}function ff(i,n){return`${i}-content-${n}`}var u1=nf,f1=sf,d1=af,h1=cf;function p1({className:i,...n}){return a.jsx(u1,{"data-slot":"tabs",className:Hn("flex flex-col gap-2",i),...n})}function m1({className:i,...n}){return a.jsx(f1,{"data-slot":"tabs-list",className:Hn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",i),...n})}function ou({className:i,...n}){return a.jsx(d1,{"data-slot":"tabs-trigger",className:Hn("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 au({className:i,...n}){return a.jsx(h1,{"data-slot":"tabs-content",className:Hn("flex-1 outline-none",i),...n})}var g1=Object.defineProperty,li=Object.getOwnPropertySymbols,df=Object.prototype.hasOwnProperty,hf=Object.prototype.propertyIsEnumerable,lu=(i,n,r)=>n in i?g1(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,na=(i,n)=>{for(var r in n||(n={}))df.call(n,r)&&lu(i,r,n[r]);if(li)for(var r of li(n))hf.call(n,r)&&lu(i,r,n[r]);return i},ra=(i,n)=>{var r={};for(var o in i)df.call(i,o)&&n.indexOf(o)<0&&(r[o]=i[o]);if(i!=null&&li)for(var o of li(i))n.indexOf(o)<0&&hf.call(i,o)&&(r[o]=i[o]);return r};var nr;(i=>{const n=class Ce{constructor(d,m,h,v){if(this.version=d,this.errorCorrectionLevel=m,this.modules=[],this.isFunction=[],d<Ce.MIN_VERSION||d>Ce.MAX_VERSION)throw new RangeError("Version value out of range");if(v<-1||v>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let b=[];for(let T=0;T<this.size;T++)b.push(!1);for(let T=0;T<this.size;T++)this.modules.push(b.slice()),this.isFunction.push(b.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(h);if(this.drawCodewords(S),v==-1){let T=1e9;for(let L=0;L<8;L++){this.applyMask(L),this.drawFormatBits(L);const R=this.getPenaltyScore();R<T&&(v=L,T=R),this.applyMask(L)}}u(0<=v&&v<=7),this.mask=v,this.applyMask(v),this.drawFormatBits(v),this.isFunction=[]}static encodeText(d,m){const h=i.QrSegment.makeSegments(d);return Ce.encodeSegments(h,m)}static encodeBinary(d,m){const h=i.QrSegment.makeBytes(d);return Ce.encodeSegments([h],m)}static encodeSegments(d,m,h=1,v=40,b=-1,S=!0){if(!(Ce.MIN_VERSION<=h&&h<=v&&v<=Ce.MAX_VERSION)||b<-1||b>7)throw new RangeError("Invalid value");let T,L;for(T=h;;T++){const I=Ce.getNumDataCodewords(T,m)*8,k=p.getTotalBits(d,T);if(k<=I){L=k;break}if(T>=v)throw new RangeError("Data too long")}for(const I of[Ce.Ecc.MEDIUM,Ce.Ecc.QUARTILE,Ce.Ecc.HIGH])S&&L<=Ce.getNumDataCodewords(T,I)*8&&(m=I);let R=[];for(const I of d){r(I.mode.modeBits,4,R),r(I.numChars,I.mode.numCharCountBits(T),R);for(const k of I.getData())R.push(k)}u(R.length==L);const D=Ce.getNumDataCodewords(T,m)*8;u(R.length<=D),r(0,Math.min(4,D-R.length),R),r(0,(8-R.length%8)%8,R),u(R.length%8==0);for(let I=236;R.length<D;I^=253)r(I,8,R);let G=[];for(;G.length*8<R.length;)G.push(0);return R.forEach((I,k)=>G[k>>>3]|=I<<7-(k&7)),new Ce(T,m,G,b)}getModule(d,m){return 0<=d&&d<this.size&&0<=m&&m<this.size&&this.modules[m][d]}getModules(){return this.modules}drawFunctionPatterns(){for(let h=0;h<this.size;h++)this.setFunctionModule(6,h,h%2==0),this.setFunctionModule(h,6,h%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const d=this.getAlignmentPatternPositions(),m=d.length;for(let h=0;h<m;h++)for(let v=0;v<m;v++)h==0&&v==0||h==0&&v==m-1||h==m-1&&v==0||this.drawAlignmentPattern(d[h],d[v]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(d){const m=this.errorCorrectionLevel.formatBits<<3|d;let h=m;for(let b=0;b<10;b++)h=h<<1^(h>>>9)*1335;const v=(m<<10|h)^21522;u(v>>>15==0);for(let b=0;b<=5;b++)this.setFunctionModule(8,b,o(v,b));this.setFunctionModule(8,7,o(v,6)),this.setFunctionModule(8,8,o(v,7)),this.setFunctionModule(7,8,o(v,8));for(let b=9;b<15;b++)this.setFunctionModule(14-b,8,o(v,b));for(let b=0;b<8;b++)this.setFunctionModule(this.size-1-b,8,o(v,b));for(let b=8;b<15;b++)this.setFunctionModule(8,this.size-15+b,o(v,b));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let h=0;h<12;h++)d=d<<1^(d>>>11)*7973;const m=this.version<<12|d;u(m>>>18==0);for(let h=0;h<18;h++){const v=o(m,h),b=this.size-11+h%3,S=Math.floor(h/3);this.setFunctionModule(b,S,v),this.setFunctionModule(S,b,v)}}drawFinderPattern(d,m){for(let h=-4;h<=4;h++)for(let v=-4;v<=4;v++){const b=Math.max(Math.abs(v),Math.abs(h)),S=d+v,T=m+h;0<=S&&S<this.size&&0<=T&&T<this.size&&this.setFunctionModule(S,T,b!=2&&b!=4)}}drawAlignmentPattern(d,m){for(let h=-2;h<=2;h++)for(let v=-2;v<=2;v++)this.setFunctionModule(d+v,m+h,Math.max(Math.abs(v),Math.abs(h))!=1)}setFunctionModule(d,m,h){this.modules[m][d]=h,this.isFunction[m][d]=!0}addEccAndInterleave(d){const m=this.version,h=this.errorCorrectionLevel;if(d.length!=Ce.getNumDataCodewords(m,h))throw new RangeError("Invalid argument");const v=Ce.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][m],b=Ce.ECC_CODEWORDS_PER_BLOCK[h.ordinal][m],S=Math.floor(Ce.getNumRawDataModules(m)/8),T=v-S%v,L=Math.floor(S/v);let R=[];const D=Ce.reedSolomonComputeDivisor(b);for(let I=0,k=0;I<v;I++){let q=d.slice(k,k+L-b+(I<T?0:1));k+=q.length;const $=Ce.reedSolomonComputeRemainder(q,D);I<T&&q.push(0),R.push(q.concat($))}let G=[];for(let I=0;I<R[0].length;I++)R.forEach((k,q)=>{(I!=L-b||q>=T)&&G.push(k[I])});return u(G.length==S),G}drawCodewords(d){if(d.length!=Math.floor(Ce.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let m=0;for(let h=this.size-1;h>=1;h-=2){h==6&&(h=5);for(let v=0;v<this.size;v++)for(let b=0;b<2;b++){const S=h-b,L=(h+1&2)==0?this.size-1-v:v;!this.isFunction[L][S]&&m<d.length*8&&(this.modules[L][S]=o(d[m>>>3],7-(m&7)),m++)}}u(m==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let m=0;m<this.size;m++)for(let h=0;h<this.size;h++){let v;switch(d){case 0:v=(h+m)%2==0;break;case 1:v=m%2==0;break;case 2:v=h%3==0;break;case 3:v=(h+m)%3==0;break;case 4:v=(Math.floor(h/3)+Math.floor(m/2))%2==0;break;case 5:v=h*m%2+h*m%3==0;break;case 6:v=(h*m%2+h*m%3)%2==0;break;case 7:v=((h+m)%2+h*m%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[m][h]&&v&&(this.modules[m][h]=!this.modules[m][h])}}getPenaltyScore(){let d=0;for(let b=0;b<this.size;b++){let S=!1,T=0,L=[0,0,0,0,0,0,0];for(let R=0;R<this.size;R++)this.modules[b][R]==S?(T++,T==5?d+=Ce.PENALTY_N1:T>5&&d++):(this.finderPenaltyAddHistory(T,L),S||(d+=this.finderPenaltyCountPatterns(L)*Ce.PENALTY_N3),S=this.modules[b][R],T=1);d+=this.finderPenaltyTerminateAndCount(S,T,L)*Ce.PENALTY_N3}for(let b=0;b<this.size;b++){let S=!1,T=0,L=[0,0,0,0,0,0,0];for(let R=0;R<this.size;R++)this.modules[R][b]==S?(T++,T==5?d+=Ce.PENALTY_N1:T>5&&d++):(this.finderPenaltyAddHistory(T,L),S||(d+=this.finderPenaltyCountPatterns(L)*Ce.PENALTY_N3),S=this.modules[R][b],T=1);d+=this.finderPenaltyTerminateAndCount(S,T,L)*Ce.PENALTY_N3}for(let b=0;b<this.size-1;b++)for(let S=0;S<this.size-1;S++){const T=this.modules[b][S];T==this.modules[b][S+1]&&T==this.modules[b+1][S]&&T==this.modules[b+1][S+1]&&(d+=Ce.PENALTY_N2)}let m=0;for(const b of this.modules)m=b.reduce((S,T)=>S+(T?1:0),m);const h=this.size*this.size,v=Math.ceil(Math.abs(m*20-h*10)/h)-1;return u(0<=v&&v<=9),d+=v*Ce.PENALTY_N4,u(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,m=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let h=[6];for(let v=this.size-7;h.length<d;v-=m)h.splice(1,0,v);return h}}static getNumRawDataModules(d){if(d<Ce.MIN_VERSION||d>Ce.MAX_VERSION)throw new RangeError("Version number out of range");let m=(16*d+128)*d+64;if(d>=2){const h=Math.floor(d/7)+2;m-=(25*h-10)*h-55,d>=7&&(m-=36)}return u(208<=m&&m<=29648),m}static getNumDataCodewords(d,m){return Math.floor(Ce.getNumRawDataModules(d)/8)-Ce.ECC_CODEWORDS_PER_BLOCK[m.ordinal][d]*Ce.NUM_ERROR_CORRECTION_BLOCKS[m.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let m=[];for(let v=0;v<d-1;v++)m.push(0);m.push(1);let h=1;for(let v=0;v<d;v++){for(let b=0;b<m.length;b++)m[b]=Ce.reedSolomonMultiply(m[b],h),b+1<m.length&&(m[b]^=m[b+1]);h=Ce.reedSolomonMultiply(h,2)}return m}static reedSolomonComputeRemainder(d,m){let h=m.map(v=>0);for(const v of d){const b=v^h.shift();h.push(0),m.forEach((S,T)=>h[T]^=Ce.reedSolomonMultiply(S,b))}return h}static reedSolomonMultiply(d,m){if(d>>>8||m>>>8)throw new RangeError("Byte out of range");let h=0;for(let v=7;v>=0;v--)h=h<<1^(h>>>7)*285,h^=(m>>>v&1)*d;return u(h>>>8==0),h}finderPenaltyCountPatterns(d){const m=d[1];u(m<=this.size*3);const h=m>0&&d[2]==m&&d[3]==m*3&&d[4]==m&&d[5]==m;return(h&&d[0]>=m*4&&d[6]>=m?1:0)+(h&&d[6]>=m*4&&d[0]>=m?1:0)}finderPenaltyTerminateAndCount(d,m,h){return d&&(this.finderPenaltyAddHistory(m,h),m=0),m+=this.size,this.finderPenaltyAddHistory(m,h),this.finderPenaltyCountPatterns(h)}finderPenaltyAddHistory(d,m){m[0]==0&&(d+=this.size),m.pop(),m.unshift(d)}};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(x,d,m){if(d<0||d>31||x>>>d)throw new RangeError("Value out of range");for(let h=d-1;h>=0;h--)m.push(x>>>h&1)}function o(x,d){return(x>>>d&1)!=0}function u(x){if(!x)throw new Error("Assertion error")}const l=class Je{constructor(d,m,h){if(this.mode=d,this.numChars=m,this.bitData=h,m<0)throw new RangeError("Invalid argument");this.bitData=h.slice()}static makeBytes(d){let m=[];for(const h of d)r(h,8,m);return new Je(Je.Mode.BYTE,d.length,m)}static makeNumeric(d){if(!Je.isNumeric(d))throw new RangeError("String contains non-numeric characters");let m=[];for(let h=0;h<d.length;){const v=Math.min(d.length-h,3);r(parseInt(d.substring(h,h+v),10),v*3+1,m),h+=v}return new Je(Je.Mode.NUMERIC,d.length,m)}static makeAlphanumeric(d){if(!Je.isAlphanumeric(d))throw new RangeError("String contains unencodable characters in alphanumeric mode");let m=[],h;for(h=0;h+2<=d.length;h+=2){let v=Je.ALPHANUMERIC_CHARSET.indexOf(d.charAt(h))*45;v+=Je.ALPHANUMERIC_CHARSET.indexOf(d.charAt(h+1)),r(v,11,m)}return h<d.length&&r(Je.ALPHANUMERIC_CHARSET.indexOf(d.charAt(h)),6,m),new Je(Je.Mode.ALPHANUMERIC,d.length,m)}static makeSegments(d){return d==""?[]:Je.isNumeric(d)?[Je.makeNumeric(d)]:Je.isAlphanumeric(d)?[Je.makeAlphanumeric(d)]:[Je.makeBytes(Je.toUtf8ByteArray(d))]}static makeEci(d){let m=[];if(d<0)throw new RangeError("ECI assignment value out of range");if(d<128)r(d,8,m);else if(d<16384)r(2,2,m),r(d,14,m);else if(d<1e6)r(6,3,m),r(d,21,m);else throw new RangeError("ECI assignment value out of range");return new Je(Je.Mode.ECI,0,m)}static isNumeric(d){return Je.NUMERIC_REGEX.test(d)}static isAlphanumeric(d){return Je.ALPHANUMERIC_REGEX.test(d)}getData(){return this.bitData.slice()}static getTotalBits(d,m){let h=0;for(const v of d){const b=v.mode.numCharCountBits(m);if(v.numChars>=1<<b)return 1/0;h+=4+b+v.bitData.length}return h}static toUtf8ByteArray(d){d=encodeURI(d);let m=[];for(let h=0;h<d.length;h++)d.charAt(h)!="%"?m.push(d.charCodeAt(h)):(m.push(parseInt(d.substring(h+1,h+3),16)),h+=2);return m}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=l;i.QrSegment=l})(nr||(nr={}));(i=>{(n=>{const r=class{constructor(u,l){this.ordinal=u,this.formatBits=l}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),n.Ecc=r})(i.QrCode||(i.QrCode={}))})(nr||(nr={}));(i=>{(n=>{const r=class{constructor(u,l){this.modeBits=u,this.numBitsCharCount=l}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),n.Mode=r})(i.QrSegment||(i.QrSegment={}))})(nr||(nr={}));var yr=nr;var _1={L:yr.QrCode.Ecc.LOW,M:yr.QrCode.Ecc.MEDIUM,Q:yr.QrCode.Ecc.QUARTILE,H:yr.QrCode.Ecc.HIGH},pf=128,mf="L",gf="#FFFFFF",_f="#000000",xf=!1,vf=1,x1=4,v1=0,b1=.1;function bf(i,n=0){const r=[];return i.forEach(function(o,u){let l=null;o.forEach(function(p,x){if(!p&&l!==null){r.push(`M${l+n} ${u+n}h${x-l}v1H${l+n}z`),l=null;return}if(x===o.length-1){if(!p)return;l===null?r.push(`M${x+n},${u+n} h1v1H${x+n}z`):r.push(`M${l+n},${u+n} h${x+1-l}v1H${l+n}z`);return}p&&l===null&&(l=x)})}),r.join("")}function yf(i,n){return i.slice().map((r,o)=>o<n.y||o>=n.y+n.h?r:r.map((u,l)=>l<n.x||l>=n.x+n.w?u:!1))}function y1(i,n,r,o){if(o==null)return null;const u=i.length+r*2,l=Math.floor(n*b1),p=u/n,x=(o.width||l)*p,d=(o.height||l)*p,m=o.x==null?i.length/2-x/2:o.x*p,h=o.y==null?i.length/2-d/2:o.y*p,v=o.opacity==null?1:o.opacity;let b=null;if(o.excavate){let T=Math.floor(m),L=Math.floor(h),R=Math.ceil(x+m-T),D=Math.ceil(d+h-L);b={x:T,y:L,w:R,h:D}}const S=o.crossOrigin;return{x:m,y:h,h:d,w:x,excavation:b,opacity:v,crossOrigin:S}}function w1(i,n){return n!=null?Math.max(Math.floor(n),0):i?x1:v1}function wf({value:i,level:n,minVersion:r,includeMargin:o,marginSize:u,imageSettings:l,size:p,boostLevel:x}){let d=Oe.useMemo(()=>{const T=(Array.isArray(i)?i:[i]).reduce((L,R)=>(L.push(...yr.QrSegment.makeSegments(R)),L),[]);return yr.QrCode.encodeSegments(T,_1[n],r,void 0,void 0,x)},[i,n,r,x]);const{cells:m,margin:h,numCells:v,calculatedImageSettings:b}=Oe.useMemo(()=>{let S=d.getModules();const T=w1(o,u),L=S.length+T*2,R=y1(S,p,T,l);return{cells:S,margin:T,numCells:L,calculatedImageSettings:R}},[d,p,l,o,u]);return{qrcode:d,margin:h,cells:m,numCells:v,calculatedImageSettings:b}}var E1=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),S1=Oe.forwardRef(function(n,r){const o=n,{value:u,size:l=pf,level:p=mf,bgColor:x=gf,fgColor:d=_f,includeMargin:m=xf,minVersion:h=vf,boostLevel:v,marginSize:b,imageSettings:S}=o,L=ra(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:R}=L,D=ra(L,["style"]),G=S?.src,I=Oe.useRef(null),k=Oe.useRef(null),q=Oe.useCallback(H=>{I.current=H,typeof r=="function"?r(H):r&&(r.current=H)},[r]),[$,X]=Oe.useState(!1),{margin:Y,cells:F,numCells:P,calculatedImageSettings:A}=wf({value:u,level:p,minVersion:h,boostLevel:v,includeMargin:m,marginSize:b,imageSettings:S,size:l});Oe.useEffect(()=>{if(I.current!=null){const H=I.current,V=H.getContext("2d");if(!V)return;let K=F;const re=k.current,ie=A!=null&&re!==null&&re.complete&&re.naturalHeight!==0&&re.naturalWidth!==0;ie&&A.excavation!=null&&(K=yf(F,A.excavation));const ye=window.devicePixelRatio||1;H.height=H.width=l*ye;const we=l/P*ye;V.scale(we,we),V.fillStyle=x,V.fillRect(0,0,P,P),V.fillStyle=d,E1?V.fill(new Path2D(bf(K,Y))):F.forEach(function(se,Le){se.forEach(function(Me,ge){Me&&V.fillRect(ge+Y,Le+Y,1,1)})}),A&&(V.globalAlpha=A.opacity),ie&&V.drawImage(re,A.x+Y,A.y+Y,A.w,A.h)}}),Oe.useEffect(()=>{X(!1)},[G]);const de=na({height:l,width:l},R);let ae=null;return G!=null&&(ae=Oe.createElement("img",{src:G,key:G,style:{display:"none"},onLoad:()=>{X(!0)},ref:k,crossOrigin:A?.crossOrigin})),Oe.createElement(Oe.Fragment,null,Oe.createElement("canvas",na({style:de,height:l,width:l,ref:q,role:"img"},D)),ae)});S1.displayName="QRCodeCanvas";var Ef=Oe.forwardRef(function(n,r){const o=n,{value:u,size:l=pf,level:p=mf,bgColor:x=gf,fgColor:d=_f,includeMargin:m=xf,minVersion:h=vf,boostLevel:v,title:b,marginSize:S,imageSettings:T}=o,L=ra(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:R,cells:D,numCells:G,calculatedImageSettings:I}=wf({value:u,level:p,minVersion:h,boostLevel:v,includeMargin:m,marginSize:S,imageSettings:T,size:l});let k=D,q=null;T!=null&&I!=null&&(I.excavation!=null&&(k=yf(D,I.excavation)),q=Oe.createElement("image",{href:T.src,height:I.h,width:I.w,x:I.x+R,y:I.y+R,preserveAspectRatio:"none",opacity:I.opacity,crossOrigin:I.crossOrigin}));const $=bf(k,R);return Oe.createElement("svg",na({height:l,width:l,viewBox:`0 0 ${G} ${G}`,ref:r,role:"img"},L),!!b&&Oe.createElement("title",null,b),Oe.createElement("path",{fill:x,d:`M0,0 h${G}v${G}H0z`,shapeRendering:"crispEdges"}),Oe.createElement("path",{fill:d,d:$,shapeRendering:"crispEdges"}),q)});Ef.displayName="QRCodeSVG";var Vr={exports:{}};var C1=Vr.exports,cu;function N1(){return cu||(cu=1,(function(i,n){(function(){var r,o="4.17.21",u=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",x="Invalid `variable` option passed into `_.template`",d="__lodash_hash_undefined__",m=500,h="__lodash_placeholder__",v=1,b=2,S=4,T=1,L=2,R=1,D=2,G=4,I=8,k=16,q=32,$=64,X=128,Y=256,F=512,P=30,A="...",de=800,ae=16,H=1,V=2,K=3,re=1/0,ie=9007199254740991,ye=17976931348623157e292,we=NaN,se=4294967295,Le=se-1,Me=se>>>1,ge=[["ary",X],["bind",R],["bindKey",D],["curry",I],["curryRight",k],["flip",F],["partial",q],["partialRight",$],["rearg",Y]],Be="[object Arguments]",Ze="[object Array]",pt="[object AsyncFunction]",Ke="[object Boolean]",Pe="[object Date]",ot="[object DOMException]",ft="[object Error]",He="[object Function]",Gt="[object GeneratorFunction]",Xe="[object Map]",at="[object Number]",ee="[object Null]",Z="[object Object]",M="[object Promise]",Q="[object Proxy]",xe="[object RegExp]",oe="[object Set]",fe="[object String]",ve="[object Symbol]",mt="[object Undefined]",yt="[object WeakMap]",Nt="[object WeakSet]",lt="[object ArrayBuffer]",dt="[object DataView]",Rn="[object Float32Array]",kn="[object Float64Array]",sr="[object Int8Array]",An="[object Int16Array]",Nr="[object Int32Array]",tn="[object Uint8Array]",ir="[object Uint8ClampedArray]",nn="[object Uint16Array]",xn="[object Uint32Array]",xi=/\b__p \+= '';/g,vi=/\b(__p \+=) '' \+/g,bi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ns=/&(?:amp|lt|gt|quot|#39);/g,Tr=/[&<>"']/g,rs=RegExp(ns.source),ss=RegExp(Tr.source),yi=/<%-([\s\S]+?)%>/g,wi=/<%([\s\S]+?)%>/g,or=/<%=([\s\S]+?)%>/g,Ei=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/,Ci=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Rr=/[\\^$.*+?()[\]{}|]/g,Ni=RegExp(Rr.source),kr=/^\s+/,Ar=/\s/,W=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ne=/\{\n\/\* \[wrapped with (.+)\] \*/,pe=/,? & /,Ye=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,un=/[()=,{}\[\]\/\s]/,st=/\\(\\)?/g,ze=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,et=/\w*$/,Tt=/^[-+]0x[0-9a-f]+$/i,is=/^0b[01]+$/i,Ti=/^\[object .+?Constructor\]$/,qe=/^0o[0-7]+$/i,Rt=/^(?:0|[1-9]\d*)$/,Lt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,wt=/($^)/,qn=/['\n\r\u2028\u2029\\]/g,os="\\ud800-\\udfff",pd="\\u0300-\\u036f",md="\\ufe20-\\ufe2f",gd="\\u20d0-\\u20ff",Na=pd+md+gd,Ta="\\u2700-\\u27bf",Ra="a-z\\xdf-\\xf6\\xf8-\\xff",_d="\\xac\\xb1\\xd7\\xf7",xd="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",vd="\\u2000-\\u206f",bd=" \\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",ka="A-Z\\xc0-\\xd6\\xd8-\\xde",Aa="\\ufe0e\\ufe0f",Pa=_d+xd+vd+bd,Ri="['’]",yd="["+os+"]",ja="["+Pa+"]",as="["+Na+"]",Ia="\\d+",wd="["+Ta+"]",La="["+Ra+"]",Ma="[^"+os+Pa+Ia+Ta+Ra+ka+"]",ki="\\ud83c[\\udffb-\\udfff]",Ed="(?:"+as+"|"+ki+")",Da="[^"+os+"]",Ai="(?:\\ud83c[\\udde6-\\uddff]){2}",Pi="[\\ud800-\\udbff][\\udc00-\\udfff]",ar="["+ka+"]",Oa="\\u200d",Fa="(?:"+La+"|"+Ma+")",Sd="(?:"+ar+"|"+Ma+")",Ba="(?:"+Ri+"(?:d|ll|m|re|s|t|ve))?",Ua="(?:"+Ri+"(?:D|LL|M|RE|S|T|VE))?",Wa=Ed+"?",Ga="["+Aa+"]?",Cd="(?:"+Oa+"(?:"+[Da,Ai,Pi].join("|")+")"+Ga+Wa+")*",Nd="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Td="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ha=Ga+Wa+Cd,Rd="(?:"+[wd,Ai,Pi].join("|")+")"+Ha,kd="(?:"+[Da+as+"?",as,Ai,Pi,yd].join("|")+")",Ad=RegExp(Ri,"g"),Pd=RegExp(as,"g"),ji=RegExp(ki+"(?="+ki+")|"+kd+Ha,"g"),jd=RegExp([ar+"?"+La+"+"+Ba+"(?="+[ja,ar,"$"].join("|")+")",Sd+"+"+Ua+"(?="+[ja,ar+Fa,"$"].join("|")+")",ar+"?"+Fa+"+"+Ba,ar+"+"+Ua,Td,Nd,Ia,Rd].join("|"),"g"),Id=RegExp("["+Oa+os+Na+Aa+"]"),Ld=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Md=["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"],Dd=-1,Ge={};Ge[Rn]=Ge[kn]=Ge[sr]=Ge[An]=Ge[Nr]=Ge[tn]=Ge[ir]=Ge[nn]=Ge[xn]=!0,Ge[Be]=Ge[Ze]=Ge[lt]=Ge[Ke]=Ge[dt]=Ge[Pe]=Ge[ft]=Ge[He]=Ge[Xe]=Ge[at]=Ge[Z]=Ge[xe]=Ge[oe]=Ge[fe]=Ge[yt]=!1;var We={};We[Be]=We[Ze]=We[lt]=We[dt]=We[Ke]=We[Pe]=We[Rn]=We[kn]=We[sr]=We[An]=We[Nr]=We[Xe]=We[at]=We[Z]=We[xe]=We[oe]=We[fe]=We[ve]=We[tn]=We[ir]=We[nn]=We[xn]=!0,We[ft]=We[He]=We[yt]=!1;var Od={À:"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"},Fd={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Bd={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Ud={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Wd=parseFloat,Gd=parseInt,za=typeof Xs=="object"&&Xs&&Xs.Object===Object&&Xs,Hd=typeof self=="object"&&self&&self.Object===Object&&self,gt=za||Hd||Function("return this")(),Ii=n&&!n.nodeType&&n,$n=Ii&&!0&&i&&!i.nodeType&&i,qa=$n&&$n.exports===Ii,Li=qa&&za.process,Ht=(function(){try{var C=$n&&$n.require&&$n.require("util").types;return C||Li&&Li.binding&&Li.binding("util")}catch{}})(),$a=Ht&&Ht.isArrayBuffer,Xa=Ht&&Ht.isDate,Ya=Ht&&Ht.isMap,Va=Ht&&Ht.isRegExp,Ka=Ht&&Ht.isSet,Qa=Ht&&Ht.isTypedArray;function Mt(C,O,j){switch(j.length){case 0:return C.call(O);case 1:return C.call(O,j[0]);case 2:return C.call(O,j[0],j[1]);case 3:return C.call(O,j[0],j[1],j[2])}return C.apply(O,j)}function zd(C,O,j,te){for(var he=-1,je=C==null?0:C.length;++he<je;){var ct=C[he];O(te,ct,j(ct),C)}return te}function zt(C,O){for(var j=-1,te=C==null?0:C.length;++j<te&&O(C[j],j,C)!==!1;);return C}function qd(C,O){for(var j=C==null?0:C.length;j--&&O(C[j],j,C)!==!1;);return C}function Ja(C,O){for(var j=-1,te=C==null?0:C.length;++j<te;)if(!O(C[j],j,C))return!1;return!0}function Pn(C,O){for(var j=-1,te=C==null?0:C.length,he=0,je=[];++j<te;){var ct=C[j];O(ct,j,C)&&(je[he++]=ct)}return je}function ls(C,O){var j=C==null?0:C.length;return!!j&&lr(C,O,0)>-1}function Mi(C,O,j){for(var te=-1,he=C==null?0:C.length;++te<he;)if(j(O,C[te]))return!0;return!1}function $e(C,O){for(var j=-1,te=C==null?0:C.length,he=Array(te);++j<te;)he[j]=O(C[j],j,C);return he}function jn(C,O){for(var j=-1,te=O.length,he=C.length;++j<te;)C[he+j]=O[j];return C}function Di(C,O,j,te){var he=-1,je=C==null?0:C.length;for(te&&je&&(j=C[++he]);++he<je;)j=O(j,C[he],he,C);return j}function $d(C,O,j,te){var he=C==null?0:C.length;for(te&&he&&(j=C[--he]);he--;)j=O(j,C[he],he,C);return j}function Oi(C,O){for(var j=-1,te=C==null?0:C.length;++j<te;)if(O(C[j],j,C))return!0;return!1}var Xd=Fi("length");function Yd(C){return C.split("")}function Vd(C){return C.match(Ye)||[]}function Za(C,O,j){var te;return j(C,function(he,je,ct){if(O(he,je,ct))return te=je,!1}),te}function cs(C,O,j,te){for(var he=C.length,je=j+(te?1:-1);te?je--:++je<he;)if(O(C[je],je,C))return je;return-1}function lr(C,O,j){return O===O?ah(C,O,j):cs(C,el,j)}function Kd(C,O,j,te){for(var he=j-1,je=C.length;++he<je;)if(te(C[he],O))return he;return-1}function el(C){return C!==C}function tl(C,O){var j=C==null?0:C.length;return j?Ui(C,O)/j:we}function Fi(C){return function(O){return O==null?r:O[C]}}function Bi(C){return function(O){return C==null?r:C[O]}}function nl(C,O,j,te,he){return he(C,function(je,ct,Ue){j=te?(te=!1,je):O(j,je,ct,Ue)}),j}function Qd(C,O){var j=C.length;for(C.sort(O);j--;)C[j]=C[j].value;return C}function Ui(C,O){for(var j,te=-1,he=C.length;++te<he;){var je=O(C[te]);je!==r&&(j=j===r?je:j+je)}return j}function Wi(C,O){for(var j=-1,te=Array(C);++j<C;)te[j]=O(j);return te}function Jd(C,O){return $e(O,function(j){return[j,C[j]]})}function rl(C){return C&&C.slice(0,al(C)+1).replace(kr,"")}function Dt(C){return function(O){return C(O)}}function Gi(C,O){return $e(O,function(j){return C[j]})}function Pr(C,O){return C.has(O)}function sl(C,O){for(var j=-1,te=C.length;++j<te&&lr(O,C[j],0)>-1;);return j}function il(C,O){for(var j=C.length;j--&&lr(O,C[j],0)>-1;);return j}function Zd(C,O){for(var j=C.length,te=0;j--;)C[j]===O&&++te;return te}var eh=Bi(Od),th=Bi(Fd);function nh(C){return"\\"+Ud[C]}function rh(C,O){return C==null?r:C[O]}function cr(C){return Id.test(C)}function sh(C){return Ld.test(C)}function ih(C){for(var O,j=[];!(O=C.next()).done;)j.push(O.value);return j}function Hi(C){var O=-1,j=Array(C.size);return C.forEach(function(te,he){j[++O]=[he,te]}),j}function ol(C,O){return function(j){return C(O(j))}}function In(C,O){for(var j=-1,te=C.length,he=0,je=[];++j<te;){var ct=C[j];(ct===O||ct===h)&&(C[j]=h,je[he++]=j)}return je}function us(C){var O=-1,j=Array(C.size);return C.forEach(function(te){j[++O]=te}),j}function oh(C){var O=-1,j=Array(C.size);return C.forEach(function(te){j[++O]=[te,te]}),j}function ah(C,O,j){for(var te=j-1,he=C.length;++te<he;)if(C[te]===O)return te;return-1}function lh(C,O,j){for(var te=j+1;te--;)if(C[te]===O)return te;return te}function ur(C){return cr(C)?uh(C):Xd(C)}function rn(C){return cr(C)?fh(C):Yd(C)}function al(C){for(var O=C.length;O--&&Ar.test(C.charAt(O)););return O}var ch=Bi(Bd);function uh(C){for(var O=ji.lastIndex=0;ji.test(C);)++O;return O}function fh(C){return C.match(ji)||[]}function dh(C){return C.match(jd)||[]}var hh=(function C(O){O=O==null?gt:fr.defaults(gt.Object(),O,fr.pick(gt,Md));var j=O.Array,te=O.Date,he=O.Error,je=O.Function,ct=O.Math,Ue=O.Object,zi=O.RegExp,ph=O.String,qt=O.TypeError,fs=j.prototype,mh=je.prototype,dr=Ue.prototype,ds=O["__core-js_shared__"],hs=mh.toString,Fe=dr.hasOwnProperty,gh=0,ll=(function(){var e=/[^.]+$/.exec(ds&&ds.keys&&ds.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),ps=dr.toString,_h=hs.call(Ue),xh=gt._,vh=zi("^"+hs.call(Fe).replace(Rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ms=qa?O.Buffer:r,Ln=O.Symbol,gs=O.Uint8Array,cl=ms?ms.allocUnsafe:r,_s=ol(Ue.getPrototypeOf,Ue),ul=Ue.create,fl=dr.propertyIsEnumerable,xs=fs.splice,dl=Ln?Ln.isConcatSpreadable:r,jr=Ln?Ln.iterator:r,Xn=Ln?Ln.toStringTag:r,vs=(function(){try{var e=Jn(Ue,"defineProperty");return e({},"",{}),e}catch{}})(),bh=O.clearTimeout!==gt.clearTimeout&&O.clearTimeout,yh=te&&te.now!==gt.Date.now&&te.now,wh=O.setTimeout!==gt.setTimeout&&O.setTimeout,bs=ct.ceil,ys=ct.floor,qi=Ue.getOwnPropertySymbols,Eh=ms?ms.isBuffer:r,hl=O.isFinite,Sh=fs.join,Ch=ol(Ue.keys,Ue),ut=ct.max,xt=ct.min,Nh=te.now,Th=O.parseInt,pl=ct.random,Rh=fs.reverse,$i=Jn(O,"DataView"),Ir=Jn(O,"Map"),Xi=Jn(O,"Promise"),hr=Jn(O,"Set"),Lr=Jn(O,"WeakMap"),Mr=Jn(Ue,"create"),ws=Lr&&new Lr,pr={},kh=Zn($i),Ah=Zn(Ir),Ph=Zn(Xi),jh=Zn(hr),Ih=Zn(Lr),Es=Ln?Ln.prototype:r,Dr=Es?Es.valueOf:r,ml=Es?Es.toString:r;function g(e){if(Qe(e)&&!me(e)&&!(e instanceof Te)){if(e instanceof $t)return e;if(Fe.call(e,"__wrapped__"))return gc(e)}return new $t(e)}var mr=(function(){function e(){}return function(t){if(!Ve(t))return{};if(ul)return ul(t);e.prototype=t;var s=new e;return e.prototype=r,s}})();function Ss(){}function $t(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}g.templateSettings={escape:yi,evaluate:wi,interpolate:or,variable:"",imports:{_:g}},g.prototype=Ss.prototype,g.prototype.constructor=g,$t.prototype=mr(Ss.prototype),$t.prototype.constructor=$t;function Te(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=se,this.__views__=[]}function Lh(){var e=new Te(this.__wrapped__);return e.__actions__=kt(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=kt(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=kt(this.__views__),e}function Mh(){if(this.__filtered__){var e=new Te(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Dh(){var e=this.__wrapped__.value(),t=this.__dir__,s=me(e),c=t<0,f=s?e.length:0,_=Yp(0,f,this.__views__),y=_.start,E=_.end,N=E-y,B=c?E:y-1,U=this.__iteratees__,z=U.length,J=0,ne=xt(N,this.__takeCount__);if(!s||!c&&f==N&&ne==N)return Bl(e,this.__actions__);var ce=[];e:for(;N--&&J<ne;){B+=t;for(var be=-1,ue=e[B];++be<z;){var Se=U[be],Re=Se.iteratee,Bt=Se.type,Ct=Re(ue);if(Bt==V)ue=Ct;else if(!Ct){if(Bt==H)continue e;break e}}ce[J++]=ue}return ce}Te.prototype=mr(Ss.prototype),Te.prototype.constructor=Te;function Yn(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 Oh(){this.__data__=Mr?Mr(null):{},this.size=0}function Fh(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Bh(e){var t=this.__data__;if(Mr){var s=t[e];return s===d?r:s}return Fe.call(t,e)?t[e]:r}function Uh(e){var t=this.__data__;return Mr?t[e]!==r:Fe.call(t,e)}function Wh(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=Mr&&t===r?d:t,this}Yn.prototype.clear=Oh,Yn.prototype.delete=Fh,Yn.prototype.get=Bh,Yn.prototype.has=Uh,Yn.prototype.set=Wh;function vn(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.__data__=[],this.size=0}function Hh(e){var t=this.__data__,s=Cs(t,e);if(s<0)return!1;var c=t.length-1;return s==c?t.pop():xs.call(t,s,1),--this.size,!0}function zh(e){var t=this.__data__,s=Cs(t,e);return s<0?r:t[s][1]}function qh(e){return Cs(this.__data__,e)>-1}function $h(e,t){var s=this.__data__,c=Cs(s,e);return c<0?(++this.size,s.push([e,t])):s[c][1]=t,this}vn.prototype.clear=Gh,vn.prototype.delete=Hh,vn.prototype.get=zh,vn.prototype.has=qh,vn.prototype.set=$h;function bn(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 Xh(){this.size=0,this.__data__={hash:new Yn,map:new(Ir||vn),string:new Yn}}function Yh(e){var t=Os(this,e).delete(e);return this.size-=t?1:0,t}function Vh(e){return Os(this,e).get(e)}function Kh(e){return Os(this,e).has(e)}function Qh(e,t){var s=Os(this,e),c=s.size;return s.set(e,t),this.size+=s.size==c?0:1,this}bn.prototype.clear=Xh,bn.prototype.delete=Yh,bn.prototype.get=Vh,bn.prototype.has=Kh,bn.prototype.set=Qh;function Vn(e){var t=-1,s=e==null?0:e.length;for(this.__data__=new bn;++t<s;)this.add(e[t])}function Jh(e){return this.__data__.set(e,d),this}function Zh(e){return this.__data__.has(e)}Vn.prototype.add=Vn.prototype.push=Jh,Vn.prototype.has=Zh;function sn(e){var t=this.__data__=new vn(e);this.size=t.size}function ep(){this.__data__=new vn,this.size=0}function tp(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s}function np(e){return this.__data__.get(e)}function rp(e){return this.__data__.has(e)}function sp(e,t){var s=this.__data__;if(s instanceof vn){var c=s.__data__;if(!Ir||c.length<u-1)return c.push([e,t]),this.size=++s.size,this;s=this.__data__=new bn(c)}return s.set(e,t),this.size=s.size,this}sn.prototype.clear=ep,sn.prototype.delete=tp,sn.prototype.get=np,sn.prototype.has=rp,sn.prototype.set=sp;function gl(e,t){var s=me(e),c=!s&&er(e),f=!s&&!c&&Bn(e),_=!s&&!c&&!f&&vr(e),y=s||c||f||_,E=y?Wi(e.length,ph):[],N=E.length;for(var B in e)(t||Fe.call(e,B))&&!(y&&(B=="length"||f&&(B=="offset"||B=="parent")||_&&(B=="buffer"||B=="byteLength"||B=="byteOffset")||Sn(B,N)))&&E.push(B);return E}function _l(e){var t=e.length;return t?e[so(0,t-1)]:r}function ip(e,t){return Fs(kt(e),Kn(t,0,e.length))}function op(e){return Fs(kt(e))}function Yi(e,t,s){(s!==r&&!on(e[t],s)||s===r&&!(t in e))&&yn(e,t,s)}function Or(e,t,s){var c=e[t];(!(Fe.call(e,t)&&on(c,s))||s===r&&!(t in e))&&yn(e,t,s)}function Cs(e,t){for(var s=e.length;s--;)if(on(e[s][0],t))return s;return-1}function ap(e,t,s,c){return Mn(e,function(f,_,y){t(c,f,s(f),y)}),c}function xl(e,t){return e&&dn(t,ht(t),e)}function lp(e,t){return e&&dn(t,Pt(t),e)}function yn(e,t,s){t=="__proto__"&&vs?vs(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function Vi(e,t){for(var s=-1,c=t.length,f=j(c),_=e==null;++s<c;)f[s]=_?r:Ao(e,t[s]);return f}function Kn(e,t,s){return e===e&&(s!==r&&(e=e<=s?e:s),t!==r&&(e=e>=t?e:t)),e}function Xt(e,t,s,c,f,_){var y,E=t&v,N=t&b,B=t&S;if(s&&(y=f?s(e,c,f,_):s(e)),y!==r)return y;if(!Ve(e))return e;var U=me(e);if(U){if(y=Kp(e),!E)return kt(e,y)}else{var z=vt(e),J=z==He||z==Gt;if(Bn(e))return Gl(e,E);if(z==Z||z==Be||J&&!f){if(y=N||J?{}:ac(e),!E)return N?Bp(e,lp(y,e)):Fp(e,xl(y,e))}else{if(!We[z])return f?e:{};y=Qp(e,z,E)}}_||(_=new sn);var ne=_.get(e);if(ne)return ne;_.set(e,y),Dc(e)?e.forEach(function(ue){y.add(Xt(ue,t,s,ue,e,_))}):Lc(e)&&e.forEach(function(ue,Se){y.set(Se,Xt(ue,t,s,Se,e,_))});var ce=B?N?go:mo:N?Pt:ht,be=U?r:ce(e);return zt(be||e,function(ue,Se){be&&(Se=ue,ue=e[Se]),Or(y,Se,Xt(ue,t,s,Se,e,_))}),y}function cp(e){var t=ht(e);return function(s){return vl(s,e,t)}}function vl(e,t,s){var c=s.length;if(e==null)return!c;for(e=Ue(e);c--;){var f=s[c],_=t[f],y=e[f];if(y===r&&!(f in e)||!_(y))return!1}return!0}function bl(e,t,s){if(typeof e!="function")throw new qt(p);return zr(function(){e.apply(r,s)},t)}function Fr(e,t,s,c){var f=-1,_=ls,y=!0,E=e.length,N=[],B=t.length;if(!E)return N;s&&(t=$e(t,Dt(s))),c?(_=Mi,y=!1):t.length>=u&&(_=Pr,y=!1,t=new Vn(t));e:for(;++f<E;){var U=e[f],z=s==null?U:s(U);if(U=c||U!==0?U:0,y&&z===z){for(var J=B;J--;)if(t[J]===z)continue e;N.push(U)}else _(t,z,c)||N.push(U)}return N}var Mn=Xl(fn),yl=Xl(Qi,!0);function up(e,t){var s=!0;return Mn(e,function(c,f,_){return s=!!t(c,f,_),s}),s}function Ns(e,t,s){for(var c=-1,f=e.length;++c<f;){var _=e[c],y=t(_);if(y!=null&&(E===r?y===y&&!Ft(y):s(y,E)))var E=y,N=_}return N}function fp(e,t,s,c){var f=e.length;for(s=_e(s),s<0&&(s=-s>f?0:f+s),c=c===r||c>f?f:_e(c),c<0&&(c+=f),c=s>c?0:Fc(c);s<c;)e[s++]=t;return e}function wl(e,t){var s=[];return Mn(e,function(c,f,_){t(c,f,_)&&s.push(c)}),s}function _t(e,t,s,c,f){var _=-1,y=e.length;for(s||(s=Zp),f||(f=[]);++_<y;){var E=e[_];t>0&&s(E)?t>1?_t(E,t-1,s,c,f):jn(f,E):c||(f[f.length]=E)}return f}var Ki=Yl(),El=Yl(!0);function fn(e,t){return e&&Ki(e,t,ht)}function Qi(e,t){return e&&El(e,t,ht)}function Ts(e,t){return Pn(t,function(s){return Cn(e[s])})}function Qn(e,t){t=On(t,e);for(var s=0,c=t.length;e!=null&&s<c;)e=e[hn(t[s++])];return s&&s==c?e:r}function Sl(e,t,s){var c=t(e);return me(e)?c:jn(c,s(e))}function Et(e){return e==null?e===r?mt:ee:Xn&&Xn in Ue(e)?Xp(e):om(e)}function Ji(e,t){return e>t}function dp(e,t){return e!=null&&Fe.call(e,t)}function hp(e,t){return e!=null&&t in Ue(e)}function pp(e,t,s){return e>=xt(t,s)&&e<ut(t,s)}function Zi(e,t,s){for(var c=s?Mi:ls,f=e[0].length,_=e.length,y=_,E=j(_),N=1/0,B=[];y--;){var U=e[y];y&&t&&(U=$e(U,Dt(t))),N=xt(U.length,N),E[y]=!s&&(t||f>=120&&U.length>=120)?new Vn(y&&U):r}U=e[0];var z=-1,J=E[0];e:for(;++z<f&&B.length<N;){var ne=U[z],ce=t?t(ne):ne;if(ne=s||ne!==0?ne:0,!(J?Pr(J,ce):c(B,ce,s))){for(y=_;--y;){var be=E[y];if(!(be?Pr(be,ce):c(e[y],ce,s)))continue e}J&&J.push(ce),B.push(ne)}}return B}function mp(e,t,s,c){return fn(e,function(f,_,y){t(c,s(f),_,y)}),c}function Br(e,t,s){t=On(t,e),e=fc(e,t);var c=e==null?e:e[hn(Vt(t))];return c==null?r:Mt(c,e,s)}function Cl(e){return Qe(e)&&Et(e)==Be}function gp(e){return Qe(e)&&Et(e)==lt}function _p(e){return Qe(e)&&Et(e)==Pe}function Ur(e,t,s,c,f){return e===t?!0:e==null||t==null||!Qe(e)&&!Qe(t)?e!==e&&t!==t:xp(e,t,s,c,Ur,f)}function xp(e,t,s,c,f,_){var y=me(e),E=me(t),N=y?Ze:vt(e),B=E?Ze:vt(t);N=N==Be?Z:N,B=B==Be?Z:B;var U=N==Z,z=B==Z,J=N==B;if(J&&Bn(e)){if(!Bn(t))return!1;y=!0,U=!1}if(J&&!U)return _||(_=new sn),y||vr(e)?sc(e,t,s,c,f,_):qp(e,t,N,s,c,f,_);if(!(s&T)){var ne=U&&Fe.call(e,"__wrapped__"),ce=z&&Fe.call(t,"__wrapped__");if(ne||ce){var be=ne?e.value():e,ue=ce?t.value():t;return _||(_=new sn),f(be,ue,s,c,_)}}return J?(_||(_=new sn),$p(e,t,s,c,f,_)):!1}function vp(e){return Qe(e)&&vt(e)==Xe}function eo(e,t,s,c){var f=s.length,_=f,y=!c;if(e==null)return!_;for(e=Ue(e);f--;){var E=s[f];if(y&&E[2]?E[1]!==e[E[0]]:!(E[0]in e))return!1}for(;++f<_;){E=s[f];var N=E[0],B=e[N],U=E[1];if(y&&E[2]){if(B===r&&!(N in e))return!1}else{var z=new sn;if(c)var J=c(B,U,N,e,t,z);if(!(J===r?Ur(U,B,T|L,c,z):J))return!1}}return!0}function Nl(e){if(!Ve(e)||tm(e))return!1;var t=Cn(e)?vh:Ti;return t.test(Zn(e))}function bp(e){return Qe(e)&&Et(e)==xe}function yp(e){return Qe(e)&&vt(e)==oe}function wp(e){return Qe(e)&&zs(e.length)&&!!Ge[Et(e)]}function Tl(e){return typeof e=="function"?e:e==null?jt:typeof e=="object"?me(e)?Al(e[0],e[1]):kl(e):Vc(e)}function to(e){if(!Hr(e))return Ch(e);var t=[];for(var s in Ue(e))Fe.call(e,s)&&s!="constructor"&&t.push(s);return t}function Ep(e){if(!Ve(e))return im(e);var t=Hr(e),s=[];for(var c in e)c=="constructor"&&(t||!Fe.call(e,c))||s.push(c);return s}function no(e,t){return e<t}function Rl(e,t){var s=-1,c=At(e)?j(e.length):[];return Mn(e,function(f,_,y){c[++s]=t(f,_,y)}),c}function kl(e){var t=xo(e);return t.length==1&&t[0][2]?cc(t[0][0],t[0][1]):function(s){return s===e||eo(s,e,t)}}function Al(e,t){return bo(e)&&lc(t)?cc(hn(e),t):function(s){var c=Ao(s,e);return c===r&&c===t?Po(s,e):Ur(t,c,T|L)}}function Rs(e,t,s,c,f){e!==t&&Ki(t,function(_,y){if(f||(f=new sn),Ve(_))Sp(e,t,y,s,Rs,c,f);else{var E=c?c(wo(e,y),_,y+"",e,t,f):r;E===r&&(E=_),Yi(e,y,E)}},Pt)}function Sp(e,t,s,c,f,_,y){var E=wo(e,s),N=wo(t,s),B=y.get(N);if(B){Yi(e,s,B);return}var U=_?_(E,N,s+"",e,t,y):r,z=U===r;if(z){var J=me(N),ne=!J&&Bn(N),ce=!J&&!ne&&vr(N);U=N,J||ne||ce?me(E)?U=E:tt(E)?U=kt(E):ne?(z=!1,U=Gl(N,!0)):ce?(z=!1,U=Hl(N,!0)):U=[]:qr(N)||er(N)?(U=E,er(E)?U=Bc(E):(!Ve(E)||Cn(E))&&(U=ac(N))):z=!1}z&&(y.set(N,U),f(U,N,c,_,y),y.delete(N)),Yi(e,s,U)}function Pl(e,t){var s=e.length;if(s)return t+=t<0?s:0,Sn(t,s)?e[t]:r}function jl(e,t,s){t.length?t=$e(t,function(_){return me(_)?function(y){return Qn(y,_.length===1?_[0]:_)}:_}):t=[jt];var c=-1;t=$e(t,Dt(le()));var f=Rl(e,function(_,y,E){var N=$e(t,function(B){return B(_)});return{criteria:N,index:++c,value:_}});return Qd(f,function(_,y){return Op(_,y,s)})}function Cp(e,t){return Il(e,t,function(s,c){return Po(e,c)})}function Il(e,t,s){for(var c=-1,f=t.length,_={};++c<f;){var y=t[c],E=Qn(e,y);s(E,y)&&Wr(_,On(y,e),E)}return _}function Np(e){return function(t){return Qn(t,e)}}function ro(e,t,s,c){var f=c?Kd:lr,_=-1,y=t.length,E=e;for(e===t&&(t=kt(t)),s&&(E=$e(e,Dt(s)));++_<y;)for(var N=0,B=t[_],U=s?s(B):B;(N=f(E,U,N,c))>-1;)E!==e&&xs.call(E,N,1),xs.call(e,N,1);return e}function Ll(e,t){for(var s=e?t.length:0,c=s-1;s--;){var f=t[s];if(s==c||f!==_){var _=f;Sn(f)?xs.call(e,f,1):ao(e,f)}}return e}function so(e,t){return e+ys(pl()*(t-e+1))}function Tp(e,t,s,c){for(var f=-1,_=ut(bs((t-e)/(s||1)),0),y=j(_);_--;)y[c?_:++f]=e,e+=s;return y}function io(e,t){var s="";if(!e||t<1||t>ie)return s;do t%2&&(s+=e),t=ys(t/2),t&&(e+=e);while(t);return s}function Ee(e,t){return Eo(uc(e,t,jt),e+"")}function Rp(e){return _l(br(e))}function kp(e,t){var s=br(e);return Fs(s,Kn(t,0,s.length))}function Wr(e,t,s,c){if(!Ve(e))return e;t=On(t,e);for(var f=-1,_=t.length,y=_-1,E=e;E!=null&&++f<_;){var N=hn(t[f]),B=s;if(N==="__proto__"||N==="constructor"||N==="prototype")return e;if(f!=y){var U=E[N];B=c?c(U,N,E):r,B===r&&(B=Ve(U)?U:Sn(t[f+1])?[]:{})}Or(E,N,B),E=E[N]}return e}var Ml=ws?function(e,t){return ws.set(e,t),e}:jt,Ap=vs?function(e,t){return vs(e,"toString",{configurable:!0,enumerable:!1,value:Io(t),writable:!0})}:jt;function Pp(e){return Fs(br(e))}function Yt(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 _=j(f);++c<f;)_[c]=e[c+t];return _}function jp(e,t){var s;return Mn(e,function(c,f,_){return s=t(c,f,_),!s}),!!s}function ks(e,t,s){var c=0,f=e==null?c:e.length;if(typeof t=="number"&&t===t&&f<=Me){for(;c<f;){var _=c+f>>>1,y=e[_];y!==null&&!Ft(y)&&(s?y<=t:y<t)?c=_+1:f=_}return f}return oo(e,t,jt,s)}function oo(e,t,s,c){var f=0,_=e==null?0:e.length;if(_===0)return 0;t=s(t);for(var y=t!==t,E=t===null,N=Ft(t),B=t===r;f<_;){var U=ys((f+_)/2),z=s(e[U]),J=z!==r,ne=z===null,ce=z===z,be=Ft(z);if(y)var ue=c||ce;else B?ue=ce&&(c||J):E?ue=ce&&J&&(c||!ne):N?ue=ce&&J&&!ne&&(c||!be):ne||be?ue=!1:ue=c?z<=t:z<t;ue?f=U+1:_=U}return xt(_,Le)}function Dl(e,t){for(var s=-1,c=e.length,f=0,_=[];++s<c;){var y=e[s],E=t?t(y):y;if(!s||!on(E,N)){var N=E;_[f++]=y===0?0:y}}return _}function Ol(e){return typeof e=="number"?e:Ft(e)?we:+e}function Ot(e){if(typeof e=="string")return e;if(me(e))return $e(e,Ot)+"";if(Ft(e))return ml?ml.call(e):"";var t=e+"";return t=="0"&&1/e==-re?"-0":t}function Dn(e,t,s){var c=-1,f=ls,_=e.length,y=!0,E=[],N=E;if(s)y=!1,f=Mi;else if(_>=u){var B=t?null:Hp(e);if(B)return us(B);y=!1,f=Pr,N=new Vn}else N=t?[]:E;e:for(;++c<_;){var U=e[c],z=t?t(U):U;if(U=s||U!==0?U:0,y&&z===z){for(var J=N.length;J--;)if(N[J]===z)continue e;t&&N.push(z),E.push(U)}else f(N,z,s)||(N!==E&&N.push(z),E.push(U))}return E}function ao(e,t){return t=On(t,e),e=fc(e,t),e==null||delete e[hn(Vt(t))]}function Fl(e,t,s,c){return Wr(e,t,s(Qn(e,t)),c)}function As(e,t,s,c){for(var f=e.length,_=c?f:-1;(c?_--:++_<f)&&t(e[_],_,e););return s?Yt(e,c?0:_,c?_+1:f):Yt(e,c?_+1:0,c?f:_)}function Bl(e,t){var s=e;return s instanceof Te&&(s=s.value()),Di(t,function(c,f){return f.func.apply(f.thisArg,jn([c],f.args))},s)}function lo(e,t,s){var c=e.length;if(c<2)return c?Dn(e[0]):[];for(var f=-1,_=j(c);++f<c;)for(var y=e[f],E=-1;++E<c;)E!=f&&(_[f]=Fr(_[f]||y,e[E],t,s));return Dn(_t(_,1),t,s)}function Ul(e,t,s){for(var c=-1,f=e.length,_=t.length,y={};++c<f;){var E=c<_?t[c]:r;s(y,e[c],E)}return y}function co(e){return tt(e)?e:[]}function uo(e){return typeof e=="function"?e:jt}function On(e,t){return me(e)?e:bo(e,t)?[e]:mc(De(e))}var Ip=Ee;function Fn(e,t,s){var c=e.length;return s=s===r?c:s,!t&&s>=c?e:Yt(e,t,s)}var Wl=bh||function(e){return gt.clearTimeout(e)};function Gl(e,t){if(t)return e.slice();var s=e.length,c=cl?cl(s):new e.constructor(s);return e.copy(c),c}function fo(e){var t=new e.constructor(e.byteLength);return new gs(t).set(new gs(e)),t}function Lp(e,t){var s=t?fo(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Mp(e){var t=new e.constructor(e.source,et.exec(e));return t.lastIndex=e.lastIndex,t}function Dp(e){return Dr?Ue(Dr.call(e)):{}}function Hl(e,t){var s=t?fo(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function zl(e,t){if(e!==t){var s=e!==r,c=e===null,f=e===e,_=Ft(e),y=t!==r,E=t===null,N=t===t,B=Ft(t);if(!E&&!B&&!_&&e>t||_&&y&&N&&!E&&!B||c&&y&&N||!s&&N||!f)return 1;if(!c&&!_&&!B&&e<t||B&&s&&f&&!c&&!_||E&&s&&f||!y&&f||!N)return-1}return 0}function Op(e,t,s){for(var c=-1,f=e.criteria,_=t.criteria,y=f.length,E=s.length;++c<y;){var N=zl(f[c],_[c]);if(N){if(c>=E)return N;var B=s[c];return N*(B=="desc"?-1:1)}}return e.index-t.index}function ql(e,t,s,c){for(var f=-1,_=e.length,y=s.length,E=-1,N=t.length,B=ut(_-y,0),U=j(N+B),z=!c;++E<N;)U[E]=t[E];for(;++f<y;)(z||f<_)&&(U[s[f]]=e[f]);for(;B--;)U[E++]=e[f++];return U}function $l(e,t,s,c){for(var f=-1,_=e.length,y=-1,E=s.length,N=-1,B=t.length,U=ut(_-E,0),z=j(U+B),J=!c;++f<U;)z[f]=e[f];for(var ne=f;++N<B;)z[ne+N]=t[N];for(;++y<E;)(J||f<_)&&(z[ne+s[y]]=e[f++]);return z}function kt(e,t){var s=-1,c=e.length;for(t||(t=j(c));++s<c;)t[s]=e[s];return t}function dn(e,t,s,c){var f=!s;s||(s={});for(var _=-1,y=t.length;++_<y;){var E=t[_],N=c?c(s[E],e[E],E,s,e):r;N===r&&(N=e[E]),f?yn(s,E,N):Or(s,E,N)}return s}function Fp(e,t){return dn(e,vo(e),t)}function Bp(e,t){return dn(e,ic(e),t)}function Ps(e,t){return function(s,c){var f=me(s)?zd:ap,_=t?t():{};return f(s,e,le(c,2),_)}}function gr(e){return Ee(function(t,s){var c=-1,f=s.length,_=f>1?s[f-1]:r,y=f>2?s[2]:r;for(_=e.length>3&&typeof _=="function"?(f--,_):r,y&&St(s[0],s[1],y)&&(_=f<3?r:_,f=1),t=Ue(t);++c<f;){var E=s[c];E&&e(t,E,c,_)}return t})}function Xl(e,t){return function(s,c){if(s==null)return s;if(!At(s))return e(s,c);for(var f=s.length,_=t?f:-1,y=Ue(s);(t?_--:++_<f)&&c(y[_],_,y)!==!1;);return s}}function Yl(e){return function(t,s,c){for(var f=-1,_=Ue(t),y=c(t),E=y.length;E--;){var N=y[e?E:++f];if(s(_[N],N,_)===!1)break}return t}}function Up(e,t,s){var c=t&R,f=Gr(e);function _(){var y=this&&this!==gt&&this instanceof _?f:e;return y.apply(c?s:this,arguments)}return _}function Vl(e){return function(t){t=De(t);var s=cr(t)?rn(t):r,c=s?s[0]:t.charAt(0),f=s?Fn(s,1).join(""):t.slice(1);return c[e]()+f}}function _r(e){return function(t){return Di(Xc($c(t).replace(Ad,"")),e,"")}}function Gr(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=mr(e.prototype),c=e.apply(s,t);return Ve(c)?c:s}}function Wp(e,t,s){var c=Gr(e);function f(){for(var _=arguments.length,y=j(_),E=_,N=xr(f);E--;)y[E]=arguments[E];var B=_<3&&y[0]!==N&&y[_-1]!==N?[]:In(y,N);if(_-=B.length,_<s)return ec(e,t,js,f.placeholder,r,y,B,r,r,s-_);var U=this&&this!==gt&&this instanceof f?c:e;return Mt(U,this,y)}return f}function Kl(e){return function(t,s,c){var f=Ue(t);if(!At(t)){var _=le(s,3);t=ht(t),s=function(E){return _(f[E],E,f)}}var y=e(t,s,c);return y>-1?f[_?t[y]:y]:r}}function Ql(e){return En(function(t){var s=t.length,c=s,f=$t.prototype.thru;for(e&&t.reverse();c--;){var _=t[c];if(typeof _!="function")throw new qt(p);if(f&&!y&&Ds(_)=="wrapper")var y=new $t([],!0)}for(c=y?c:s;++c<s;){_=t[c];var E=Ds(_),N=E=="wrapper"?_o(_):r;N&&yo(N[0])&&N[1]==(X|I|q|Y)&&!N[4].length&&N[9]==1?y=y[Ds(N[0])].apply(y,N[3]):y=_.length==1&&yo(_)?y[E]():y.thru(_)}return function(){var B=arguments,U=B[0];if(y&&B.length==1&&me(U))return y.plant(U).value();for(var z=0,J=s?t[z].apply(this,B):U;++z<s;)J=t[z].call(this,J);return J}})}function js(e,t,s,c,f,_,y,E,N,B){var U=t&X,z=t&R,J=t&D,ne=t&(I|k),ce=t&F,be=J?r:Gr(e);function ue(){for(var Se=arguments.length,Re=j(Se),Bt=Se;Bt--;)Re[Bt]=arguments[Bt];if(ne)var Ct=xr(ue),Ut=Zd(Re,Ct);if(c&&(Re=ql(Re,c,f,ne)),_&&(Re=$l(Re,_,y,ne)),Se-=Ut,ne&&Se<B){var nt=In(Re,Ct);return ec(e,t,js,ue.placeholder,s,Re,nt,E,N,B-Se)}var an=z?s:this,Tn=J?an[e]:e;return Se=Re.length,E?Re=am(Re,E):ce&&Se>1&&Re.reverse(),U&&N<Se&&(Re.length=N),this&&this!==gt&&this instanceof ue&&(Tn=be||Gr(Tn)),Tn.apply(an,Re)}return ue}function Jl(e,t){return function(s,c){return mp(s,e,t(c),{})}}function Is(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=Ot(s),c=Ot(c)):(s=Ol(s),c=Ol(c)),f=e(s,c)}return f}}function ho(e){return En(function(t){return t=$e(t,Dt(le())),Ee(function(s){var c=this;return e(t,function(f){return Mt(f,c,s)})})})}function Ls(e,t){t=t===r?" ":Ot(t);var s=t.length;if(s<2)return s?io(t,e):t;var c=io(t,bs(e/ur(t)));return cr(t)?Fn(rn(c),0,e).join(""):c.slice(0,e)}function Gp(e,t,s,c){var f=t&R,_=Gr(e);function y(){for(var E=-1,N=arguments.length,B=-1,U=c.length,z=j(U+N),J=this&&this!==gt&&this instanceof y?_:e;++B<U;)z[B]=c[B];for(;N--;)z[B++]=arguments[++E];return Mt(J,f?s:this,z)}return y}function Zl(e){return function(t,s,c){return c&&typeof c!="number"&&St(t,s,c)&&(s=c=r),t=Nn(t),s===r?(s=t,t=0):s=Nn(s),c=c===r?t<s?1:-1:Nn(c),Tp(t,s,c,e)}}function Ms(e){return function(t,s){return typeof t=="string"&&typeof s=="string"||(t=Kt(t),s=Kt(s)),e(t,s)}}function ec(e,t,s,c,f,_,y,E,N,B){var U=t&I,z=U?y:r,J=U?r:y,ne=U?_:r,ce=U?r:_;t|=U?q:$,t&=~(U?$:q),t&G||(t&=-4);var be=[e,t,f,ne,z,ce,J,E,N,B],ue=s.apply(r,be);return yo(e)&&dc(ue,be),ue.placeholder=c,hc(ue,e,t)}function po(e){var t=ct[e];return function(s,c){if(s=Kt(s),c=c==null?0:xt(_e(c),292),c&&hl(s)){var f=(De(s)+"e").split("e"),_=t(f[0]+"e"+(+f[1]+c));return f=(De(_)+"e").split("e"),+(f[0]+"e"+(+f[1]-c))}return t(s)}}var Hp=hr&&1/us(new hr([,-0]))[1]==re?function(e){return new hr(e)}:Do;function tc(e){return function(t){var s=vt(t);return s==Xe?Hi(t):s==oe?oh(t):Jd(t,e(t))}}function wn(e,t,s,c,f,_,y,E){var N=t&D;if(!N&&typeof e!="function")throw new qt(p);var B=c?c.length:0;if(B||(t&=-97,c=f=r),y=y===r?y:ut(_e(y),0),E=E===r?E:_e(E),B-=f?f.length:0,t&$){var U=c,z=f;c=f=r}var J=N?r:_o(e),ne=[e,t,s,c,f,U,z,_,y,E];if(J&&sm(ne,J),e=ne[0],t=ne[1],s=ne[2],c=ne[3],f=ne[4],E=ne[9]=ne[9]===r?N?0:e.length:ut(ne[9]-B,0),!E&&t&(I|k)&&(t&=-25),!t||t==R)var ce=Up(e,t,s);else t==I||t==k?ce=Wp(e,t,E):(t==q||t==(R|q))&&!f.length?ce=Gp(e,t,s,c):ce=js.apply(r,ne);var be=J?Ml:dc;return hc(be(ce,ne),e,t)}function nc(e,t,s,c){return e===r||on(e,dr[s])&&!Fe.call(c,s)?t:e}function rc(e,t,s,c,f,_){return Ve(e)&&Ve(t)&&(_.set(t,e),Rs(e,t,r,rc,_),_.delete(t)),e}function zp(e){return qr(e)?r:e}function sc(e,t,s,c,f,_){var y=s&T,E=e.length,N=t.length;if(E!=N&&!(y&&N>E))return!1;var B=_.get(e),U=_.get(t);if(B&&U)return B==t&&U==e;var z=-1,J=!0,ne=s&L?new Vn:r;for(_.set(e,t),_.set(t,e);++z<E;){var ce=e[z],be=t[z];if(c)var ue=y?c(be,ce,z,t,e,_):c(ce,be,z,e,t,_);if(ue!==r){if(ue)continue;J=!1;break}if(ne){if(!Oi(t,function(Se,Re){if(!Pr(ne,Re)&&(ce===Se||f(ce,Se,s,c,_)))return ne.push(Re)})){J=!1;break}}else if(!(ce===be||f(ce,be,s,c,_))){J=!1;break}}return _.delete(e),_.delete(t),J}function qp(e,t,s,c,f,_,y){switch(s){case dt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case lt:return!(e.byteLength!=t.byteLength||!_(new gs(e),new gs(t)));case Ke:case Pe:case at:return on(+e,+t);case ft:return e.name==t.name&&e.message==t.message;case xe:case fe:return e==t+"";case Xe:var E=Hi;case oe:var N=c&T;if(E||(E=us),e.size!=t.size&&!N)return!1;var B=y.get(e);if(B)return B==t;c|=L,y.set(e,t);var U=sc(E(e),E(t),c,f,_,y);return y.delete(e),U;case ve:if(Dr)return Dr.call(e)==Dr.call(t)}return!1}function $p(e,t,s,c,f,_){var y=s&T,E=mo(e),N=E.length,B=mo(t),U=B.length;if(N!=U&&!y)return!1;for(var z=N;z--;){var J=E[z];if(!(y?J in t:Fe.call(t,J)))return!1}var ne=_.get(e),ce=_.get(t);if(ne&&ce)return ne==t&&ce==e;var be=!0;_.set(e,t),_.set(t,e);for(var ue=y;++z<N;){J=E[z];var Se=e[J],Re=t[J];if(c)var Bt=y?c(Re,Se,J,t,e,_):c(Se,Re,J,e,t,_);if(!(Bt===r?Se===Re||f(Se,Re,s,c,_):Bt)){be=!1;break}ue||(ue=J=="constructor")}if(be&&!ue){var Ct=e.constructor,Ut=t.constructor;Ct!=Ut&&"constructor"in e&&"constructor"in t&&!(typeof Ct=="function"&&Ct instanceof Ct&&typeof Ut=="function"&&Ut instanceof Ut)&&(be=!1)}return _.delete(e),_.delete(t),be}function En(e){return Eo(uc(e,r,vc),e+"")}function mo(e){return Sl(e,ht,vo)}function go(e){return Sl(e,Pt,ic)}var _o=ws?function(e){return ws.get(e)}:Do;function Ds(e){for(var t=e.name+"",s=pr[t],c=Fe.call(pr,t)?s.length:0;c--;){var f=s[c],_=f.func;if(_==null||_==e)return f.name}return t}function xr(e){var t=Fe.call(g,"placeholder")?g:e;return t.placeholder}function le(){var e=g.iteratee||Lo;return e=e===Lo?Tl:e,arguments.length?e(arguments[0],arguments[1]):e}function Os(e,t){var s=e.__data__;return em(t)?s[typeof t=="string"?"string":"hash"]:s.map}function xo(e){for(var t=ht(e),s=t.length;s--;){var c=t[s],f=e[c];t[s]=[c,f,lc(f)]}return t}function Jn(e,t){var s=rh(e,t);return Nl(s)?s:r}function Xp(e){var t=Fe.call(e,Xn),s=e[Xn];try{e[Xn]=r;var c=!0}catch{}var f=ps.call(e);return c&&(t?e[Xn]=s:delete e[Xn]),f}var vo=qi?function(e){return e==null?[]:(e=Ue(e),Pn(qi(e),function(t){return fl.call(e,t)}))}:Oo,ic=qi?function(e){for(var t=[];e;)jn(t,vo(e)),e=_s(e);return t}:Oo,vt=Et;($i&&vt(new $i(new ArrayBuffer(1)))!=dt||Ir&&vt(new Ir)!=Xe||Xi&&vt(Xi.resolve())!=M||hr&&vt(new hr)!=oe||Lr&&vt(new Lr)!=yt)&&(vt=function(e){var t=Et(e),s=t==Z?e.constructor:r,c=s?Zn(s):"";if(c)switch(c){case kh:return dt;case Ah:return Xe;case Ph:return M;case jh:return oe;case Ih:return yt}return t});function Yp(e,t,s){for(var c=-1,f=s.length;++c<f;){var _=s[c],y=_.size;switch(_.type){case"drop":e+=y;break;case"dropRight":t-=y;break;case"take":t=xt(t,e+y);break;case"takeRight":e=ut(e,t-y);break}}return{start:e,end:t}}function Vp(e){var t=e.match(Ne);return t?t[1].split(pe):[]}function oc(e,t,s){t=On(t,e);for(var c=-1,f=t.length,_=!1;++c<f;){var y=hn(t[c]);if(!(_=e!=null&&s(e,y)))break;e=e[y]}return _||++c!=f?_:(f=e==null?0:e.length,!!f&&zs(f)&&Sn(y,f)&&(me(e)||er(e)))}function Kp(e){var t=e.length,s=new e.constructor(t);return t&&typeof e[0]=="string"&&Fe.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function ac(e){return typeof e.constructor=="function"&&!Hr(e)?mr(_s(e)):{}}function Qp(e,t,s){var c=e.constructor;switch(t){case lt:return fo(e);case Ke:case Pe:return new c(+e);case dt:return Lp(e,s);case Rn:case kn:case sr:case An:case Nr:case tn:case ir:case nn:case xn:return Hl(e,s);case Xe:return new c;case at:case fe:return new c(e);case xe:return Mp(e);case oe:return new c;case ve:return Dp(e)}}function Jp(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(W,`{
6
+ /* [wrapped with `+t+`] */
7
+ `)}function Zp(e){return me(e)||er(e)||!!(dl&&e&&e[dl])}function Sn(e,t){var s=typeof e;return t=t??ie,!!t&&(s=="number"||s!="symbol"&&Rt.test(e))&&e>-1&&e%1==0&&e<t}function St(e,t,s){if(!Ve(s))return!1;var c=typeof t;return(c=="number"?At(s)&&Sn(t,s.length):c=="string"&&t in s)?on(s[t],e):!1}function bo(e,t){if(me(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||Ft(e)?!0:Si.test(e)||!Ei.test(e)||t!=null&&e in Ue(t)}function em(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function yo(e){var t=Ds(e),s=g[t];if(typeof s!="function"||!(t in Te.prototype))return!1;if(e===s)return!0;var c=_o(s);return!!c&&e===c[0]}function tm(e){return!!ll&&ll in e}var nm=ds?Cn:Fo;function Hr(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||dr;return e===s}function lc(e){return e===e&&!Ve(e)}function cc(e,t){return function(s){return s==null?!1:s[e]===t&&(t!==r||e in Ue(s))}}function rm(e){var t=Gs(e,function(c){return s.size===m&&s.clear(),c}),s=t.cache;return t}function sm(e,t){var s=e[1],c=t[1],f=s|c,_=f<(R|D|X),y=c==X&&s==I||c==X&&s==Y&&e[7].length<=t[8]||c==(X|Y)&&t[7].length<=t[8]&&s==I;if(!(_||y))return e;c&R&&(e[2]=t[2],f|=s&R?0:G);var E=t[3];if(E){var N=e[3];e[3]=N?ql(N,E,t[4]):E,e[4]=N?In(e[3],h):t[4]}return E=t[5],E&&(N=e[5],e[5]=N?$l(N,E,t[6]):E,e[6]=N?In(e[5],h):t[6]),E=t[7],E&&(e[7]=E),c&X&&(e[8]=e[8]==null?t[8]:xt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=f,e}function im(e){var t=[];if(e!=null)for(var s in Ue(e))t.push(s);return t}function om(e){return ps.call(e)}function uc(e,t,s){return t=ut(t===r?e.length-1:t,0),function(){for(var c=arguments,f=-1,_=ut(c.length-t,0),y=j(_);++f<_;)y[f]=c[t+f];f=-1;for(var E=j(t+1);++f<t;)E[f]=c[f];return E[t]=s(y),Mt(e,this,E)}}function fc(e,t){return t.length<2?e:Qn(e,Yt(t,0,-1))}function am(e,t){for(var s=e.length,c=xt(t.length,s),f=kt(e);c--;){var _=t[c];e[c]=Sn(_,s)?f[_]:r}return e}function wo(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var dc=pc(Ml),zr=wh||function(e,t){return gt.setTimeout(e,t)},Eo=pc(Ap);function hc(e,t,s){var c=t+"";return Eo(e,Jp(c,lm(Vp(c),s)))}function pc(e){var t=0,s=0;return function(){var c=Nh(),f=ae-(c-s);if(s=c,f>0){if(++t>=de)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Fs(e,t){var s=-1,c=e.length,f=c-1;for(t=t===r?c:t;++s<t;){var _=so(s,f),y=e[_];e[_]=e[s],e[s]=y}return e.length=t,e}var mc=rm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Ci,function(s,c,f,_){t.push(f?_.replace(st,"$1"):c||s)}),t});function hn(e){if(typeof e=="string"||Ft(e))return e;var t=e+"";return t=="0"&&1/e==-re?"-0":t}function Zn(e){if(e!=null){try{return hs.call(e)}catch{}try{return e+""}catch{}}return""}function lm(e,t){return zt(ge,function(s){var c="_."+s[0];t&s[1]&&!ls(e,c)&&e.push(c)}),e.sort()}function gc(e){if(e instanceof Te)return e.clone();var t=new $t(e.__wrapped__,e.__chain__);return t.__actions__=kt(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function cm(e,t,s){(s?St(e,t,s):t===r)?t=1:t=ut(_e(t),0);var c=e==null?0:e.length;if(!c||t<1)return[];for(var f=0,_=0,y=j(bs(c/t));f<c;)y[_++]=Yt(e,f,f+=t);return y}function um(e){for(var t=-1,s=e==null?0:e.length,c=0,f=[];++t<s;){var _=e[t];_&&(f[c++]=_)}return f}function fm(){var e=arguments.length;if(!e)return[];for(var t=j(e-1),s=arguments[0],c=e;c--;)t[c-1]=arguments[c];return jn(me(s)?kt(s):[s],_t(t,1))}var dm=Ee(function(e,t){return tt(e)?Fr(e,_t(t,1,tt,!0)):[]}),hm=Ee(function(e,t){var s=Vt(t);return tt(s)&&(s=r),tt(e)?Fr(e,_t(t,1,tt,!0),le(s,2)):[]}),pm=Ee(function(e,t){var s=Vt(t);return tt(s)&&(s=r),tt(e)?Fr(e,_t(t,1,tt,!0),r,s):[]});function mm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:_e(t),Yt(e,t<0?0:t,c)):[]}function gm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:_e(t),t=c-t,Yt(e,0,t<0?0:t)):[]}function _m(e,t){return e&&e.length?As(e,le(t,3),!0,!0):[]}function xm(e,t){return e&&e.length?As(e,le(t,3),!0):[]}function vm(e,t,s,c){var f=e==null?0:e.length;return f?(s&&typeof s!="number"&&St(e,t,s)&&(s=0,c=f),fp(e,t,s,c)):[]}function _c(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:_e(s);return f<0&&(f=ut(c+f,0)),cs(e,le(t,3),f)}function xc(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return s!==r&&(f=_e(s),f=s<0?ut(c+f,0):xt(f,c-1)),cs(e,le(t,3),f,!0)}function vc(e){var t=e==null?0:e.length;return t?_t(e,1):[]}function bm(e){var t=e==null?0:e.length;return t?_t(e,re):[]}function ym(e,t){var s=e==null?0:e.length;return s?(t=t===r?1:_e(t),_t(e,t)):[]}function wm(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 bc(e){return e&&e.length?e[0]:r}function Em(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=s==null?0:_e(s);return f<0&&(f=ut(c+f,0)),lr(e,t,f)}function Sm(e){var t=e==null?0:e.length;return t?Yt(e,0,-1):[]}var Cm=Ee(function(e){var t=$e(e,co);return t.length&&t[0]===e[0]?Zi(t):[]}),Nm=Ee(function(e){var t=Vt(e),s=$e(e,co);return t===Vt(s)?t=r:s.pop(),s.length&&s[0]===e[0]?Zi(s,le(t,2)):[]}),Tm=Ee(function(e){var t=Vt(e),s=$e(e,co);return t=typeof t=="function"?t:r,t&&s.pop(),s.length&&s[0]===e[0]?Zi(s,r,t):[]});function Rm(e,t){return e==null?"":Sh.call(e,t)}function Vt(e){var t=e==null?0:e.length;return t?e[t-1]:r}function km(e,t,s){var c=e==null?0:e.length;if(!c)return-1;var f=c;return s!==r&&(f=_e(s),f=f<0?ut(c+f,0):xt(f,c-1)),t===t?lh(e,t,f):cs(e,el,f,!0)}function Am(e,t){return e&&e.length?Pl(e,_e(t)):r}var Pm=Ee(yc);function yc(e,t){return e&&e.length&&t&&t.length?ro(e,t):e}function jm(e,t,s){return e&&e.length&&t&&t.length?ro(e,t,le(s,2)):e}function Im(e,t,s){return e&&e.length&&t&&t.length?ro(e,t,r,s):e}var Lm=En(function(e,t){var s=e==null?0:e.length,c=Vi(e,t);return Ll(e,$e(t,function(f){return Sn(f,s)?+f:f}).sort(zl)),c});function Mm(e,t){var s=[];if(!(e&&e.length))return s;var c=-1,f=[],_=e.length;for(t=le(t,3);++c<_;){var y=e[c];t(y,c,e)&&(s.push(y),f.push(c))}return Ll(e,f),s}function So(e){return e==null?e:Rh.call(e)}function Dm(e,t,s){var c=e==null?0:e.length;return c?(s&&typeof s!="number"&&St(e,t,s)?(t=0,s=c):(t=t==null?0:_e(t),s=s===r?c:_e(s)),Yt(e,t,s)):[]}function Om(e,t){return ks(e,t)}function Fm(e,t,s){return oo(e,t,le(s,2))}function Bm(e,t){var s=e==null?0:e.length;if(s){var c=ks(e,t);if(c<s&&on(e[c],t))return c}return-1}function Um(e,t){return ks(e,t,!0)}function Wm(e,t,s){return oo(e,t,le(s,2),!0)}function Gm(e,t){var s=e==null?0:e.length;if(s){var c=ks(e,t,!0)-1;if(on(e[c],t))return c}return-1}function Hm(e){return e&&e.length?Dl(e):[]}function zm(e,t){return e&&e.length?Dl(e,le(t,2)):[]}function qm(e){var t=e==null?0:e.length;return t?Yt(e,1,t):[]}function $m(e,t,s){return e&&e.length?(t=s||t===r?1:_e(t),Yt(e,0,t<0?0:t)):[]}function Xm(e,t,s){var c=e==null?0:e.length;return c?(t=s||t===r?1:_e(t),t=c-t,Yt(e,t<0?0:t,c)):[]}function Ym(e,t){return e&&e.length?As(e,le(t,3),!1,!0):[]}function Vm(e,t){return e&&e.length?As(e,le(t,3)):[]}var Km=Ee(function(e){return Dn(_t(e,1,tt,!0))}),Qm=Ee(function(e){var t=Vt(e);return tt(t)&&(t=r),Dn(_t(e,1,tt,!0),le(t,2))}),Jm=Ee(function(e){var t=Vt(e);return t=typeof t=="function"?t:r,Dn(_t(e,1,tt,!0),r,t)});function Zm(e){return e&&e.length?Dn(e):[]}function e0(e,t){return e&&e.length?Dn(e,le(t,2)):[]}function t0(e,t){return t=typeof t=="function"?t:r,e&&e.length?Dn(e,r,t):[]}function Co(e){if(!(e&&e.length))return[];var t=0;return e=Pn(e,function(s){if(tt(s))return t=ut(s.length,t),!0}),Wi(t,function(s){return $e(e,Fi(s))})}function wc(e,t){if(!(e&&e.length))return[];var s=Co(e);return t==null?s:$e(s,function(c){return Mt(t,r,c)})}var n0=Ee(function(e,t){return tt(e)?Fr(e,t):[]}),r0=Ee(function(e){return lo(Pn(e,tt))}),s0=Ee(function(e){var t=Vt(e);return tt(t)&&(t=r),lo(Pn(e,tt),le(t,2))}),i0=Ee(function(e){var t=Vt(e);return t=typeof t=="function"?t:r,lo(Pn(e,tt),r,t)}),o0=Ee(Co);function a0(e,t){return Ul(e||[],t||[],Or)}function l0(e,t){return Ul(e||[],t||[],Wr)}var c0=Ee(function(e){var t=e.length,s=t>1?e[t-1]:r;return s=typeof s=="function"?(e.pop(),s):r,wc(e,s)});function Ec(e){var t=g(e);return t.__chain__=!0,t}function u0(e,t){return t(e),e}function Bs(e,t){return t(e)}var f0=En(function(e){var t=e.length,s=t?e[0]:0,c=this.__wrapped__,f=function(_){return Vi(_,e)};return t>1||this.__actions__.length||!(c instanceof Te)||!Sn(s)?this.thru(f):(c=c.slice(s,+s+(t?1:0)),c.__actions__.push({func:Bs,args:[f],thisArg:r}),new $t(c,this.__chain__).thru(function(_){return t&&!_.length&&_.push(r),_}))});function d0(){return Ec(this)}function h0(){return new $t(this.value(),this.__chain__)}function p0(){this.__values__===r&&(this.__values__=Oc(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function m0(){return this}function g0(e){for(var t,s=this;s instanceof Ss;){var c=gc(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 _0(){var e=this.__wrapped__;if(e instanceof Te){var t=e;return this.__actions__.length&&(t=new Te(this)),t=t.reverse(),t.__actions__.push({func:Bs,args:[So],thisArg:r}),new $t(t,this.__chain__)}return this.thru(So)}function x0(){return Bl(this.__wrapped__,this.__actions__)}var v0=Ps(function(e,t,s){Fe.call(e,s)?++e[s]:yn(e,s,1)});function b0(e,t,s){var c=me(e)?Ja:up;return s&&St(e,t,s)&&(t=r),c(e,le(t,3))}function y0(e,t){var s=me(e)?Pn:wl;return s(e,le(t,3))}var w0=Kl(_c),E0=Kl(xc);function S0(e,t){return _t(Us(e,t),1)}function C0(e,t){return _t(Us(e,t),re)}function N0(e,t,s){return s=s===r?1:_e(s),_t(Us(e,t),s)}function Sc(e,t){var s=me(e)?zt:Mn;return s(e,le(t,3))}function Cc(e,t){var s=me(e)?qd:yl;return s(e,le(t,3))}var T0=Ps(function(e,t,s){Fe.call(e,s)?e[s].push(t):yn(e,s,[t])});function R0(e,t,s,c){e=At(e)?e:br(e),s=s&&!c?_e(s):0;var f=e.length;return s<0&&(s=ut(f+s,0)),qs(e)?s<=f&&e.indexOf(t,s)>-1:!!f&&lr(e,t,s)>-1}var k0=Ee(function(e,t,s){var c=-1,f=typeof t=="function",_=At(e)?j(e.length):[];return Mn(e,function(y){_[++c]=f?Mt(t,y,s):Br(y,t,s)}),_}),A0=Ps(function(e,t,s){yn(e,s,t)});function Us(e,t){var s=me(e)?$e:Rl;return s(e,le(t,3))}function P0(e,t,s,c){return e==null?[]:(me(t)||(t=t==null?[]:[t]),s=c?r:s,me(s)||(s=s==null?[]:[s]),jl(e,t,s))}var j0=Ps(function(e,t,s){e[s?0:1].push(t)},function(){return[[],[]]});function I0(e,t,s){var c=me(e)?Di:nl,f=arguments.length<3;return c(e,le(t,4),s,f,Mn)}function L0(e,t,s){var c=me(e)?$d:nl,f=arguments.length<3;return c(e,le(t,4),s,f,yl)}function M0(e,t){var s=me(e)?Pn:wl;return s(e,Hs(le(t,3)))}function D0(e){var t=me(e)?_l:Rp;return t(e)}function O0(e,t,s){(s?St(e,t,s):t===r)?t=1:t=_e(t);var c=me(e)?ip:kp;return c(e,t)}function F0(e){var t=me(e)?op:Pp;return t(e)}function B0(e){if(e==null)return 0;if(At(e))return qs(e)?ur(e):e.length;var t=vt(e);return t==Xe||t==oe?e.size:to(e).length}function U0(e,t,s){var c=me(e)?Oi:jp;return s&&St(e,t,s)&&(t=r),c(e,le(t,3))}var W0=Ee(function(e,t){if(e==null)return[];var s=t.length;return s>1&&St(e,t[0],t[1])?t=[]:s>2&&St(t[0],t[1],t[2])&&(t=[t[0]]),jl(e,_t(t,1),[])}),Ws=yh||function(){return gt.Date.now()};function G0(e,t){if(typeof t!="function")throw new qt(p);return e=_e(e),function(){if(--e<1)return t.apply(this,arguments)}}function Nc(e,t,s){return t=s?r:t,t=e&&t==null?e.length:t,wn(e,X,r,r,r,r,t)}function Tc(e,t){var s;if(typeof t!="function")throw new qt(p);return e=_e(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=r),s}}var No=Ee(function(e,t,s){var c=R;if(s.length){var f=In(s,xr(No));c|=q}return wn(e,c,t,s,f)}),Rc=Ee(function(e,t,s){var c=R|D;if(s.length){var f=In(s,xr(Rc));c|=q}return wn(t,c,e,s,f)});function kc(e,t,s){t=s?r:t;var c=wn(e,I,r,r,r,r,r,t);return c.placeholder=kc.placeholder,c}function Ac(e,t,s){t=s?r:t;var c=wn(e,k,r,r,r,r,r,t);return c.placeholder=Ac.placeholder,c}function Pc(e,t,s){var c,f,_,y,E,N,B=0,U=!1,z=!1,J=!0;if(typeof e!="function")throw new qt(p);t=Kt(t)||0,Ve(s)&&(U=!!s.leading,z="maxWait"in s,_=z?ut(Kt(s.maxWait)||0,t):_,J="trailing"in s?!!s.trailing:J);function ne(nt){var an=c,Tn=f;return c=f=r,B=nt,y=e.apply(Tn,an),y}function ce(nt){return B=nt,E=zr(Se,t),U?ne(nt):y}function be(nt){var an=nt-N,Tn=nt-B,Kc=t-an;return z?xt(Kc,_-Tn):Kc}function ue(nt){var an=nt-N,Tn=nt-B;return N===r||an>=t||an<0||z&&Tn>=_}function Se(){var nt=Ws();if(ue(nt))return Re(nt);E=zr(Se,be(nt))}function Re(nt){return E=r,J&&c?ne(nt):(c=f=r,y)}function Bt(){E!==r&&Wl(E),B=0,c=N=f=E=r}function Ct(){return E===r?y:Re(Ws())}function Ut(){var nt=Ws(),an=ue(nt);if(c=arguments,f=this,N=nt,an){if(E===r)return ce(N);if(z)return Wl(E),E=zr(Se,t),ne(N)}return E===r&&(E=zr(Se,t)),y}return Ut.cancel=Bt,Ut.flush=Ct,Ut}var H0=Ee(function(e,t){return bl(e,1,t)}),z0=Ee(function(e,t,s){return bl(e,Kt(t)||0,s)});function q0(e){return wn(e,F)}function Gs(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new qt(p);var s=function(){var c=arguments,f=t?t.apply(this,c):c[0],_=s.cache;if(_.has(f))return _.get(f);var y=e.apply(this,c);return s.cache=_.set(f,y)||_,y};return s.cache=new(Gs.Cache||bn),s}Gs.Cache=bn;function Hs(e){if(typeof e!="function")throw new qt(p);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 $0(e){return Tc(2,e)}var X0=Ip(function(e,t){t=t.length==1&&me(t[0])?$e(t[0],Dt(le())):$e(_t(t,1),Dt(le()));var s=t.length;return Ee(function(c){for(var f=-1,_=xt(c.length,s);++f<_;)c[f]=t[f].call(this,c[f]);return Mt(e,this,c)})}),To=Ee(function(e,t){var s=In(t,xr(To));return wn(e,q,r,t,s)}),jc=Ee(function(e,t){var s=In(t,xr(jc));return wn(e,$,r,t,s)}),Y0=En(function(e,t){return wn(e,Y,r,r,r,t)});function V0(e,t){if(typeof e!="function")throw new qt(p);return t=t===r?t:_e(t),Ee(e,t)}function K0(e,t){if(typeof e!="function")throw new qt(p);return t=t==null?0:ut(_e(t),0),Ee(function(s){var c=s[t],f=Fn(s,0,t);return c&&jn(f,c),Mt(e,this,f)})}function Q0(e,t,s){var c=!0,f=!0;if(typeof e!="function")throw new qt(p);return Ve(s)&&(c="leading"in s?!!s.leading:c,f="trailing"in s?!!s.trailing:f),Pc(e,t,{leading:c,maxWait:t,trailing:f})}function J0(e){return Nc(e,1)}function Z0(e,t){return To(uo(t),e)}function eg(){if(!arguments.length)return[];var e=arguments[0];return me(e)?e:[e]}function tg(e){return Xt(e,S)}function ng(e,t){return t=typeof t=="function"?t:r,Xt(e,S,t)}function rg(e){return Xt(e,v|S)}function sg(e,t){return t=typeof t=="function"?t:r,Xt(e,v|S,t)}function ig(e,t){return t==null||vl(e,t,ht(t))}function on(e,t){return e===t||e!==e&&t!==t}var og=Ms(Ji),ag=Ms(function(e,t){return e>=t}),er=Cl((function(){return arguments})())?Cl:function(e){return Qe(e)&&Fe.call(e,"callee")&&!fl.call(e,"callee")},me=j.isArray,lg=$a?Dt($a):gp;function At(e){return e!=null&&zs(e.length)&&!Cn(e)}function tt(e){return Qe(e)&&At(e)}function cg(e){return e===!0||e===!1||Qe(e)&&Et(e)==Ke}var Bn=Eh||Fo,ug=Xa?Dt(Xa):_p;function fg(e){return Qe(e)&&e.nodeType===1&&!qr(e)}function dg(e){if(e==null)return!0;if(At(e)&&(me(e)||typeof e=="string"||typeof e.splice=="function"||Bn(e)||vr(e)||er(e)))return!e.length;var t=vt(e);if(t==Xe||t==oe)return!e.size;if(Hr(e))return!to(e).length;for(var s in e)if(Fe.call(e,s))return!1;return!0}function hg(e,t){return Ur(e,t)}function pg(e,t,s){s=typeof s=="function"?s:r;var c=s?s(e,t):r;return c===r?Ur(e,t,r,s):!!c}function Ro(e){if(!Qe(e))return!1;var t=Et(e);return t==ft||t==ot||typeof e.message=="string"&&typeof e.name=="string"&&!qr(e)}function mg(e){return typeof e=="number"&&hl(e)}function Cn(e){if(!Ve(e))return!1;var t=Et(e);return t==He||t==Gt||t==pt||t==Q}function Ic(e){return typeof e=="number"&&e==_e(e)}function zs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=ie}function Ve(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Qe(e){return e!=null&&typeof e=="object"}var Lc=Ya?Dt(Ya):vp;function gg(e,t){return e===t||eo(e,t,xo(t))}function _g(e,t,s){return s=typeof s=="function"?s:r,eo(e,t,xo(t),s)}function xg(e){return Mc(e)&&e!=+e}function vg(e){if(nm(e))throw new he(l);return Nl(e)}function bg(e){return e===null}function yg(e){return e==null}function Mc(e){return typeof e=="number"||Qe(e)&&Et(e)==at}function qr(e){if(!Qe(e)||Et(e)!=Z)return!1;var t=_s(e);if(t===null)return!0;var s=Fe.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&hs.call(s)==_h}var ko=Va?Dt(Va):bp;function wg(e){return Ic(e)&&e>=-ie&&e<=ie}var Dc=Ka?Dt(Ka):yp;function qs(e){return typeof e=="string"||!me(e)&&Qe(e)&&Et(e)==fe}function Ft(e){return typeof e=="symbol"||Qe(e)&&Et(e)==ve}var vr=Qa?Dt(Qa):wp;function Eg(e){return e===r}function Sg(e){return Qe(e)&&vt(e)==yt}function Cg(e){return Qe(e)&&Et(e)==Nt}var Ng=Ms(no),Tg=Ms(function(e,t){return e<=t});function Oc(e){if(!e)return[];if(At(e))return qs(e)?rn(e):kt(e);if(jr&&e[jr])return ih(e[jr]());var t=vt(e),s=t==Xe?Hi:t==oe?us:br;return s(e)}function Nn(e){if(!e)return e===0?e:0;if(e=Kt(e),e===re||e===-re){var t=e<0?-1:1;return t*ye}return e===e?e:0}function _e(e){var t=Nn(e),s=t%1;return t===t?s?t-s:t:0}function Fc(e){return e?Kn(_e(e),0,se):0}function Kt(e){if(typeof e=="number")return e;if(Ft(e))return we;if(Ve(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ve(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=rl(e);var s=is.test(e);return s||qe.test(e)?Gd(e.slice(2),s?2:8):Tt.test(e)?we:+e}function Bc(e){return dn(e,Pt(e))}function Rg(e){return e?Kn(_e(e),-ie,ie):e===0?e:0}function De(e){return e==null?"":Ot(e)}var kg=gr(function(e,t){if(Hr(t)||At(t)){dn(t,ht(t),e);return}for(var s in t)Fe.call(t,s)&&Or(e,s,t[s])}),Uc=gr(function(e,t){dn(t,Pt(t),e)}),$s=gr(function(e,t,s,c){dn(t,Pt(t),e,c)}),Ag=gr(function(e,t,s,c){dn(t,ht(t),e,c)}),Pg=En(Vi);function jg(e,t){var s=mr(e);return t==null?s:xl(s,t)}var Ig=Ee(function(e,t){e=Ue(e);var s=-1,c=t.length,f=c>2?t[2]:r;for(f&&St(t[0],t[1],f)&&(c=1);++s<c;)for(var _=t[s],y=Pt(_),E=-1,N=y.length;++E<N;){var B=y[E],U=e[B];(U===r||on(U,dr[B])&&!Fe.call(e,B))&&(e[B]=_[B])}return e}),Lg=Ee(function(e){return e.push(r,rc),Mt(Wc,r,e)});function Mg(e,t){return Za(e,le(t,3),fn)}function Dg(e,t){return Za(e,le(t,3),Qi)}function Og(e,t){return e==null?e:Ki(e,le(t,3),Pt)}function Fg(e,t){return e==null?e:El(e,le(t,3),Pt)}function Bg(e,t){return e&&fn(e,le(t,3))}function Ug(e,t){return e&&Qi(e,le(t,3))}function Wg(e){return e==null?[]:Ts(e,ht(e))}function Gg(e){return e==null?[]:Ts(e,Pt(e))}function Ao(e,t,s){var c=e==null?r:Qn(e,t);return c===r?s:c}function Hg(e,t){return e!=null&&oc(e,t,dp)}function Po(e,t){return e!=null&&oc(e,t,hp)}var zg=Jl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=ps.call(t)),e[t]=s},Io(jt)),qg=Jl(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=ps.call(t)),Fe.call(e,t)?e[t].push(s):e[t]=[s]},le),$g=Ee(Br);function ht(e){return At(e)?gl(e):to(e)}function Pt(e){return At(e)?gl(e,!0):Ep(e)}function Xg(e,t){var s={};return t=le(t,3),fn(e,function(c,f,_){yn(s,t(c,f,_),c)}),s}function Yg(e,t){var s={};return t=le(t,3),fn(e,function(c,f,_){yn(s,f,t(c,f,_))}),s}var Vg=gr(function(e,t,s){Rs(e,t,s)}),Wc=gr(function(e,t,s,c){Rs(e,t,s,c)}),Kg=En(function(e,t){var s={};if(e==null)return s;var c=!1;t=$e(t,function(_){return _=On(_,e),c||(c=_.length>1),_}),dn(e,go(e),s),c&&(s=Xt(s,v|b|S,zp));for(var f=t.length;f--;)ao(s,t[f]);return s});function Qg(e,t){return Gc(e,Hs(le(t)))}var Jg=En(function(e,t){return e==null?{}:Cp(e,t)});function Gc(e,t){if(e==null)return{};var s=$e(go(e),function(c){return[c]});return t=le(t),Il(e,s,function(c,f){return t(c,f[0])})}function Zg(e,t,s){t=On(t,e);var c=-1,f=t.length;for(f||(f=1,e=r);++c<f;){var _=e==null?r:e[hn(t[c])];_===r&&(c=f,_=s),e=Cn(_)?_.call(e):_}return e}function e_(e,t,s){return e==null?e:Wr(e,t,s)}function t_(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:Wr(e,t,s,c)}var Hc=tc(ht),zc=tc(Pt);function n_(e,t,s){var c=me(e),f=c||Bn(e)||vr(e);if(t=le(t,4),s==null){var _=e&&e.constructor;f?s=c?new _:[]:Ve(e)?s=Cn(_)?mr(_s(e)):{}:s={}}return(f?zt:fn)(e,function(y,E,N){return t(s,y,E,N)}),s}function r_(e,t){return e==null?!0:ao(e,t)}function s_(e,t,s){return e==null?e:Fl(e,t,uo(s))}function i_(e,t,s,c){return c=typeof c=="function"?c:r,e==null?e:Fl(e,t,uo(s),c)}function br(e){return e==null?[]:Gi(e,ht(e))}function o_(e){return e==null?[]:Gi(e,Pt(e))}function a_(e,t,s){return s===r&&(s=t,t=r),s!==r&&(s=Kt(s),s=s===s?s:0),t!==r&&(t=Kt(t),t=t===t?t:0),Kn(Kt(e),t,s)}function l_(e,t,s){return t=Nn(t),s===r?(s=t,t=0):s=Nn(s),e=Kt(e),pp(e,t,s)}function c_(e,t,s){if(s&&typeof s!="boolean"&&St(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=Nn(e),t===r?(t=e,e=0):t=Nn(t)),e>t){var c=e;e=t,t=c}if(s||e%1||t%1){var f=pl();return xt(e+f*(t-e+Wd("1e-"+((f+"").length-1))),t)}return so(e,t)}var u_=_r(function(e,t,s){return t=t.toLowerCase(),e+(s?qc(t):t)});function qc(e){return jo(De(e).toLowerCase())}function $c(e){return e=De(e),e&&e.replace(Lt,eh).replace(Pd,"")}function f_(e,t,s){e=De(e),t=Ot(t);var c=e.length;s=s===r?c:Kn(_e(s),0,c);var f=s;return s-=t.length,s>=0&&e.slice(s,f)==t}function d_(e){return e=De(e),e&&ss.test(e)?e.replace(Tr,th):e}function h_(e){return e=De(e),e&&Ni.test(e)?e.replace(Rr,"\\$&"):e}var p_=_r(function(e,t,s){return e+(s?"-":"")+t.toLowerCase()}),m_=_r(function(e,t,s){return e+(s?" ":"")+t.toLowerCase()}),g_=Vl("toLowerCase");function __(e,t,s){e=De(e),t=_e(t);var c=t?ur(e):0;if(!t||c>=t)return e;var f=(t-c)/2;return Ls(ys(f),s)+e+Ls(bs(f),s)}function x_(e,t,s){e=De(e),t=_e(t);var c=t?ur(e):0;return t&&c<t?e+Ls(t-c,s):e}function v_(e,t,s){e=De(e),t=_e(t);var c=t?ur(e):0;return t&&c<t?Ls(t-c,s)+e:e}function b_(e,t,s){return s||t==null?t=0:t&&(t=+t),Th(De(e).replace(kr,""),t||0)}function y_(e,t,s){return(s?St(e,t,s):t===r)?t=1:t=_e(t),io(De(e),t)}function w_(){var e=arguments,t=De(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var E_=_r(function(e,t,s){return e+(s?"_":"")+t.toLowerCase()});function S_(e,t,s){return s&&typeof s!="number"&&St(e,t,s)&&(t=s=r),s=s===r?se:s>>>0,s?(e=De(e),e&&(typeof t=="string"||t!=null&&!ko(t))&&(t=Ot(t),!t&&cr(e))?Fn(rn(e),0,s):e.split(t,s)):[]}var C_=_r(function(e,t,s){return e+(s?" ":"")+jo(t)});function N_(e,t,s){return e=De(e),s=s==null?0:Kn(_e(s),0,e.length),t=Ot(t),e.slice(s,s+t.length)==t}function T_(e,t,s){var c=g.templateSettings;s&&St(e,t,s)&&(t=r),e=De(e),t=$s({},t,c,nc);var f=$s({},t.imports,c.imports,nc),_=ht(f),y=Gi(f,_),E,N,B=0,U=t.interpolate||wt,z="__p += '",J=zi((t.escape||wt).source+"|"+U.source+"|"+(U===or?ze:wt).source+"|"+(t.evaluate||wt).source+"|$","g"),ne="//# sourceURL="+(Fe.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Dd+"]")+`
8
+ `;e.replace(J,function(ue,Se,Re,Bt,Ct,Ut){return Re||(Re=Bt),z+=e.slice(B,Ut).replace(qn,nh),Se&&(E=!0,z+=`' +
9
+ __e(`+Se+`) +
10
+ '`),Ct&&(N=!0,z+=`';
11
+ `+Ct+`;
12
+ __p += '`),Re&&(z+=`' +
13
+ ((__t = (`+Re+`)) == null ? '' : __t) +
14
+ '`),B=Ut+ue.length,ue}),z+=`';
15
+ `;var ce=Fe.call(t,"variable")&&t.variable;if(!ce)z=`with (obj) {
16
+ `+z+`
17
+ }
18
+ `;else if(un.test(ce))throw new he(x);z=(N?z.replace(xi,""):z).replace(vi,"$1").replace(bi,"$1;"),z="function("+(ce||"obj")+`) {
19
+ `+(ce?"":`obj || (obj = {});
20
+ `)+"var __t, __p = ''"+(E?", __e = _.escape":"")+(N?`, __j = Array.prototype.join;
21
+ function print() { __p += __j.call(arguments, '') }
22
+ `:`;
23
+ `)+z+`return __p
24
+ }`;var be=Yc(function(){return je(_,ne+"return "+z).apply(r,y)});if(be.source=z,Ro(be))throw be;return be}function R_(e){return De(e).toLowerCase()}function k_(e){return De(e).toUpperCase()}function A_(e,t,s){if(e=De(e),e&&(s||t===r))return rl(e);if(!e||!(t=Ot(t)))return e;var c=rn(e),f=rn(t),_=sl(c,f),y=il(c,f)+1;return Fn(c,_,y).join("")}function P_(e,t,s){if(e=De(e),e&&(s||t===r))return e.slice(0,al(e)+1);if(!e||!(t=Ot(t)))return e;var c=rn(e),f=il(c,rn(t))+1;return Fn(c,0,f).join("")}function j_(e,t,s){if(e=De(e),e&&(s||t===r))return e.replace(kr,"");if(!e||!(t=Ot(t)))return e;var c=rn(e),f=sl(c,rn(t));return Fn(c,f).join("")}function I_(e,t){var s=P,c=A;if(Ve(t)){var f="separator"in t?t.separator:f;s="length"in t?_e(t.length):s,c="omission"in t?Ot(t.omission):c}e=De(e);var _=e.length;if(cr(e)){var y=rn(e);_=y.length}if(s>=_)return e;var E=s-ur(c);if(E<1)return c;var N=y?Fn(y,0,E).join(""):e.slice(0,E);if(f===r)return N+c;if(y&&(E+=N.length-E),ko(f)){if(e.slice(E).search(f)){var B,U=N;for(f.global||(f=zi(f.source,De(et.exec(f))+"g")),f.lastIndex=0;B=f.exec(U);)var z=B.index;N=N.slice(0,z===r?E:z)}}else if(e.indexOf(Ot(f),E)!=E){var J=N.lastIndexOf(f);J>-1&&(N=N.slice(0,J))}return N+c}function L_(e){return e=De(e),e&&rs.test(e)?e.replace(ns,ch):e}var M_=_r(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),jo=Vl("toUpperCase");function Xc(e,t,s){return e=De(e),t=s?r:t,t===r?sh(e)?dh(e):Vd(e):e.match(t)||[]}var Yc=Ee(function(e,t){try{return Mt(e,r,t)}catch(s){return Ro(s)?s:new he(s)}}),D_=En(function(e,t){return zt(t,function(s){s=hn(s),yn(e,s,No(e[s],e))}),e});function O_(e){var t=e==null?0:e.length,s=le();return e=t?$e(e,function(c){if(typeof c[1]!="function")throw new qt(p);return[s(c[0]),c[1]]}):[],Ee(function(c){for(var f=-1;++f<t;){var _=e[f];if(Mt(_[0],this,c))return Mt(_[1],this,c)}})}function F_(e){return cp(Xt(e,v))}function Io(e){return function(){return e}}function B_(e,t){return e==null||e!==e?t:e}var U_=Ql(),W_=Ql(!0);function jt(e){return e}function Lo(e){return Tl(typeof e=="function"?e:Xt(e,v))}function G_(e){return kl(Xt(e,v))}function H_(e,t){return Al(e,Xt(t,v))}var z_=Ee(function(e,t){return function(s){return Br(s,e,t)}}),q_=Ee(function(e,t){return function(s){return Br(e,s,t)}});function Mo(e,t,s){var c=ht(t),f=Ts(t,c);s==null&&!(Ve(t)&&(f.length||!c.length))&&(s=t,t=e,e=this,f=Ts(t,ht(t)));var _=!(Ve(s)&&"chain"in s)||!!s.chain,y=Cn(e);return zt(f,function(E){var N=t[E];e[E]=N,y&&(e.prototype[E]=function(){var B=this.__chain__;if(_||B){var U=e(this.__wrapped__),z=U.__actions__=kt(this.__actions__);return z.push({func:N,args:arguments,thisArg:e}),U.__chain__=B,U}return N.apply(e,jn([this.value()],arguments))})}),e}function $_(){return gt._===this&&(gt._=xh),this}function Do(){}function X_(e){return e=_e(e),Ee(function(t){return Pl(t,e)})}var Y_=ho($e),V_=ho(Ja),K_=ho(Oi);function Vc(e){return bo(e)?Fi(hn(e)):Np(e)}function Q_(e){return function(t){return e==null?r:Qn(e,t)}}var J_=Zl(),Z_=Zl(!0);function Oo(){return[]}function Fo(){return!1}function ex(){return{}}function tx(){return""}function nx(){return!0}function rx(e,t){if(e=_e(e),e<1||e>ie)return[];var s=se,c=xt(e,se);t=le(t),e-=se;for(var f=Wi(c,t);++s<e;)t(s);return f}function sx(e){return me(e)?$e(e,hn):Ft(e)?[e]:kt(mc(De(e)))}function ix(e){var t=++gh;return De(e)+t}var ox=Is(function(e,t){return e+t},0),ax=po("ceil"),lx=Is(function(e,t){return e/t},1),cx=po("floor");function ux(e){return e&&e.length?Ns(e,jt,Ji):r}function fx(e,t){return e&&e.length?Ns(e,le(t,2),Ji):r}function dx(e){return tl(e,jt)}function hx(e,t){return tl(e,le(t,2))}function px(e){return e&&e.length?Ns(e,jt,no):r}function mx(e,t){return e&&e.length?Ns(e,le(t,2),no):r}var gx=Is(function(e,t){return e*t},1),_x=po("round"),xx=Is(function(e,t){return e-t},0);function vx(e){return e&&e.length?Ui(e,jt):0}function bx(e,t){return e&&e.length?Ui(e,le(t,2)):0}return g.after=G0,g.ary=Nc,g.assign=kg,g.assignIn=Uc,g.assignInWith=$s,g.assignWith=Ag,g.at=Pg,g.before=Tc,g.bind=No,g.bindAll=D_,g.bindKey=Rc,g.castArray=eg,g.chain=Ec,g.chunk=cm,g.compact=um,g.concat=fm,g.cond=O_,g.conforms=F_,g.constant=Io,g.countBy=v0,g.create=jg,g.curry=kc,g.curryRight=Ac,g.debounce=Pc,g.defaults=Ig,g.defaultsDeep=Lg,g.defer=H0,g.delay=z0,g.difference=dm,g.differenceBy=hm,g.differenceWith=pm,g.drop=mm,g.dropRight=gm,g.dropRightWhile=_m,g.dropWhile=xm,g.fill=vm,g.filter=y0,g.flatMap=S0,g.flatMapDeep=C0,g.flatMapDepth=N0,g.flatten=vc,g.flattenDeep=bm,g.flattenDepth=ym,g.flip=q0,g.flow=U_,g.flowRight=W_,g.fromPairs=wm,g.functions=Wg,g.functionsIn=Gg,g.groupBy=T0,g.initial=Sm,g.intersection=Cm,g.intersectionBy=Nm,g.intersectionWith=Tm,g.invert=zg,g.invertBy=qg,g.invokeMap=k0,g.iteratee=Lo,g.keyBy=A0,g.keys=ht,g.keysIn=Pt,g.map=Us,g.mapKeys=Xg,g.mapValues=Yg,g.matches=G_,g.matchesProperty=H_,g.memoize=Gs,g.merge=Vg,g.mergeWith=Wc,g.method=z_,g.methodOf=q_,g.mixin=Mo,g.negate=Hs,g.nthArg=X_,g.omit=Kg,g.omitBy=Qg,g.once=$0,g.orderBy=P0,g.over=Y_,g.overArgs=X0,g.overEvery=V_,g.overSome=K_,g.partial=To,g.partialRight=jc,g.partition=j0,g.pick=Jg,g.pickBy=Gc,g.property=Vc,g.propertyOf=Q_,g.pull=Pm,g.pullAll=yc,g.pullAllBy=jm,g.pullAllWith=Im,g.pullAt=Lm,g.range=J_,g.rangeRight=Z_,g.rearg=Y0,g.reject=M0,g.remove=Mm,g.rest=V0,g.reverse=So,g.sampleSize=O0,g.set=e_,g.setWith=t_,g.shuffle=F0,g.slice=Dm,g.sortBy=W0,g.sortedUniq=Hm,g.sortedUniqBy=zm,g.split=S_,g.spread=K0,g.tail=qm,g.take=$m,g.takeRight=Xm,g.takeRightWhile=Ym,g.takeWhile=Vm,g.tap=u0,g.throttle=Q0,g.thru=Bs,g.toArray=Oc,g.toPairs=Hc,g.toPairsIn=zc,g.toPath=sx,g.toPlainObject=Bc,g.transform=n_,g.unary=J0,g.union=Km,g.unionBy=Qm,g.unionWith=Jm,g.uniq=Zm,g.uniqBy=e0,g.uniqWith=t0,g.unset=r_,g.unzip=Co,g.unzipWith=wc,g.update=s_,g.updateWith=i_,g.values=br,g.valuesIn=o_,g.without=n0,g.words=Xc,g.wrap=Z0,g.xor=r0,g.xorBy=s0,g.xorWith=i0,g.zip=o0,g.zipObject=a0,g.zipObjectDeep=l0,g.zipWith=c0,g.entries=Hc,g.entriesIn=zc,g.extend=Uc,g.extendWith=$s,Mo(g,g),g.add=ox,g.attempt=Yc,g.camelCase=u_,g.capitalize=qc,g.ceil=ax,g.clamp=a_,g.clone=tg,g.cloneDeep=rg,g.cloneDeepWith=sg,g.cloneWith=ng,g.conformsTo=ig,g.deburr=$c,g.defaultTo=B_,g.divide=lx,g.endsWith=f_,g.eq=on,g.escape=d_,g.escapeRegExp=h_,g.every=b0,g.find=w0,g.findIndex=_c,g.findKey=Mg,g.findLast=E0,g.findLastIndex=xc,g.findLastKey=Dg,g.floor=cx,g.forEach=Sc,g.forEachRight=Cc,g.forIn=Og,g.forInRight=Fg,g.forOwn=Bg,g.forOwnRight=Ug,g.get=Ao,g.gt=og,g.gte=ag,g.has=Hg,g.hasIn=Po,g.head=bc,g.identity=jt,g.includes=R0,g.indexOf=Em,g.inRange=l_,g.invoke=$g,g.isArguments=er,g.isArray=me,g.isArrayBuffer=lg,g.isArrayLike=At,g.isArrayLikeObject=tt,g.isBoolean=cg,g.isBuffer=Bn,g.isDate=ug,g.isElement=fg,g.isEmpty=dg,g.isEqual=hg,g.isEqualWith=pg,g.isError=Ro,g.isFinite=mg,g.isFunction=Cn,g.isInteger=Ic,g.isLength=zs,g.isMap=Lc,g.isMatch=gg,g.isMatchWith=_g,g.isNaN=xg,g.isNative=vg,g.isNil=yg,g.isNull=bg,g.isNumber=Mc,g.isObject=Ve,g.isObjectLike=Qe,g.isPlainObject=qr,g.isRegExp=ko,g.isSafeInteger=wg,g.isSet=Dc,g.isString=qs,g.isSymbol=Ft,g.isTypedArray=vr,g.isUndefined=Eg,g.isWeakMap=Sg,g.isWeakSet=Cg,g.join=Rm,g.kebabCase=p_,g.last=Vt,g.lastIndexOf=km,g.lowerCase=m_,g.lowerFirst=g_,g.lt=Ng,g.lte=Tg,g.max=ux,g.maxBy=fx,g.mean=dx,g.meanBy=hx,g.min=px,g.minBy=mx,g.stubArray=Oo,g.stubFalse=Fo,g.stubObject=ex,g.stubString=tx,g.stubTrue=nx,g.multiply=gx,g.nth=Am,g.noConflict=$_,g.noop=Do,g.now=Ws,g.pad=__,g.padEnd=x_,g.padStart=v_,g.parseInt=b_,g.random=c_,g.reduce=I0,g.reduceRight=L0,g.repeat=y_,g.replace=w_,g.result=Zg,g.round=_x,g.runInContext=C,g.sample=D0,g.size=B0,g.snakeCase=E_,g.some=U0,g.sortedIndex=Om,g.sortedIndexBy=Fm,g.sortedIndexOf=Bm,g.sortedLastIndex=Um,g.sortedLastIndexBy=Wm,g.sortedLastIndexOf=Gm,g.startCase=C_,g.startsWith=N_,g.subtract=xx,g.sum=vx,g.sumBy=bx,g.template=T_,g.times=rx,g.toFinite=Nn,g.toInteger=_e,g.toLength=Fc,g.toLower=R_,g.toNumber=Kt,g.toSafeInteger=Rg,g.toString=De,g.toUpper=k_,g.trim=A_,g.trimEnd=P_,g.trimStart=j_,g.truncate=I_,g.unescape=L_,g.uniqueId=ix,g.upperCase=M_,g.upperFirst=jo,g.each=Sc,g.eachRight=Cc,g.first=bc,Mo(g,(function(){var e={};return fn(g,function(t,s){Fe.call(g.prototype,s)||(e[s]=t)}),e})(),{chain:!1}),g.VERSION=o,zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){g[e].placeholder=g}),zt(["drop","take"],function(e,t){Te.prototype[e]=function(s){s=s===r?1:ut(_e(s),0);var c=this.__filtered__&&!t?new Te(this):this.clone();return c.__filtered__?c.__takeCount__=xt(s,c.__takeCount__):c.__views__.push({size:xt(s,se),type:e+(c.__dir__<0?"Right":"")}),c},Te.prototype[e+"Right"]=function(s){return this.reverse()[e](s).reverse()}}),zt(["filter","map","takeWhile"],function(e,t){var s=t+1,c=s==H||s==K;Te.prototype[e]=function(f){var _=this.clone();return _.__iteratees__.push({iteratee:le(f,3),type:s}),_.__filtered__=_.__filtered__||c,_}}),zt(["head","last"],function(e,t){var s="take"+(t?"Right":"");Te.prototype[e]=function(){return this[s](1).value()[0]}}),zt(["initial","tail"],function(e,t){var s="drop"+(t?"":"Right");Te.prototype[e]=function(){return this.__filtered__?new Te(this):this[s](1)}}),Te.prototype.compact=function(){return this.filter(jt)},Te.prototype.find=function(e){return this.filter(e).head()},Te.prototype.findLast=function(e){return this.reverse().find(e)},Te.prototype.invokeMap=Ee(function(e,t){return typeof e=="function"?new Te(this):this.map(function(s){return Br(s,e,t)})}),Te.prototype.reject=function(e){return this.filter(Hs(le(e)))},Te.prototype.slice=function(e,t){e=_e(e);var s=this;return s.__filtered__&&(e>0||t<0)?new Te(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==r&&(t=_e(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Te.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Te.prototype.toArray=function(){return this.take(se)},fn(Te.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),c=/^(?:head|last)$/.test(t),f=g[c?"take"+(t=="last"?"Right":""):t],_=c||/^find/.test(t);f&&(g.prototype[t]=function(){var y=this.__wrapped__,E=c?[1]:arguments,N=y instanceof Te,B=E[0],U=N||me(y),z=function(Se){var Re=f.apply(g,jn([Se],E));return c&&J?Re[0]:Re};U&&s&&typeof B=="function"&&B.length!=1&&(N=U=!1);var J=this.__chain__,ne=!!this.__actions__.length,ce=_&&!J,be=N&&!ne;if(!_&&U){y=be?y:new Te(this);var ue=e.apply(y,E);return ue.__actions__.push({func:Bs,args:[z],thisArg:r}),new $t(ue,J)}return ce&&be?e.apply(this,E):(ue=this.thru(z),ce?c?ue.value()[0]:ue.value():ue)})}),zt(["pop","push","shift","sort","splice","unshift"],function(e){var t=fs[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);g.prototype[e]=function(){var f=arguments;if(c&&!this.__chain__){var _=this.value();return t.apply(me(_)?_:[],f)}return this[s](function(y){return t.apply(me(y)?y:[],f)})}}),fn(Te.prototype,function(e,t){var s=g[t];if(s){var c=s.name+"";Fe.call(pr,c)||(pr[c]=[]),pr[c].push({name:t,func:s})}}),pr[js(r,D).name]=[{name:"wrapper",func:r}],Te.prototype.clone=Lh,Te.prototype.reverse=Mh,Te.prototype.value=Dh,g.prototype.at=f0,g.prototype.chain=d0,g.prototype.commit=h0,g.prototype.next=p0,g.prototype.plant=g0,g.prototype.reverse=_0,g.prototype.toJSON=g.prototype.valueOf=g.prototype.value=x0,g.prototype.first=g.prototype.head,jr&&(g.prototype[jr]=m0),g}),fr=hh();$n?(($n.exports=fr)._=fr,Ii._=fr):gt._=fr}).call(C1)})(Vr,Vr.exports)),Vr.exports}var Sf=N1();const T1=yx(Sf);function R1(i,n){const[r,o]=w.useState(i),u=w.useRef(T1.debounce(o,n)),l=w.useCallback(p=>{u.current(p)},[]);return[r,l]}const k1=()=>{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 A1({devices:i,currentDeviceId:n,onSelectDevice:r,onOpenConfig:o,onConnectWifi:u,onDisconnectWifi:l}){const p=Jr(),[x,d]=w.useState(k1),[m,h]=w.useState(!1),[v,b]=w.useState(""),[S,T]=w.useState("5555"),[L,R]=w.useState(""),[D,G]=w.useState(""),[I,k]=w.useState("direct"),[q,$]=w.useState(""),[X,Y]=w.useState(""),[F,P]=w.useState("5555"),[A,de]=w.useState(""),[ae,H]=w.useState(!1),[V,K]=w.useState([]),[re,ie]=R1(!1,300),[ye,we]=w.useState(""),[se,Le]=w.useState(null),[Me,ge]=w.useState(!1),Be=w.useRef(null);w.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(x))},[x]),w.useEffect(()=>{const M=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.key==="b"&&(Q.preventDefault(),d(!x))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x]);const Ze=()=>{d(!x)},pt=M=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(M)?M.split(".").every(oe=>{const fe=parseInt(oe,10);return fe>=0&&fe<=255}):!1,Ke=M=>{const Q=parseInt(M,10);return!isNaN(Q)&&Q>=1&&Q<=65535},Pe=M=>/^\d{6}$/.test(M),ot=async()=>{R(""),G("");let M=!1;if(pt(v)||(R(p.deviceSidebar.invalidIpError),M=!0),Ke(S)||(G(p.deviceSidebar.invalidPortError),M=!0),!M){H(!0);try{const Q=await Qc({ip:v,port:parseInt(S,10)});Q.success?(h(!1),b(""),T("5555")):R(Q.message||p.toasts.wifiManualConnectError)}catch{R(p.toasts.wifiManualConnectError)}finally{H(!1)}}},ft=async()=>{de(""),R(""),G("");let M=!1;if(pt(v)||(R(p.deviceSidebar.invalidIpError),M=!0),Ke(X)||(G(p.deviceSidebar.invalidPortError),M=!0),Ke(F)||(G(p.deviceSidebar.invalidPortError),M=!0),Pe(q)||(de(p.deviceSidebar.invalidPairingCodeError),M=!0),!M){H(!0);try{const Q=await Nx({ip:v,pairing_port:parseInt(X,10),pairing_code:q,connection_port:parseInt(F,10)});Q.success?(h(!1),b(""),T("5555"),$(""),Y(""),P("5555"),k("direct")):Q.error==="invalid_pairing_code"?de(Q.message):Q.error==="invalid_ip"?R(Q.message):R(Q.message||p.toasts.wifiPairError)}catch{R(p.toasts.wifiPairError)}finally{H(!1)}}},He=w.useCallback(()=>{Be.current!==null&&(clearInterval(Be.current),Be.current=null)},[]),Gt=w.useCallback(M=>{He(),Be.current=window.setInterval(async()=>{try{const Q=await wx(M);Le(xe=>xe?{...xe,status:Q.status}:null),["connected","timeout","error"].includes(Q.status)&&(He(),Q.status==="connected"&&setTimeout(()=>{h(!1),Le(null)},2e3))}catch(Q){console.error("[QR Pairing] Status poll failed:",Q)}},1e3)},[He]),Xe=w.useCallback(async()=>{ge(!0);try{const M=await Ex();M.success&&M.qr_payload&&M.session_id&&(Le({sessionId:M.session_id,payload:M.qr_payload,status:"listening",expiresAt:M.expires_at??Date.now()+12e4}),Gt(M.session_id))}catch(M){console.error("[QR Pairing] Generation failed:",M)}finally{ge(!1)}},[Gt]),at=w.useCallback(async()=>{if(se)try{await Sx(se.sessionId),Le(null),He()}catch(M){console.error("[QR Pairing] Cancel failed:",M)}},[se,He]);w.useEffect(()=>{(!m||I!=="pair")&&(se&&se.status==="listening"&&at(),He())},[m,I,se,He,at]),w.useEffect(()=>()=>{He()},[He]),w.useEffect(()=>{m&&I==="pair"&&!se&&!Me&&Xe()},[m,I,se,Me,Xe]);const ee=w.useCallback(async()=>{ie(!0),we("");try{const M=await Cx();M.success?K(M.devices):(we(M.error||p.deviceSidebar.scanError.replace("{error}","Unknown error")),K([]))}catch(M){we(p.deviceSidebar.scanError.replace("{error}",String(M))),K([])}finally{ie(!1)}},[p.deviceSidebar.scanError,ie]),Z=async(M,Q)=>{if(!Q&&!M.has_pairing){H(!0),R("");try{const xe=await Qc({ip:M.ip,port:M.port});xe.success?h(!1):R(xe.message||p.toasts.wifiManualConnectError)}catch(xe){R(p.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",xe)}finally{H(!1)}}else Q&&M.has_pairing&&(b(M.ip),Y(M.pairing_port?String(M.pairing_port):""),P(String(M.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return w.useEffect(()=>{if(m){ee();const M=setInterval(()=>{ee()},5e3);return()=>{clearInterval(M)}}},[m,ee]),a.jsxs(a.Fragment,{children:[x&&a.jsx(Ae,{variant:"outline",size:"icon",onClick:Ze,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(ha,{className:"h-4 w-4"})}),a.jsxs("div",{className:`
25
+ ${x?"w-0 -ml-4 opacity-0":"w-80 opacity-100"}
26
+ transition-all duration-300 ease-in-out
27
+ h-full min-h-0
28
+ bg-white dark:bg-slate-950
29
+ border-r border-slate-200 dark:border-slate-800
30
+ flex flex-col
31
+ overflow-hidden
32
+ `,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,p.deviceSidebar.devices)]})]})}),a.jsx(Ae,{variant:"ghost",size:"icon",onClick:Ze,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($u,{className:"h-4 w-4"})})]}),a.jsx($r,{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(kv,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:p.deviceSidebar.noDevicesConnected}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:p.deviceSidebar.clickToRefresh})]}):i.map(M=>a.jsx(Xv,{id:M.id,serial:M.serial,model:M.model,status:M.status,connectionType:M.connection_type,agent:M.agent,isActive:n===M.id,onClick:()=>r(M.id),onConnectWifi:async()=>{await u(M.id)},onDisconnectWifi:async()=>{await l(M.id)}},M.id))}),a.jsx($r,{className:"mx-4"}),a.jsxs("div",{className:"p-3 space-y-2",children:[a.jsxs(Ae,{variant:"outline",onClick:()=>h(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(Qx,{className:"h-4 w-4"}),p.deviceSidebar.addDevice]}),a.jsxs(Ae,{variant:"outline",onClick:o,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[a.jsx(Xu,{className:"h-4 w-4"}),p.deviceSidebar.settings]})]}),a.jsx(Uu,{open:m,onOpenChange:h,children:a.jsxs(Wu,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[a.jsxs(Gu,{children:[a.jsx(Hu,{children:p.deviceSidebar.manualConnectTitle}),a.jsx(zu,{children:p.deviceSidebar.manualConnectDescription})]}),a.jsxs(p1,{value:I,onValueChange:k,className:"w-full",children:[a.jsxs(m1,{className:"grid w-full grid-cols-2",children:[a.jsx(ou,{value:"direct",children:p.deviceSidebar.directConnectTab}),a.jsx(ou,{value:"pair",children:p.deviceSidebar.pairTab})]}),a.jsxs(au,{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:p.deviceSidebar.discoveredDevices}),a.jsx(Ae,{variant:"outline",size:"sm",onClick:ee,disabled:re,className:"h-8",children:re?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"}),p.deviceSidebar.scanning]}):p.deviceSidebar.scanAgain})]}),ye&&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:ye})}),(()=>{const M=V.filter(Q=>!Q.has_pairing);return!re&&M.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(ea,{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:p.deviceSidebar.noDirectDevices})]}):M.length>0?a.jsx("div",{className:"space-y-2",children:M.map(Q=>a.jsx("button",{onClick:()=>Z(Q,!1),disabled:ae,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(Zo,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:Q.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[Q.ip,":",Q.port]})]})})},`${Q.ip}:${Q.port}`))}):null})(),L&&I==="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:L})}),a.jsxs("div",{className:"relative my-4",children:[a.jsx($r,{}),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:p.deviceSidebar.orManualConnect})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"rounded-lg bg-amber-50 dark:bg-amber-950/20 p-3 text-sm",children:a.jsx("p",{className:"text-amber-800 dark:text-amber-200",children:p.deviceSidebar.directConnectNote})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"ip",children:p.deviceSidebar.ipAddress}),a.jsx(Jt,{id:"ip",placeholder:"192.168.1.100",value:v,onChange:M=>b(M.target.value),onKeyDown:M=>M.key==="Enter"&&ot(),className:L?"border-red-500":""})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"port",children:p.deviceSidebar.port}),a.jsx(Jt,{id:"port",type:"number",value:S,onChange:M=>T(M.target.value),onKeyDown:M=>M.key==="Enter"&&ot(),className:D?"border-red-500":""}),D&&a.jsx("p",{className:"text-sm text-red-500",children:D})]}),a.jsx(Ae,{onClick:ot,disabled:ae,className:"w-full",children:ae?p.common.loading:p.deviceSidebar.connect})]})]}),a.jsxs(au,{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:p.deviceSidebar.discoveredDevices}),a.jsx(Ae,{variant:"outline",size:"sm",onClick:ee,disabled:re,className:"h-8",children:re?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"}),p.deviceSidebar.scanning]}):p.deviceSidebar.scanAgain})]}),ye&&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:ye})}),(()=>{const M=V.filter(Q=>Q.has_pairing);return!re&&M.length===0?a.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[a.jsx(ea,{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:p.deviceSidebar.noPairingDevices})]}):M.length>0?a.jsx("div",{className:"space-y-2",children:M.map(Q=>a.jsx("button",{onClick:()=>Z(Q,!0),disabled:ae,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(Zo,{className:"h-4 w-4 text-[#1d9bf0]"}),a.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:Q.name})]}),a.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[Q.ip,":",Q.port]}),a.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[a.jsx(tr,{className:"h-3 w-3"}),a.jsx("span",{children:p.deviceSidebar.pairingRequired})]})]})})},`${Q.ip}:${Q.port}`))}):null})(),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"relative my-4",children:[a.jsx($r,{}),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:p.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:p.deviceSidebar.qrPairingTitle}),a.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[a.jsx("li",{children:p.deviceSidebar.qrStep1}),a.jsx("li",{children:p.deviceSidebar.qrStep2}),a.jsx("li",{children:p.deviceSidebar.qrStep3})]})]}),se&&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(Ef,{value:se.payload,size:200,level:"M"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[se.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:p.deviceSidebar.qrWaitingForScan})]}),se.status==="pairing"&&a.jsxs(a.Fragment,{children:[a.jsx(pn,{className:"h-4 w-4 animate-spin text-blue-500"}),a.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:p.deviceSidebar.qrPairing})]}),se.status==="connected"&&a.jsxs(a.Fragment,{children:[a.jsx(hv,{className:"h-4 w-4 text-green-500"}),a.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:p.deviceSidebar.qrConnected})]}),se.status==="timeout"&&a.jsxs(a.Fragment,{children:[a.jsx(ii,{className:"h-4 w-4 text-amber-500"}),a.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:p.deviceSidebar.qrTimeout})]}),se.status==="error"&&a.jsxs(a.Fragment,{children:[a.jsx(ii,{className:"h-4 w-4 text-red-500"}),a.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:p.deviceSidebar.qrError})]})]}),a.jsxs("div",{className:"flex gap-2 w-full",children:[(se.status==="timeout"||se.status==="error")&&a.jsx(Ae,{variant:"outline",onClick:Xe,className:"flex-1",children:p.deviceSidebar.qrRegenerate}),se.status==="listening"&&a.jsx(Ae,{variant:"outline",onClick:at,className:"flex-1",children:p.common.cancel}),se.status==="connected"&&a.jsx(Ae,{onClick:()=>h(!1),className:"flex-1",children:p.common.confirm})]})]})}),!se&&Me&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[a.jsx(pn,{className:"h-4 w-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:p.common.loading})]})]}),a.jsxs("div",{className:"relative my-4",children:[a.jsx($r,{}),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:p.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:p.deviceSidebar.pairingInstructions}),a.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[a.jsx("li",{children:p.deviceSidebar.pairingStep1}),a.jsx("li",{children:p.deviceSidebar.pairingStep2}),a.jsx("li",{children:p.deviceSidebar.pairingStep3}),a.jsx("li",{children:p.deviceSidebar.pairingStep4})]}),a.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:p.deviceSidebar.pairingNote})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"pair-ip",children:p.deviceSidebar.ipAddress}),a.jsx(Jt,{id:"pair-ip",placeholder:"192.168.1.100",value:v,onChange:M=>b(M.target.value),className:L?"border-red-500":""}),L&&I==="pair"&&a.jsx("p",{className:"text-sm text-red-500",children:L})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"pairing-port",children:p.deviceSidebar.pairingPort}),a.jsx(Jt,{id:"pairing-port",type:"number",placeholder:"37831",value:X,onChange:M=>Y(M.target.value),className:D?"border-red-500":""}),D&&a.jsx("p",{className:"text-sm text-red-500",children:D})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"pairing-code",children:p.deviceSidebar.pairingCode}),a.jsx(Jt,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:q,onChange:M=>$(M.target.value.replace(/\D/g,"")),onKeyDown:M=>M.key==="Enter"&&ft(),className:A?"border-red-500":""}),A&&a.jsx("p",{className:"text-sm text-red-500",children:A})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"connection-port",children:p.deviceSidebar.connectionPort}),a.jsx(Jt,{id:"connection-port",type:"number",value:F,onChange:M=>P(M.target.value),onKeyDown:M=>M.key==="Enter"&&ft()})]}),a.jsx(Ae,{onClick:ft,disabled:ae,className:"w-full",children:ae?p.common.loading:p.deviceSidebar.pairAndConnect})]})]})]}),a.jsx(qu,{children:a.jsx(Ae,{variant:"outline",onClick:()=>{h(!1),R(""),G(""),de(""),we(""),b(""),T("5555"),$(""),Y(""),P("5555"),k("direct"),K([])},children:p.common.cancel})})]})})]})]})}const gn=Object.create(null);gn.open="0";gn.close="1";gn.ping="2";gn.pong="3";gn.message="4";gn.upgrade="5";gn.noop="6";const ei=Object.create(null);Object.keys(gn).forEach(i=>{ei[gn[i]]=i});const sa={type:"error",data:"parser error"},Cf=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Nf=typeof ArrayBuffer=="function",Tf=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,ga=({type:i,data:n},r,o)=>Cf&&n instanceof Blob?r?o(n):uu(n,o):Nf&&(n instanceof ArrayBuffer||Tf(n))?r?o(n):uu(new Blob([n]),o):o(gn[i]+(n||"")),uu=(i,n)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];n("b"+(o||""))},r.readAsDataURL(i)};function fu(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let Uo;function P1(i,n){if(Cf&&i.data instanceof Blob)return i.data.arrayBuffer().then(fu).then(n);if(Nf&&(i.data instanceof ArrayBuffer||Tf(i.data)))return n(fu(i.data));ga(i,!1,r=>{Uo||(Uo=new TextEncoder),n(Uo.encode(r))})}const du="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Kr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<du.length;i++)Kr[du.charCodeAt(i)]=i;const j1=i=>{let n=i.length*.75,r=i.length,o,u=0,l,p,x,d;i[i.length-1]==="="&&(n--,i[i.length-2]==="="&&n--);const m=new ArrayBuffer(n),h=new Uint8Array(m);for(o=0;o<r;o+=4)l=Kr[i.charCodeAt(o)],p=Kr[i.charCodeAt(o+1)],x=Kr[i.charCodeAt(o+2)],d=Kr[i.charCodeAt(o+3)],h[u++]=l<<2|p>>4,h[u++]=(p&15)<<4|x>>2,h[u++]=(x&3)<<6|d&63;return m},I1=typeof ArrayBuffer=="function",_a=(i,n)=>{if(typeof i!="string")return{type:"message",data:Rf(i,n)};const r=i.charAt(0);return r==="b"?{type:"message",data:L1(i.substring(1),n)}:ei[r]?i.length>1?{type:ei[r],data:i.substring(1)}:{type:ei[r]}:sa},L1=(i,n)=>{if(I1){const r=j1(i);return Rf(r,n)}else return{base64:!0,data:i}},Rf=(i,n)=>{switch(n){case"blob":return i instanceof Blob?i:new Blob([i]);case"arraybuffer":default:return i instanceof ArrayBuffer?i:i.buffer}},kf="",M1=(i,n)=>{const r=i.length,o=new Array(r);let u=0;i.forEach((l,p)=>{ga(l,!1,x=>{o[p]=x,++u===r&&n(o.join(kf))})})},D1=(i,n)=>{const r=i.split(kf),o=[];for(let u=0;u<r.length;u++){const l=_a(r[u],n);if(o.push(l),l.type==="error")break}return o};function O1(){return new TransformStream({transform(i,n){P1(i,r=>{const o=r.length;let u;if(o<126)u=new Uint8Array(1),new DataView(u.buffer).setUint8(0,o);else if(o<65536){u=new Uint8Array(3);const l=new DataView(u.buffer);l.setUint8(0,126),l.setUint16(1,o)}else{u=new Uint8Array(9);const l=new DataView(u.buffer);l.setUint8(0,127),l.setBigUint64(1,BigInt(o))}i.data&&typeof i.data!="string"&&(u[0]|=128),n.enqueue(u),n.enqueue(r)})}})}let Wo;function Js(i){return i.reduce((n,r)=>n+r.length,0)}function Zs(i,n){if(i[0].length===n)return i.shift();const r=new Uint8Array(n);let o=0;for(let u=0;u<n;u++)r[u]=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 F1(i,n){Wo||(Wo=new TextDecoder);const r=[];let o=0,u=-1,l=!1;return new TransformStream({transform(p,x){for(r.push(p);;){if(o===0){if(Js(r)<1)break;const d=Zs(r,1);l=(d[0]&128)===128,u=d[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(Js(r)<2)break;const d=Zs(r,2);u=new DataView(d.buffer,d.byteOffset,d.length).getUint16(0),o=3}else if(o===2){if(Js(r)<8)break;const d=Zs(r,8),m=new DataView(d.buffer,d.byteOffset,d.length),h=m.getUint32(0);if(h>Math.pow(2,21)-1){x.enqueue(sa);break}u=h*Math.pow(2,32)+m.getUint32(4),o=3}else{if(Js(r)<u)break;const d=Zs(r,u);x.enqueue(_a(l?d:Wo.decode(d),n)),o=0}if(u===0||u>i){x.enqueue(sa);break}}}})}const Af=4;function it(i){if(i)return B1(i)}function B1(i){for(var n in it.prototype)i[n]=it.prototype[n];return i}it.prototype.on=it.prototype.addEventListener=function(i,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(n),this};it.prototype.once=function(i,n){function r(){this.off(i,r),n.apply(this,arguments)}return r.fn=n,this.on(i,r),this};it.prototype.off=it.prototype.removeListener=it.prototype.removeAllListeners=it.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,u=0;u<r.length;u++)if(o=r[u],o===n||o.fn===n){r.splice(u,1);break}return r.length===0&&delete this._callbacks["$"+i],this};it.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,u=r.length;o<u;++o)r[o].apply(this,n)}return this};it.prototype.emitReserved=it.prototype.emit;it.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};it.prototype.hasListeners=function(i){return!!this.listeners(i).length};const di=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,r)=>r(n,0),Zt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),U1="arraybuffer";function Pf(i,...n){return n.reduce((r,o)=>(i.hasOwnProperty(o)&&(r[o]=i[o]),r),{})}const W1=Zt.setTimeout,G1=Zt.clearTimeout;function hi(i,n){n.useNativeTimers?(i.setTimeoutFn=W1.bind(Zt),i.clearTimeoutFn=G1.bind(Zt)):(i.setTimeoutFn=Zt.setTimeout.bind(Zt),i.clearTimeoutFn=Zt.clearTimeout.bind(Zt))}const H1=1.33;function z1(i){return typeof i=="string"?q1(i):Math.ceil((i.byteLength||i.size)*H1)}function q1(i){let n=0,r=0;for(let o=0,u=i.length;o<u;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 jf(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function $1(i){let n="";for(let r in i)i.hasOwnProperty(r)&&(n.length&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(i[r]));return n}function X1(i){let n={},r=i.split("&");for(let o=0,u=r.length;o<u;o++){let l=r[o].split("=");n[decodeURIComponent(l[0])]=decodeURIComponent(l[1])}return n}class Y1 extends Error{constructor(n,r,o){super(n),this.description=r,this.context=o,this.type="TransportError"}}class xa extends it{constructor(n){super(),this.writable=!1,hi(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 Y1(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=_a(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=$1(n);return r.length?"?"+r:""}}class V1 extends xa{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)};D1(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,M1(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]=jf()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let If=!1;try{If=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const K1=If;function Q1(){}class J1 extends V1{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",(u,l)=>{this.onError("xhr post error",u,l)})}doPoll(){const n=this.request();n.on("data",this.onData.bind(this)),n.on("error",(r,o)=>{this.onError("xhr poll error",r,o)}),this.pollXhr=n}}class mn extends it{constructor(n,r,o){super(),this.createRequest=n,hi(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=Pf(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 u in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(u)&&o.setRequestHeader(u,this._opts.extraHeaders[u])}}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 u;o.readyState===3&&((u=this._opts.cookieJar)===null||u===void 0||u.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(u){this.setTimeoutFn(()=>{this._onError(u)},0);return}typeof document<"u"&&(this._index=mn.requestsCount++,mn.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=Q1,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete mn.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()}}mn.requestsCount=0;mn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",hu);else if(typeof addEventListener=="function"){const i="onpagehide"in Zt?"pagehide":"unload";addEventListener(i,hu,!1)}}function hu(){for(let i in mn.requests)mn.requests.hasOwnProperty(i)&&mn.requests[i].abort()}const Z1=(function(){const i=Lf({xdomain:!1});return i&&i.responseType!==null})();class eb extends J1{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=Z1&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new mn(Lf,this.uri(),n)}}function Lf(i){const n=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||K1))return new XMLHttpRequest}catch{}if(!n)try{return new Zt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Mf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class tb extends xa{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,o=Mf?{}:Pf(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(u){return this.emitReserved("error",u)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=n=>this.onClose({description:"websocket connection closed",context:n}),this.ws.onmessage=n=>this.onData(n.data),this.ws.onerror=n=>this.onError("websocket error",n)}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const o=n[r],u=r===n.length-1;ga(o,this.supportsBinary,l=>{try{this.doWrite(o,l)}catch{}u&&di(()=>{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]=jf()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const Go=Zt.WebSocket||Zt.MozWebSocket;class nb extends tb{createSocket(n,r,o){return Mf?new Go(n,r,o):r?new Go(n,r):new Go(n)}doWrite(n,r){this.ws.send(r)}}class rb extends xa{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=F1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=n.readable.pipeThrough(r).getReader(),u=O1();u.readable.pipeTo(n.writable),this._writer=u.writable.getWriter();const l=()=>{o.read().then(({done:x,value:d})=>{x||(this.onPacket(d),l())}).catch(x=>{})};l();const p={type:"open"};this.query.sid&&(p.data=`{"sid":"${this.query.sid}"}`),this._writer.write(p).then(()=>this.onOpen())})})}write(n){this.writable=!1;for(let r=0;r<n.length;r++){const o=n[r],u=r===n.length-1;this._writer.write(o).then(()=>{u&&di(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const sb={websocket:nb,webtransport:rb,polling:eb},ib=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ob=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ia(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 u=ib.exec(i||""),l={},p=14;for(;p--;)l[ob[p]]=u[p]||"";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=ab(l,l.path),l.queryKey=lb(l,l.query),l}function ab(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 lb(i,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,l){u&&(r[u]=l)}),r}const oa=typeof addEventListener=="function"&&typeof removeEventListener=="function",ti=[];oa&&addEventListener("offline",()=>{ti.forEach(i=>i())},!1);class Gn extends it{constructor(n,r){if(super(),this.binaryType=U1,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=ia(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=ia(r.host).host);hi(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 u=o.prototype.name;this.transports.push(u),this._transportsByName[u]=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=X1(this.opts.query)),oa&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ti.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(n){const r=Object.assign({},this.opts.query);r.EIO=Af,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&&Gn.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",Gn.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 u=this.writeBuffer[o].data;if(u&&(r+=z1(u)),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,di(()=>{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,u){if(typeof r=="function"&&(u=r,r=void 0),typeof o=="function"&&(u=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),u&&this.once("flush",u),this.flush()}close(){const n=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),n()},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(Gn.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(),oa&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=ti.indexOf(this._offlineEventListener);o!==-1&&ti.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}Gn.protocol=Af;class cb extends Gn{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;Gn.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",v=>{if(!o)if(v.type==="pong"&&v.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Gn.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(h(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const b=new Error("probe error");b.transport=r.name,this.emitReserved("upgradeError",b)}}))};function l(){o||(o=!0,h(),r.close(),r=null)}const p=v=>{const b=new Error("probe error: "+v);b.transport=r.name,l(),this.emitReserved("upgradeError",b)};function x(){p("transport closed")}function d(){p("socket closed")}function m(v){r&&v.name!==r.name&&l()}const h=()=>{r.removeListener("open",u),r.removeListener("error",p),r.removeListener("close",x),this.off("close",d),this.off("upgrading",m)};r.once("open",u),r.once("error",p),r.once("close",x),this.once("close",d),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 ub=class extends cb{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(u=>sb[u]).filter(u=>!!u)),super(n,o)}};function fb(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=ia(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 db=typeof ArrayBuffer=="function",hb=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Df=Object.prototype.toString,pb=typeof Blob=="function"||typeof Blob<"u"&&Df.call(Blob)==="[object BlobConstructor]",mb=typeof File=="function"||typeof File<"u"&&Df.call(File)==="[object FileConstructor]";function va(i){return db&&(i instanceof ArrayBuffer||hb(i))||pb&&i instanceof Blob||mb&&i instanceof File}function ni(i,n){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let r=0,o=i.length;r<o;r++)if(ni(i[r]))return!0;return!1}if(va(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return ni(i.toJSON(),!0);for(const r in i)if(Object.prototype.hasOwnProperty.call(i,r)&&ni(i[r]))return!0;return!1}function gb(i){const n=[],r=i.data,o=i;return o.data=aa(r,n),o.attachments=n.length,{packet:o,buffers:n}}function aa(i,n){if(!i)return i;if(va(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]=aa(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]=aa(i[o],n));return r}return i}function _b(i,n){return i.data=la(i.data,n),delete i.attachments,i}function la(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]=la(i[r],n);else if(typeof i=="object")for(const r in i)Object.prototype.hasOwnProperty.call(i,r)&&(i[r]=la(i[r],n));return i}const xb=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],vb=5;var ke;(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"})(ke||(ke={}));class bb{constructor(n){this.replacer=n}encode(n){return(n.type===ke.EVENT||n.type===ke.ACK)&&ni(n)?this.encodeAsBinary({type:n.type===ke.EVENT?ke.BINARY_EVENT:ke.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let r=""+n.type;return(n.type===ke.BINARY_EVENT||n.type===ke.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=gb(n),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function pu(i){return Object.prototype.toString.call(i)==="[object Object]"}class ba extends it{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===ke.BINARY_EVENT;o||r.type===ke.BINARY_ACK?(r.type=o?ke.EVENT:ke.ACK,this.reconstructor=new yb(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(va(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(ke[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===ke.BINARY_EVENT||o.type===ke.BINARY_ACK){const l=r+1;for(;n.charAt(++r)!=="-"&&r!=n.length;);const p=n.substring(l,r);if(p!=Number(p)||n.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(p)}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 u=n.charAt(r+1);if(u!==""&&Number(u)==u){const l=r+1;for(;++r;){const p=n.charAt(r);if(p==null||Number(p)!=p){--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(ba.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 ke.CONNECT:return pu(r);case ke.DISCONNECT:return r===void 0;case ke.CONNECT_ERROR:return typeof r=="string"||pu(r);case ke.EVENT:case ke.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&xb.indexOf(r[0])===-1);case ke.ACK:case ke.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class yb{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=_b(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const wb=Object.freeze(Object.defineProperty({__proto__:null,Decoder:ba,Encoder:bb,get PacketType(){return ke},protocol:vb},Symbol.toStringTag,{value:"Module"}));function ln(i,n,r){return i.on(n,r),function(){i.off(n,r)}}const Eb=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Of extends it{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=[ln(n,"open",this.onopen.bind(this)),ln(n,"packet",this.onpacket.bind(this)),ln(n,"error",this.onerror.bind(this)),ln(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,u,l;if(Eb.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 p={type:ke.EVENT,data:r};if(p.options={},p.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const h=this.ids++,v=r.pop();this._registerAckCallback(h,v),p.id=h}const x=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,d=this.connected&&!(!((l=this.io.engine)===null||l===void 0)&&l._hasPingExpired());return this.flags.volatile&&!x||(d?(this.notifyOutgoingListeners(p),this.packet(p)):this.sendBuffer.push(p)),this.flags={},this}_registerAckCallback(n,r){var o;const u=(o=this.flags.timeout)!==null&&o!==void 0?o:this._opts.ackTimeout;if(u===void 0){this.acks[n]=r;return}const l=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let x=0;x<this.sendBuffer.length;x++)this.sendBuffer[x].id===n&&this.sendBuffer.splice(x,1);r.call(this,new Error("operation has timed out"))},u),p=(...x)=>{this.io.clearTimeoutFn(l),r.apply(this,x)};p.withError=!0,this.acks[n]=p}emitWithAck(n,...r){return new Promise((o,u)=>{const l=(p,x)=>p?u(p):o(x);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((u,...l)=>o!==this._queue[0]?void 0:(u!==null?o.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(u)):(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:ke.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 ke.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 ke.EVENT:case ke.BINARY_EVENT:this.onevent(n);break;case ke.ACK:case ke.BINARY_ACK:this.onack(n);break;case ke.DISCONNECT:this.ondisconnect();break;case ke.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(...u){o||(o=!0,r.packet({type:ke.ACK,id:n,data:u}))}}onack(n){const r=this.acks[n.id];typeof r=="function"&&(delete this.acks[n.id],r.withError&&n.data.unshift(null),r.apply(this,n.data))}onconnect(n,r){this.id=n,this.recovered=r&&this._pid===r,this._pid=r,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(n=>this.emitEvent(n)),this.receiveBuffer=[],this.sendBuffer.forEach(n=>{this.notifyOutgoingListeners(n),this.packet(n)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(n=>n()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ke.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 Cr(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}Cr.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};Cr.prototype.reset=function(){this.attempts=0};Cr.prototype.setMin=function(i){this.ms=i};Cr.prototype.setMax=function(i){this.max=i};Cr.prototype.setJitter=function(i){this.jitter=i};class ca extends it{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,hi(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 Cr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=n;const u=r.parser||wb;this.encoder=new u.Encoder,this.decoder=new u.Decoder,this._autoConnect=r.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(n){return arguments.length?(this._reconnection=!!n,n||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(n){return n===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=n,this)}reconnectionDelay(n){var r;return n===void 0?this._reconnectionDelay:(this._reconnectionDelay=n,(r=this.backoff)===null||r===void 0||r.setMin(n),this)}randomizationFactor(n){var r;return n===void 0?this._randomizationFactor:(this._randomizationFactor=n,(r=this.backoff)===null||r===void 0||r.setJitter(n),this)}reconnectionDelayMax(n){var r;return n===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=n,(r=this.backoff)===null||r===void 0||r.setMax(n),this)}timeout(n){return arguments.length?(this._timeout=n,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(n){if(~this._readyState.indexOf("open"))return this;this.engine=new ub(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=ln(r,"open",function(){o.onopen(),n&&n()}),l=x=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",x),n?n(x):this.maybeReconnectOnOpen()},p=ln(r,"error",l);if(this._timeout!==!1){const x=this._timeout,d=this.setTimeoutFn(()=>{u(),l(new Error("timeout")),r.close()},x);this.opts.autoUnref&&d.unref(),this.subs.push(()=>{this.clearTimeoutFn(d)})}return this.subs.push(u),this.subs.push(p),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(ln(n,"ping",this.onping.bind(this)),ln(n,"data",this.ondata.bind(this)),ln(n,"error",this.onerror.bind(this)),ln(n,"close",this.onclose.bind(this)),ln(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){di(()=>{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 Of(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(u=>{u?(n._reconnecting=!1,n.reconnect(),this.emitReserved("reconnect_error",u)):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 Xr={};function ri(i,n){typeof i=="object"&&(n=i,i=void 0),n=n||{};const r=fb(i,n.path||"/socket.io"),o=r.source,u=r.id,l=r.path,p=Xr[u]&&l in Xr[u].nsps,x=n.forceNew||n["force new connection"]||n.multiplex===!1||p;let d;return x?d=new ca(o,n):(Xr[u]||(Xr[u]=new ca(o,n)),d=Xr[u]),r.query&&!n.query&&(n.query=r.queryKey),d.socket(r.path,n)}Object.assign(ri,{Manager:ca,Socket:Of,io:ri,connect:ri});function Sb(i,n){return(i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24)>>>0}const si={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:Cb}=globalThis;class Nb{#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 Tb={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},Rb={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},kb={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},Ab={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 bt extends Nb{static ObuType=Tb;static ColorPrimaries=Rb;static TransferCharacteristics=kb;static MatrixCoefficients=Ab;#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 u=this.getPosition();if(r.obu_type!==bt.ObuType.SequenceHeader&&r.obu_type!==bt.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const d=!!(this.#t&1<<r.obu_extension_header.temporal_id),m=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!d||!m){this.skip(Number(o));return}}let l;switch(r.obu_type){case bt.ObuType.SequenceHeader:l=this.sequenceHeaderObu();break}const p=this.getPosition(),x=(p[0]-u[0])*8+(u[1]-p[1]);return o>0&&this.skip(Number(o)*8-x),{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(),u=!!this.f1();this.f1();let l;return o&&(l=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:o,obu_has_size_field:u,obu_extension_header:l}}obuExtensionHeader(){const n=this.f(3),r=this.f(2);return this.skip(3),{temporal_id:n,spatial_id:r}}static SelectScreenContentTools=2;static SelectIntegerMv=2;sequenceHeaderObu(){const n=this.f(3),r=!!this.f1(),o=!!this.f1();let u=!1,l,p=!1,x,d=!1,m=0;const h=[],v=[],b=[],S=[],T=[];let L,R;if(o)h[0]=0,v[0]=this.f(5),b[0]=0,S[0]=!1,T[0]=!1;else{u=!!this.f1(),u&&(l=this.timingInfo(),p=!!this.f1(),p&&(x=this.decoderModelInfo(),L=[])),d=!!this.f1(),d&&(R=[]),m=this.f(5);for(let Pe=0;Pe<=m;Pe+=1)h[Pe]=this.f(12),v[Pe]=this.f(5),v[Pe]>7?b[Pe]=this.f1():b[Pe]=0,p?(S[Pe]=!!this.f1(),S[Pe]&&(L[Pe]=this.operatingParametersInfo(x))):S[Pe]=!1,d&&(T[Pe]=!!this.f1(),T[Pe]&&(R[Pe]=this.f(4)))}const D=this.chooseOperatingPoint();this.#t=h[D];const G=this.f(4),I=this.f(4),k=this.f(G+1),q=this.f(I+1);let $=!1,X,Y;o||($=!!this.f1(),$&&(X=this.f(4),Y=this.f(3)));const F=!!this.f1(),P=!!this.f1(),A=!!this.f1();let de=!1,ae=!1,H=!1,V=!1,K=!1,re=!1,ie=!1,ye=!1,we=bt.SelectScreenContentTools,se=!1,Le=bt.SelectIntegerMv,Me;o||(de=!!this.f1(),ae=!!this.f1(),H=!!this.f1(),V=!!this.f1(),K=!!this.f1(),K&&(re=!!this.f1(),ie=!!this.f1()),ye=!!this.f1(),ye||(we=this.f1()),we>0&&(se=!!this.f1(),se||(Le=this.f1())),K&&(Me=this.f(3)));const ge=!!this.f1(),Be=!!this.f1(),Ze=!!this.f1(),pt=this.colorConfig(n),Ke=!!this.f1();return{seq_profile:n,still_picture:r,reduced_still_picture_header:o,timing_info_present_flag:u,timing_info:l,decoder_model_info_present_flag:p,decoder_model_info:x,initial_display_delay_present_flag:d,initial_display_delay_minus_1:R,operating_points_cnt_minus_1:m,operating_point_idc:h,seq_level_idx:v,seq_tier:b,decoder_model_present_for_this_op:S,operating_parameters_info:L,initial_display_delay_present_for_this_op:T,frame_width_bits_minus_1:G,frame_height_bits_minus_1:I,max_frame_width_minus_1:k,max_frame_height_minus_1:q,frame_id_numbers_present_flag:$,delta_frame_id_length_minus_2:X,additional_frame_id_length_minus_1:Y,use_128x128_superblock:F,enable_filter_intra:P,enable_intra_edge_filter:A,enable_interintra_compound:de,enable_masked_compound:ae,enable_warped_motion:H,enable_dual_filter:V,enable_order_hint:K,enable_jnt_comp:re,enable_ref_frame_mvs:ie,seq_choose_screen_content_tools:ye,seq_force_screen_content_tools:we,seq_choose_integer_mv:se,seq_force_integer_mv:Le,order_hint_bits_minus_1:Me,enable_superres:ge,enable_cdef:Be,enable_restoration:Ze,color_config:pt,film_grain_params_present:Ke}}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 u;return o&&(u=this.uvlc()),{num_units_in_display_tick:n,time_scale:r,equal_picture_interval:o,num_ticks_per_picture_minus_1:u}}decoderModelInfo(){const n=this.f(5),r=this.f(32),o=this.f(5),u=this.f(5);return{buffer_delay_length_minus_1:n,num_units_in_decoding_tick:r,buffer_removal_time_length_minus_1:o,frame_presentation_time_length_minus_1:u}}operatingParametersInfo(n){const r=n.buffer_delay_length_minus_1+1,o=this.f(r),u=this.f(r),l=!!this.f1();return{decoder_buffer_delay:o,encoder_buffer_delay:u,low_delay_mode_flag:l}}chooseOperatingPoint(){return 0}colorConfig(n){const r=!!this.f1();let o=!1,u=8;n===2&&r?(o=!!this.f1(),u=o?12:10):n<=2&&(u=r?10:8);let l=!1;n===1&&(l=!!this.f1());const p=!!this.f1();let x=bt.ColorPrimaries.Unspecified,d=bt.TransferCharacteristics.Unspecified,m=bt.MatrixCoefficients.Unspecified;p&&(x=this.f(8),d=this.f(8),m=this.f(8));let h=!1,v,b,S=0,T=!1;if(l)h=!!this.f1(),v=!0,b=!0;else{if(x===bt.ColorPrimaries.Bt709&&d===bt.TransferCharacteristics.Srgb&&m===bt.MatrixCoefficients.Identity)h=!0,v=!1,b=!1;else{switch(h=!!this.f1(),n){case 0:v=!0,b=!0;break;case 1:v=!1,b=!1;break;default:u==12?(v=!!this.f1(),v?b=!!this.f1():b=!1):(v=!0,b=!1);break}v&&b&&(S=this.f(2))}T=!!this.f1()}return{high_bitdepth:r,twelve_bit:o,BitDepth:u,mono_chrome:l,color_description_present_flag:p,color_primaries:x,transfer_characteristics:d,matrix_coefficients:m,color_range:h,subsampling_x:v,subsampling_y:b,chroma_sample_position:S,separate_uv_delta_q:T}}}function*Ff(i){let n=-1,r=0,o=!1;for(let u=0;u<i.length;u+=1){const l=i[u];if(o){if(l>3)throw new Error("Invalid data");o=!1;continue}if(l===0){r+=1;continue}const p=r;if(r=0,n===-1){if(p>=2&&l===1){n=u+1;continue}throw new Error("Invalid data")}if(!(p<2)){if(l===1){yield i.subarray(n,u-p),n=u+1;continue}if(p>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 pi{#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 u=0;u<8;u+=1)if((o>>u&1)===1){this.#t=r,this.#n=u,this.#l();return}}throw new Error("Stop bit not found")}#l(){if(this.#o=this.#e[this.#i],this.#r===2&&this.#o===3){this.#r=0,this.#i+=1,this.#l();return}this.#o===0?this.#r+=1:this.#r=0}next(){if(this.ended)throw new Error("Bit index out of bounds");const n=this.#o>>this.#s&1;return this.#s-=1,this.#s<0&&(this.#i+=1,this.#s=7,this.#l()),n}read(n){if(n>32)throw new Error("Read length too large");let r=0;for(let 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}#f(){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.#f(),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.#f(),o=this.readBytes(n);return this.#a(r),o}}function Pb(i){const n=new pi(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 u=n.read(8),l=n.peek(8),p=!!n.next(),x=!!n.next(),d=!!n.next(),m=!!n.next(),h=!!n.next(),v=!!n.next();if(n.read(2)!==0)throw new Error("Invalid data");const b=n.read(8),S=n.decodeExponentialGolombNumber();if(u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128||u===138||u===139||u===134){const X=n.decodeExponentialGolombNumber();if(X===3&&n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber(),n.next(),!!n.next())for(let F=0;F<(X!==3?8:12);F+=1)n.next()}n.decodeExponentialGolombNumber();const T=n.decodeExponentialGolombNumber();if(T===0)n.decodeExponentialGolombNumber();else if(T===1){n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber();const X=n.decodeExponentialGolombNumber();for(let Y=0;Y<X;Y+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const L=n.decodeExponentialGolombNumber(),R=n.decodeExponentialGolombNumber(),D=n.next();D||n.next(),n.next();const G=!!n.next();let I,k,q,$;return G?(I=n.decodeExponentialGolombNumber(),k=n.decodeExponentialGolombNumber(),q=n.decodeExponentialGolombNumber(),$=n.decodeExponentialGolombNumber()):(I=0,k=0,q=0,$=0),n.next(),{profile_idc:u,constraint_set:l,constraint_set0_flag:p,constraint_set1_flag:x,constraint_set2_flag:d,constraint_set3_flag:m,constraint_set4_flag:h,constraint_set5_flag:v,level_idc:b,seq_parameter_set_id:S,pic_width_in_mbs_minus1:L,pic_height_in_map_units_minus1:R,frame_mbs_only_flag:D,frame_cropping_flag:G,frame_crop_left_offset:I,frame_crop_right_offset:k,frame_crop_top_offset:q,frame_crop_bottom_offset:$}}function jb(i){let n,r;for(const o of Ff(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 Ib(i){const{sequenceParameterSet:n,pictureParameterSet:r}=jb(i),{profile_idc:o,constraint_set:u,level_idc:l,pic_width_in_mbs_minus1:p,pic_height_in_map_units_minus1:x,frame_mbs_only_flag:d,frame_crop_left_offset:m,frame_crop_right_offset:h,frame_crop_top_offset:v,frame_crop_bottom_offset:b}=Pb(n),S=(p+1)*16,T=(x+1)*(2-d)*16,L=m*2,R=h*2,D=v*2,G=b*2,I=S-L-R,k=T-D-G;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:u,levelIndex:l,encodedWidth:S,encodedHeight:T,cropLeft:L,cropRight:R,cropTop:D,cropBottom:G,croppedWidth:I,croppedHeight:k}}function Lb(i){switch(i){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function Mb(i){switch(i){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function Db(i){const n=new pi(i);if(n.next()!==0)throw new Error("Invalid NALU header");const r=n.read(6),o=n.read(6),u=n.read(3);return{nal_unit_type:r,nuh_layer_id:o,nuh_temporal_id_plus1:u}}function Ob(i){const n=new pi(i),r=n.read(4),o=!!n.next(),u=!!n.next(),l=n.read(6),p=n.read(3),x=!!n.next();n.skip(16);const d=Bf(n,!0,p),m=!!n.next(),h=[],v=[],b=[];for(let P=m?0:p;P<=p;P+=1)h[P]=n.decodeExponentialGolombNumber(),v[P]=n.decodeExponentialGolombNumber(),b[P]=n.decodeExponentialGolombNumber();const S=n.read(6),T=n.decodeExponentialGolombNumber(),L=[];for(let P=1;P<=T;P+=1){L[P]=[];for(let A=0;A<=S;A+=1)L[P][A]=!!n.next()}const R=!!n.next();let D,G,I,k,q,$,X,Y;if(R){D=n.read(32),G=n.read(32),I=!!n.next(),I&&(k=n.decodeExponentialGolombNumber()),q=n.decodeExponentialGolombNumber(),$=[],X=[!0],Y=[];for(let P=0;P<q;P+=1)$[P]=n.decodeExponentialGolombNumber(),P>0&&(X[P]=!!n.next()),Y[P]=Uf(n,X[P],p)}const F=!!n.next();return{vps_video_parameter_set_id:r,vps_base_layer_internal_flag:o,vps_base_layer_available_flag:u,vps_max_layers_minus1:l,vps_max_sub_layers_minus1:p,vps_temporal_id_nesting_flag:x,profileTierLevel:d,vps_sub_layer_ordering_info_present_flag:m,vps_max_dec_pic_buffering_minus1:h,vps_max_num_reorder_pics:v,vps_max_latency_increase_plus1:b,vps_max_layer_id:S,vps_num_layer_sets_minus1:T,layer_id_included_flag:L,vps_timing_info_present_flag:R,vps_num_units_in_tick:D,vps_time_scale:G,vps_poc_proportional_to_timing_flag:I,vps_num_ticks_poc_diff_one_minus1:k,vps_num_hrd_parameters:q,hrd_layer_set_idx:$,cprms_present_flag:X,hrdParameters:Y,vps_extension_flag:F}}function Fb(i){const n=new pi(i),r=n.read(4),o=n.read(3),u=!!n.next(),l=Bf(n,!0,o),p=n.decodeExponentialGolombNumber(),x=n.decodeExponentialGolombNumber();let d;x===3&&(d=!!n.next());const m=n.decodeExponentialGolombNumber(),h=n.decodeExponentialGolombNumber(),v=!!n.next();let b,S,T,L;v&&(b=n.decodeExponentialGolombNumber(),S=n.decodeExponentialGolombNumber(),T=n.decodeExponentialGolombNumber(),L=n.decodeExponentialGolombNumber());const R=n.decodeExponentialGolombNumber(),D=n.decodeExponentialGolombNumber(),G=n.decodeExponentialGolombNumber(),I=[],k=[],q=[],$=!!n.next();for(let ve=$?0:o;ve<=o;ve+=1)I[ve]=n.decodeExponentialGolombNumber(),k[ve]=n.decodeExponentialGolombNumber(),q[ve]=n.decodeExponentialGolombNumber();const X=n.decodeExponentialGolombNumber(),Y=n.decodeExponentialGolombNumber(),F=n.decodeExponentialGolombNumber(),P=n.decodeExponentialGolombNumber(),A=n.decodeExponentialGolombNumber(),de=n.decodeExponentialGolombNumber(),ae=!!n.next();let H,V;ae&&(H=!!n.next(),H&&(V=Bb(n)));const K=!!n.next(),re=!!n.next(),ie=!!n.next();let ye,we,se,Le,Me;ie&&(ye=n.read(4),we=n.read(4),se=n.read(4),Le=n.read(4),Me=!!n.next());const ge=n.decodeExponentialGolombNumber(),Be=[];for(let ve=0;ve<ge;ve+=1)Be[ve]=Ub(n,ve,ge,Be);const Ze=!!n.next();let pt,Ke,Pe;if(Ze){pt=n.decodeExponentialGolombNumber(),Ke=[],Pe=[];for(let ve=0;ve<pt;ve+=1)Ke[ve]=n.read(G+4),Pe[ve]=!!n.next()}const ot=!!n.next(),ft=!!n.next(),He=!!n.next();let Gt;He&&(Gt=Wb(n,o));const Xe=!!n.next();let at,ee,Z,M,Q;if(Xe&&(at=!!n.next(),ee=!!n.next(),Z=!!n.next(),M=!!n.next(),Q=n.read(4)),at)throw new Error("Not implemented");let xe;ee&&(xe=Hb(n));let oe;if(Z&&(oe=zb(n)),M)throw new Error("Not implemented");let fe;if(Q){fe=[];let ve=0;for(;!n.ended;)fe[ve]=!!n.next(),ve+=1}return{sps_video_parameter_set_id:r,sps_max_sub_layers_minus1:o,sps_temporal_id_nesting_flag:u,profileTierLevel:l,sps_seq_parameter_set_id:p,chroma_format_idc:x,separate_colour_plane_flag:d,pic_width_in_luma_samples:m,pic_height_in_luma_samples:h,conformance_window_flag:v,conf_win_left_offset:b,conf_win_right_offset:S,conf_win_top_offset:T,conf_win_bottom_offset:L,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:D,log2_max_pic_order_cnt_lsb_minus4:G,sps_sub_layer_ordering_info_present_flag:$,sps_max_dec_pic_buffering_minus1:I,sps_max_num_reorder_pics:k,sps_max_latency_increase_plus1:q,log2_min_luma_coding_block_size_minus3:X,log2_diff_max_min_luma_coding_block_size:Y,log2_min_luma_transform_block_size_minus2:F,log2_diff_max_min_luma_transform_block_size:P,max_transform_hierarchy_depth_inter:A,max_transform_hierarchy_depth_intra:de,scaling_list_enabled_flag:ae,sps_scaling_list_data_present_flag:H,scalingListData:V,amp_enabled_flag:K,sample_adaptive_offset_enabled_flag:re,pcm_enabled_flag:ie,pcm_sample_bit_depth_luma_minus1:ye,pcm_sample_bit_depth_chroma_minus1:we,log2_min_pcm_luma_coding_block_size_minus3:se,log2_diff_max_min_pcm_luma_coding_block_size:Le,pcm_loop_filter_disabled_flag:Me,num_short_term_ref_pic_sets:ge,shortTermRefPicSets:Be,long_term_ref_pics_present_flag:Ze,num_long_term_ref_pics_sps:pt,lt_ref_pic_poc_lsb_sps:Ke,used_by_curr_pic_lt_sps_flag:Pe,sps_temporal_mvp_enabled_flag:ot,strong_intra_smoothing_enabled_flag:ft,vui_parameters_present_flag:He,vuiParameters:Gt,sps_extension_present_flag:Xe,sps_range_extension_flag:at,sps_multilayer_extension_flag:ee,sps_3d_extension_flag:Z,sps_scc_extension_flag:M,sps_extension_4bits:Q,spsMultilayerExtension:xe,sps3dExtension:oe,sps_extension_data_flag:fe}}function mu(i){const n=i.read(2),r=!!i.next(),o=i.read(5),u=i.peekBytes(4),l=[];for(let $=0;$<32;$+=1)l[$]=!!i.next();const p=i.peekBytes(6),x=!!i.next(),d=!!i.next(),m=!!i.next(),h=!!i.next();let v,b,S,T,L,R,D,G,I,k;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]?(v=!!i.next(),b=!!i.next(),S=!!i.next(),T=!!i.next(),L=!!i.next(),R=!!i.next(),D=!!i.next(),G=!!i.next(),I=!!i.next(),o===5||l[5]||o===9||l[9]||o===10||l[10]||o===11||l[11]?(k=!!i.next(),i.skip(33)):i.skip(34)):o===2||l[2]?(i.skip(7),G=!!i.next(),i.skip(35)):i.skip(43);let q;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]?q=!!i.next():i.skip(1),{profile_space:n,tier_flag:r,profile_idc:o,profileCompatibilitySet:u,profile_compatibility_flag:l,constraintSet:p,progressive_source_flag:x,interlaced_source_flag:d,non_packed_constraint_flag:m,frame_only_constraint_flag:h,max_12bit_constraint_flag:v,max_10bit_constraint_flag:b,max_8bit_constraint_flag:S,max_422chroma_constraint_flag:T,max_420chroma_constraint_flag:L,max_monochrome_constraint_flag:R,intra_constraint_flag:D,one_picture_only_constraint_flag:G,lower_bit_rate_constraint_flag:I,max_14bit_constraint_flag:k,inbld_flag:q}}function Bf(i,n,r){let o;o=mu(i);const u=i.read(8),l=[],p=[];for(let m=0;m<r;m+=1)l[m]=!!i.next(),p[m]=!!i.next();if(r>0)for(let m=r;m<8;m+=1)i.read(2);const x=[],d=[];for(let m=0;m<r;m+=1)l[m]&&(x[m]=mu(i)),p[m]&&(d[m]=i.read(8));return{generalProfileTier:o,general_level_idc:u,sub_layer_profile_present_flag:l,sub_layer_level_present_flag:p,subLayerProfileTier:x,sub_layer_level_idc:d}}function Bb(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 p=Math.min(64,1<<4+(r<<1));r>1&&(l=i.decodeExponentialGolombNumber()+8),n[r][o]=[];for(let x=0;x<p;x+=1){const d=i.decodeExponentialGolombNumber();l=(l+d+256)%256,n[r][o][x]=l}}}return n}function Ub(i,n,r,o){let u=!1;n!==0&&(u=!!i.next());let l=0,p=!1,x=0;const d=[],m=[];let h=0,v=0;const b=[],S=[],T=[],L=[];if(u){n===r&&(l=i.decodeExponentialGolombNumber()),p=!!i.next(),x=i.decodeExponentialGolombNumber();const R=n-(l+1),D=o[R],G=D.num_negative_pics+D.num_positive_pics;for(let A=0;A<=G;A+=1)d[A]=!!i.next(),d[A]?m[A]=!0:m[A]=!!i.next();const I=(1-2*Number(p))*(x+1),k=[],q=[],$=[],X=[];let Y=0;for(let A=0;A<D.num_negative_pics;A+=1)Y-=D.delta_poc_s0_minus1[A]+1,k[A]=Y;Y=0;for(let A=0;A<D.num_positive_pics;A+=1)Y+=D.delta_poc_s1_minus1[A]+1,q[A]=Y;let F=0;if(D.num_positive_pics>0)for(let A=D.num_positive_pics-1;A>=0;A-=1)Y=q[A]+I,Y<0&&m[D.num_negative_pics+A]&&($[F]=Y,S[F]=d[D.num_negative_pics+A],F+=1);I<0&&m[G]&&($[F]=I,S[F]=d[G],F+=1);for(let A=0;A<D.num_negative_pics;A+=1)Y=k[A]+I,Y<0&&m[A]&&($[F]=Y,S[F]=d[A],F+=1);h=F;let P=0;for(F=0;F<h;F+=1){const A=$[F];b[F]=-(A-P-1),P=A}if(F=0,D.num_negative_pics>0)for(let A=D.num_negative_pics-1;A>=0;A-=1)Y=k[A]+I,Y>0&&m[A]&&(X[F]=Y,L[F]=d[A],F+=1);I>0&&m[G]&&(X[F]=I,L[F]=d[G],F+=1);for(let A=0;A<D.num_positive_pics;A+=1)Y=q[A]+I,Y>0&&m[D.num_negative_pics+A]&&(X[F]=Y,L[F]=d[D.num_negative_pics+A],F+=1);for(v=F,P=0,F=0;F<v;F+=1){const A=X[F];T[F]=A-P-1,P=A}}else{h=i.decodeExponentialGolombNumber(),v=i.decodeExponentialGolombNumber();for(let R=0;R<h;R+=1)b[R]=i.decodeExponentialGolombNumber(),S[R]=!!i.next();for(let R=0;R<v;R+=1)T[R]=i.decodeExponentialGolombNumber(),L[R]=!!i.next()}return{stRpsIdx:n,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:u,delta_idx_minus1:l,delta_rps_sign:p,abs_delta_rps_minus1:x,used_by_curr_pic_flag:d,use_delta_flag:m,num_negative_pics:h,num_positive_pics:v,delta_poc_s0_minus1:b,used_by_curr_pic_s0_flag:S,delta_poc_s1_minus1:T,used_by_curr_pic_s1_flag:L}}function Wb(i,n){const r=!!i.next();let o,u,l;r&&(o=i.read(8),o===255&&(u=i.read(16),l=i.read(16)));const p=!!i.next();let x;p&&(x=!!i.next());const d=!!i.next();let m,h,v,b,S,T;d&&(m=i.read(3),h=!!i.next(),v=!!i.next(),v&&(b=i.read(8),S=i.read(8),T=i.read(8)));const L=!!i.next();let R,D;L&&(R=i.decodeExponentialGolombNumber(),D=i.decodeExponentialGolombNumber());const G=!!i.next(),I=!!i.next(),k=!!i.next(),q=!!i.next();let $,X,Y,F;q&&($=i.decodeExponentialGolombNumber(),X=i.decodeExponentialGolombNumber(),Y=i.decodeExponentialGolombNumber(),F=i.decodeExponentialGolombNumber());const P=!!i.next();let A,de,ae,H,V,K;P&&(A=i.read(32),de=i.read(32),ae=!!i.next(),ae&&(H=i.decodeExponentialGolombNumber()),V=!!i.next(),V&&(K=Uf(i,!0,n)));const re=!!i.next();let ie,ye,we,se,Le,Me,ge,Be;return re&&(ie=!!i.next(),ye=!!i.next(),we=!!i.next(),se=i.decodeExponentialGolombNumber(),Le=i.decodeExponentialGolombNumber(),Me=i.decodeExponentialGolombNumber(),ge=i.decodeExponentialGolombNumber(),Be=i.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:o,sar_width:u,sar_height:l,overscan_info_present_flag:p,overscan_appropriate_flag:x,video_signal_type_present_flag:d,video_format:m,video_full_range_flag:h,colour_description_present_flag:v,colour_primaries:b,transfer_characteristics:S,matrix_coeffs:T,chroma_loc_info_present_flag:L,chroma_sample_loc_type_top_field:R,chroma_sample_loc_type_bottom_field:D,neutral_chroma_indication_flag:G,field_seq_flag:I,frame_field_info_present_flag:k,default_display_window_flag:q,def_disp_win_left_offset:$,def_disp_win_right_offset:X,def_disp_win_top_offset:Y,def_disp_win_bottom_offset:F,vui_timing_info_present_flag:P,vui_num_units_in_tick:A,vui_time_scale:de,vui_poc_proportional_to_timing_flag:ae,vui_num_ticks_poc_diff_one_minus1:H,vui_hrd_parameters_present_flag:V,vui_hrd_parameters:K,bitstream_restriction_flag:re,tiles_fixed_structure_flag:ie,motion_vectors_over_pic_boundaries_flag:ye,restricted_ref_pic_lists_flag:we,min_spatial_segmentation_idc:se,max_bytes_per_pic_denom:Le,max_bits_per_min_cu_denom:Me,log2_max_mv_length_horizontal:ge,log2_max_mv_length_vertical:Be}}function Uf(i,n,r){let o,u,l,p,x,d,m,h,v,b,S,T,L;n&&(o=!!i.next(),u=!!i.next(),(o||u)&&(l=!!i.next(),l&&(p=i.read(8),x=i.read(5),d=!!i.next(),m=i.read(5)),h=i.read(4),v=i.read(4),l&&(b=i.read(4)),S=i.read(5),T=i.read(5),L=i.read(5)));const R=[],D=[],G=[],I=[],k=[],q=[],$=[];for(let X=0;X<=r;X+=1)R[X]=!!i.next(),R[X]||(D[X]=!!i.next()),D[X]?G[X]=i.decodeExponentialGolombNumber():I[X]=!!i.next(),I[X]||(k[X]=i.decodeExponentialGolombNumber()),o&&(q[X]=gu(i,X,_u(k[X]))),u&&($[X]=gu(i,X,_u(k[X])));return{nal_hrd_parameters_present_flag:o,vcl_hrd_parameters_present_flag:u,sub_pic_hrd_params_present_flag:l,tick_divisor_minus2:p,du_cpb_removal_delay_increment_length_minus1:x,sub_pic_cpb_params_in_pic_timing_sei_flag:d,dpb_output_delay_du_length_minus1:m,bit_rate_scale:h,cpb_size_scale:v,cpb_size_du_scale:b,initial_cpb_removal_delay_length_minus1:S,au_cpb_removal_delay_length_minus1:T,dpb_output_delay_length_minus1:L,fixed_pic_rate_general_flag:R,fixed_pic_rate_within_cvs_flag:D,elemental_duration_in_tc_minus1:G,low_delay_hrd_flag:I,cpb_cnt_minus1:k,nalHrdParameters:q,vclHrdParameters:$}}function gu(i,n,r){const o=[],u=[],l=[],p=[],x=[];for(let d=0;d<r;d+=1)o[d]=i.decodeExponentialGolombNumber(),u[d]=i.decodeExponentialGolombNumber(),n>0&&(x[d]=!!i.next());return{bit_rate_value_minus1:o,cpb_size_value_minus1:u,cpb_size_du_value_minus1:l,bit_rate_du_value_minus1:p,cbr_flag:x}}function _u(i){return i+1}function Gb(i){let n,r,o,u=0;for(const l of Ff(i)){const p=Db(l),x={...p,data:l,rbsp:l.subarray(2)};switch(p.nal_unit_type){case 32:n=x;break;case 33:r=x;break;case 34:o=x;break;default:continue}if(u+=1,u===3)return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}}throw new Error("Invalid data")}function Hb(i){return{inter_view_mv_vert_constraint_flag:!!i.next()}}function zb(i){const n=[],r=[];n[0]=!!i.next(),r[0]=!!i.next();const o=i.decodeExponentialGolombNumber(),u=!!i.next(),l=!!i.next(),p=!!i.next(),x=!!i.next();n[1]=!!i.next(),r[1]=!!i.next();const d=!!i.next(),m=i.decodeExponentialGolombNumber(),h=!!i.next(),v=!!i.next(),b=!!i.next(),S=!!i.next(),T=!!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:u,depth_ref_enabled_flag:l,vsp_mc_enabled_flag:p,dbbp_enabled_flag:x,tex_mc_enabled_flag:d,log2_texmc_sub_pb_size_minus3:m,intra_contour_enabled_flag:h,intra_dc_only_wedge_enabled_flag:v,cqt_cu_part_pred_enabled_flag:b,inter_dc_only_enabled_flag:S,skip_intra_enabled_flag:T}}function qb(i){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}=Gb(i),{profileTierLevel:{generalProfileTier:{profile_space:u,tier_flag:l,profile_idc:p,profileCompatibilitySet:x,constraintSet:d},general_level_idc:m}}=Ob(n.rbsp),{chroma_format_idc:h,pic_width_in_luma_samples:v,pic_height_in_luma_samples:b,conf_win_left_offset:S=0,conf_win_right_offset:T=0,conf_win_top_offset:L=0,conf_win_bottom_offset:R=0}=Fb(r.rbsp),D=Lb(h),G=Mb(h),I=v-D*(S+T),k=b-G*(L+R);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o,generalProfileSpace:u,generalProfileIndex:p,generalProfileCompatibilitySet:x,generalTierFlag:l,generalLevelIndex:m,generalConstraintSet:d,encodedWidth:v,encodedHeight:b,cropLeft:S,cropRight:T,cropTop:L,cropBottom:R,croppedWidth:I,croppedHeight:k}}function xu(i){return i.toString(16).toUpperCase()}function Ho(i){return i.toString(16).toUpperCase().padStart(2,"0")}function Yr(i){return i.toString(10).padStart(2,"0")}class $b{#e;#t;constructor(n,r){this.#e=n,this.#t=r}#n(n){const o=new bt(n).searchSequenceHeaderObu();if(!o)return;const{seq_profile:u,seq_level_idx:[l=0],max_frame_width_minus_1:p,max_frame_height_minus_1:x,color_config:{BitDepth:d,mono_chrome:m,subsampling_x:h,subsampling_y:v,chroma_sample_position:b,color_description_present_flag:S}}=o;let T,L,R,D;S?{color_primaries:T,transfer_characteristics:L,matrix_coefficients:R,color_range:D}=o.color_config:(T=bt.ColorPrimaries.Bt709,L=bt.TransferCharacteristics.Bt709,R=bt.MatrixCoefficients.Bt709,D=!1);const G=p+1,I=x+1;this.#t(G,I);const k=["av01",u.toString(16),Yr(l)+(o.seq_tier[0]?"H":"M"),Yr(d),m?"1":"0",(h?"1":"0")+(v?"1":"0")+b.toString(),Yr(T),Yr(L),Yr(R),D?"1":"0"].join(".");this.#e.configure({codec:k,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 Wf{#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 Xb extends Wf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{profileIndex:r,constraintSet:o,levelIndex:u,croppedWidth:l,croppedHeight:p}=Ib(n);this.#t(l,p);const x="avc1."+Ho(r)+Ho(o)+Ho(u);this.#e.configure({codec:x,optimizeForLatency:!0})}}class Yb extends Wf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{generalProfileSpace:r,generalProfileIndex:o,generalProfileCompatibilitySet:u,generalTierFlag:l,generalLevelIndex:p,generalConstraintSet:x,croppedWidth:d,croppedHeight:m}=qb(n);this.#t(d,m);const h=["hev1",["","A","B","C"][r]+o.toString(),xu(Sb(u,0)),(l?"H":"L")+p.toString(),...Array.from(x,xu)].join(".");this.#e.configure({codec:h,codedWidth:d,codedHeight:m,optimizeForLatency:!0})}}class Vb{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 u={listener:n,thisArg:r,args:o};return this.addEventListener(u)};fire(n){for(const r of this.listeners.slice())r.listener.apply(r.thisArg,[n,...r.args])}dispose(){this.listeners.length=0}}class Kb{#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 Qb{#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,u)=>{this.#e.toBlob(l=>{l?o(l):u(new Error("Failed to convert canvas to blob"))},"image/png")})}}const vu=new Kb(()=>new Qb,4);class bu{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}#f=new Vb;get sizeChanged(){return this.#f.event}#a;#p=!1;#u;#d;#m=0;constructor({codec:n,renderer:r}){switch(this.#e=n,this.#s=r,this.#a=new VideoDecoder({output:o=>{if(this.#d?.close(),this.#d=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 si.H264:this.#t=new Xb(this.#a,this.#h);break;case si.H265:this.#t=new Yb(this.#a,this.#h);break;case si.AV1:this.#t=new $b(this.#a,this.#h);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new Cb({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.#f.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.#d;if(!n)return;const r=await vu.borrow(),o=await r.capture(n);return vu.return(r),o}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#d?.close()}}var zo={exports:{}},qo={exports:{}},yu;function ya(){return yu||(yu=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")},qo.exports=i})()),qo.exports}var $o={exports:{}},Xo={exports:{}},Yo={exports:{}},wu;function Jb(){return wu||(wu=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}Yo.exports=i})()),Yo.exports}var Eu;function Zb(){return Eu||(Eu=1,(function(){var i=Jb();function n(r,o){var u=r.format.width|0,l=r.format.height|0,p=i(r.format.width/r.format.chromaWidth)|0,x=i(r.format.height/r.format.chromaHeight)|0,d=r.y.bytes,m=r.u.bytes,h=r.v.bytes,v=r.y.stride|0,b=r.u.stride|0,S=r.v.stride|0,T=u<<2,L=0,R=0,D=0,G=0,I=0,k=0,q=0,$=0,X=0,Y=0,F=0,P=0,A=0,de=0,ae=0,H=0,V=0,K=0;if(p==1&&x==1)for(q=0,$=T,K=0,H=0;H<l;H+=2){for(R=H*v|0,D=R+v|0,G=K*b|0,I=K*S|0,ae=0;ae<u;ae+=2)X=m[G++]|0,Y=h[I++]|0,P=(409*Y|0)-57088|0,A=(100*X|0)+(208*Y|0)-34816|0,de=(516*X|0)-70912|0,F=298*d[R++]|0,o[q]=F+P>>8,o[q+1]=F-A>>8,o[q+2]=F+de>>8,q+=4,F=298*d[R++]|0,o[q]=F+P>>8,o[q+1]=F-A>>8,o[q+2]=F+de>>8,q+=4,F=298*d[D++]|0,o[$]=F+P>>8,o[$+1]=F-A>>8,o[$+2]=F+de>>8,$+=4,F=298*d[D++]|0,o[$]=F+P>>8,o[$+1]=F-A>>8,o[$+2]=F+de>>8,$+=4;q+=T,$+=T,K++}else for(k=0,H=0;H<l;H++)for(V=0,K=H>>x,L=H*v|0,G=K*b|0,I=K*S|0,ae=0;ae<u;ae++)V=ae>>p,X=m[G+V]|0,Y=h[I+V]|0,P=(409*Y|0)-57088|0,A=(100*X|0)+(208*Y|0)-34816|0,de=(516*X|0)-70912|0,F=298*d[L++]|0,o[k]=F+P>>8,o[k+1]=F-A>>8,o[k+2]=F+de>>8,k+=4}Xo.exports={convertYCbCr:n}})()),Xo.exports}var Su;function ey(){return Su||(Su=1,(function(){var i=ya(),n=Zb();function r(o){var u=this,l=o.getContext("2d"),p=null,x=null,d=null;function m(v,b){p=l.createImageData(v,b);for(var S=p.data,T=v*b*4,L=0;L<T;L+=4)S[L+3]=255}function h(v,b){x=document.createElement("canvas"),x.width=v,x.height=b,d=x.getContext("2d")}return u.drawFrame=function(b){var S=b.format;(o.width!==S.displayWidth||o.height!==S.displayHeight)&&(o.width=S.displayWidth,o.height=S.displayHeight),(p===null||p.width!=S.width||p.height!=S.height)&&m(S.width,S.height),n.convertYCbCr(b,p.data);var T=S.cropWidth!=S.displayWidth||S.cropHeight!=S.displayHeight,L;T?(x||h(S.cropWidth,S.cropHeight),L=d):L=l,L.putImageData(p,-S.cropLeft,-S.cropTop,S.cropLeft,S.cropTop,S.cropWidth,S.cropHeight),T&&l.drawImage(x,0,0,S.displayWidth,S.displayHeight)},u.clear=function(){l.clearRect(0,0,o.width,o.height)},u}r.prototype=Object.create(i.prototype),$o.exports=r})()),$o.exports}var Vo={exports:{}},Ko,Cu;function ty(){return Cu||(Cu=1,Ko={vertex:`precision mediump float;
33
+
34
+ attribute vec2 aPosition;
35
+ attribute vec2 aLumaPosition;
36
+ attribute vec2 aChromaPosition;
37
+ varying vec2 vLumaPosition;
38
+ varying vec2 vChromaPosition;
39
+ void main() {
40
+ gl_Position = vec4(aPosition, 0, 1);
41
+ vLumaPosition = aLumaPosition;
42
+ vChromaPosition = aChromaPosition;
43
+ }
44
+ `,fragment:`// inspired by https://github.com/mbebenita/Broadway/blob/master/Player/canvas.js
45
+
46
+ precision mediump float;
47
+
48
+ uniform sampler2D uTextureY;
49
+ uniform sampler2D uTextureCb;
50
+ uniform sampler2D uTextureCr;
51
+ varying vec2 vLumaPosition;
52
+ varying vec2 vChromaPosition;
53
+ void main() {
54
+ // Y, Cb, and Cr planes are uploaded as ALPHA textures.
55
+ float fY = texture2D(uTextureY, vLumaPosition).w;
56
+ float fCb = texture2D(uTextureCb, vChromaPosition).w;
57
+ float fCr = texture2D(uTextureCr, vChromaPosition).w;
58
+
59
+ // Premultipy the Y...
60
+ float fYmul = fY * 1.1643828125;
61
+
62
+ // And convert that to RGB!
63
+ gl_FragColor = vec4(
64
+ fYmul + 1.59602734375 * fCr - 0.87078515625,
65
+ fYmul - 0.39176171875 * fCb - 0.81296875 * fCr + 0.52959375,
66
+ fYmul + 2.017234375 * fCb - 1.081390625,
67
+ 1
68
+ );
69
+ }
70
+ `,vertexStripe:`precision mediump float;
71
+
72
+ attribute vec2 aPosition;
73
+ attribute vec2 aTexturePosition;
74
+ varying vec2 vTexturePosition;
75
+
76
+ void main() {
77
+ gl_Position = vec4(aPosition, 0, 1);
78
+ vTexturePosition = aTexturePosition;
79
+ }
80
+ `,fragmentStripe:`// extra 'stripe' texture fiddling to work around IE 11's poor performance on gl.LUMINANCE and gl.ALPHA textures
81
+
82
+ precision mediump float;
83
+
84
+ uniform sampler2D uStripe;
85
+ uniform sampler2D uTexture;
86
+ varying vec2 vTexturePosition;
87
+ void main() {
88
+ // Y, Cb, and Cr planes are mapped into a pseudo-RGBA texture
89
+ // so we can upload them without expanding the bytes on IE 11
90
+ // which doesn't allow LUMINANCE or ALPHA textures
91
+ // The stripe textures mark which channel to keep for each pixel.
92
+ // Each texture extraction will contain the relevant value in one
93
+ // channel only.
94
+
95
+ float fLuminance = dot(
96
+ texture2D(uStripe, vTexturePosition),
97
+ texture2D(uTexture, vTexturePosition)
98
+ );
99
+
100
+ gl_FragColor = vec4(0, 0, 0, fLuminance);
101
+ }
102
+ `}),Ko}var Nu;function ny(){return Nu||(Nu=1,(function(){var i=ya(),n=ty();function r(o){var u=this,l=r.contextForCanvas(o);if(l===null)throw new Error("WebGL unavailable");function p(H,V){var K=l.createShader(H);if(l.shaderSource(K,V),l.compileShader(K),!l.getShaderParameter(K,l.COMPILE_STATUS)){var re=l.getShaderInfoLog(K);throw l.deleteShader(K),new Error("GL shader compilation for "+H+" failed: "+re)}return K}var x,d,m=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),h={},v={},b={},S,T,L,R,D,G,I,k,q,$;function X(H,V){return(!h[H]||V)&&(h[H]=l.createTexture()),h[H]}function Y(H,V,K,re,ie){var ye=!h[H]||V,we=X(H,V);if(l.activeTexture(l.TEXTURE0),r.stripe){var se=!h[H+"_temp"]||V,Le=X(H+"_temp",V);l.bindTexture(l.TEXTURE_2D,Le),se?(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,re,0,l.RGBA,l.UNSIGNED_BYTE,ie)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K/4,re,l.RGBA,l.UNSIGNED_BYTE,ie);var Me=h[H+"_stripe"],ge=!Me||V;ge&&(Me=X(H+"_stripe",V)),l.bindTexture(l.TEXTURE_2D,Me),ge&&(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,A(K)))}else l.bindTexture(l.TEXTURE_2D,we),ye?(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,re,0,l.ALPHA,l.UNSIGNED_BYTE,ie)):l.texSubImage2D(l.TEXTURE_2D,0,0,0,K,re,l.ALPHA,l.UNSIGNED_BYTE,ie)}function F(H,V,K,re){var ie=h[H];l.useProgram(d);var ye=v[H];(!ye||V)&&(l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,ie),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,K,re,0,l.RGBA,l.UNSIGNED_BYTE,null),ye=v[H]=l.createFramebuffer()),l.bindFramebuffer(l.FRAMEBUFFER,ye),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,ie,0);var we=h[H+"_temp"];l.activeTexture(l.TEXTURE1),l.bindTexture(l.TEXTURE_2D,we),l.uniform1i(G,1);var se=h[H+"_stripe"];l.activeTexture(l.TEXTURE2),l.bindTexture(l.TEXTURE_2D,se),l.uniform1i(D,2),l.bindBuffer(l.ARRAY_BUFFER,S),l.enableVertexAttribArray(T),l.vertexAttribPointer(T,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,L),l.enableVertexAttribArray(R),l.vertexAttribPointer(R,2,l.FLOAT,!1,0,0),l.viewport(0,0,K,re),l.drawArrays(l.TRIANGLES,0,m.length/2),l.bindFramebuffer(l.FRAMEBUFFER,null)}function P(H,V,K){l.activeTexture(V),l.bindTexture(l.TEXTURE_2D,h[H]),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.LINEAR),l.uniform1i(l.getUniformLocation(x,H),K)}function A(H){if(b[H])return b[H];for(var V=H,K=new Uint32Array(V),re=0;re<V;re+=4)K[re]=255,K[re+1]=65280,K[re+2]=16711680,K[re+3]=4278190080;return b[H]=new Uint8Array(K.buffer)}function de(H,V){var K=p(l.VERTEX_SHADER,H),re=p(l.FRAGMENT_SHADER,V),ie=l.createProgram();if(l.attachShader(ie,K),l.attachShader(ie,re),l.linkProgram(ie),!l.getProgramParameter(ie,l.LINK_STATUS)){var ye=l.getProgramInfoLog(ie);throw l.deleteProgram(ie),new Error("GL program linking failed: "+ye)}return ie}function ae(){if(r.stripe){d=de(n.vertexStripe,n.fragmentStripe),l.getAttribLocation(d,"aPosition"),L=l.createBuffer();var H=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);l.bindBuffer(l.ARRAY_BUFFER,L),l.bufferData(l.ARRAY_BUFFER,H,l.STATIC_DRAW),R=l.getAttribLocation(d,"aTexturePosition"),D=l.getUniformLocation(d,"uStripe"),G=l.getUniformLocation(d,"uTexture")}x=de(n.vertex,n.fragment),S=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,S),l.bufferData(l.ARRAY_BUFFER,m,l.STATIC_DRAW),T=l.getAttribLocation(x,"aPosition"),I=l.createBuffer(),k=l.getAttribLocation(x,"aLumaPosition"),q=l.createBuffer(),$=l.getAttribLocation(x,"aChromaPosition")}return u.drawFrame=function(H){var V=H.format,K=!x||o.width!==V.displayWidth||o.height!==V.displayHeight;if(K&&(o.width=V.displayWidth,o.height=V.displayHeight,u.clear()),x||ae(),K){var re=function(ie,ye,we){var se=V.cropLeft/we,Le=(V.cropLeft+V.cropWidth)/we,Me=(V.cropTop+V.cropHeight)/V.height,ge=V.cropTop/V.height,Be=new Float32Array([se,Me,Le,Me,se,ge,se,ge,Le,Me,Le,ge]);l.bindBuffer(l.ARRAY_BUFFER,ie),l.bufferData(l.ARRAY_BUFFER,Be,l.STATIC_DRAW)};re(I,k,H.y.stride),re(q,$,H.u.stride*V.width/V.chromaWidth)}Y("uTextureY",K,H.y.stride,V.height,H.y.bytes),Y("uTextureCb",K,H.u.stride,V.chromaHeight,H.u.bytes),Y("uTextureCr",K,H.v.stride,V.chromaHeight,H.v.bytes),r.stripe&&(F("uTextureY",K,H.y.stride,V.height),F("uTextureCb",K,H.u.stride,V.chromaHeight),F("uTextureCr",K,H.v.stride,V.chromaHeight)),l.useProgram(x),l.viewport(0,0,o.width,o.height),P("uTextureY",l.TEXTURE0,0),P("uTextureCb",l.TEXTURE1,1),P("uTextureCr",l.TEXTURE2,2),l.bindBuffer(l.ARRAY_BUFFER,S),l.enableVertexAttribArray(T),l.vertexAttribPointer(T,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,I),l.enableVertexAttribArray(k),l.vertexAttribPointer(k,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,q),l.enableVertexAttribArray($),l.vertexAttribPointer($,2,l.FLOAT,!1,0,0),l.drawArrays(l.TRIANGLES,0,m.length/2)},u.clear=function(){l.viewport(0,0,o.width,o.height),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT)},u.clear(),u}r.stripe=!1,r.contextForCanvas=function(o){var u={preferLowPowerToHighPerformance:!0,powerPreference:"low-power",failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0};return o.getContext("webgl",u)||o.getContext("experimental-webgl",u)},r.isAvailable=function(){var o=document.createElement("canvas"),u;o.width=1,o.height=1;try{u=r.contextForCanvas(o)}catch{return!1}if(u){var l=u.TEXTURE0,p=4,x=4,d=u.createTexture(),m=new Uint8Array(p*x),h=r.stripe?p/4:p,v=r.stripe?u.RGBA:u.ALPHA,b=r.stripe?u.NEAREST:u.LINEAR;u.activeTexture(l),u.bindTexture(u.TEXTURE_2D,d),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,b),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,b),u.texImage2D(u.TEXTURE_2D,0,v,h,x,0,v,u.UNSIGNED_BYTE,m);var S=u.getError();return!S}else return!1},r.prototype=Object.create(i.prototype),Vo.exports=r})()),Vo.exports}var Tu;function ry(){return Tu||(Tu=1,(function(){var i=ya(),n=ey(),r=ny(),o={FrameSink:i,SoftwareFrameSink:n,WebGLFrameSink:r,attach:function(u,l){l=l||{};var p="webGL"in l?l.webGL:r.isAvailable();return p?new r(u,l):new n(u,l)}};zo.exports=o})()),zo.exports}ry();function Gf(){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 Hf{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=Gf()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class sy extends Hf{#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 iy=Promise.resolve();function Ru(i,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return i.getContext("webgl2",r)||i.getContext("webgl",r)}class Qr extends Hf{static vertexShaderSource=`
103
+ attribute vec2 xy;
104
+
105
+ varying highp vec2 uv;
106
+
107
+ void main(void) {
108
+ gl_Position = vec4(xy, 0.0, 1.0);
109
+ // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).
110
+ // UV coordinates are Y-flipped relative to vertex coordinates.
111
+ uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);
112
+ }
113
+ `;static fragmentShaderSource=`
114
+ varying highp vec2 uv;
115
+
116
+ uniform sampler2D texture;
117
+
118
+ void main(void) {
119
+ gl_FragColor = texture2D(texture, uv);
120
+ }
121
+ `;static get isSupported(){const n=Gf();return!!Ru(n)}#e;constructor(n,r){super(n);const o=Ru(this.canvas,r);if(!o)throw new Error("WebGL not supported");this.#e=o;const u=o.createShader(o.VERTEX_SHADER);if(o.shaderSource(u,Qr.vertexShaderSource),o.compileShader(u),!o.getShaderParameter(u,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(u));const l=o.createShader(o.FRAGMENT_SHADER);if(o.shaderSource(l,Qr.fragmentShaderSource),o.compileShader(l),!o.getShaderParameter(l,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(l));const p=o.createProgram();if(o.attachShader(p,u),o.attachShader(p,l),o.linkProgram(p),!o.getProgramParameter(p,o.LINK_STATUS))throw new Error(o.getProgramInfoLog(p));o.useProgram(p);const x=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,x),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),o.STATIC_DRAW);const d=o.getAttribLocation(p,"xy");o.vertexAttribPointer(d,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(d);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),iy}}const ku=50,oy=300;function ay({deviceId:i,className:n,onFallback:r,fallbackTimeout:o=5e3,enableControl:u=!1,onTapSuccess:l,onTapError:p,onSwipeSuccess:x,onSwipeError:d,onStreamReady:m}){const h=w.useRef(null),v=w.useRef(null),b=w.useRef(null),S=w.useRef(null),T=w.useRef(null),L=w.useRef(null),R=w.useRef(null),D=w.useRef(!1),G=w.useRef(!1),I=w.useRef(r),k=w.useRef(o),q=w.useRef(m),[$,X]=w.useState("connecting"),[Y,F]=w.useState(null),[P,A]=w.useState(null),[de,ae]=w.useState(null),H=w.useRef(!1),V=w.useRef(null),K=w.useRef(!1),re=w.useRef(0),ie=w.useRef(null),ye=w.useRef(null),we=w.useRef(null),se=w.useRef(null);w.useEffect(()=>{I.current=r,k.current=o,q.current=m},[r,o,m]),w.useEffect(()=>{(async()=>{try{const Z=await Ou(i);Z.success&&ae({width:Z.width,height:Z.height})}catch(Z){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",Z)}})()},[i]);const Le=w.useCallback(()=>{const ee=S.current,Z=b.current;if(!ee||!Z||!P)return;const M=Z.clientWidth,Q=Z.clientHeight,{width:xe,height:oe}=P,fe=xe/oe;let ve=M,mt=M/fe;mt>Q&&(mt=Q,ve=Q*fe),ee.width=xe,ee.height=oe,ee.style.width=`${ve}px`,ee.style.height=`${mt}px`},[P]);w.useEffect(()=>{const ee=()=>Le();return window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[Le]),w.useEffect(()=>{Le()},[P,Le]);const Me=w.useCallback(async()=>{if(Qr.isSupported){const Z=new Qr;return{renderer:Z,element:Z.canvas}}const ee=new sy;return{renderer:ee,element:ee.canvas}},[]),ge=w.useCallback(async ee=>{if(!bu.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:Z,element:M}=await Me();return S.current=M,b.current&&!M.parentElement&&b.current.appendChild(M),new bu({codec:ee,renderer:Z})},[Me]),Be=w.useCallback(()=>{D.current||(D.current=!0,T.current&&(clearTimeout(T.current),T.current=null))},[]),Ze=w.useCallback(ee=>{let Z=!1,M=[];const Q=new TransformStream({transform(oe,fe){if(oe.type==="configuration"){fe.enqueue(oe),Z=!0,M.length>0&&(M.forEach(ve=>fe.enqueue(ve)),M=[]);return}if(oe.type==="data"&&!Z){M.push(oe);return}fe.enqueue(oe)}});return new ReadableStream({start(oe){let fe=!1;const ve=lt=>{if(!fe)try{Be();const dt={...lt,data:lt.data instanceof Uint8Array?lt.data:new Uint8Array(lt.data)};oe.enqueue(dt)}catch(dt){console.error("[ScrcpyPlayer] Video enqueue error:",dt),fe=!0,Nt()}},mt=lt=>{fe||(oe.error(new Error(lt?.message||"Socket error")),fe=!0,Nt())},yt=()=>{fe||(oe.close(),fe=!0,Nt())},Nt=()=>{h.current?.off("video-data",ve),h.current?.off("error",mt),h.current?.off("disconnect",yt)};return h.current?.on("video-data",ve),h.current?.on("error",mt),h.current?.on("disconnect",yt),()=>{fe=!0,Nt()}}}).pipeThrough(Q)},[Be]),pt=w.useCallback((ee=!1)=>{if(ee&&(G.current=!0),v.current){try{v.current.dispose()}catch(Z){console.error("[ScrcpyPlayer] Failed to dispose decoder:",Z)}v.current=null}S.current=null,h.current&&(h.current.disconnect(),h.current=null),q.current?.(null),L.current&&(clearTimeout(L.current),L.current=null),T.current&&(clearTimeout(T.current),T.current=null),X("disconnected"),A(null),F(null)},[]),Ke=w.useCallback(()=>{pt(!0),D.current=!1,X("connecting"),F(null);const ee=ri({path:"/socket.io",transports:["websocket"],timeout:1e4});h.current=ee,ee.on("connect",()=>{ee.emit("connect-device",{device_id:i,maxSize:1280,bitRate:4e6}),T.current=setTimeout(()=>{D.current||(X("error"),F("Video stream timeout"),G.current=!0,ee.close(),I.current?.())},k.current)}),ee.on("video-metadata",async Z=>{try{v.current&&(v.current.dispose(),v.current=null);const M=Z?.codec?Z.codec:si.H264;v.current=await ge(M),v.current.sizeChanged(({width:xe,height:oe})=>{A({width:xe,height:oe})}),Ze(Z).pipeTo(v.current.writable).catch(xe=>{console.error("[ScrcpyPlayer] Video stream error:",xe)}),X("connected"),q.current?.({close:()=>ee.close()})}catch(M){console.error("[ScrcpyPlayer] Decoder initialization failed:",M),X("error"),F("Decoder initialization failed"),G.current=!0,ee.close(),I.current?.()}}),ee.on("error",Z=>{console.error("[ScrcpyPlayer] Socket error:",Z),X("error"),F(Z?.message||"Socket error")}),ee.on("disconnect",()=>{if(G.current){G.current=!1;return}X("disconnected"),q.current?.(null),L.current||(L.current=setTimeout(()=>{L.current=null,R.current?.()},3e3))})},[i,pt,ge,Ze]);w.useEffect(()=>{R.current=Ke},[Ke]),w.useEffect(()=>(queueMicrotask(()=>{Ke()}),()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),we.current&&(clearTimeout(we.current),we.current=null),pt(!0)}),[Ke,pt]);const Pe=()=>{if(P)return{width:P.width,height:P.height};const ee=S.current;return ee?{width:ee.width,height:ee.height}:null},ot=(ee,Z)=>{const M=S.current,Q=Pe();if(!M||!Q)return null;const xe=M.getBoundingClientRect();if(ee<xe.left||ee>xe.right||Z<xe.top||Z>xe.bottom)return null;const oe=ee-xe.left,fe=Z-xe.top,ve=Math.round(oe/xe.width*Q.width),mt=Math.round(fe/xe.height*Q.height),yt=de?de.width/Q.width:1,Nt=de?de.height/Q.height:1;return{x:Math.round(ve*yt),y:Math.round(mt*Nt)}},ft=async ee=>{if(!u||$!=="connected")return;const Z=ot(ee.clientX,ee.clientY);if(Z){H.current=!0,K.current=!1,V.current={x:ee.clientX,y:ee.clientY};try{await Rx(Z.x,Z.y,i)}catch(M){console.error("[ScrcpyPlayer] Touch down failed:",M)}}},He=ee=>{if(!H.current||$!=="connected")return;const Z=Date.now(),M=ot(ee.clientX,ee.clientY);if(M){if(V.current){const Q=ee.clientX-V.current.x,xe=ee.clientY-V.current.y;Math.hypot(Q,xe)>4&&(K.current=!0)}if(ie.current=M,Z-re.current<ku){ye.current||(ye.current=setTimeout(()=>{ye.current=null,ie.current&&(Zc(ie.current.x,ie.current.y,i).catch(Q=>{console.error("[ScrcpyPlayer] Touch move failed:",Q)}),ie.current=null,re.current=Date.now())},ku));return}re.current=Z,Zc(M.x,M.y,i).catch(Q=>{console.error("[ScrcpyPlayer] Touch move failed:",Q)})}},Gt=async ee=>{if(!H.current||$!=="connected")return;const Z=ot(ee.clientX,ee.clientY);if(H.current=!1,V.current=null,!!Z)try{await Jc(Z.x,Z.y,i),K.current?x?.():l?.()}catch(M){const Q=String(M);K.current?d?.(Q):p?.(Q)}},Xe=async ee=>{if(!H.current||$!=="connected")return;const Z=ot(ee.clientX,ee.clientY);if(H.current=!1,V.current=null,!!Z)try{await Jc(Z.x,Z.y,i)}catch(M){console.error("[ScrcpyPlayer] Touch cancel failed:",M)}},at=ee=>{if(!u||$!=="connected")return;ee.preventDefault();const Z=ee.deltaY;se.current||(se.current={deltaY:0}),se.current.deltaY+=Z,we.current&&clearTimeout(we.current),we.current=setTimeout(async()=>{const M=se.current;if(se.current=null,!M)return;const Q=S.current,xe=Pe();if(!Q||!xe)return;const oe=Q.getBoundingClientRect(),fe=oe.left+oe.width/2,ve=oe.top+oe.height/2,mt=ot(fe,ve);if(!mt)return;const yt=Math.max(Math.min(M.deltaY,600),-600),Nt=ve+yt,lt=ot(fe,Nt);if(lt)try{const dt=await Tx(mt.x,mt.y,lt.x,lt.y,300,i);dt.success?x?.():d?.(dt.error||"Scroll failed")}catch(dt){d?.(String(dt))}},oy)};return a.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${n||""}`,children:a.jsx("div",{ref:b,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:ft,onMouseMove:He,onMouseUp:Gt,onMouseLeave:Xe,onWheel:at,children:$!=="connected"&&a.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[$==="connecting"&&"Connecting...",$==="error"&&(Y||"Connection error"),$==="disconnected"&&"Disconnected"]})})})}const zf=w.forwardRef(({className:i,value:n=0,max:r=100,...o},u)=>{const l=Math.min(Math.max(n/r*100,0),100);return a.jsx("div",{ref:u,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,className:Hn("relative h-2 w-full overflow-hidden rounded-full bg-slate-200 dark:bg-slate-800",i),...o,children:a.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-in-out",style:{width:`${l}%`}})})});zf.displayName="Progress";function ly({state:i,isStreaming:n,className:r="",decisionModelName:o="Decision Model",visionModelName:u="Vision Model"}){const[l,p]=Oe.useState("decision"),x=m=>{p(h=>h===m?null:m)},d=i.totalSteps>0?Math.round(i.currentStep/i.totalSteps*100):0;return a.jsxs("div",{className:`space-y-3 ${r}`,children:[n&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-500 dark:text-slate-400",children:[a.jsxs("span",{children:["Step ",i.currentStep," / ",i.totalSteps||"?"]}),a.jsxs("span",{children:[d,"%"]})]}),a.jsx(zf,{value:d,className:"h-1.5"})]}),i.taskPlan.length>0&&a.jsxs(wr,{className:"p-3 bg-slate-50 dark:bg-slate-900/50 border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Yu,{className:"w-4 h-4 text-blue-500"}),a.jsx("span",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:"Task Plan"})]}),a.jsx("ul",{className:"space-y-1",children:i.taskPlan.map((m,h)=>a.jsxs("li",{className:`text-xs flex items-start gap-2 ${h<i.currentStep?"text-green-600 dark:text-green-400":h===i.currentStep?"text-blue-600 dark:text-blue-400 font-medium":"text-slate-500 dark:text-slate-400"}`,children:[a.jsx("span",{className:"flex-shrink-0 w-4 h-4 rounded-full border flex items-center justify-center text-[10px]",children:h<i.currentStep?a.jsx(Wn,{className:"w-3 h-3"}):h+1}),a.jsx("span",{className:"line-clamp-1",children:m})]},h))})]}),a.jsxs(wr,{className:`overflow-hidden transition-all duration-200 ${i.decisionActive?"border-purple-300 dark:border-purple-700 shadow-sm shadow-purple-100 dark:shadow-purple-900/20":"border-slate-200 dark:border-slate-800"}`,children:[a.jsxs("button",{onClick:()=>x("decision"),className:"w-full p-3 flex items-center justify-between hover:bg-slate-50 dark:hover:bg-slate-900/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${i.decisionActive?"bg-purple-100 dark:bg-purple-900/30":"bg-slate-100 dark:bg-slate-800"}`,children:a.jsx(da,{className:`w-4 h-4 ${i.decisionActive?"text-purple-600 dark:text-purple-400":"text-slate-400"}`})}),a.jsxs("div",{className:"text-left",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:o}),a.jsx(Qt,{variant:i.decisionActive?"default":"secondary",className:"text-[10px] px-1.5 py-0",children:"决策模型"})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.decisionStage==="analyzing"?"Analyzing task...":i.decisionStage==="deciding"?"Making decision...":i.decisionStage==="generating"?"Generating content...":i.decisionActive?"Active":"Idle"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[i.decisionActive&&a.jsx(pn,{className:"w-4 h-4 text-purple-500 animate-spin"}),l==="decision"?a.jsx(eu,{className:"w-4 h-4 text-slate-400"}):a.jsx(Jo,{className:"w-4 h-4 text-slate-400"})]})]}),l==="decision"&&a.jsxs("div",{className:"px-3 pb-3 space-y-2 border-t border-slate-100 dark:border-slate-800",children:[i.decisionThinking&&a.jsxs("div",{className:"mt-2 p-2 bg-purple-50 dark:bg-purple-900/20 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[a.jsx(kx,{className:"w-3 h-3 text-purple-500"}),a.jsx("span",{className:"text-[10px] font-medium text-purple-600 dark:text-purple-400",children:"Thinking"})]}),a.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300 whitespace-pre-wrap",children:[i.decisionThinking,i.decisionActive&&a.jsx("span",{className:"inline-block w-1 h-3 ml-0.5 bg-purple-500 animate-pulse"})]})]}),i.decisionResult&&a.jsxs("div",{className:"mt-2 p-2 bg-slate-50 dark:bg-slate-900/50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[a.jsx(ai,{className:"w-3 h-3 text-amber-500"}),a.jsx("span",{className:"text-[10px] font-medium text-slate-600 dark:text-slate-400",children:"Decision"})]}),a.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300",children:i.decisionResult})]}),i.decisions.length>0&&a.jsxs("details",{className:"mt-2",children:[a.jsxs("summary",{className:"text-[10px] text-slate-500 cursor-pointer hover:text-slate-700 dark:hover:text-slate-300",children:["View decision history (",i.decisions.length,")"]}),a.jsx("div",{className:"mt-1 space-y-1 max-h-32 overflow-y-auto",children:i.decisions.slice(-5).map((m,h)=>a.jsxs("div",{className:"text-[10px] p-1.5 bg-slate-100 dark:bg-slate-800 rounded",children:[a.jsxs("span",{className:"text-purple-600 dark:text-purple-400",children:["[",m.decision.action,"]"]})," ",m.decision.target]},h))})]})]})]}),a.jsxs(wr,{className:`overflow-hidden transition-all duration-200 ${i.visionActive?"border-green-300 dark:border-green-700 shadow-sm shadow-green-100 dark:shadow-green-900/20":"border-slate-200 dark:border-slate-800"}`,children:[a.jsxs("button",{onClick:()=>x("vision"),className:"w-full p-3 flex items-center justify-between hover:bg-slate-50 dark:hover:bg-slate-900/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${i.visionActive?"bg-green-100 dark:bg-green-900/30":"bg-slate-100 dark:bg-slate-800"}`,children:a.jsx(oi,{className:`w-4 h-4 ${i.visionActive?"text-green-600 dark:text-green-400":"text-slate-400"}`})}),a.jsxs("div",{className:"text-left",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:u}),a.jsx(Qt,{variant:i.visionActive?"success":"secondary",className:"text-[10px] px-1.5 py-0",children:"视觉模型"})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.visionStage==="capturing"?"Capturing screen...":i.visionStage==="recognizing"?"Recognizing elements...":i.visionStage==="executing"?"Executing action...":i.visionActive?"Active":"Idle"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[i.visionActive&&a.jsx(pn,{className:"w-4 h-4 text-green-500 animate-spin"}),l==="vision"?a.jsx(eu,{className:"w-4 h-4 text-slate-400"}):a.jsx(Jo,{className:"w-4 h-4 text-slate-400"})]})]}),l==="vision"&&a.jsxs("div",{className:"px-3 pb-3 space-y-2 border-t border-slate-100 dark:border-slate-800",children:[i.visionDescription&&a.jsxs("div",{className:"mt-2 p-2 bg-green-50 dark:bg-green-900/20 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[a.jsx(oi,{className:"w-3 h-3 text-green-500"}),a.jsx("span",{className:"text-[10px] font-medium text-green-600 dark:text-green-400",children:"Screen Recognition"})]}),a.jsx("p",{className:"text-xs text-green-700 dark:text-green-300 line-clamp-3",children:i.visionDescription})]}),i.visionAction&&a.jsxs("div",{className:"mt-2 p-2 bg-slate-50 dark:bg-slate-900/50 rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[a.jsx(ai,{className:"w-3 h-3 text-amber-500"}),a.jsx("span",{className:"text-[10px] font-medium text-slate-600 dark:text-slate-400",children:"Action"})]}),a.jsx("p",{className:"text-xs text-slate-700 dark:text-slate-300",children:i.visionAction})]}),i.actions.length>0&&a.jsxs("details",{className:"mt-2",children:[a.jsxs("summary",{className:"text-[10px] text-slate-500 cursor-pointer hover:text-slate-700 dark:hover:text-slate-300",children:["View action history (",i.actions.length,")"]}),a.jsx("div",{className:"mt-1 space-y-1 max-h-32 overflow-y-auto",children:i.actions.slice(-5).map((m,h)=>a.jsxs("div",{className:`text-[10px] p-1.5 rounded flex items-center gap-1 ${m.success?"bg-green-50 dark:bg-green-900/20":"bg-red-50 dark:bg-red-900/20"}`,children:[m.success?a.jsx(Wn,{className:"w-3 h-3 text-green-500"}):a.jsx(ii,{className:"w-3 h-3 text-red-500"}),a.jsxs("span",{className:m.success?"text-green-700 dark:text-green-300":"text-red-700 dark:text-red-300",children:["[",m.action_type,"] ",m.target]})]},h))})]})]})]})]})}function cy(){const[i,n]=Oe.useState({decisionActive:!1,decisionStage:"idle",decisionThinking:"",decisionResult:"",taskPlan:[],visionActive:!1,visionStage:"idle",visionDescription:"",visionAction:"",currentStep:0,totalSteps:0,decisions:[],recognitions:[],actions:[]}),r=Oe.useCallback(u=>{n(l=>{switch(u.type){case"decision_start":return{...l,decisionActive:!0,decisionStage:u.stage,visionActive:!1};case"decision_thinking":return{...l,decisionThinking:l.decisionThinking+u.chunk};case"decision_result":return{...l,decisionActive:!1,decisionStage:"idle",decisionThinking:"",decisionResult:`${u.decision.action}: ${u.decision.target}`,decisions:[...l.decisions,u]};case"task_plan":return{...l,taskPlan:u.plan.steps,totalSteps:u.plan.estimated_actions};case"vision_start":return{...l,visionActive:!0,visionStage:u.stage,decisionActive:!1};case"vision_recognition":return{...l,visionDescription:u.description,recognitions:[...l.recognitions,u]};case"action_start":return{...l,visionStage:"executing",visionAction:`${u.action.action}: ${u.action.target}`};case"action_result":return{...l,visionActive:!1,visionStage:"idle",visionAction:`${u.action_type}: ${u.target} - ${u.success?"Success":"Failed"}`,actions:[...l.actions,u]};case"step_complete":return{...l,currentStep:u.step};case"task_complete":return{...l,decisionActive:!1,visionActive:!1,decisionStage:"idle",visionStage:"idle"};case"error":case"aborted":return{...l,decisionActive:!1,visionActive:!1,decisionStage:"idle",visionStage:"idle"};default:return l}})},[]),o=Oe.useCallback(()=>{n({decisionActive:!1,decisionStage:"idle",decisionThinking:"",decisionResult:"",taskPlan:[],visionActive:!1,visionStage:"idle",visionDescription:"",visionAction:"",currentStep:0,totalSteps:0,decisions:[],recognitions:[],actions:[]})},[]);return{state:i,handleEvent:r,reset:o}}var mi="Popover",[qf]=Zr(mi,[Fu]),ts=Fu(),[uy,zn]=qf(mi),$f=i=>{const{__scopePopover:n,children:r,open:o,defaultOpen:u,onOpenChange:l,modal:p=!1}=i,x=ts(n),d=w.useRef(null),[m,h]=w.useState(!1),[v,b]=fa({prop:o,defaultProp:u??!1,onChange:l,caller:mi});return a.jsx(Ax,{...x,children:a.jsx(uy,{scope:n,contentId:ua(),triggerRef:d,open:v,onOpenChange:b,onOpenToggle:w.useCallback(()=>b(S=>!S),[b]),hasCustomAnchor:m,onCustomAnchorAdd:w.useCallback(()=>h(!0),[]),onCustomAnchorRemove:w.useCallback(()=>h(!1),[]),modal:p,children:r})})};$f.displayName=mi;var Xf="PopoverAnchor",fy=w.forwardRef((i,n)=>{const{__scopePopover:r,...o}=i,u=zn(Xf,r),l=ts(r),{onCustomAnchorAdd:p,onCustomAnchorRemove:x}=u;return w.useEffect(()=>(p(),()=>x()),[p,x]),a.jsx(Bu,{...l,...o,ref:n})});fy.displayName=Xf;var Yf="PopoverTrigger",Vf=w.forwardRef((i,n)=>{const{__scopePopover:r,...o}=i,u=zn(Yf,r),l=ts(r),p=cn(n,u.triggerRef),x=a.jsx(Wt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":u.open,"aria-controls":u.contentId,"data-state":ed(u.open),...o,ref:p,onClick:rt(i.onClick,u.onOpenToggle)});return u.hasCustomAnchor?x:a.jsx(Bu,{asChild:!0,...l,children:x})});Vf.displayName=Yf;var wa="PopoverPortal",[dy,hy]=qf(wa,{forceMount:void 0}),Kf=i=>{const{__scopePopover:n,forceMount:r,children:o,container:u}=i,l=zn(wa,n);return a.jsx(dy,{scope:n,forceMount:r,children:a.jsx(rr,{present:r||l.open,children:a.jsx(Px,{asChild:!0,container:u,children:o})})})};Kf.displayName=wa;var Er="PopoverContent",Qf=w.forwardRef((i,n)=>{const r=hy(Er,i.__scopePopover),{forceMount:o=r.forceMount,...u}=i,l=zn(Er,i.__scopePopover);return a.jsx(rr,{present:o||l.open,children:l.modal?a.jsx(my,{...u,ref:n}):a.jsx(gy,{...u,ref:n})})});Qf.displayName=Er;var py=Qo("PopoverContent.RemoveScroll"),my=w.forwardRef((i,n)=>{const r=zn(Er,i.__scopePopover),o=w.useRef(null),u=cn(n,o),l=w.useRef(!1);return w.useEffect(()=>{const p=o.current;if(p)return Jx(p)},[]),a.jsx(Zx,{as:py,allowPinchZoom:!0,children:a.jsx(Jf,{...i,ref:u,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rt(i.onCloseAutoFocus,p=>{p.preventDefault(),l.current||r.triggerRef.current?.focus()}),onPointerDownOutside:rt(i.onPointerDownOutside,p=>{const x=p.detail.originalEvent,d=x.button===0&&x.ctrlKey===!0,m=x.button===2||d;l.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:rt(i.onFocusOutside,p=>p.preventDefault(),{checkForDefaultPrevented:!1})})})}),gy=w.forwardRef((i,n)=>{const r=zn(Er,i.__scopePopover),o=w.useRef(!1),u=w.useRef(!1);return a.jsx(Jf,{...i,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{i.onCloseAutoFocus?.(l),l.defaultPrevented||(o.current||r.triggerRef.current?.focus(),l.preventDefault()),o.current=!1,u.current=!1},onInteractOutside:l=>{i.onInteractOutside?.(l),l.defaultPrevented||(o.current=!0,l.detail.originalEvent.type==="pointerdown"&&(u.current=!0));const p=l.target;r.triggerRef.current?.contains(p)&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&u.current&&l.preventDefault()}})}),Jf=w.forwardRef((i,n)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:u,onCloseAutoFocus:l,disableOutsidePointerEvents:p,onEscapeKeyDown:x,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:h,...v}=i,b=zn(Er,r),S=ts(r);return ev(),a.jsx(tv,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:u,onUnmountAutoFocus:l,children:a.jsx(jx,{asChild:!0,disableOutsidePointerEvents:p,onInteractOutside:h,onEscapeKeyDown:x,onPointerDownOutside:d,onFocusOutside:m,onDismiss:()=>b.onOpenChange(!1),children:a.jsx(Ix,{"data-state":ed(b.open),role:"dialog",id:b.contentId,...S,...v,ref:n,style:{...v.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Zf="PopoverClose",_y=w.forwardRef((i,n)=>{const{__scopePopover:r,...o}=i,u=zn(Zf,r);return a.jsx(Wt.button,{type:"button",...o,ref:n,onClick:rt(i.onClick,()=>u.onOpenChange(!1))})});_y.displayName=Zf;var xy="PopoverArrow",vy=w.forwardRef((i,n)=>{const{__scopePopover:r,...o}=i,u=ts(r);return a.jsx(Lx,{...u,...o,ref:n})});vy.displayName=xy;function ed(i){return i?"open":"closed"}var by=$f,yy=Vf,wy=Kf,Ey=Qf;function Au({...i}){return a.jsx(by,{"data-slot":"popover",...i})}function Pu({...i}){return a.jsx(yy,{"data-slot":"popover-trigger",...i})}function ju({className:i,align:n="center",sideOffset:r=4,...o}){return a.jsx(wy,{children:a.jsx(Ey,{"data-slot":"popover-content",align:n,sideOffset:r,className:Hn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",i),...o})})}function Sy(i,[n,r]){return Math.min(r,Math.max(n,i))}function Cy(i,n){return w.useReducer((r,o)=>n[r][o]??r,i)}var Ea="ScrollArea",[td]=Zr(Ea),[Ny,en]=td(Ea),nd=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,type:o="hover",dir:u,scrollHideDelay:l=600,...p}=i,[x,d]=w.useState(null),[m,h]=w.useState(null),[v,b]=w.useState(null),[S,T]=w.useState(null),[L,R]=w.useState(null),[D,G]=w.useState(0),[I,k]=w.useState(0),[q,$]=w.useState(!1),[X,Y]=w.useState(!1),F=cn(n,A=>d(A)),P=pa(u);return a.jsx(Ny,{scope:r,type:o,dir:P,scrollHideDelay:l,scrollArea:x,viewport:m,onViewportChange:h,content:v,onContentChange:b,scrollbarX:S,onScrollbarXChange:T,scrollbarXEnabled:q,onScrollbarXEnabledChange:$,scrollbarY:L,onScrollbarYChange:R,scrollbarYEnabled:X,onScrollbarYEnabledChange:Y,onCornerWidthChange:G,onCornerHeightChange:k,children:a.jsx(Wt.div,{dir:P,...p,ref:F,style:{position:"relative","--radix-scroll-area-corner-width":D+"px","--radix-scroll-area-corner-height":I+"px",...i.style}})})});nd.displayName=Ea;var rd="ScrollAreaViewport",sd=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,children:o,nonce:u,...l}=i,p=en(rd,r),x=w.useRef(null),d=cn(n,x,p.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:u}),a.jsx(Wt.div,{"data-radix-scroll-area-viewport":"",...l,ref:d,style:{overflowX:p.scrollbarXEnabled?"scroll":"hidden",overflowY:p.scrollbarYEnabled?"scroll":"hidden",...i.style},children:a.jsx("div",{ref:p.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});sd.displayName=rd;var _n="ScrollAreaScrollbar",id=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=en(_n,i.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:p}=u,x=i.orientation==="horizontal";return w.useEffect(()=>(x?l(!0):p(!0),()=>{x?l(!1):p(!1)}),[x,l,p]),u.type==="hover"?a.jsx(Ty,{...o,ref:n,forceMount:r}):u.type==="scroll"?a.jsx(Ry,{...o,ref:n,forceMount:r}):u.type==="auto"?a.jsx(od,{...o,ref:n,forceMount:r}):u.type==="always"?a.jsx(Sa,{...o,ref:n}):null});id.displayName=_n;var Ty=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=en(_n,i.__scopeScrollArea),[l,p]=w.useState(!1);return w.useEffect(()=>{const x=u.scrollArea;let d=0;if(x){const m=()=>{window.clearTimeout(d),p(!0)},h=()=>{d=window.setTimeout(()=>p(!1),u.scrollHideDelay)};return x.addEventListener("pointerenter",m),x.addEventListener("pointerleave",h),()=>{window.clearTimeout(d),x.removeEventListener("pointerenter",m),x.removeEventListener("pointerleave",h)}}},[u.scrollArea,u.scrollHideDelay]),a.jsx(rr,{present:r||l,children:a.jsx(od,{"data-state":l?"visible":"hidden",...o,ref:n})})}),Ry=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=en(_n,i.__scopeScrollArea),l=i.orientation==="horizontal",p=_i(()=>d("SCROLL_END"),100),[x,d]=Cy("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 w.useEffect(()=>{if(x==="idle"){const m=window.setTimeout(()=>d("HIDE"),u.scrollHideDelay);return()=>window.clearTimeout(m)}},[x,u.scrollHideDelay,d]),w.useEffect(()=>{const m=u.viewport,h=l?"scrollLeft":"scrollTop";if(m){let v=m[h];const b=()=>{const S=m[h];v!==S&&(d("SCROLL"),p()),v=S};return m.addEventListener("scroll",b),()=>m.removeEventListener("scroll",b)}},[u.viewport,l,d,p]),a.jsx(rr,{present:r||x!=="hidden",children:a.jsx(Sa,{"data-state":x==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:rt(i.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:rt(i.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),od=w.forwardRef((i,n)=>{const r=en(_n,i.__scopeScrollArea),{forceMount:o,...u}=i,[l,p]=w.useState(!1),x=i.orientation==="horizontal",d=_i(()=>{if(r.viewport){const m=r.viewport.offsetWidth<r.viewport.scrollWidth,h=r.viewport.offsetHeight<r.viewport.scrollHeight;p(x?m:h)}},10);return Sr(r.viewport,d),Sr(r.content,d),a.jsx(rr,{present:o||l,children:a.jsx(Sa,{"data-state":l?"visible":"hidden",...u,ref:n})})}),Sa=w.forwardRef((i,n)=>{const{orientation:r="vertical",...o}=i,u=en(_n,i.__scopeScrollArea),l=w.useRef(null),p=w.useRef(0),[x,d]=w.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=fd(x.viewport,x.content),h={...o,sizes:x,onSizesChange:d,hasThumb:m>0&&m<1,onThumbChange:b=>l.current=b,onThumbPointerUp:()=>p.current=0,onThumbPointerDown:b=>p.current=b};function v(b,S){return Ly(b,p.current,x,S)}return r==="horizontal"?a.jsx(ky,{...h,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const b=u.viewport.scrollLeft,S=Iu(b,x,u.dir);l.current.style.transform=`translate3d(${S}px, 0, 0)`}},onWheelScroll:b=>{u.viewport&&(u.viewport.scrollLeft=b)},onDragScroll:b=>{u.viewport&&(u.viewport.scrollLeft=v(b,u.dir))}}):r==="vertical"?a.jsx(Ay,{...h,ref:n,onThumbPositionChange:()=>{if(u.viewport&&l.current){const b=u.viewport.scrollTop,S=Iu(b,x);l.current.style.transform=`translate3d(0, ${S}px, 0)`}},onWheelScroll:b=>{u.viewport&&(u.viewport.scrollTop=b)},onDragScroll:b=>{u.viewport&&(u.viewport.scrollTop=v(b))}}):null}),ky=w.forwardRef((i,n)=>{const{sizes:r,onSizesChange:o,...u}=i,l=en(_n,i.__scopeScrollArea),[p,x]=w.useState(),d=w.useRef(null),m=cn(n,d,l.onScrollbarXChange);return w.useEffect(()=>{d.current&&x(getComputedStyle(d.current))},[d]),a.jsx(ld,{"data-orientation":"horizontal",...u,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":gi(r)+"px",...i.style},onThumbPointerDown:h=>i.onThumbPointerDown(h.x),onDragScroll:h=>i.onDragScroll(h.x),onWheelScroll:(h,v)=>{if(l.viewport){const b=l.viewport.scrollLeft+h.deltaX;i.onWheelScroll(b),hd(b,v)&&h.preventDefault()}},onResize:()=>{d.current&&l.viewport&&p&&o({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:ui(p.paddingLeft),paddingEnd:ui(p.paddingRight)}})}})}),Ay=w.forwardRef((i,n)=>{const{sizes:r,onSizesChange:o,...u}=i,l=en(_n,i.__scopeScrollArea),[p,x]=w.useState(),d=w.useRef(null),m=cn(n,d,l.onScrollbarYChange);return w.useEffect(()=>{d.current&&x(getComputedStyle(d.current))},[d]),a.jsx(ld,{"data-orientation":"vertical",...u,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":gi(r)+"px",...i.style},onThumbPointerDown:h=>i.onThumbPointerDown(h.y),onDragScroll:h=>i.onDragScroll(h.y),onWheelScroll:(h,v)=>{if(l.viewport){const b=l.viewport.scrollTop+h.deltaY;i.onWheelScroll(b),hd(b,v)&&h.preventDefault()}},onResize:()=>{d.current&&l.viewport&&p&&o({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:ui(p.paddingTop),paddingEnd:ui(p.paddingBottom)}})}})}),[Py,ad]=td(_n),ld=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:u,onThumbChange:l,onThumbPointerUp:p,onThumbPointerDown:x,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:h,onResize:v,...b}=i,S=en(_n,r),[T,L]=w.useState(null),R=cn(n,F=>L(F)),D=w.useRef(null),G=w.useRef(""),I=S.viewport,k=o.content-o.viewport,q=Un(h),$=Un(d),X=_i(v,10);function Y(F){if(D.current){const P=F.clientX-D.current.left,A=F.clientY-D.current.top;m({x:P,y:A})}}return w.useEffect(()=>{const F=P=>{const A=P.target;T?.contains(A)&&q(P,k)};return document.addEventListener("wheel",F,{passive:!1}),()=>document.removeEventListener("wheel",F,{passive:!1})},[I,T,k,q]),w.useEffect($,[o,$]),Sr(T,X),Sr(S.content,X),a.jsx(Py,{scope:r,scrollbar:T,hasThumb:u,onThumbChange:Un(l),onThumbPointerUp:Un(p),onThumbPositionChange:$,onThumbPointerDown:Un(x),children:a.jsx(Wt.div,{...b,ref:R,style:{position:"absolute",...b.style},onPointerDown:rt(i.onPointerDown,F=>{F.button===0&&(F.target.setPointerCapture(F.pointerId),D.current=T.getBoundingClientRect(),G.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),Y(F))}),onPointerMove:rt(i.onPointerMove,Y),onPointerUp:rt(i.onPointerUp,F=>{const P=F.target;P.hasPointerCapture(F.pointerId)&&P.releasePointerCapture(F.pointerId),document.body.style.webkitUserSelect=G.current,S.viewport&&(S.viewport.style.scrollBehavior=""),D.current=null})})})}),ci="ScrollAreaThumb",cd=w.forwardRef((i,n)=>{const{forceMount:r,...o}=i,u=ad(ci,i.__scopeScrollArea);return a.jsx(rr,{present:r||u.hasThumb,children:a.jsx(jy,{ref:n,...o})})}),jy=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,style:o,...u}=i,l=en(ci,r),p=ad(ci,r),{onThumbPositionChange:x}=p,d=cn(n,v=>p.onThumbChange(v)),m=w.useRef(void 0),h=_i(()=>{m.current&&(m.current(),m.current=void 0)},100);return w.useEffect(()=>{const v=l.viewport;if(v){const b=()=>{if(h(),!m.current){const S=My(v,x);m.current=S,x()}};return x(),v.addEventListener("scroll",b),()=>v.removeEventListener("scroll",b)}},[l.viewport,h,x]),a.jsx(Wt.div,{"data-state":p.hasThumb?"visible":"hidden",...u,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:rt(i.onPointerDownCapture,v=>{const S=v.target.getBoundingClientRect(),T=v.clientX-S.left,L=v.clientY-S.top;p.onThumbPointerDown({x:T,y:L})}),onPointerUp:rt(i.onPointerUp,p.onThumbPointerUp)})});cd.displayName=ci;var Ca="ScrollAreaCorner",ud=w.forwardRef((i,n)=>{const r=en(Ca,i.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?a.jsx(Iy,{...i,ref:n}):null});ud.displayName=Ca;var Iy=w.forwardRef((i,n)=>{const{__scopeScrollArea:r,...o}=i,u=en(Ca,r),[l,p]=w.useState(0),[x,d]=w.useState(0),m=!!(l&&x);return Sr(u.scrollbarX,()=>{const h=u.scrollbarX?.offsetHeight||0;u.onCornerHeightChange(h),d(h)}),Sr(u.scrollbarY,()=>{const h=u.scrollbarY?.offsetWidth||0;u.onCornerWidthChange(h),p(h)}),m?a.jsx(Wt.div,{...o,ref:n,style:{width:l,height:x,position:"absolute",right:u.dir==="ltr"?0:void 0,left:u.dir==="rtl"?0:void 0,bottom:0,...i.style}}):null});function ui(i){return i?parseInt(i,10):0}function fd(i,n){const r=i/n;return isNaN(r)?0:r}function gi(i){const n=fd(i.viewport,i.content),r=i.scrollbar.paddingStart+i.scrollbar.paddingEnd,o=(i.scrollbar.size-r)*n;return Math.max(o,18)}function Ly(i,n,r,o="ltr"){const u=gi(r),l=u/2,p=n||l,x=u-p,d=r.scrollbar.paddingStart+p,m=r.scrollbar.size-r.scrollbar.paddingEnd-x,h=r.content-r.viewport,v=o==="ltr"?[0,h]:[h*-1,0];return dd([d,m],v)(i)}function Iu(i,n,r="ltr"){const o=gi(n),u=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,l=n.scrollbar.size-u,p=n.content-n.viewport,x=l-o,d=r==="ltr"?[0,p]:[p*-1,0],m=Sy(i,d);return dd([0,p],[0,x])(m)}function dd(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 hd(i,n){return i>0&&i<n}var My=(i,n=()=>{})=>{let r={left:i.scrollLeft,top:i.scrollTop},o=0;return(function u(){const l={left:i.scrollLeft,top:i.scrollTop},p=r.left!==l.left,x=r.top!==l.top;(p||x)&&n(),r=l,o=window.requestAnimationFrame(u)})(),()=>window.cancelAnimationFrame(o)};function _i(i,n){const r=Un(i),o=w.useRef(0);return w.useEffect(()=>()=>window.clearTimeout(o.current),[]),w.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,n)},[r,n])}function Sr(i,n){const r=Un(n);Mx(()=>{let o=0;if(i){const u=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return u.observe(i),()=>{window.cancelAnimationFrame(o),u.unobserve(i)}}},[i,r])}var Dy=nd,Oy=sd,Fy=ud;function Lu({className:i,children:n,...r}){return a.jsxs(Dy,{"data-slot":"scroll-area",className:Hn("relative",i),...r,children:[a.jsx(Oy,{"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(By,{}),a.jsx(Fy,{})]})}function By({className:i,orientation:n="vertical",...r}){return a.jsx(id,{"data-slot":"scroll-area-scrollbar",orientation:n,className:Hn("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(cd,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Uy=100,Wy=20;function Mu(i,n,r,o){return{id:Date.now().toString(),deviceId:i||"unknown",deviceName:n||"Unknown Device",taskText:r?.content||"No task description",success:o?.success??!1,steps:o?.steps??0,startTime:r?.timestamp||new Date,endTime:o?.timestamp||new Date,duration:(o?.timestamp?.getTime()||Date.now())-(r?.timestamp?.getTime()||Date.now()),thinking:o?.thinking??[],actions:o?.actions??[],finalMessage:o?.content||"No result message",errorMessage:o?.success===!1?o?.content||"Unknown error":void 0}}function Du(i,n){try{const r=`history-${i}`,o=localStorage.getItem(r),u=o?JSON.parse(o):[];u.unshift(n);const l=u.slice(0,Uy);localStorage.setItem(r,JSON.stringify(l))}catch(r){if(r instanceof Error&&r.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old history");try{const o=`history-${i}`,u=localStorage.getItem(o),p=(u?JSON.parse(u):[]).slice(0,Wy);p.unshift(n),localStorage.setItem(o,JSON.stringify(p))}catch(o){console.error("Failed to save history even after reduction:",o)}}else console.warn("Failed to save history:",r)}}function Gy(i){try{const n=`history-${i}`,r=localStorage.getItem(n);return r?JSON.parse(r).map(u=>({...u,startTime:new Date(u.startTime),endTime:new Date(u.endTime)})):[]}catch(n){return console.warn("Failed to load history:",n),[]}}function Hy(i,n){try{const r=`history-${i}`,o=localStorage.getItem(r);if(!o)return;const l=JSON.parse(o).filter(p=>p.id!==n);localStorage.setItem(r,JSON.stringify(l))}catch(r){console.warn("Failed to delete history item:",r)}}function zy(i){try{const n=`history-${i}`;localStorage.removeItem(n)}catch(n){console.warn("Failed to clear history:",n)}}function qy(i){const r=new Date().getTime()-i.getTime(),o=Math.floor(r/6e4),u=Math.floor(r/36e5),l=Math.floor(r/864e5);return o<1?"Just now":o<60?`${o}m ago`:u<24?`${u}h ago`:l<7?`${l}d ago`:i.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $y(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 Xy({item:i,onSelect:n,onDelete:r}){const o=Jr(),u=l=>{l.stopPropagation(),confirm(o.history.deleteConfirm)&&r(i.id)};return a.jsx(wr,{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.taskText}),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:qy(i.startTime)}),a.jsx("span",{children:"•"}),a.jsxs("span",{children:[i.steps," ",i.steps===1?"step":"steps"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:$y(i.duration)})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Qt,{variant:i.success?"success":"destructive",className:"shrink-0",children:i.success?a.jsxs(a.Fragment,{children:[a.jsx(Wn,{className:"w-3 h-3 mr-1"}),o.history.success]}):a.jsxs(a.Fragment,{children:[a.jsx(tr,{className:"w-3 h-3 mr-1"}),o.history.failed]})}),a.jsx(Ae,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 hover:text-red-500 dark:text-slate-500 dark:hover:text-red-400",onClick:u,title:o.history.deleteItem,children:a.jsx(nv,{className:"w-3 h-3"})})]})]})]})})}function Yy({deviceId:i,deviceSerial:n,deviceName:r,config:o,isConfigured:u,thinkingMode:l="fast",onThinkingModeChange:p}){const x=Jr(),[d,m]=w.useState([]),[h,v]=w.useState(""),[b,S]=w.useState(!1),[T,L]=w.useState(!1),[R,D]=w.useState(null),[G,I]=w.useState(!1),[k,q]=w.useState(null),[$,X]=w.useState(!0),[Y,F]=w.useState(!1),[P,A]=w.useState("auto"),[de,ae]=w.useState(null),[H,V]=w.useState("success"),[K,re]=w.useState(!1),[ie,ye]=w.useState([]),[we,se]=w.useState([]),[Le,Me]=w.useState(!1),[ge,Be]=w.useState(!1),[Ze,pt]=w.useState(!1),{state:Ke,handleEvent:Pe,reset:ot}=cy(),ft=w.useRef(null),He=(W,Ne=2e3,pe="success")=>{ft.current&&clearTimeout(ft.current),V(pe),ae(W),ft.current=setTimeout(()=>{ae(null)},Ne)};w.useEffect(()=>()=>{ft.current&&clearTimeout(ft.current)},[]);const[Gt,Xe]=w.useState(!1),[at,ee]=w.useState(!1),Z=w.useRef(null),M=()=>{Z.current&&clearTimeout(Z.current),Xe(!0)},Q=()=>{Z.current=setTimeout(()=>{Xe(!1)},500)};w.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current)},[]);const xe=()=>{ee(W=>!W)},oe=w.useRef(null),fe=w.useRef(null),ve=w.useRef(null),mt=w.useRef(null),yt=w.useRef(null),Nt=w.useRef(!1),lt=w.useRef(!1),dt=w.useRef(null),Rn=w.useRef(0),kn=w.useRef(null),[sr,An]=w.useState(!0),[Nr,tn]=w.useState(!1),ir=w.useRef(Sf.throttle(()=>{const W=yt.current;if(!W)return;const Ne=80,pe=W.scrollHeight-W.scrollTop-W.clientHeight,Ye=pe<=1;An(Ye),pe<=Ne&&tn(!1)},100));w.useEffect(()=>{const W=ir.current;return()=>{W.cancel()}},[]);const nn=w.useCallback(async()=>{if(o)try{await Dx({model_config:{base_url:o.base_url||void 0,api_key:o.api_key||void 0,model_name:o.model_name||void 0},agent_config:{device_id:i}}),I(!0),D(null)}catch(W){const Ne=W instanceof Error?W.message:"Initialization failed";D(Ne)}},[i,o]),xn=w.useCallback(async()=>{if(o)try{await Ox({device_id:i,decision_base_url:o.decision_base_url||"https://api-inference.modelscope.cn/v1",decision_api_key:o.decision_api_key||"",decision_model_name:o.decision_model_name||"ZhipuAI/GLM-4.7",vision_base_url:o.base_url,vision_api_key:o.api_key,vision_model_name:o.model_name,thinking_mode:l}),pt(!0),D(null)}catch(W){const Ne=W instanceof Error?W.message:"Dual model initialization failed";D(Ne)}},[i,o,l]),xi=w.useCallback(async()=>{ge?Be(!1):(Ze||await xn(),Be(!0))},[ge,Ze,xn]);w.useEffect(()=>{ge&&Ze&&xn()},[l]),w.useEffect(()=>{u&&o&&!G&&!lt.current&&(lt.current=!0,nn())},[u,o,G,nn]),w.useEffect(()=>{if(K){const W=Gy(n);ye(W)}},[K,n]);const vi=W=>{const Ne={id:`${W.id}-user`,role:"user",content:W.taskText,timestamp:W.startTime},pe={id:`${W.id}-agent`,role:"assistant",content:W.finalMessage,timestamp:W.endTime,steps:W.steps,success:W.success,thinking:W.thinking,actions:W.actions,isStreaming:!1},Ye=[Ne,pe];m(Ye),Rn.current=Ye.length,kn.current=[pe.id,pe.content?.length??0,pe.currentThinking?.length??0,pe.thinking?JSON.stringify(pe.thinking).length:0,pe.steps??"",pe.isStreaming?1:0].join("|"),tn(!1),An(!0),re(!1)},bi=()=>{confirm(x.history.clearAllConfirm)&&(zy(n),ye([]))},ns=W=>{Hy(n,W),ye(Ne=>Ne.filter(pe=>pe.id!==W))};w.useEffect(()=>{if(!G||!o)return;const W=dt.current;W&&(W.base_url!==o.base_url||W.model_name!==o.model_name||W.api_key!==o.api_key)&&(console.log(`[DevicePanel] Config changed for device ${i}, re-initializing...`),nn()),dt.current=o},[o,G,i,nn]);const Tr=w.useCallback(async()=>{const W=h.trim();if(!W||b)return;G||await nn();const Ne={id:Date.now().toString(),role:"user",content:W,timestamp:new Date};m(qe=>[...qe,Ne]),v(""),S(!0),D(null);const pe=[],Ye=[];let un="";const st=[];let ze=null;const et=(Date.now()+1).toString(),Tt={id:et,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};m(qe=>[...qe,Tt]);const is=()=>{if(st.length>0){const qe=st.join("");st.length=0,un+=qe,m(Rt=>Rt.map(Lt=>Lt.id===et?{...Lt,currentThinking:un}:Lt))}ze=null},Ti=Fx(Ne.content,i,qe=>{st.push(qe.chunk),ze===null&&(ze=setTimeout(is,50))},qe=>{ze!==null&&(clearTimeout(ze),is());const Rt=qe.thinking&&qe.thinking.length>0?qe.thinking:un;Rt&&pe.push(Rt),un="",Ye.push(qe.action),m(Lt=>Lt.map(wt=>wt.id===et?{...wt,thinking:[...pe],actions:[...Ye],steps:qe.step,currentThinking:""}:wt))},qe=>{ze!==null&&clearTimeout(ze);const Rt={...Tt,content:qe.message,success:qe.success,isStreaming:!1,steps:qe.steps,thinking:[...pe],actions:[...Ye],timestamp:new Date,currentThinking:void 0};m(wt=>wt.map(qn=>qn.id===et?Rt:qn)),S(!1),oe.current=null;const Lt=Mu(n,r,Ne,Rt);Du(n,Lt)},qe=>{ze!==null&&clearTimeout(ze);const Rt={...Tt,content:`Error: ${qe.message}`,success:!1,isStreaming:!1,thinking:[...pe],actions:[...Ye],timestamp:new Date,currentThinking:void 0};m(wt=>wt.map(qn=>qn.id===et?Rt:qn)),S(!1),D(qe.message),oe.current=null;const Lt=Mu(n,r,Ne,Rt);Du(n,Lt)},qe=>{ze!==null&&clearTimeout(ze);const Rt={...Tt,content:qe.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...pe],actions:[...Ye],timestamp:new Date,currentThinking:void 0};m(Lt=>Lt.map(wt=>wt.id===et?Rt:wt)),S(!1),oe.current=null,ae(x.chat.aborted),V("success"),setTimeout(()=>ae(null),2e3)});oe.current=Ti},[h,b,G,i,n,r,nn,x,ae,V]),rs=w.useCallback(async()=>{const W=h.trim();if(!W||b)return;Ze||await xn();const Ne={id:Date.now().toString(),role:"user",content:W,timestamp:new Date};m(st=>[...st,Ne]),v(""),S(!0),D(null),ot();const pe=(Date.now()+1).toString(),Ye={id:pe,role:"assistant",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0};m(st=>[...st,Ye]);const un=Bx(Ne.content,i,st=>{if(Pe(st),st.type==="task_complete"){const ze=st;m(et=>et.map(Tt=>Tt.id===pe?{...Tt,content:ze.message,success:ze.success,steps:ze.steps,isStreaming:!1}:Tt)),S(!1),fe.current=null}else if(st.type==="error"){const ze=st;m(et=>et.map(Tt=>Tt.id===pe?{...Tt,content:`Error: ${ze.message}`,success:!1,isStreaming:!1}:Tt)),S(!1),D(ze.message),fe.current=null}else st.type==="aborted"&&(m(ze=>ze.map(et=>et.id===pe?{...et,content:"Task aborted",success:!1,isStreaming:!1}:et)),S(!1),fe.current=null)},st=>{m(ze=>ze.map(et=>et.id===pe?{...et,content:`Error: ${st.message}`,success:!1,isStreaming:!1}:et)),S(!1),D(st.message),fe.current=null});fe.current=un},[h,b,Ze,i,xn,Pe,ot]),ss=w.useCallback(async()=>{ge?await rs():await Tr()},[ge,rs,Tr]),yi=w.useCallback(async()=>{oe.current&&oe.current.close(),fe.current&&fe.current.close(),m([]),S(!1),D(null),tn(!1),An(!0),oe.current=null,fe.current=null,Rn.current=0,kn.current=null,ot(),ge?await Ux(i):await Wx(i)},[i,ge,ot]),wi=w.useCallback(async()=>{if(!(!oe.current&&!fe.current)){L(!0);try{oe.current&&(oe.current.close(),oe.current=null),fe.current&&(fe.current.close(),fe.current=null),m(W=>{const Ne=W[W.length-1];return Ne&&Ne.role==="assistant"&&Ne.isStreaming?W.map((pe,Ye)=>Ye===W.length-1?{...pe,content:pe.content||x.chat.aborted,isStreaming:!1,success:!1,currentThinking:void 0}:pe):W}),ge?Gx(i).catch(W=>console.error("Backend abort failed:",W)):Hx(i).catch(W=>console.error("Backend abort failed:",W)),ae(x.chat.aborted),V("success"),setTimeout(()=>ae(null),2e3)}catch(W){console.error("Failed to abort chat:",W),ae(x.chat.abortFailed),V("error"),setTimeout(()=>ae(null),2e3)}finally{S(!1),L(!1)}}},[i,ge,x]),or=w.useCallback(()=>{mt.current?.scrollIntoView({behavior:"smooth"})},[]);w.useEffect(()=>{const W=d[d.length-1],Ne=W?.thinking?JSON.stringify(W.thinking).length:0,pe=W?[W.id,W.content?.length??0,W.currentThinking?.length??0,Ne,W.steps??"",W.isStreaming?1:0].join("|"):null,Ye=d.length>Rn.current,un=pe!==kn.current&&d.length>0;if(Rn.current=d.length,kn.current=pe,sr){or(),tn(!1);return}if(d.length===0){tn(!1);return}(Ye||un)&&tn(!0)},[d,sr,or]),w.useEffect(()=>()=>{oe.current&&oe.current.close(),fe.current&&fe.current.close(),ve.current&&ve.current.close()},[i]),w.useEffect(()=>{(async()=>{try{const Ne=await qx();se(Ne.workflows)}catch(Ne){console.error("Failed to load workflows:",Ne)}})()},[]);const Ei=W=>{v(W.text),Me(!1)},Si=()=>{ir.current()},Ci=()=>{or(),tn(!1),An(!0)};w.useEffect(()=>{if(!i||!(P==="screenshot"||P==="auto"&&Y))return;const Ne=async()=>{if(!Nt.current){Nt.current=!0;try{const Ye=await Ou(i);Ye.success&&q(Ye)}catch(Ye){console.error("Failed to fetch screenshot:",Ye)}finally{Nt.current=!1}}};Ne();const pe=setInterval(Ne,500);return()=>clearInterval(pe)},[i,Y,P]);const Rr=W=>{(W.metaKey||W.ctrlKey)&&W.key==="Enter"&&(W.preventDefault(),ss())},Ni=w.useCallback(W=>{ve.current=W},[]),kr=w.useCallback(()=>{F(!0),X(!1)},[]),Ar=W=>{A(W)};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(wr,{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(Qs,{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(Au,{open:K,onOpenChange:re,children:[a.jsx(Pu,{asChild:!0,children:a.jsx(Ae,{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:x.history.title,children:a.jsx(nu,{className:"h-4 w-4"})})}),a.jsxs(ju,{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:x.history.title}),ie.length>0&&a.jsx(Ae,{variant:"ghost",size:"sm",onClick:bi,className:"h-7 text-xs",children:x.history.clearAll})]}),a.jsx(Lu,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:ie.length>0?ie.map(W=>a.jsx(Xy,{item:W,onSelect:vi,onDelete:ns},W.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(nu,{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:x.history.noHistory}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:x.history.noHistoryDescription})]})})})]})]}),u?G?a.jsxs(Qt,{variant:"success",children:[a.jsx(Wn,{className:"w-3 h-3 mr-1"}),x.devicePanel.ready]}):a.jsx(Ae,{onClick:nn,disabled:!u||!o,size:"sm",variant:"twitter",children:x.devicePanel.initializing}):a.jsxs(Qt,{variant:"warning",children:[a.jsx(tr,{className:"w-3 h-3 mr-1"}),x.devicePanel.noConfig]}),a.jsxs(Ys,{children:[a.jsx(Vs,{asChild:!0,children:a.jsx(Ae,{variant:ge?"default":"ghost",size:"icon",onClick:xi,className:`h-8 w-8 rounded-full ${ge?"bg-purple-500 hover:bg-purple-600 text-white":"text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300"}`,children:a.jsx(da,{className:"h-4 w-4"})})}),a.jsx(Ks,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:ge?x.devicePanel.tooltips.disableDualModel:x.devicePanel.tooltips.enableDualModel}),a.jsx("p",{className:"text-xs opacity-80",children:ge?x.devicePanel.tooltips.disableDualModelDesc:x.devicePanel.tooltips.enableDualModelDesc})]})})]}),ge&&p&&a.jsxs(a.Fragment,{children:[a.jsxs(Ys,{children:[a.jsx(Vs,{asChild:!0,children:a.jsx(Ae,{variant:l==="fast"?"default":"ghost",size:"icon",onClick:()=>p("fast"),className:`h-8 w-8 rounded-full ${l==="fast"?"bg-green-500 hover:bg-green-600 text-white":"text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300"}`,children:a.jsx(ai,{className:"h-4 w-4"})})}),a.jsx(Ks,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:x.devicePanel.tooltips.fastMode}),a.jsx("p",{className:"text-xs opacity-80",children:x.devicePanel.tooltips.fastModeDesc})]})})]}),a.jsxs(Ys,{children:[a.jsx(Vs,{asChild:!0,children:a.jsx(Ae,{variant:l==="deep"?"default":"ghost",size:"icon",onClick:()=>p("deep"),className:`h-8 w-8 rounded-full ${l==="deep"?"bg-blue-500 hover:bg-blue-600 text-white":"text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300"}`,children:a.jsx(Yu,{className:"h-4 w-4"})})}),a.jsx(Ks,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:x.devicePanel.tooltips.deepMode}),a.jsx("p",{className:"text-xs opacity-80",children:x.devicePanel.tooltips.deepModeDesc})]})})]})]}),a.jsx(Ae,{variant:"ghost",size:"icon",onClick:yi,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(Pv,{className:"h-4 w-4"})})]})]}),ge&&a.jsx("div",{className:"border-b border-slate-200 dark:border-slate-800 p-4",children:a.jsx(ly,{state:Ke,isStreaming:b,className:"",decisionModelName:o?.decision_model_name||"ZhipuAI/GLM-4.7",visionModelName:o?.model_name||"autoglm-phone"})}),R&&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(tr,{className:"w-4 h-4 flex-shrink-0"}),R]}),a.jsxs("div",{className:"flex-1 min-h-0 relative",children:[a.jsxs("div",{className:"h-full overflow-y-auto p-4",ref:yt,onScroll:Si,children:[d.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(Qs,{className:"h-8 w-8 text-slate-400"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:x.devicePanel.readyToHelp}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:x.devicePanel.describeTask})]}):d.map(W=>a.jsx("div",{className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:W.role==="assistant"?a.jsxs("div",{className:"max-w-[85%] space-y-3",children:[W.thinking?.map((Ne,pe)=>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(Qs,{className:"h-3 w-3 text-[#1d9bf0]"})}),a.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",pe+1]})]}),a.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:Ne}),W.actions?.[pe]&&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(W.actions[pe],null,2)})]})]},pe)),W.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(Qs,{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:[W.currentThinking,a.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),W.content&&a.jsxs("div",{className:`
122
+ rounded-2xl px-4 py-3 flex items-start gap-2
123
+ ${W.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"}
124
+ `,children:[a.jsx(Wn,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${W.success===!1?"text-red-500":"text-green-500"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"whitespace-pre-wrap",children:W.content}),W.steps!==void 0&&a.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[W.steps," steps completed"]})]})]}),W.isStreaming&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[a.jsx(pn,{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:W.content})}),a.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:W.timestamp.toLocaleTimeString()})]})},W.id)),a.jsx("div",{ref:mt})]}),Nr&&a.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:a.jsx(Ae,{onClick:Ci,size:"sm",className:"pointer-events-auto shadow-lg bg-[#1d9bf0] text-white hover:bg-[#1a8cd8]","aria-label":x.devicePanel.newMessages,children:x.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(rv,{value:h,onChange:W=>v(W.target.value),onKeyDown:Rr,placeholder:u?G?x.devicePanel.whatToDo:x.devicePanel.initDeviceFirst:x.devicePanel.configureFirst,disabled:b,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(Ys,{children:[a.jsx(Vs,{asChild:!0,children:a.jsxs(Au,{open:Le,onOpenChange:Me,children:[a.jsx(Pu,{asChild:!0,children:a.jsx(Ae,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(zx,{className:"w-4 h-4"})})}),a.jsx(ju,{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:x.workflows.selectWorkflow}),we.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:x.workflows.empty}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Lu,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:we.map(W=>a.jsxs("button",{onClick:()=>Ei(W),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:W.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:W.text})]},W.uuid))})})]})})]})}),a.jsx(Ks,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:x.devicePanel.tooltips.workflowButton}),a.jsx("p",{className:"text-xs opacity-80",children:x.devicePanel.tooltips.workflowButtonDesc})]})})]}),b&&a.jsx(Ae,{onClick:wi,disabled:T,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:x.chat.abortChat,children:T?a.jsx(pn,{className:"h-4 w-4 animate-spin"}):a.jsx(Uv,{className:"h-4 w-4"})}),!b&&a.jsx(Ae,{onClick:ss,disabled:!h.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:a.jsx(Iv,{className:"h-4 w-4"})})]})})]}),a.jsxs(wr,{className:"w-[320px] flex-shrink-0 relative min-h-0 overflow-hidden bg-background",onMouseEnter:M,onMouseLeave:Q,children:[a.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${Gt?"opacity-100":"opacity-0 pointer-events-none"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 bg-popover/90 backdrop-blur rounded-xl p-1 shadow-lg border border-border transition-all duration-300 ${at?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>Ar("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${P==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:x.devicePanel.auto}),a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>Ar("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${P==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(Hv,{className:"w-3 h-3 mr-1"}),x.devicePanel.video]}),a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>Ar("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${P==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[a.jsx(ru,{className:"w-3 h-3 mr-1"}),x.devicePanel.image]})]}),a.jsx(Ae,{variant:"ghost",size:"icon",onClick:xe,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:at?"Hide controls":"Show controls",children:at?a.jsx(ha,{className:"w-4 h-4"}):a.jsx($u,{className:"w-4 h-4"})})]})}),a.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:a.jsxs(Qt,{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:[P==="auto"&&x.devicePanel.auto,P==="video"&&a.jsxs(a.Fragment,{children:[a.jsx(Tv,{className:"w-3 h-3 mr-1"}),x.devicePanel.video]}),P==="screenshot"&&a.jsxs(a.Fragment,{children:[a.jsx(ru,{className:"w-3 h-3 mr-1"}),x.devicePanel.imageRefresh]})]})}),de&&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:[H==="error"&&a.jsx(tr,{className:"w-4 h-4"}),H==="tap"&&a.jsx(Ev,{className:"w-4 h-4"}),H==="swipe"&&a.jsx(iv,{className:"w-4 h-4"}),H==="success"&&a.jsx(Wn,{className:"w-4 h-4"}),a.jsx("span",{children:de})]}),P==="video"||P==="auto"&&$&&!Y?a.jsx(ay,{deviceId:i,className:"w-full h-full",enableControl:!0,onFallback:kr,onTapSuccess:()=>He(x.devicePanel.tapped,2e3,"tap"),onTapError:W=>He(x.devicePanel.tapError.replace("{error}",W),3e3,"error"),onSwipeSuccess:()=>He(x.devicePanel.swiped,2e3,"swipe"),onSwipeError:W=>He(x.devicePanel.swipeError.replace("{error}",W),3e3,"error"),onStreamReady:Ni,fallbackTimeout:1e5}):a.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:k&&k.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,${k.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:k.width>k.height?"100%":"auto",height:k.width>k.height?"auto":"100%"}}),k.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:x.devicePanel.sensitiveContent})]}):k?.error?a.jsxs("div",{className:"text-center text-destructive",children:[a.jsx(tr,{className:"w-8 h-8 mx-auto mb-2"}),a.jsx("p",{className:"font-medium",children:x.devicePanel.screenshotFailed}),a.jsx("p",{className:"text-xs mt-1 opacity-60",children:k.error})]}):a.jsxs("div",{className:"text-center text-muted-foreground",children:[a.jsx(pn,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),a.jsx("p",{className:"text-sm",children:x.devicePanel.loading})]})})]})]})}function Vy({message:i,type:n="info",onClose:r,duration:o=3e3}){w.useEffect(()=>{const p=setTimeout(()=>{r()},o);return()=>clearTimeout(p)},[o,r]);const u={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-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"})})};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:`${u[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 Ky=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone",api_key:""},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",api_key:""},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b",api_key:""}}];function nw(){const i=Jr(),[n,r]=w.useState([]),[o,u]=w.useState(""),[l,p]=w.useState({}),[x,d]=w.useState({message:"",type:"info",visible:!1}),m=(P,A="info")=>{d({message:P,type:A,visible:!0})},[h,v]=w.useState(null),[b,S]=w.useState(!1),[T,L]=w.useState(!1),[R,D]=w.useState(!1),[G,I]=w.useState(!1),[k,q]=w.useState({base_url:"",model_name:"",api_key:"",thinking_mode:"deep",dual_model_enabled:!1,decision_base_url:"",decision_model_name:"",decision_api_key:""});w.useEffect(()=>{(async()=>{try{const A=await Xx();v({base_url:A.base_url,model_name:A.model_name,api_key:A.api_key||void 0,thinking_mode:A.thinking_mode||"deep",dual_model_enabled:A.dual_model_enabled||!1,decision_base_url:A.decision_base_url||void 0,decision_model_name:A.decision_model_name||void 0,decision_api_key:A.decision_api_key||void 0}),q({base_url:A.base_url,model_name:A.model_name,api_key:A.api_key||"",thinking_mode:A.thinking_mode||"deep",dual_model_enabled:A.dual_model_enabled||!1,decision_base_url:A.decision_base_url||"",decision_model_name:A.decision_model_name||"",decision_api_key:A.decision_api_key||""}),A.base_url||S(!0)}catch(A){console.error("Failed to load config:",A),S(!0)}})()},[]);const $=w.useCallback(async()=>{try{const P=await $x(),A=new Map,de=new Map;for(const H of P.devices)if(H.serial){const V=de.get(H.serial)||[];V.push(H),de.set(H.serial,V)}else A.set(H.id,H);Array.from(de.values()).forEach(H=>{const K=H.find(re=>re.connection_type==="remote")||H[0];A.set(K.id,K)});const ae=Array.from(A.values());r(ae),ae.length>0&&!o&&u(ae[0].id),o&&!ae.find(H=>H.id===o)&&u(ae[0]?.id||"")}catch(P){console.error("Failed to load devices:",P)}},[o]);w.useEffect(()=>{const P=setTimeout(()=>{$()},0),A=setInterval($,3e3);return()=>{clearTimeout(P),clearInterval(A)}},[$]);const X=async()=>{if(!k.base_url){m(i.chat.baseUrlRequired,"error");return}try{await Yx({base_url:k.base_url,model_name:k.model_name||"autoglm-phone-9b",api_key:k.api_key||void 0,thinking_mode:k.thinking_mode,dual_model_enabled:k.dual_model_enabled,decision_base_url:k.decision_base_url||void 0,decision_model_name:k.decision_model_name||void 0,decision_api_key:k.decision_api_key||void 0}),v({base_url:k.base_url,model_name:k.model_name,api_key:k.api_key||void 0,thinking_mode:k.thinking_mode,dual_model_enabled:k.dual_model_enabled,decision_base_url:k.decision_base_url||void 0,decision_model_name:k.decision_model_name||void 0,decision_api_key:k.decision_api_key||void 0}),S(!1),m(i.toasts.configSaved,"success")}catch(P){console.error("Failed to save config:",P),m(`Failed to save: ${P instanceof Error?P.message:"Unknown error"}`,"error")}},Y=async P=>{try{const A=await Kx({device_id:P});A.success&&A.device_id?(u(A.device_id),m(i.toasts.wifiConnected,"success")):A.success||m(A.message||A.error||i.toasts.connectionFailed,"error")}catch(A){m(i.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",A)}},F=async P=>{try{const A=await Vx(P);A.success?m(i.toasts.wifiDisconnected,"success"):m(A.message||A.error||i.toasts.disconnectFailed,"error")}catch(A){m(i.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",A)}};return a.jsxs("div",{className:"h-full flex relative min-h-0",children:[x.visible&&a.jsx(Vy,{message:x.message,type:x.type,onClose:()=>d(P=>({...P,visible:!1}))}),a.jsx(Uu,{open:b,onOpenChange:S,children:a.jsxs(Wu,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[a.jsxs(Gu,{className:"flex-shrink-0",children:[a.jsxs(Hu,{className:"flex items-center gap-2",children:[a.jsx(Xu,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),a.jsx(zu,{children:i.chat.configureApi})]}),a.jsxs("div",{className:"space-y-4 py-4 overflow-y-auto flex-1 min-h-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{className:"text-sm font-medium",children:i.chat.selectPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ky.map(P=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>q(A=>({...A,base_url:P.config.base_url,model_name:P.config.model_name,api_key:P.config.api_key})),className:`w-full text-left p-3 rounded-lg border transition-all ${k.base_url===P.config.base_url&&(P.name!=="custom"||P.name==="custom"&&k.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(Mv,{className:`w-4 h-4 ${k.base_url===P.config.base_url&&(P.name!=="custom"||P.name==="custom"&&k.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[P.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[P.name].description})]}),"apiKeyUrl"in P&&a.jsx("a",{href:P.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:A=>A.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(vv,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},P.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(It,{htmlFor:"base_url",children:[i.chat.baseUrl," *"]}),a.jsx(Jt,{id:"base_url",value:k.base_url,onChange:P=>q({...k,base_url:P.target.value}),placeholder:"http://localhost:8080/v1"}),!k.base_url&&a.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[a.jsx(tr,{className:"w-3 h-3"}),i.chat.baseUrlRequired]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"api_key",children:i.chat.apiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(Jt,{id:"api_key",type:T?"text":"password",value:k.api_key,onChange:P=>q({...k,api_key:P.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(Ae,{type:"button",variant:"ghost",size:"icon",onClick:()=>L(!T),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:T?a.jsx(tu,{className:"w-4 h-4 text-slate-400"}):a.jsx(oi,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"model_name",children:i.chat.modelName}),a.jsx(Jt,{id:"model_name",value:k.model_name,onChange:P=>q({...k,model_name:P.target.value}),placeholder:"autoglm-phone-9b"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{className:"text-sm font-medium",children:i.chat.thinkingMode||"思考模式"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>q({...k,thinking_mode:"fast"}),className:`flex items-center gap-2 p-3 rounded-lg border transition-all ${k.thinking_mode==="fast"?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50"}`,children:[a.jsx(ai,{className:`w-4 h-4 ${k.thinking_mode==="fast"?"text-[#1d9bf0]":"text-slate-400"}`}),a.jsxs("div",{className:"text-left",children:[a.jsx("div",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.chat.fastMode||"快速响应"}),a.jsx("div",{className:"text-xs text-slate-500",children:i.chat.fastModeDesc||"减少思考时间"})]})]}),a.jsxs("button",{type:"button",onClick:()=>q({...k,thinking_mode:"deep"}),className:`flex items-center gap-2 p-3 rounded-lg border transition-all ${k.thinking_mode==="deep"?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50"}`,children:[a.jsx(da,{className:`w-4 h-4 ${k.thinking_mode==="deep"?"text-[#1d9bf0]":"text-slate-400"}`}),a.jsxs("div",{className:"text-left",children:[a.jsx("div",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.chat.deepMode||"深度思考"}),a.jsx("div",{className:"text-xs text-slate-500",children:i.chat.deepModeDesc||"完整分析过程"})]})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("button",{type:"button",onClick:()=>I(!G),className:"flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-300 hover:text-[#1d9bf0] transition-colors",children:[G?a.jsx(Jo,{className:"w-4 h-4"}):a.jsx(ha,{className:"w-4 h-4"}),i.chat.advancedSettings||"高级设置(决策模型)"]}),G&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-slate-200 dark:border-slate-700",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"decision_base_url",children:i.chat.decisionBaseUrl||"决策模型 Base URL"}),a.jsx(Jt,{id:"decision_base_url",value:k.decision_base_url,onChange:P=>q({...k,decision_base_url:P.target.value}),placeholder:"https://api-inference.modelscope.cn/v1"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"decision_model_name",children:i.chat.decisionModelName||"决策模型名称"}),a.jsx(Jt,{id:"decision_model_name",value:k.decision_model_name,onChange:P=>q({...k,decision_model_name:P.target.value}),placeholder:"ZhipuAI/GLM-4.7"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(It,{htmlFor:"decision_api_key",children:i.chat.decisionApiKey||"决策模型 API Key"}),a.jsxs("div",{className:"relative",children:[a.jsx(Jt,{id:"decision_api_key",type:R?"text":"password",value:k.decision_api_key,onChange:P=>q({...k,decision_api_key:P.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(Ae,{type:"button",variant:"ghost",size:"icon",onClick:()=>D(!R),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:R?a.jsx(tu,{className:"w-4 h-4 text-slate-400"}):a.jsx(oi,{className:"w-4 h-4 text-slate-400"})})]})]})]})]})]}),a.jsxs(qu,{className:"sm:justify-between gap-2 flex-shrink-0",children:[a.jsx(Ae,{variant:"outline",onClick:()=>{S(!1),h&&q({base_url:h.base_url,model_name:h.model_name,api_key:h.api_key||"",thinking_mode:h.thinking_mode||"deep",dual_model_enabled:h.dual_model_enabled||!1,decision_base_url:h.decision_base_url||"",decision_model_name:h.decision_model_name||"",decision_api_key:h.decision_api_key||""})},children:i.chat.cancel}),a.jsxs(Ae,{onClick:X,variant:"twitter",children:[a.jsx(Wn,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),a.jsx(A1,{devices:n,currentDeviceId:o,onSelectDevice:u,onOpenConfig:()=>S(!0),onConnectWifi:Y,onDisconnectWifi:F}),a.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4",children:n.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})]})}):n.map(P=>a.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${P.id===o?"":"hidden"}`,children:a.jsx(Yy,{deviceId:P.id,deviceSerial:P.serial,deviceName:P.model,config:h,isVisible:P.id===o,isConfigured:!!h?.base_url,thinkingMode:l[P.serial]||"fast",onThinkingModeChange:A=>{p(de=>({...de,[P.serial]:A}))}})},P.serial))})]})}export{nw as component};