autoglm-gui 1.2.1__py3-none-any.whl → 1.3.0__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 +49 -15
  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-CrBXGOgB.js} +1 -1
  19. AutoGLM_GUI/static/assets/chat-Di2fwu8V.js +124 -0
  20. AutoGLM_GUI/static/assets/dialog-CHJSPLHJ.js +45 -0
  21. AutoGLM_GUI/static/assets/{index-B_AaKuOT.js → index-9IaIXvyy.js} +1 -1
  22. AutoGLM_GUI/static/assets/index-Dt7cVkfR.js +12 -0
  23. AutoGLM_GUI/static/assets/index-Z0uYCPOO.css +1 -0
  24. AutoGLM_GUI/static/assets/{workflows-xX_QH-wI.js → workflows-DHadKApI.js} +1 -1
  25. AutoGLM_GUI/static/index.html +2 -2
  26. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.0.dist-info}/METADATA +11 -4
  27. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.0.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.0.dist-info}/WHEEL +0 -0
  33. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.0.dist-info}/entry_points.txt +0 -0
  34. {autoglm_gui-1.2.1.dist-info → autoglm_gui-1.3.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,124 +0,0 @@
1
- import{c as He,j as c,u as Yr,r as w,B as De,e as $r,f as Vr,R as Ge,g as en,h as ko,i as qo,P as jt,k as et,m as $o,n as Pn,o as Xn,p as Yn,q as Wi,s as cx,t as ux,v as fx,w as hx,x as dx,S as Wr,y as kc,z as px,A as pu,C as mx,D as Ic,E as Lc,F as gx,G as mu,H as _x,I as gu,J as xx,K as vx,L as bx,M as yx,N as wx,O as Ex,Q as Sx,T as Cx,U as Tx,V as Rx,l as Nx,W as Ax,X as Px,Y as kx,Z as Ix,_ as Lx}from"./index-CvQkCi2d.js";import{L as kn,P as Dx,D as _u,d as xu,e as vu,f as bu,j as yu,g as sn,I as xn,i as wu,k as Mx,R as Ox,u as jx,F as Fx,C as Io,T as Bx,h as Ux}from"./dialog-Dwuk2Hgl.js";const Wx=[["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"}]],Gx=He("arrow-up-down",Wx);const Hx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Eu=He("chevron-left",Hx);const zx=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Su=He("chevron-right",zx);const qx=[["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"}]],qn=He("circle-alert",qx);const $x=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Xx=He("circle-check-big",$x);const Yx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],dr=He("circle-check",Yx);const Vx=[["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"}]],Lo=He("circle-x",Vx);const Kx=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qx=He("clock",Kx);const Jx=[["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"}]],Zx=He("external-link",Jx);const ev=[["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"}]],tv=He("eye-off",ev);const nv=[["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"}]],rv=He("eye",nv);const iv=[["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"}]],sv=He("fingerprint-pattern",iv);const ov=[["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"}]],Dc=He("history",ov);const av=[["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"}]],Mc=He("image",av);const lv=[["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"}]],cv=He("monitor-play",lv);const uv=[["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"}]],fv=He("plug",uv);const hv=[["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"}]],dv=He("rotate-ccw",hv);const pv=[["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"}]],mv=He("send",pv);const gv=[["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"}]],_v=He("server",gv);const xv=[["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"}]],Cu=He("settings",xv);const vv=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Do=He("smartphone",vv);const bv=[["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"}]],Gi=He("sparkles",bv);const yv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],wv=He("square",yv);const Ev=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Sv=He("video",Ev);const Cv=[["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"}]],Tv=He("wifi-off",Cv);const Rv=[["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"}]],Mo=He("wifi",Rv);function Oc({isOpen:s,title:n,content:r,onConfirm:o,onCancel:u,confirmText:a="确认",cancelText:d="取消"}){return s?c.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:c.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden transform transition-all animate-in zoom-in-95 duration-200",onClick:v=>v.stopPropagation(),children:[c.jsxs("div",{className:"p-6",children:[c.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),c.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),c.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[c.jsx("button",{onClick:v=>{v.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:d}),c.jsx("button",{onClick:v=>{v.stopPropagation(),o()},className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:a})]})]})}):null}function Nv({id:s,model:n,status:r,connectionType:o,agent:u,isActive:a,onClick:d,onConnectWifi:v,onDisconnectWifi:h}){const g=Yr(),m=r==="device",x=o==="usb",y=o==="remote",[S,C]=w.useState(!1),[P,A]=w.useState(!1),[j,U]=w.useState(!1),R=H=>{H.stopPropagation(),!(S||!v)&&A(!0)},I=H=>{H.stopPropagation(),!(S||!h)&&U(!0)},X=async()=>{A(!1),C(!0);try{v&&await v()}finally{C(!1)}},$=async()=>{U(!1),C(!0);try{h&&await h()}finally{C(!1)}};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{onClick:d,role:"button",tabIndex:0,onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&d()},className:`
2
- group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
3
- border-2
4
- ${a?"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:[a&&c.jsx("div",{className:"absolute left-0 top-2 bottom-2 w-1 bg-[#1d9bf0] rounded-r"}),c.jsxs("div",{className:"flex items-center gap-3 pl-2",children:[c.jsx("div",{className:`relative flex-shrink-0 ${m?"status-online":"status-offline"} w-3 h-3 rounded-full transition-all ${a?"scale-110":""}`}),c.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-0.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Do,{className:`w-4 h-4 ${a?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),c.jsx("span",{className:`font-semibold text-sm truncate ${a?"text-slate-900 dark:text-slate-100":"text-slate-700 dark:text-slate-300"}`,children:n||g.deviceCard.unknownDevice})]}),c.jsx("span",{className:`text-xs font-mono truncate ${a?"text-slate-500 dark:text-slate-400":"text-slate-400 dark:text-slate-500"}`,children:s})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[x&&v&&c.jsx(De,{variant:"ghost",size:"icon",onClick:R,disabled:S,className:`h-8 w-8 rounded-full ${a?"bg-[#1d9bf0]/10 text-[#1d9bf0] hover:bg-[#1d9bf0]/20":"text-slate-400 dark:text-slate-500 hover:text-[#1d9bf0] dark:hover:text-[#1d9bf0] hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:g.deviceCard.connectViaWifi,children:S?c.jsx(kn,{className:"w-4 h-4 animate-spin"}):c.jsx(Mo,{className:"w-4 h-4"})}),y&&h&&c.jsx(De,{variant:"ghost",size:"icon",onClick:I,disabled:S,className:`h-8 w-8 rounded-full ${a?"bg-red-500/10 text-red-500 hover:bg-red-500/20":"text-slate-400 dark:text-slate-500 hover:text-red-500 dark:hover:text-red-500 hover:bg-slate-100 dark:hover:bg-slate-800"}`,title:g.deviceCard.disconnectWifi,children:S?c.jsx(kn,{className:"w-4 h-4 animate-spin"}):c.jsx(Tv,{className:"w-4 h-4"})}),u?c.jsxs($r,{variant:u.state==="idle"?"success":u.state==="busy"?"warning":u.state==="error"?"destructive":"secondary",className:`text-xs ${a?u.state==="idle"?"bg-green-500/10 text-green-600 dark:text-green-400":u.state==="busy"?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":u.state==="error"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-slate-500/10 text-slate-600 dark:text-slate-400":""}`,children:[u.state==="idle"&&c.jsx(dr,{className:"w-3 h-3 mr-1"}),u.state==="busy"&&c.jsx(kn,{className:"w-3 h-3 mr-1 animate-spin"}),u.state==="error"&&c.jsx(Lo,{className:"w-3 h-3 mr-1"}),u.state==="initializing"&&c.jsx(Qx,{className:"w-3 h-3 mr-1"}),u.state==="idle"&&g.deviceCard.agentIdle,u.state==="busy"&&g.deviceCard.agentBusy,u.state==="error"&&g.deviceCard.agentError,u.state==="initializing"&&g.deviceCard.agentInitializing]}):null]})]})]}),c.jsx(Oc,{isOpen:P,title:g.deviceCard.connectWifiTitle,content:g.deviceCard.connectWifiContent,onConfirm:X,onCancel:()=>A(!1)}),c.jsx(Oc,{isOpen:j,title:g.deviceCard.disconnectWifiTitle,content:g.deviceCard.disconnectWifiContent,onConfirm:$,onCancel:()=>U(!1)})]})}function Av(s){const n=s+"CollectionProvider",[r,o]=Vr(n),[u,a]=r(n,{collectionRef:{current:null},itemMap:new Map}),d=P=>{const{scope:A,children:j}=P,U=Ge.useRef(null),R=Ge.useRef(new Map).current;return c.jsx(u,{scope:A,itemMap:R,collectionRef:U,children:j})};d.displayName=n;const v=s+"CollectionSlot",h=ko(v),g=Ge.forwardRef((P,A)=>{const{scope:j,children:U}=P,R=a(v,j),I=en(A,R.collectionRef);return c.jsx(h,{ref:I,children:U})});g.displayName=v;const m=s+"CollectionItemSlot",x="data-radix-collection-item",y=ko(m),S=Ge.forwardRef((P,A)=>{const{scope:j,children:U,...R}=P,I=Ge.useRef(null),X=en(A,I),$=a(m,j);return Ge.useEffect(()=>($.itemMap.set(I,{ref:I,...R}),()=>void $.itemMap.delete(I))),c.jsx(y,{[x]:"",ref:X,children:U})});S.displayName=m;function C(P){const A=a(s+"CollectionConsumer",P);return Ge.useCallback(()=>{const U=A.collectionRef.current;if(!U)return[];const R=Array.from(U.querySelectorAll(`[${x}]`));return Array.from(A.itemMap.values()).sort(($,H)=>R.indexOf($.ref.current)-R.indexOf(H.ref.current))},[A.collectionRef,A.itemMap])}return[{Provider:d,Slot:g,ItemSlot:S},C,o]}var Pv=w.createContext(void 0);function Xo(s){const n=w.useContext(Pv);return s||n||"ltr"}var vo="rovingFocusGroup.onEntryFocus",kv={bubbles:!1,cancelable:!0},Kr="RovingFocusGroup",[Oo,Tu,Iv]=Av(Kr),[Lv,Ru]=Vr(Kr,[Iv]),[Dv,Mv]=Lv(Kr),Nu=w.forwardRef((s,n)=>c.jsx(Oo.Provider,{scope:s.__scopeRovingFocusGroup,children:c.jsx(Oo.Slot,{scope:s.__scopeRovingFocusGroup,children:c.jsx(Ov,{...s,ref:n})})}));Nu.displayName=Kr;var Ov=w.forwardRef((s,n)=>{const{__scopeRovingFocusGroup:r,orientation:o,loop:u=!1,dir:a,currentTabStopId:d,defaultCurrentTabStopId:v,onCurrentTabStopIdChange:h,onEntryFocus:g,preventScrollOnEntryFocus:m=!1,...x}=s,y=w.useRef(null),S=en(n,y),C=Xo(a),[P,A]=$o({prop:d,defaultProp:v??null,onChange:h,caller:Kr}),[j,U]=w.useState(!1),R=Pn(g),I=Tu(r),X=w.useRef(!1),[$,H]=w.useState(0);return w.useEffect(()=>{const G=y.current;if(G)return G.addEventListener(vo,R),()=>G.removeEventListener(vo,R)},[R]),c.jsx(Dv,{scope:r,orientation:o,dir:C,loop:u,currentTabStopId:P,onItemFocus:w.useCallback(G=>A(G),[A]),onItemShiftTab:w.useCallback(()=>U(!0),[]),onFocusableItemAdd:w.useCallback(()=>H(G=>G+1),[]),onFocusableItemRemove:w.useCallback(()=>H(G=>G-1),[]),children:c.jsx(jt.div,{tabIndex:j||$===0?-1:0,"data-orientation":o,...x,ref:S,style:{outline:"none",...s.style},onMouseDown:et(s.onMouseDown,()=>{X.current=!0}),onFocus:et(s.onFocus,G=>{const M=!X.current;if(G.target===G.currentTarget&&M&&!j){const Y=new CustomEvent(vo,kv);if(G.currentTarget.dispatchEvent(Y),!Y.defaultPrevented){const B=I().filter(Q=>Q.focusable),he=B.find(Q=>Q.active),de=B.find(Q=>Q.id===P),V=[he,de,...B].filter(Boolean).map(Q=>Q.ref.current);ku(V,m)}}X.current=!1}),onBlur:et(s.onBlur,()=>U(!1))})})}),Au="RovingFocusGroupItem",Pu=w.forwardRef((s,n)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:u=!1,tabStopId:a,children:d,...v}=s,h=qo(),g=a||h,m=Mv(Au,r),x=m.currentTabStopId===g,y=Tu(r),{onFocusableItemAdd:S,onFocusableItemRemove:C,currentTabStopId:P}=m;return w.useEffect(()=>{if(o)return S(),()=>C()},[o,S,C]),c.jsx(Oo.ItemSlot,{scope:r,id:g,focusable:o,active:u,children:c.jsx(jt.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...v,ref:n,onMouseDown:et(s.onMouseDown,A=>{o?m.onItemFocus(g):A.preventDefault()}),onFocus:et(s.onFocus,()=>m.onItemFocus(g)),onKeyDown:et(s.onKeyDown,A=>{if(A.key==="Tab"&&A.shiftKey){m.onItemShiftTab();return}if(A.target!==A.currentTarget)return;const j=Bv(A,m.orientation,m.dir);if(j!==void 0){if(A.metaKey||A.ctrlKey||A.altKey||A.shiftKey)return;A.preventDefault();let R=y().filter(I=>I.focusable).map(I=>I.ref.current);if(j==="last")R.reverse();else if(j==="prev"||j==="next"){j==="prev"&&R.reverse();const I=R.indexOf(A.currentTarget);R=m.loop?Uv(R,I+1):R.slice(I+1)}setTimeout(()=>ku(R))}}),children:typeof d=="function"?d({isCurrentTabStop:x,hasTabStop:P!=null}):d})})});Pu.displayName=Au;var jv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fv(s,n){return n!=="rtl"?s:s==="ArrowLeft"?"ArrowRight":s==="ArrowRight"?"ArrowLeft":s}function Bv(s,n,r){const o=Fv(s.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return jv[o]}function ku(s,n=!1){const r=document.activeElement;for(const o of s)if(o===r||(o.focus({preventScroll:n}),document.activeElement!==r))return}function Uv(s,n){return s.map((r,o)=>s[(n+o)%s.length])}var Wv=Nu,Gv=Pu,Zi="Tabs",[Hv]=Vr(Zi,[Ru]),Iu=Ru(),[zv,Yo]=Hv(Zi),Lu=w.forwardRef((s,n)=>{const{__scopeTabs:r,value:o,onValueChange:u,defaultValue:a,orientation:d="horizontal",dir:v,activationMode:h="automatic",...g}=s,m=Xo(v),[x,y]=$o({prop:o,onChange:u,defaultProp:a??"",caller:Zi});return c.jsx(zv,{scope:r,baseId:qo(),value:x,onValueChange:y,orientation:d,dir:m,activationMode:h,children:c.jsx(jt.div,{dir:m,"data-orientation":d,...g,ref:n})})});Lu.displayName=Zi;var Du="TabsList",Mu=w.forwardRef((s,n)=>{const{__scopeTabs:r,loop:o=!0,...u}=s,a=Yo(Du,r),d=Iu(r);return c.jsx(Wv,{asChild:!0,...d,orientation:a.orientation,dir:a.dir,loop:o,children:c.jsx(jt.div,{role:"tablist","aria-orientation":a.orientation,...u,ref:n})})});Mu.displayName=Du;var Ou="TabsTrigger",ju=w.forwardRef((s,n)=>{const{__scopeTabs:r,value:o,disabled:u=!1,...a}=s,d=Yo(Ou,r),v=Iu(r),h=Uu(d.baseId,o),g=Wu(d.baseId,o),m=o===d.value;return c.jsx(Gv,{asChild:!0,...v,focusable:!u,active:m,children:c.jsx(jt.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":g,"data-state":m?"active":"inactive","data-disabled":u?"":void 0,disabled:u,id:h,...a,ref:n,onMouseDown:et(s.onMouseDown,x=>{!u&&x.button===0&&x.ctrlKey===!1?d.onValueChange(o):x.preventDefault()}),onKeyDown:et(s.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&d.onValueChange(o)}),onFocus:et(s.onFocus,()=>{const x=d.activationMode!=="manual";!m&&!u&&x&&d.onValueChange(o)})})})});ju.displayName=Ou;var Fu="TabsContent",Bu=w.forwardRef((s,n)=>{const{__scopeTabs:r,value:o,forceMount:u,children:a,...d}=s,v=Yo(Fu,r),h=Uu(v.baseId,o),g=Wu(v.baseId,o),m=o===v.value,x=w.useRef(m);return w.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),c.jsx(Xn,{present:u||m,children:({present:y})=>c.jsx(jt.div,{"data-state":m?"active":"inactive","data-orientation":v.orientation,role:"tabpanel","aria-labelledby":h,hidden:!y,id:g,tabIndex:0,...d,ref:n,style:{...s.style,animationDuration:x.current?"0s":void 0},children:y&&a})})});Bu.displayName=Fu;function Uu(s,n){return`${s}-trigger-${n}`}function Wu(s,n){return`${s}-content-${n}`}var qv=Lu,$v=Mu,Xv=ju,Yv=Bu;function Vv({className:s,...n}){return c.jsx(qv,{"data-slot":"tabs",className:Yn("flex flex-col gap-2",s),...n})}function Kv({className:s,...n}){return c.jsx($v,{"data-slot":"tabs-list",className:Yn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",s),...n})}function jc({className:s,...n}){return c.jsx(Xv,{"data-slot":"tabs-trigger",className:Yn("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),...n})}function Fc({className:s,...n}){return c.jsx(Yv,{"data-slot":"tabs-content",className:Yn("flex-1 outline-none",s),...n})}var Qv=Object.defineProperty,Ki=Object.getOwnPropertySymbols,Gu=Object.prototype.hasOwnProperty,Hu=Object.prototype.propertyIsEnumerable,Bc=(s,n,r)=>n in s?Qv(s,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[n]=r,jo=(s,n)=>{for(var r in n||(n={}))Gu.call(n,r)&&Bc(s,r,n[r]);if(Ki)for(var r of Ki(n))Hu.call(n,r)&&Bc(s,r,n[r]);return s},Fo=(s,n)=>{var r={};for(var o in s)Gu.call(s,o)&&n.indexOf(o)<0&&(r[o]=s[o]);if(s!=null&&Ki)for(var o of Ki(s))n.indexOf(o)<0&&Hu.call(s,o)&&(r[o]=s[o]);return r};var $n;(s=>{const n=class Ee{constructor(h,g,m,x){if(this.version=h,this.errorCorrectionLevel=g,this.modules=[],this.isFunction=[],h<Ee.MIN_VERSION||h>Ee.MAX_VERSION)throw new RangeError("Version value out of range");if(x<-1||x>7)throw new RangeError("Mask value out of range");this.size=h*4+17;let y=[];for(let C=0;C<this.size;C++)y.push(!1);for(let C=0;C<this.size;C++)this.modules.push(y.slice()),this.isFunction.push(y.slice());this.drawFunctionPatterns();const S=this.addEccAndInterleave(m);if(this.drawCodewords(S),x==-1){let C=1e9;for(let P=0;P<8;P++){this.applyMask(P),this.drawFormatBits(P);const A=this.getPenaltyScore();A<C&&(x=P,C=A),this.applyMask(P)}}u(0<=x&&x<=7),this.mask=x,this.applyMask(x),this.drawFormatBits(x),this.isFunction=[]}static encodeText(h,g){const m=s.QrSegment.makeSegments(h);return Ee.encodeSegments(m,g)}static encodeBinary(h,g){const m=s.QrSegment.makeBytes(h);return Ee.encodeSegments([m],g)}static encodeSegments(h,g,m=1,x=40,y=-1,S=!0){if(!(Ee.MIN_VERSION<=m&&m<=x&&x<=Ee.MAX_VERSION)||y<-1||y>7)throw new RangeError("Invalid value");let C,P;for(C=m;;C++){const R=Ee.getNumDataCodewords(C,g)*8,I=d.getTotalBits(h,C);if(I<=R){P=I;break}if(C>=x)throw new RangeError("Data too long")}for(const R of[Ee.Ecc.MEDIUM,Ee.Ecc.QUARTILE,Ee.Ecc.HIGH])S&&P<=Ee.getNumDataCodewords(C,R)*8&&(g=R);let A=[];for(const R of h){r(R.mode.modeBits,4,A),r(R.numChars,R.mode.numCharCountBits(C),A);for(const I of R.getData())A.push(I)}u(A.length==P);const j=Ee.getNumDataCodewords(C,g)*8;u(A.length<=j),r(0,Math.min(4,j-A.length),A),r(0,(8-A.length%8)%8,A),u(A.length%8==0);for(let R=236;A.length<j;R^=253)r(R,8,A);let U=[];for(;U.length*8<A.length;)U.push(0);return A.forEach((R,I)=>U[I>>>3]|=R<<7-(I&7)),new Ee(C,g,U,y)}getModule(h,g){return 0<=h&&h<this.size&&0<=g&&g<this.size&&this.modules[g][h]}getModules(){return this.modules}drawFunctionPatterns(){for(let m=0;m<this.size;m++)this.setFunctionModule(6,m,m%2==0),this.setFunctionModule(m,6,m%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const h=this.getAlignmentPatternPositions(),g=h.length;for(let m=0;m<g;m++)for(let x=0;x<g;x++)m==0&&x==0||m==0&&x==g-1||m==g-1&&x==0||this.drawAlignmentPattern(h[m],h[x]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(h){const g=this.errorCorrectionLevel.formatBits<<3|h;let m=g;for(let y=0;y<10;y++)m=m<<1^(m>>>9)*1335;const x=(g<<10|m)^21522;u(x>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,o(x,y));this.setFunctionModule(8,7,o(x,6)),this.setFunctionModule(8,8,o(x,7)),this.setFunctionModule(7,8,o(x,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,o(x,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,o(x,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,o(x,y));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let h=this.version;for(let m=0;m<12;m++)h=h<<1^(h>>>11)*7973;const g=this.version<<12|h;u(g>>>18==0);for(let m=0;m<18;m++){const x=o(g,m),y=this.size-11+m%3,S=Math.floor(m/3);this.setFunctionModule(y,S,x),this.setFunctionModule(S,y,x)}}drawFinderPattern(h,g){for(let m=-4;m<=4;m++)for(let x=-4;x<=4;x++){const y=Math.max(Math.abs(x),Math.abs(m)),S=h+x,C=g+m;0<=S&&S<this.size&&0<=C&&C<this.size&&this.setFunctionModule(S,C,y!=2&&y!=4)}}drawAlignmentPattern(h,g){for(let m=-2;m<=2;m++)for(let x=-2;x<=2;x++)this.setFunctionModule(h+x,g+m,Math.max(Math.abs(x),Math.abs(m))!=1)}setFunctionModule(h,g,m){this.modules[g][h]=m,this.isFunction[g][h]=!0}addEccAndInterleave(h){const g=this.version,m=this.errorCorrectionLevel;if(h.length!=Ee.getNumDataCodewords(g,m))throw new RangeError("Invalid argument");const x=Ee.NUM_ERROR_CORRECTION_BLOCKS[m.ordinal][g],y=Ee.ECC_CODEWORDS_PER_BLOCK[m.ordinal][g],S=Math.floor(Ee.getNumRawDataModules(g)/8),C=x-S%x,P=Math.floor(S/x);let A=[];const j=Ee.reedSolomonComputeDivisor(y);for(let R=0,I=0;R<x;R++){let X=h.slice(I,I+P-y+(R<C?0:1));I+=X.length;const $=Ee.reedSolomonComputeRemainder(X,j);R<C&&X.push(0),A.push(X.concat($))}let U=[];for(let R=0;R<A[0].length;R++)A.forEach((I,X)=>{(R!=P-y||X>=C)&&U.push(I[R])});return u(U.length==S),U}drawCodewords(h){if(h.length!=Math.floor(Ee.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let g=0;for(let m=this.size-1;m>=1;m-=2){m==6&&(m=5);for(let x=0;x<this.size;x++)for(let y=0;y<2;y++){const S=m-y,P=(m+1&2)==0?this.size-1-x:x;!this.isFunction[P][S]&&g<h.length*8&&(this.modules[P][S]=o(h[g>>>3],7-(g&7)),g++)}}u(g==h.length*8)}applyMask(h){if(h<0||h>7)throw new RangeError("Mask value out of range");for(let g=0;g<this.size;g++)for(let m=0;m<this.size;m++){let x;switch(h){case 0:x=(m+g)%2==0;break;case 1:x=g%2==0;break;case 2:x=m%3==0;break;case 3:x=(m+g)%3==0;break;case 4:x=(Math.floor(m/3)+Math.floor(g/2))%2==0;break;case 5:x=m*g%2+m*g%3==0;break;case 6:x=(m*g%2+m*g%3)%2==0;break;case 7:x=((m+g)%2+m*g%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[g][m]&&x&&(this.modules[g][m]=!this.modules[g][m])}}getPenaltyScore(){let h=0;for(let y=0;y<this.size;y++){let S=!1,C=0,P=[0,0,0,0,0,0,0];for(let A=0;A<this.size;A++)this.modules[y][A]==S?(C++,C==5?h+=Ee.PENALTY_N1:C>5&&h++):(this.finderPenaltyAddHistory(C,P),S||(h+=this.finderPenaltyCountPatterns(P)*Ee.PENALTY_N3),S=this.modules[y][A],C=1);h+=this.finderPenaltyTerminateAndCount(S,C,P)*Ee.PENALTY_N3}for(let y=0;y<this.size;y++){let S=!1,C=0,P=[0,0,0,0,0,0,0];for(let A=0;A<this.size;A++)this.modules[A][y]==S?(C++,C==5?h+=Ee.PENALTY_N1:C>5&&h++):(this.finderPenaltyAddHistory(C,P),S||(h+=this.finderPenaltyCountPatterns(P)*Ee.PENALTY_N3),S=this.modules[A][y],C=1);h+=this.finderPenaltyTerminateAndCount(S,C,P)*Ee.PENALTY_N3}for(let y=0;y<this.size-1;y++)for(let S=0;S<this.size-1;S++){const C=this.modules[y][S];C==this.modules[y][S+1]&&C==this.modules[y+1][S]&&C==this.modules[y+1][S+1]&&(h+=Ee.PENALTY_N2)}let g=0;for(const y of this.modules)g=y.reduce((S,C)=>S+(C?1:0),g);const m=this.size*this.size,x=Math.ceil(Math.abs(g*20-m*10)/m)-1;return u(0<=x&&x<=9),h+=x*Ee.PENALTY_N4,u(0<=h&&h<=2568888),h}getAlignmentPatternPositions(){if(this.version==1)return[];{const h=Math.floor(this.version/7)+2,g=this.version==32?26:Math.ceil((this.version*4+4)/(h*2-2))*2;let m=[6];for(let x=this.size-7;m.length<h;x-=g)m.splice(1,0,x);return m}}static getNumRawDataModules(h){if(h<Ee.MIN_VERSION||h>Ee.MAX_VERSION)throw new RangeError("Version number out of range");let g=(16*h+128)*h+64;if(h>=2){const m=Math.floor(h/7)+2;g-=(25*m-10)*m-55,h>=7&&(g-=36)}return u(208<=g&&g<=29648),g}static getNumDataCodewords(h,g){return Math.floor(Ee.getNumRawDataModules(h)/8)-Ee.ECC_CODEWORDS_PER_BLOCK[g.ordinal][h]*Ee.NUM_ERROR_CORRECTION_BLOCKS[g.ordinal][h]}static reedSolomonComputeDivisor(h){if(h<1||h>255)throw new RangeError("Degree out of range");let g=[];for(let x=0;x<h-1;x++)g.push(0);g.push(1);let m=1;for(let x=0;x<h;x++){for(let y=0;y<g.length;y++)g[y]=Ee.reedSolomonMultiply(g[y],m),y+1<g.length&&(g[y]^=g[y+1]);m=Ee.reedSolomonMultiply(m,2)}return g}static reedSolomonComputeRemainder(h,g){let m=g.map(x=>0);for(const x of h){const y=x^m.shift();m.push(0),g.forEach((S,C)=>m[C]^=Ee.reedSolomonMultiply(S,y))}return m}static reedSolomonMultiply(h,g){if(h>>>8||g>>>8)throw new RangeError("Byte out of range");let m=0;for(let x=7;x>=0;x--)m=m<<1^(m>>>7)*285,m^=(g>>>x&1)*h;return u(m>>>8==0),m}finderPenaltyCountPatterns(h){const g=h[1];u(g<=this.size*3);const m=g>0&&h[2]==g&&h[3]==g*3&&h[4]==g&&h[5]==g;return(m&&h[0]>=g*4&&h[6]>=g?1:0)+(m&&h[6]>=g*4&&h[0]>=g?1:0)}finderPenaltyTerminateAndCount(h,g,m){return h&&(this.finderPenaltyAddHistory(g,m),g=0),g+=this.size,this.finderPenaltyAddHistory(g,m),this.finderPenaltyCountPatterns(m)}finderPenaltyAddHistory(h,g){g[0]==0&&(h+=this.size),g.pop(),g.unshift(h)}};n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],s.QrCode=n;function r(v,h,g){if(h<0||h>31||v>>>h)throw new RangeError("Value out of range");for(let m=h-1;m>=0;m--)g.push(v>>>m&1)}function o(v,h){return(v>>>h&1)!=0}function u(v){if(!v)throw new Error("Assertion error")}const a=class Qe{constructor(h,g,m){if(this.mode=h,this.numChars=g,this.bitData=m,g<0)throw new RangeError("Invalid argument");this.bitData=m.slice()}static makeBytes(h){let g=[];for(const m of h)r(m,8,g);return new Qe(Qe.Mode.BYTE,h.length,g)}static makeNumeric(h){if(!Qe.isNumeric(h))throw new RangeError("String contains non-numeric characters");let g=[];for(let m=0;m<h.length;){const x=Math.min(h.length-m,3);r(parseInt(h.substring(m,m+x),10),x*3+1,g),m+=x}return new Qe(Qe.Mode.NUMERIC,h.length,g)}static makeAlphanumeric(h){if(!Qe.isAlphanumeric(h))throw new RangeError("String contains unencodable characters in alphanumeric mode");let g=[],m;for(m=0;m+2<=h.length;m+=2){let x=Qe.ALPHANUMERIC_CHARSET.indexOf(h.charAt(m))*45;x+=Qe.ALPHANUMERIC_CHARSET.indexOf(h.charAt(m+1)),r(x,11,g)}return m<h.length&&r(Qe.ALPHANUMERIC_CHARSET.indexOf(h.charAt(m)),6,g),new Qe(Qe.Mode.ALPHANUMERIC,h.length,g)}static makeSegments(h){return h==""?[]:Qe.isNumeric(h)?[Qe.makeNumeric(h)]:Qe.isAlphanumeric(h)?[Qe.makeAlphanumeric(h)]:[Qe.makeBytes(Qe.toUtf8ByteArray(h))]}static makeEci(h){let g=[];if(h<0)throw new RangeError("ECI assignment value out of range");if(h<128)r(h,8,g);else if(h<16384)r(2,2,g),r(h,14,g);else if(h<1e6)r(6,3,g),r(h,21,g);else throw new RangeError("ECI assignment value out of range");return new Qe(Qe.Mode.ECI,0,g)}static isNumeric(h){return Qe.NUMERIC_REGEX.test(h)}static isAlphanumeric(h){return Qe.ALPHANUMERIC_REGEX.test(h)}getData(){return this.bitData.slice()}static getTotalBits(h,g){let m=0;for(const x of h){const y=x.mode.numCharCountBits(g);if(x.numChars>=1<<y)return 1/0;m+=4+y+x.bitData.length}return m}static toUtf8ByteArray(h){h=encodeURI(h);let g=[];for(let m=0;m<h.length;m++)h.charAt(m)!="%"?g.push(h.charCodeAt(m)):(g.push(parseInt(h.substring(m+1,m+3),16)),m+=2);return g}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let d=a;s.QrSegment=a})($n||($n={}));(s=>{(n=>{const r=class{constructor(u,a){this.ordinal=u,this.formatBits=a}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),n.Ecc=r})(s.QrCode||(s.QrCode={}))})($n||($n={}));(s=>{(n=>{const r=class{constructor(u,a){this.modeBits=u,this.numBitsCharCount=a}numCharCountBits(u){return this.numBitsCharCount[Math.floor((u+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),n.Mode=r})(s.QrSegment||(s.QrSegment={}))})($n||($n={}));var hr=$n;var Jv={L:hr.QrCode.Ecc.LOW,M:hr.QrCode.Ecc.MEDIUM,Q:hr.QrCode.Ecc.QUARTILE,H:hr.QrCode.Ecc.HIGH},zu=128,qu="L",$u="#FFFFFF",Xu="#000000",Yu=!1,Vu=1,Zv=4,e1=0,t1=.1;function Ku(s,n=0){const r=[];return s.forEach(function(o,u){let a=null;o.forEach(function(d,v){if(!d&&a!==null){r.push(`M${a+n} ${u+n}h${v-a}v1H${a+n}z`),a=null;return}if(v===o.length-1){if(!d)return;a===null?r.push(`M${v+n},${u+n} h1v1H${v+n}z`):r.push(`M${a+n},${u+n} h${v+1-a}v1H${a+n}z`);return}d&&a===null&&(a=v)})}),r.join("")}function Qu(s,n){return s.slice().map((r,o)=>o<n.y||o>=n.y+n.h?r:r.map((u,a)=>a<n.x||a>=n.x+n.w?u:!1))}function n1(s,n,r,o){if(o==null)return null;const u=s.length+r*2,a=Math.floor(n*t1),d=u/n,v=(o.width||a)*d,h=(o.height||a)*d,g=o.x==null?s.length/2-v/2:o.x*d,m=o.y==null?s.length/2-h/2:o.y*d,x=o.opacity==null?1:o.opacity;let y=null;if(o.excavate){let C=Math.floor(g),P=Math.floor(m),A=Math.ceil(v+g-C),j=Math.ceil(h+m-P);y={x:C,y:P,w:A,h:j}}const S=o.crossOrigin;return{x:g,y:m,h,w:v,excavation:y,opacity:x,crossOrigin:S}}function r1(s,n){return n!=null?Math.max(Math.floor(n),0):s?Zv:e1}function Ju({value:s,level:n,minVersion:r,includeMargin:o,marginSize:u,imageSettings:a,size:d,boostLevel:v}){let h=Ge.useMemo(()=>{const C=(Array.isArray(s)?s:[s]).reduce((P,A)=>(P.push(...hr.QrSegment.makeSegments(A)),P),[]);return hr.QrCode.encodeSegments(C,Jv[n],r,void 0,void 0,v)},[s,n,r,v]);const{cells:g,margin:m,numCells:x,calculatedImageSettings:y}=Ge.useMemo(()=>{let S=h.getModules();const C=r1(o,u),P=S.length+C*2,A=n1(S,d,C,a);return{cells:S,margin:C,numCells:P,calculatedImageSettings:A}},[h,d,a,o,u]);return{qrcode:h,margin:m,cells:g,numCells:x,calculatedImageSettings:y}}var i1=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),s1=Ge.forwardRef(function(n,r){const o=n,{value:u,size:a=zu,level:d=qu,bgColor:v=$u,fgColor:h=Xu,includeMargin:g=Yu,minVersion:m=Vu,boostLevel:x,marginSize:y,imageSettings:S}=o,P=Fo(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:A}=P,j=Fo(P,["style"]),U=S?.src,R=Ge.useRef(null),I=Ge.useRef(null),X=Ge.useCallback(q=>{R.current=q,typeof r=="function"?r(q):r&&(r.current=q)},[r]),[$,H]=Ge.useState(!1),{margin:G,cells:M,numCells:Y,calculatedImageSettings:B}=Ju({value:u,level:d,minVersion:m,boostLevel:x,includeMargin:g,marginSize:y,imageSettings:S,size:a});Ge.useEffect(()=>{if(R.current!=null){const q=R.current,V=q.getContext("2d");if(!V)return;let Q=M;const ie=I.current,se=B!=null&&ie!==null&&ie.complete&&ie.naturalHeight!==0&&ie.naturalWidth!==0;se&&B.excavation!=null&&(Q=Qu(M,B.excavation));const be=window.devicePixelRatio||1;q.height=q.width=a*be;const xe=a/Y*be;V.scale(xe,xe),V.fillStyle=v,V.fillRect(0,0,Y,Y),V.fillStyle=h,i1?V.fill(new Path2D(Ku(Q,G))):M.forEach(function(ne,Re){ne.forEach(function(Ae,Fe){Ae&&V.fillRect(Fe+G,Re+G,1,1)})}),B&&(V.globalAlpha=B.opacity),se&&V.drawImage(ie,B.x+G,B.y+G,B.w,B.h)}}),Ge.useEffect(()=>{H(!1)},[U]);const he=jo({height:a,width:a},A);let de=null;return U!=null&&(de=Ge.createElement("img",{src:U,key:U,style:{display:"none"},onLoad:()=>{H(!0)},ref:I,crossOrigin:B?.crossOrigin})),Ge.createElement(Ge.Fragment,null,Ge.createElement("canvas",jo({style:he,height:a,width:a,ref:X,role:"img"},j)),de)});s1.displayName="QRCodeCanvas";var Zu=Ge.forwardRef(function(n,r){const o=n,{value:u,size:a=zu,level:d=qu,bgColor:v=$u,fgColor:h=Xu,includeMargin:g=Yu,minVersion:m=Vu,boostLevel:x,title:y,marginSize:S,imageSettings:C}=o,P=Fo(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:A,cells:j,numCells:U,calculatedImageSettings:R}=Ju({value:u,level:d,minVersion:m,boostLevel:x,includeMargin:g,marginSize:S,imageSettings:C,size:a});let I=j,X=null;C!=null&&R!=null&&(R.excavation!=null&&(I=Qu(j,R.excavation)),X=Ge.createElement("image",{href:C.src,height:R.h,width:R.w,x:R.x+A,y:R.y+A,preserveAspectRatio:"none",opacity:R.opacity,crossOrigin:R.crossOrigin}));const $=Ku(I,A);return Ge.createElement("svg",jo({height:a,width:a,viewBox:`0 0 ${U} ${U}`,ref:r,role:"img"},P),!!y&&Ge.createElement("title",null,y),Ge.createElement("path",{fill:v,d:`M0,0 h${U}v${U}H0z`,shapeRendering:"crispEdges"}),Ge.createElement("path",{fill:h,d:$,shapeRendering:"crispEdges"}),X)});Zu.displayName="QRCodeSVG";var zr={exports:{}};var o1=zr.exports,Uc;function a1(){return Uc||(Uc=1,(function(s,n){(function(){var r,o="4.17.21",u=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",d="Expected a function",v="Invalid `variable` option passed into `_.template`",h="__lodash_hash_undefined__",g=500,m="__lodash_placeholder__",x=1,y=2,S=4,C=1,P=2,A=1,j=2,U=4,R=8,I=16,X=32,$=64,H=128,G=256,M=512,Y=30,B="...",he=800,de=16,q=1,V=2,Q=3,ie=1/0,se=9007199254740991,be=17976931348623157e292,xe=NaN,ne=4294967295,Re=ne-1,Ae=ne>>>1,Fe=[["ary",H],["bind",A],["bindKey",j],["curry",R],["curryRight",I],["flip",M],["partial",X],["partialRight",$],["rearg",G]],Oe="[object Arguments]",nt="[object Array]",ut="[object AsyncFunction]",Ue="[object Boolean]",ke="[object Date]",pt="[object DOMException]",Et="[object Error]",Pe="[object Function]",St="[object GeneratorFunction]",Xe="[object Map]",ot="[object Number]",Z="[object Null]",ee="[object Object]",L="[object Promise]",K="[object Proxy]",ue="[object RegExp]",pe="[object Set]",ye="[object String]",ve="[object Symbol]",Ve="[object Undefined]",vt="[object WeakMap]",at="[object WeakSet]",lt="[object ArrayBuffer]",ft="[object DataView]",_r="[object Float32Array]",Vn="[object Float64Array]",xr="[object Int8Array]",vr="[object Int16Array]",Dn="[object Int32Array]",br="[object Uint8Array]",yr="[object Uint8ClampedArray]",wr="[object Uint16Array]",Er="[object Uint32Array]",os=/\b__p \+= '';/g,as=/\b(__p \+=) '' \+/g,Sr=/(__e\(.*?\)|\b__t\)) \+\n'';/g,z=/&(?:amp|lt|gt|quot|#39);/g,je=/[&<>"']/g,Ne=RegExp(z.source),rt=RegExp(je.source),vn=/<%-([\s\S]+?)%>/g,Kn=/<%([\s\S]+?)%>/g,Ct=/<%=([\s\S]+?)%>/g,bn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qn=/^\w*$/,Jr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Cr=/[\\^$.*+?()[\]{}|]/g,qe=RegExp(Cr.source),mt=/^\s+/,Pt=/\s/,Ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Mn=/\{\n\/\* \[wrapped with (.+)\] \*/,zf=/,? & /,qf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,$f=/[()=,{}\[\]\/\s]/,Xf=/\\(\\)?/g,Yf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,sa=/\w*$/,Vf=/^[-+]0x[0-9a-f]+$/i,Kf=/^0b[01]+$/i,Qf=/^\[object .+?Constructor\]$/,Jf=/^0o[0-7]+$/i,Zf=/^(?:0|[1-9]\d*)$/,eh=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Zr=/($^)/,th=/['\n\r\u2028\u2029\\]/g,ei="\\ud800-\\udfff",nh="\\u0300-\\u036f",rh="\\ufe20-\\ufe2f",ih="\\u20d0-\\u20ff",oa=nh+rh+ih,aa="\\u2700-\\u27bf",la="a-z\\xdf-\\xf6\\xf8-\\xff",sh="\\xac\\xb1\\xd7\\xf7",oh="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ah="\\u2000-\\u206f",lh=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ca="A-Z\\xc0-\\xd6\\xd8-\\xde",ua="\\ufe0e\\ufe0f",fa=sh+oh+ah+lh,ls="['’]",ch="["+ei+"]",ha="["+fa+"]",ti="["+oa+"]",da="\\d+",uh="["+aa+"]",pa="["+la+"]",ma="[^"+ei+fa+da+aa+la+ca+"]",cs="\\ud83c[\\udffb-\\udfff]",fh="(?:"+ti+"|"+cs+")",ga="[^"+ei+"]",us="(?:\\ud83c[\\udde6-\\uddff]){2}",fs="[\\ud800-\\udbff][\\udc00-\\udfff]",Jn="["+ca+"]",_a="\\u200d",xa="(?:"+pa+"|"+ma+")",hh="(?:"+Jn+"|"+ma+")",va="(?:"+ls+"(?:d|ll|m|re|s|t|ve))?",ba="(?:"+ls+"(?:D|LL|M|RE|S|T|VE))?",ya=fh+"?",wa="["+ua+"]?",dh="(?:"+_a+"(?:"+[ga,us,fs].join("|")+")"+wa+ya+")*",ph="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",mh="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ea=wa+ya+dh,gh="(?:"+[uh,us,fs].join("|")+")"+Ea,_h="(?:"+[ga+ti+"?",ti,us,fs,ch].join("|")+")",xh=RegExp(ls,"g"),vh=RegExp(ti,"g"),hs=RegExp(cs+"(?="+cs+")|"+_h+Ea,"g"),bh=RegExp([Jn+"?"+pa+"+"+va+"(?="+[ha,Jn,"$"].join("|")+")",hh+"+"+ba+"(?="+[ha,Jn+xa,"$"].join("|")+")",Jn+"?"+xa+"+"+va,Jn+"+"+ba,mh,ph,da,gh].join("|"),"g"),yh=RegExp("["+_a+ei+oa+ua+"]"),wh=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Eh=["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"],Sh=-1,ze={};ze[_r]=ze[Vn]=ze[xr]=ze[vr]=ze[Dn]=ze[br]=ze[yr]=ze[wr]=ze[Er]=!0,ze[Oe]=ze[nt]=ze[lt]=ze[Ue]=ze[ft]=ze[ke]=ze[Et]=ze[Pe]=ze[Xe]=ze[ot]=ze[ee]=ze[ue]=ze[pe]=ze[ye]=ze[vt]=!1;var We={};We[Oe]=We[nt]=We[lt]=We[ft]=We[Ue]=We[ke]=We[_r]=We[Vn]=We[xr]=We[vr]=We[Dn]=We[Xe]=We[ot]=We[ee]=We[ue]=We[pe]=We[ye]=We[ve]=We[br]=We[yr]=We[wr]=We[Er]=!0,We[Et]=We[Pe]=We[vt]=!1;var Ch={À:"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"},Th={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Rh={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Nh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ah=parseFloat,Ph=parseInt,Sa=typeof Wi=="object"&&Wi&&Wi.Object===Object&&Wi,kh=typeof self=="object"&&self&&self.Object===Object&&self,ht=Sa||kh||Function("return this")(),ds=n&&!n.nodeType&&n,On=ds&&!0&&s&&!s.nodeType&&s,Ca=On&&On.exports===ds,ps=Ca&&Sa.process,Bt=(function(){try{var T=On&&On.require&&On.require("util").types;return T||ps&&ps.binding&&ps.binding("util")}catch{}})(),Ta=Bt&&Bt.isArrayBuffer,Ra=Bt&&Bt.isDate,Na=Bt&&Bt.isMap,Aa=Bt&&Bt.isRegExp,Pa=Bt&&Bt.isSet,ka=Bt&&Bt.isTypedArray;function kt(T,D,k){switch(k.length){case 0:return T.call(D);case 1:return T.call(D,k[0]);case 2:return T.call(D,k[0],k[1]);case 3:return T.call(D,k[0],k[1],k[2])}return T.apply(D,k)}function Ih(T,D,k,te){for(var ce=-1,Ie=T==null?0:T.length;++ce<Ie;){var it=T[ce];D(te,it,k(it),T)}return te}function Ut(T,D){for(var k=-1,te=T==null?0:T.length;++k<te&&D(T[k],k,T)!==!1;);return T}function Lh(T,D){for(var k=T==null?0:T.length;k--&&D(T[k],k,T)!==!1;);return T}function Ia(T,D){for(var k=-1,te=T==null?0:T.length;++k<te;)if(!D(T[k],k,T))return!1;return!0}function yn(T,D){for(var k=-1,te=T==null?0:T.length,ce=0,Ie=[];++k<te;){var it=T[k];D(it,k,T)&&(Ie[ce++]=it)}return Ie}function ni(T,D){var k=T==null?0:T.length;return!!k&&Zn(T,D,0)>-1}function ms(T,D,k){for(var te=-1,ce=T==null?0:T.length;++te<ce;)if(k(D,T[te]))return!0;return!1}function $e(T,D){for(var k=-1,te=T==null?0:T.length,ce=Array(te);++k<te;)ce[k]=D(T[k],k,T);return ce}function wn(T,D){for(var k=-1,te=D.length,ce=T.length;++k<te;)T[ce+k]=D[k];return T}function gs(T,D,k,te){var ce=-1,Ie=T==null?0:T.length;for(te&&Ie&&(k=T[++ce]);++ce<Ie;)k=D(k,T[ce],ce,T);return k}function Dh(T,D,k,te){var ce=T==null?0:T.length;for(te&&ce&&(k=T[--ce]);ce--;)k=D(k,T[ce],ce,T);return k}function _s(T,D){for(var k=-1,te=T==null?0:T.length;++k<te;)if(D(T[k],k,T))return!0;return!1}var Mh=xs("length");function Oh(T){return T.split("")}function jh(T){return T.match(qf)||[]}function La(T,D,k){var te;return k(T,function(ce,Ie,it){if(D(ce,Ie,it))return te=Ie,!1}),te}function ri(T,D,k,te){for(var ce=T.length,Ie=k+(te?1:-1);te?Ie--:++Ie<ce;)if(D(T[Ie],Ie,T))return Ie;return-1}function Zn(T,D,k){return D===D?Vh(T,D,k):ri(T,Da,k)}function Fh(T,D,k,te){for(var ce=k-1,Ie=T.length;++ce<Ie;)if(te(T[ce],D))return ce;return-1}function Da(T){return T!==T}function Ma(T,D){var k=T==null?0:T.length;return k?bs(T,D)/k:xe}function xs(T){return function(D){return D==null?r:D[T]}}function vs(T){return function(D){return T==null?r:T[D]}}function Oa(T,D,k,te,ce){return ce(T,function(Ie,it,Be){k=te?(te=!1,Ie):D(k,Ie,it,Be)}),k}function Bh(T,D){var k=T.length;for(T.sort(D);k--;)T[k]=T[k].value;return T}function bs(T,D){for(var k,te=-1,ce=T.length;++te<ce;){var Ie=D(T[te]);Ie!==r&&(k=k===r?Ie:k+Ie)}return k}function ys(T,D){for(var k=-1,te=Array(T);++k<T;)te[k]=D(k);return te}function Uh(T,D){return $e(D,function(k){return[k,T[k]]})}function ja(T){return T&&T.slice(0,Wa(T)+1).replace(mt,"")}function It(T){return function(D){return T(D)}}function ws(T,D){return $e(D,function(k){return T[k]})}function Tr(T,D){return T.has(D)}function Fa(T,D){for(var k=-1,te=T.length;++k<te&&Zn(D,T[k],0)>-1;);return k}function Ba(T,D){for(var k=T.length;k--&&Zn(D,T[k],0)>-1;);return k}function Wh(T,D){for(var k=T.length,te=0;k--;)T[k]===D&&++te;return te}var Gh=vs(Ch),Hh=vs(Th);function zh(T){return"\\"+Nh[T]}function qh(T,D){return T==null?r:T[D]}function er(T){return yh.test(T)}function $h(T){return wh.test(T)}function Xh(T){for(var D,k=[];!(D=T.next()).done;)k.push(D.value);return k}function Es(T){var D=-1,k=Array(T.size);return T.forEach(function(te,ce){k[++D]=[ce,te]}),k}function Ua(T,D){return function(k){return T(D(k))}}function En(T,D){for(var k=-1,te=T.length,ce=0,Ie=[];++k<te;){var it=T[k];(it===D||it===m)&&(T[k]=m,Ie[ce++]=k)}return Ie}function ii(T){var D=-1,k=Array(T.size);return T.forEach(function(te){k[++D]=te}),k}function Yh(T){var D=-1,k=Array(T.size);return T.forEach(function(te){k[++D]=[te,te]}),k}function Vh(T,D,k){for(var te=k-1,ce=T.length;++te<ce;)if(T[te]===D)return te;return-1}function Kh(T,D,k){for(var te=k+1;te--;)if(T[te]===D)return te;return te}function tr(T){return er(T)?Jh(T):Mh(T)}function Vt(T){return er(T)?Zh(T):Oh(T)}function Wa(T){for(var D=T.length;D--&&Pt.test(T.charAt(D)););return D}var Qh=vs(Rh);function Jh(T){for(var D=hs.lastIndex=0;hs.test(T);)++D;return D}function Zh(T){return T.match(hs)||[]}function ed(T){return T.match(bh)||[]}var td=(function T(D){D=D==null?ht:nr.defaults(ht.Object(),D,nr.pick(ht,Eh));var k=D.Array,te=D.Date,ce=D.Error,Ie=D.Function,it=D.Math,Be=D.Object,Ss=D.RegExp,nd=D.String,Wt=D.TypeError,si=k.prototype,rd=Ie.prototype,rr=Be.prototype,oi=D["__core-js_shared__"],ai=rd.toString,Me=rr.hasOwnProperty,id=0,Ga=(function(){var e=/[^.]+$/.exec(oi&&oi.keys&&oi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),li=rr.toString,sd=ai.call(Be),od=ht._,ad=Ss("^"+ai.call(Me).replace(Cr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ci=Ca?D.Buffer:r,Sn=D.Symbol,ui=D.Uint8Array,Ha=ci?ci.allocUnsafe:r,fi=Ua(Be.getPrototypeOf,Be),za=Be.create,qa=rr.propertyIsEnumerable,hi=si.splice,$a=Sn?Sn.isConcatSpreadable:r,Rr=Sn?Sn.iterator:r,jn=Sn?Sn.toStringTag:r,di=(function(){try{var e=Gn(Be,"defineProperty");return e({},"",{}),e}catch{}})(),ld=D.clearTimeout!==ht.clearTimeout&&D.clearTimeout,cd=te&&te.now!==ht.Date.now&&te.now,ud=D.setTimeout!==ht.setTimeout&&D.setTimeout,pi=it.ceil,mi=it.floor,Cs=Be.getOwnPropertySymbols,fd=ci?ci.isBuffer:r,Xa=D.isFinite,hd=si.join,dd=Ua(Be.keys,Be),st=it.max,gt=it.min,pd=te.now,md=D.parseInt,Ya=it.random,gd=si.reverse,Ts=Gn(D,"DataView"),Nr=Gn(D,"Map"),Rs=Gn(D,"Promise"),ir=Gn(D,"Set"),Ar=Gn(D,"WeakMap"),Pr=Gn(Be,"create"),gi=Ar&&new Ar,sr={},_d=Hn(Ts),xd=Hn(Nr),vd=Hn(Rs),bd=Hn(ir),yd=Hn(Ar),_i=Sn?Sn.prototype:r,kr=_i?_i.valueOf:r,Va=_i?_i.toString:r;function p(e){if(Ke(e)&&!fe(e)&&!(e instanceof Se)){if(e instanceof Gt)return e;if(Me.call(e,"__wrapped__"))return Kl(e)}return new Gt(e)}var or=(function(){function e(){}return function(t){if(!Ye(t))return{};if(za)return za(t);e.prototype=t;var i=new e;return e.prototype=r,i}})();function xi(){}function Gt(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}p.templateSettings={escape:vn,evaluate:Kn,interpolate:Ct,variable:"",imports:{_:p}},p.prototype=xi.prototype,p.prototype.constructor=p,Gt.prototype=or(xi.prototype),Gt.prototype.constructor=Gt;function Se(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ne,this.__views__=[]}function wd(){var e=new Se(this.__wrapped__);return e.__actions__=Tt(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Tt(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Tt(this.__views__),e}function Ed(){if(this.__filtered__){var e=new Se(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Sd(){var e=this.__wrapped__.value(),t=this.__dir__,i=fe(e),l=t<0,f=i?e.length:0,_=Op(0,f,this.__views__),b=_.start,E=_.end,N=E-b,O=l?E:b-1,F=this.__iteratees__,W=F.length,J=0,re=gt(N,this.__takeCount__);if(!i||!l&&f==N&&re==N)return vl(e,this.__actions__);var ae=[];e:for(;N--&&J<re;){O+=t;for(var ge=-1,le=e[O];++ge<W;){var we=F[ge],Ce=we.iteratee,Mt=we.type,wt=Ce(le);if(Mt==V)le=wt;else if(!wt){if(Mt==q)continue e;break e}}ae[J++]=le}return ae}Se.prototype=or(xi.prototype),Se.prototype.constructor=Se;function Fn(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var l=e[t];this.set(l[0],l[1])}}function Cd(){this.__data__=Pr?Pr(null):{},this.size=0}function Td(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function Rd(e){var t=this.__data__;if(Pr){var i=t[e];return i===h?r:i}return Me.call(t,e)?t[e]:r}function Nd(e){var t=this.__data__;return Pr?t[e]!==r:Me.call(t,e)}function Ad(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Pr&&t===r?h:t,this}Fn.prototype.clear=Cd,Fn.prototype.delete=Td,Fn.prototype.get=Rd,Fn.prototype.has=Nd,Fn.prototype.set=Ad;function cn(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var l=e[t];this.set(l[0],l[1])}}function Pd(){this.__data__=[],this.size=0}function kd(e){var t=this.__data__,i=vi(t,e);if(i<0)return!1;var l=t.length-1;return i==l?t.pop():hi.call(t,i,1),--this.size,!0}function Id(e){var t=this.__data__,i=vi(t,e);return i<0?r:t[i][1]}function Ld(e){return vi(this.__data__,e)>-1}function Dd(e,t){var i=this.__data__,l=vi(i,e);return l<0?(++this.size,i.push([e,t])):i[l][1]=t,this}cn.prototype.clear=Pd,cn.prototype.delete=kd,cn.prototype.get=Id,cn.prototype.has=Ld,cn.prototype.set=Dd;function un(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var l=e[t];this.set(l[0],l[1])}}function Md(){this.size=0,this.__data__={hash:new Fn,map:new(Nr||cn),string:new Fn}}function Od(e){var t=ki(this,e).delete(e);return this.size-=t?1:0,t}function jd(e){return ki(this,e).get(e)}function Fd(e){return ki(this,e).has(e)}function Bd(e,t){var i=ki(this,e),l=i.size;return i.set(e,t),this.size+=i.size==l?0:1,this}un.prototype.clear=Md,un.prototype.delete=Od,un.prototype.get=jd,un.prototype.has=Fd,un.prototype.set=Bd;function Bn(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new un;++t<i;)this.add(e[t])}function Ud(e){return this.__data__.set(e,h),this}function Wd(e){return this.__data__.has(e)}Bn.prototype.add=Bn.prototype.push=Ud,Bn.prototype.has=Wd;function Kt(e){var t=this.__data__=new cn(e);this.size=t.size}function Gd(){this.__data__=new cn,this.size=0}function Hd(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}function zd(e){return this.__data__.get(e)}function qd(e){return this.__data__.has(e)}function $d(e,t){var i=this.__data__;if(i instanceof cn){var l=i.__data__;if(!Nr||l.length<u-1)return l.push([e,t]),this.size=++i.size,this;i=this.__data__=new un(l)}return i.set(e,t),this.size=i.size,this}Kt.prototype.clear=Gd,Kt.prototype.delete=Hd,Kt.prototype.get=zd,Kt.prototype.has=qd,Kt.prototype.set=$d;function Ka(e,t){var i=fe(e),l=!i&&zn(e),f=!i&&!l&&An(e),_=!i&&!l&&!f&&ur(e),b=i||l||f||_,E=b?ys(e.length,nd):[],N=E.length;for(var O in e)(t||Me.call(e,O))&&!(b&&(O=="length"||f&&(O=="offset"||O=="parent")||_&&(O=="buffer"||O=="byteLength"||O=="byteOffset")||pn(O,N)))&&E.push(O);return E}function Qa(e){var t=e.length;return t?e[Fs(0,t-1)]:r}function Xd(e,t){return Ii(Tt(e),Un(t,0,e.length))}function Yd(e){return Ii(Tt(e))}function Ns(e,t,i){(i!==r&&!Qt(e[t],i)||i===r&&!(t in e))&&fn(e,t,i)}function Ir(e,t,i){var l=e[t];(!(Me.call(e,t)&&Qt(l,i))||i===r&&!(t in e))&&fn(e,t,i)}function vi(e,t){for(var i=e.length;i--;)if(Qt(e[i][0],t))return i;return-1}function Vd(e,t,i,l){return Cn(e,function(f,_,b){t(l,f,i(f),b)}),l}function Ja(e,t){return e&&nn(t,ct(t),e)}function Kd(e,t){return e&&nn(t,Nt(t),e)}function fn(e,t,i){t=="__proto__"&&di?di(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function As(e,t){for(var i=-1,l=t.length,f=k(l),_=e==null;++i<l;)f[i]=_?r:co(e,t[i]);return f}function Un(e,t,i){return e===e&&(i!==r&&(e=e<=i?e:i),t!==r&&(e=e>=t?e:t)),e}function Ht(e,t,i,l,f,_){var b,E=t&x,N=t&y,O=t&S;if(i&&(b=f?i(e,l,f,_):i(e)),b!==r)return b;if(!Ye(e))return e;var F=fe(e);if(F){if(b=Fp(e),!E)return Tt(e,b)}else{var W=_t(e),J=W==Pe||W==St;if(An(e))return wl(e,E);if(W==ee||W==Oe||J&&!f){if(b=N||J?{}:Wl(e),!E)return N?Rp(e,Kd(b,e)):Tp(e,Ja(b,e))}else{if(!We[W])return f?e:{};b=Bp(e,W,E)}}_||(_=new Kt);var re=_.get(e);if(re)return re;_.set(e,b),gc(e)?e.forEach(function(le){b.add(Ht(le,t,i,le,e,_))}):pc(e)&&e.forEach(function(le,we){b.set(we,Ht(le,t,i,we,e,_))});var ae=O?N?Vs:Ys:N?Nt:ct,ge=F?r:ae(e);return Ut(ge||e,function(le,we){ge&&(we=le,le=e[we]),Ir(b,we,Ht(le,t,i,we,e,_))}),b}function Qd(e){var t=ct(e);return function(i){return Za(i,e,t)}}function Za(e,t,i){var l=i.length;if(e==null)return!l;for(e=Be(e);l--;){var f=i[l],_=t[f],b=e[f];if(b===r&&!(f in e)||!_(b))return!1}return!0}function el(e,t,i){if(typeof e!="function")throw new Wt(d);return Br(function(){e.apply(r,i)},t)}function Lr(e,t,i,l){var f=-1,_=ni,b=!0,E=e.length,N=[],O=t.length;if(!E)return N;i&&(t=$e(t,It(i))),l?(_=ms,b=!1):t.length>=u&&(_=Tr,b=!1,t=new Bn(t));e:for(;++f<E;){var F=e[f],W=i==null?F:i(F);if(F=l||F!==0?F:0,b&&W===W){for(var J=O;J--;)if(t[J]===W)continue e;N.push(F)}else _(t,W,l)||N.push(F)}return N}var Cn=Rl(tn),tl=Rl(ks,!0);function Jd(e,t){var i=!0;return Cn(e,function(l,f,_){return i=!!t(l,f,_),i}),i}function bi(e,t,i){for(var l=-1,f=e.length;++l<f;){var _=e[l],b=t(_);if(b!=null&&(E===r?b===b&&!Dt(b):i(b,E)))var E=b,N=_}return N}function Zd(e,t,i,l){var f=e.length;for(i=me(i),i<0&&(i=-i>f?0:f+i),l=l===r||l>f?f:me(l),l<0&&(l+=f),l=i>l?0:xc(l);i<l;)e[i++]=t;return e}function nl(e,t){var i=[];return Cn(e,function(l,f,_){t(l,f,_)&&i.push(l)}),i}function dt(e,t,i,l,f){var _=-1,b=e.length;for(i||(i=Wp),f||(f=[]);++_<b;){var E=e[_];t>0&&i(E)?t>1?dt(E,t-1,i,l,f):wn(f,E):l||(f[f.length]=E)}return f}var Ps=Nl(),rl=Nl(!0);function tn(e,t){return e&&Ps(e,t,ct)}function ks(e,t){return e&&rl(e,t,ct)}function yi(e,t){return yn(t,function(i){return mn(e[i])})}function Wn(e,t){t=Rn(t,e);for(var i=0,l=t.length;e!=null&&i<l;)e=e[rn(t[i++])];return i&&i==l?e:r}function il(e,t,i){var l=t(e);return fe(e)?l:wn(l,i(e))}function bt(e){return e==null?e===r?Ve:Z:jn&&jn in Be(e)?Mp(e):Yp(e)}function Is(e,t){return e>t}function ep(e,t){return e!=null&&Me.call(e,t)}function tp(e,t){return e!=null&&t in Be(e)}function np(e,t,i){return e>=gt(t,i)&&e<st(t,i)}function Ls(e,t,i){for(var l=i?ms:ni,f=e[0].length,_=e.length,b=_,E=k(_),N=1/0,O=[];b--;){var F=e[b];b&&t&&(F=$e(F,It(t))),N=gt(F.length,N),E[b]=!i&&(t||f>=120&&F.length>=120)?new Bn(b&&F):r}F=e[0];var W=-1,J=E[0];e:for(;++W<f&&O.length<N;){var re=F[W],ae=t?t(re):re;if(re=i||re!==0?re:0,!(J?Tr(J,ae):l(O,ae,i))){for(b=_;--b;){var ge=E[b];if(!(ge?Tr(ge,ae):l(e[b],ae,i)))continue e}J&&J.push(ae),O.push(re)}}return O}function rp(e,t,i,l){return tn(e,function(f,_,b){t(l,i(f),_,b)}),l}function Dr(e,t,i){t=Rn(t,e),e=ql(e,t);var l=e==null?e:e[rn(qt(t))];return l==null?r:kt(l,e,i)}function sl(e){return Ke(e)&&bt(e)==Oe}function ip(e){return Ke(e)&&bt(e)==lt}function sp(e){return Ke(e)&&bt(e)==ke}function Mr(e,t,i,l,f){return e===t?!0:e==null||t==null||!Ke(e)&&!Ke(t)?e!==e&&t!==t:op(e,t,i,l,Mr,f)}function op(e,t,i,l,f,_){var b=fe(e),E=fe(t),N=b?nt:_t(e),O=E?nt:_t(t);N=N==Oe?ee:N,O=O==Oe?ee:O;var F=N==ee,W=O==ee,J=N==O;if(J&&An(e)){if(!An(t))return!1;b=!0,F=!1}if(J&&!F)return _||(_=new Kt),b||ur(e)?Fl(e,t,i,l,f,_):Lp(e,t,N,i,l,f,_);if(!(i&C)){var re=F&&Me.call(e,"__wrapped__"),ae=W&&Me.call(t,"__wrapped__");if(re||ae){var ge=re?e.value():e,le=ae?t.value():t;return _||(_=new Kt),f(ge,le,i,l,_)}}return J?(_||(_=new Kt),Dp(e,t,i,l,f,_)):!1}function ap(e){return Ke(e)&&_t(e)==Xe}function Ds(e,t,i,l){var f=i.length,_=f,b=!l;if(e==null)return!_;for(e=Be(e);f--;){var E=i[f];if(b&&E[2]?E[1]!==e[E[0]]:!(E[0]in e))return!1}for(;++f<_;){E=i[f];var N=E[0],O=e[N],F=E[1];if(b&&E[2]){if(O===r&&!(N in e))return!1}else{var W=new Kt;if(l)var J=l(O,F,N,e,t,W);if(!(J===r?Mr(F,O,C|P,l,W):J))return!1}}return!0}function ol(e){if(!Ye(e)||Hp(e))return!1;var t=mn(e)?ad:Qf;return t.test(Hn(e))}function lp(e){return Ke(e)&&bt(e)==ue}function cp(e){return Ke(e)&&_t(e)==pe}function up(e){return Ke(e)&&Fi(e.length)&&!!ze[bt(e)]}function al(e){return typeof e=="function"?e:e==null?At:typeof e=="object"?fe(e)?ul(e[0],e[1]):cl(e):Ac(e)}function Ms(e){if(!Fr(e))return dd(e);var t=[];for(var i in Be(e))Me.call(e,i)&&i!="constructor"&&t.push(i);return t}function fp(e){if(!Ye(e))return Xp(e);var t=Fr(e),i=[];for(var l in e)l=="constructor"&&(t||!Me.call(e,l))||i.push(l);return i}function Os(e,t){return e<t}function ll(e,t){var i=-1,l=Rt(e)?k(e.length):[];return Cn(e,function(f,_,b){l[++i]=t(f,_,b)}),l}function cl(e){var t=Qs(e);return t.length==1&&t[0][2]?Hl(t[0][0],t[0][1]):function(i){return i===e||Ds(i,e,t)}}function ul(e,t){return Zs(e)&&Gl(t)?Hl(rn(e),t):function(i){var l=co(i,e);return l===r&&l===t?uo(i,e):Mr(t,l,C|P)}}function wi(e,t,i,l,f){e!==t&&Ps(t,function(_,b){if(f||(f=new Kt),Ye(_))hp(e,t,b,i,wi,l,f);else{var E=l?l(to(e,b),_,b+"",e,t,f):r;E===r&&(E=_),Ns(e,b,E)}},Nt)}function hp(e,t,i,l,f,_,b){var E=to(e,i),N=to(t,i),O=b.get(N);if(O){Ns(e,i,O);return}var F=_?_(E,N,i+"",e,t,b):r,W=F===r;if(W){var J=fe(N),re=!J&&An(N),ae=!J&&!re&&ur(N);F=N,J||re||ae?fe(E)?F=E:Je(E)?F=Tt(E):re?(W=!1,F=wl(N,!0)):ae?(W=!1,F=El(N,!0)):F=[]:Ur(N)||zn(N)?(F=E,zn(E)?F=vc(E):(!Ye(E)||mn(E))&&(F=Wl(N))):W=!1}W&&(b.set(N,F),f(F,N,l,_,b),b.delete(N)),Ns(e,i,F)}function fl(e,t){var i=e.length;if(i)return t+=t<0?i:0,pn(t,i)?e[t]:r}function hl(e,t,i){t.length?t=$e(t,function(_){return fe(_)?function(b){return Wn(b,_.length===1?_[0]:_)}:_}):t=[At];var l=-1;t=$e(t,It(oe()));var f=ll(e,function(_,b,E){var N=$e(t,function(O){return O(_)});return{criteria:N,index:++l,value:_}});return Bh(f,function(_,b){return Cp(_,b,i)})}function dp(e,t){return dl(e,t,function(i,l){return uo(e,l)})}function dl(e,t,i){for(var l=-1,f=t.length,_={};++l<f;){var b=t[l],E=Wn(e,b);i(E,b)&&Or(_,Rn(b,e),E)}return _}function pp(e){return function(t){return Wn(t,e)}}function js(e,t,i,l){var f=l?Fh:Zn,_=-1,b=t.length,E=e;for(e===t&&(t=Tt(t)),i&&(E=$e(e,It(i)));++_<b;)for(var N=0,O=t[_],F=i?i(O):O;(N=f(E,F,N,l))>-1;)E!==e&&hi.call(E,N,1),hi.call(e,N,1);return e}function pl(e,t){for(var i=e?t.length:0,l=i-1;i--;){var f=t[i];if(i==l||f!==_){var _=f;pn(f)?hi.call(e,f,1):Ws(e,f)}}return e}function Fs(e,t){return e+mi(Ya()*(t-e+1))}function mp(e,t,i,l){for(var f=-1,_=st(pi((t-e)/(i||1)),0),b=k(_);_--;)b[l?_:++f]=e,e+=i;return b}function Bs(e,t){var i="";if(!e||t<1||t>se)return i;do t%2&&(i+=e),t=mi(t/2),t&&(e+=e);while(t);return i}function _e(e,t){return no(zl(e,t,At),e+"")}function gp(e){return Qa(fr(e))}function _p(e,t){var i=fr(e);return Ii(i,Un(t,0,i.length))}function Or(e,t,i,l){if(!Ye(e))return e;t=Rn(t,e);for(var f=-1,_=t.length,b=_-1,E=e;E!=null&&++f<_;){var N=rn(t[f]),O=i;if(N==="__proto__"||N==="constructor"||N==="prototype")return e;if(f!=b){var F=E[N];O=l?l(F,N,E):r,O===r&&(O=Ye(F)?F:pn(t[f+1])?[]:{})}Ir(E,N,O),E=E[N]}return e}var ml=gi?function(e,t){return gi.set(e,t),e}:At,xp=di?function(e,t){return di(e,"toString",{configurable:!0,enumerable:!1,value:ho(t),writable:!0})}:At;function vp(e){return Ii(fr(e))}function zt(e,t,i){var l=-1,f=e.length;t<0&&(t=-t>f?0:f+t),i=i>f?f:i,i<0&&(i+=f),f=t>i?0:i-t>>>0,t>>>=0;for(var _=k(f);++l<f;)_[l]=e[l+t];return _}function bp(e,t){var i;return Cn(e,function(l,f,_){return i=t(l,f,_),!i}),!!i}function Ei(e,t,i){var l=0,f=e==null?l:e.length;if(typeof t=="number"&&t===t&&f<=Ae){for(;l<f;){var _=l+f>>>1,b=e[_];b!==null&&!Dt(b)&&(i?b<=t:b<t)?l=_+1:f=_}return f}return Us(e,t,At,i)}function Us(e,t,i,l){var f=0,_=e==null?0:e.length;if(_===0)return 0;t=i(t);for(var b=t!==t,E=t===null,N=Dt(t),O=t===r;f<_;){var F=mi((f+_)/2),W=i(e[F]),J=W!==r,re=W===null,ae=W===W,ge=Dt(W);if(b)var le=l||ae;else O?le=ae&&(l||J):E?le=ae&&J&&(l||!re):N?le=ae&&J&&!re&&(l||!ge):re||ge?le=!1:le=l?W<=t:W<t;le?f=F+1:_=F}return gt(_,Re)}function gl(e,t){for(var i=-1,l=e.length,f=0,_=[];++i<l;){var b=e[i],E=t?t(b):b;if(!i||!Qt(E,N)){var N=E;_[f++]=b===0?0:b}}return _}function _l(e){return typeof e=="number"?e:Dt(e)?xe:+e}function Lt(e){if(typeof e=="string")return e;if(fe(e))return $e(e,Lt)+"";if(Dt(e))return Va?Va.call(e):"";var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function Tn(e,t,i){var l=-1,f=ni,_=e.length,b=!0,E=[],N=E;if(i)b=!1,f=ms;else if(_>=u){var O=t?null:kp(e);if(O)return ii(O);b=!1,f=Tr,N=new Bn}else N=t?[]:E;e:for(;++l<_;){var F=e[l],W=t?t(F):F;if(F=i||F!==0?F:0,b&&W===W){for(var J=N.length;J--;)if(N[J]===W)continue e;t&&N.push(W),E.push(F)}else f(N,W,i)||(N!==E&&N.push(W),E.push(F))}return E}function Ws(e,t){return t=Rn(t,e),e=ql(e,t),e==null||delete e[rn(qt(t))]}function xl(e,t,i,l){return Or(e,t,i(Wn(e,t)),l)}function Si(e,t,i,l){for(var f=e.length,_=l?f:-1;(l?_--:++_<f)&&t(e[_],_,e););return i?zt(e,l?0:_,l?_+1:f):zt(e,l?_+1:0,l?f:_)}function vl(e,t){var i=e;return i instanceof Se&&(i=i.value()),gs(t,function(l,f){return f.func.apply(f.thisArg,wn([l],f.args))},i)}function Gs(e,t,i){var l=e.length;if(l<2)return l?Tn(e[0]):[];for(var f=-1,_=k(l);++f<l;)for(var b=e[f],E=-1;++E<l;)E!=f&&(_[f]=Lr(_[f]||b,e[E],t,i));return Tn(dt(_,1),t,i)}function bl(e,t,i){for(var l=-1,f=e.length,_=t.length,b={};++l<f;){var E=l<_?t[l]:r;i(b,e[l],E)}return b}function Hs(e){return Je(e)?e:[]}function zs(e){return typeof e=="function"?e:At}function Rn(e,t){return fe(e)?e:Zs(e,t)?[e]:Vl(Le(e))}var yp=_e;function Nn(e,t,i){var l=e.length;return i=i===r?l:i,!t&&i>=l?e:zt(e,t,i)}var yl=ld||function(e){return ht.clearTimeout(e)};function wl(e,t){if(t)return e.slice();var i=e.length,l=Ha?Ha(i):new e.constructor(i);return e.copy(l),l}function qs(e){var t=new e.constructor(e.byteLength);return new ui(t).set(new ui(e)),t}function wp(e,t){var i=t?qs(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}function Ep(e){var t=new e.constructor(e.source,sa.exec(e));return t.lastIndex=e.lastIndex,t}function Sp(e){return kr?Be(kr.call(e)):{}}function El(e,t){var i=t?qs(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function Sl(e,t){if(e!==t){var i=e!==r,l=e===null,f=e===e,_=Dt(e),b=t!==r,E=t===null,N=t===t,O=Dt(t);if(!E&&!O&&!_&&e>t||_&&b&&N&&!E&&!O||l&&b&&N||!i&&N||!f)return 1;if(!l&&!_&&!O&&e<t||O&&i&&f&&!l&&!_||E&&i&&f||!b&&f||!N)return-1}return 0}function Cp(e,t,i){for(var l=-1,f=e.criteria,_=t.criteria,b=f.length,E=i.length;++l<b;){var N=Sl(f[l],_[l]);if(N){if(l>=E)return N;var O=i[l];return N*(O=="desc"?-1:1)}}return e.index-t.index}function Cl(e,t,i,l){for(var f=-1,_=e.length,b=i.length,E=-1,N=t.length,O=st(_-b,0),F=k(N+O),W=!l;++E<N;)F[E]=t[E];for(;++f<b;)(W||f<_)&&(F[i[f]]=e[f]);for(;O--;)F[E++]=e[f++];return F}function Tl(e,t,i,l){for(var f=-1,_=e.length,b=-1,E=i.length,N=-1,O=t.length,F=st(_-E,0),W=k(F+O),J=!l;++f<F;)W[f]=e[f];for(var re=f;++N<O;)W[re+N]=t[N];for(;++b<E;)(J||f<_)&&(W[re+i[b]]=e[f++]);return W}function Tt(e,t){var i=-1,l=e.length;for(t||(t=k(l));++i<l;)t[i]=e[i];return t}function nn(e,t,i,l){var f=!i;i||(i={});for(var _=-1,b=t.length;++_<b;){var E=t[_],N=l?l(i[E],e[E],E,i,e):r;N===r&&(N=e[E]),f?fn(i,E,N):Ir(i,E,N)}return i}function Tp(e,t){return nn(e,Js(e),t)}function Rp(e,t){return nn(e,Bl(e),t)}function Ci(e,t){return function(i,l){var f=fe(i)?Ih:Vd,_=t?t():{};return f(i,e,oe(l,2),_)}}function ar(e){return _e(function(t,i){var l=-1,f=i.length,_=f>1?i[f-1]:r,b=f>2?i[2]:r;for(_=e.length>3&&typeof _=="function"?(f--,_):r,b&&yt(i[0],i[1],b)&&(_=f<3?r:_,f=1),t=Be(t);++l<f;){var E=i[l];E&&e(t,E,l,_)}return t})}function Rl(e,t){return function(i,l){if(i==null)return i;if(!Rt(i))return e(i,l);for(var f=i.length,_=t?f:-1,b=Be(i);(t?_--:++_<f)&&l(b[_],_,b)!==!1;);return i}}function Nl(e){return function(t,i,l){for(var f=-1,_=Be(t),b=l(t),E=b.length;E--;){var N=b[e?E:++f];if(i(_[N],N,_)===!1)break}return t}}function Np(e,t,i){var l=t&A,f=jr(e);function _(){var b=this&&this!==ht&&this instanceof _?f:e;return b.apply(l?i:this,arguments)}return _}function Al(e){return function(t){t=Le(t);var i=er(t)?Vt(t):r,l=i?i[0]:t.charAt(0),f=i?Nn(i,1).join(""):t.slice(1);return l[e]()+f}}function lr(e){return function(t){return gs(Rc(Tc(t).replace(xh,"")),e,"")}}function jr(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var i=or(e.prototype),l=e.apply(i,t);return Ye(l)?l:i}}function Ap(e,t,i){var l=jr(e);function f(){for(var _=arguments.length,b=k(_),E=_,N=cr(f);E--;)b[E]=arguments[E];var O=_<3&&b[0]!==N&&b[_-1]!==N?[]:En(b,N);if(_-=O.length,_<i)return Dl(e,t,Ti,f.placeholder,r,b,O,r,r,i-_);var F=this&&this!==ht&&this instanceof f?l:e;return kt(F,this,b)}return f}function Pl(e){return function(t,i,l){var f=Be(t);if(!Rt(t)){var _=oe(i,3);t=ct(t),i=function(E){return _(f[E],E,f)}}var b=e(t,i,l);return b>-1?f[_?t[b]:b]:r}}function kl(e){return dn(function(t){var i=t.length,l=i,f=Gt.prototype.thru;for(e&&t.reverse();l--;){var _=t[l];if(typeof _!="function")throw new Wt(d);if(f&&!b&&Pi(_)=="wrapper")var b=new Gt([],!0)}for(l=b?l:i;++l<i;){_=t[l];var E=Pi(_),N=E=="wrapper"?Ks(_):r;N&&eo(N[0])&&N[1]==(H|R|X|G)&&!N[4].length&&N[9]==1?b=b[Pi(N[0])].apply(b,N[3]):b=_.length==1&&eo(_)?b[E]():b.thru(_)}return function(){var O=arguments,F=O[0];if(b&&O.length==1&&fe(F))return b.plant(F).value();for(var W=0,J=i?t[W].apply(this,O):F;++W<i;)J=t[W].call(this,J);return J}})}function Ti(e,t,i,l,f,_,b,E,N,O){var F=t&H,W=t&A,J=t&j,re=t&(R|I),ae=t&M,ge=J?r:jr(e);function le(){for(var we=arguments.length,Ce=k(we),Mt=we;Mt--;)Ce[Mt]=arguments[Mt];if(re)var wt=cr(le),Ot=Wh(Ce,wt);if(l&&(Ce=Cl(Ce,l,f,re)),_&&(Ce=Tl(Ce,_,b,re)),we-=Ot,re&&we<O){var Ze=En(Ce,wt);return Dl(e,t,Ti,le.placeholder,i,Ce,Ze,E,N,O-we)}var Jt=W?i:this,_n=J?Jt[e]:e;return we=Ce.length,E?Ce=Vp(Ce,E):ae&&we>1&&Ce.reverse(),F&&N<we&&(Ce.length=N),this&&this!==ht&&this instanceof le&&(_n=ge||jr(_n)),_n.apply(Jt,Ce)}return le}function Il(e,t){return function(i,l){return rp(i,e,t(l),{})}}function Ri(e,t){return function(i,l){var f;if(i===r&&l===r)return t;if(i!==r&&(f=i),l!==r){if(f===r)return l;typeof i=="string"||typeof l=="string"?(i=Lt(i),l=Lt(l)):(i=_l(i),l=_l(l)),f=e(i,l)}return f}}function $s(e){return dn(function(t){return t=$e(t,It(oe())),_e(function(i){var l=this;return e(t,function(f){return kt(f,l,i)})})})}function Ni(e,t){t=t===r?" ":Lt(t);var i=t.length;if(i<2)return i?Bs(t,e):t;var l=Bs(t,pi(e/tr(t)));return er(t)?Nn(Vt(l),0,e).join(""):l.slice(0,e)}function Pp(e,t,i,l){var f=t&A,_=jr(e);function b(){for(var E=-1,N=arguments.length,O=-1,F=l.length,W=k(F+N),J=this&&this!==ht&&this instanceof b?_:e;++O<F;)W[O]=l[O];for(;N--;)W[O++]=arguments[++E];return kt(J,f?i:this,W)}return b}function Ll(e){return function(t,i,l){return l&&typeof l!="number"&&yt(t,i,l)&&(i=l=r),t=gn(t),i===r?(i=t,t=0):i=gn(i),l=l===r?t<i?1:-1:gn(l),mp(t,i,l,e)}}function Ai(e){return function(t,i){return typeof t=="string"&&typeof i=="string"||(t=$t(t),i=$t(i)),e(t,i)}}function Dl(e,t,i,l,f,_,b,E,N,O){var F=t&R,W=F?b:r,J=F?r:b,re=F?_:r,ae=F?r:_;t|=F?X:$,t&=~(F?$:X),t&U||(t&=-4);var ge=[e,t,f,re,W,ae,J,E,N,O],le=i.apply(r,ge);return eo(e)&&$l(le,ge),le.placeholder=l,Xl(le,e,t)}function Xs(e){var t=it[e];return function(i,l){if(i=$t(i),l=l==null?0:gt(me(l),292),l&&Xa(i)){var f=(Le(i)+"e").split("e"),_=t(f[0]+"e"+(+f[1]+l));return f=(Le(_)+"e").split("e"),+(f[0]+"e"+(+f[1]-l))}return t(i)}}var kp=ir&&1/ii(new ir([,-0]))[1]==ie?function(e){return new ir(e)}:go;function Ml(e){return function(t){var i=_t(t);return i==Xe?Es(t):i==pe?Yh(t):Uh(t,e(t))}}function hn(e,t,i,l,f,_,b,E){var N=t&j;if(!N&&typeof e!="function")throw new Wt(d);var O=l?l.length:0;if(O||(t&=-97,l=f=r),b=b===r?b:st(me(b),0),E=E===r?E:me(E),O-=f?f.length:0,t&$){var F=l,W=f;l=f=r}var J=N?r:Ks(e),re=[e,t,i,l,f,F,W,_,b,E];if(J&&$p(re,J),e=re[0],t=re[1],i=re[2],l=re[3],f=re[4],E=re[9]=re[9]===r?N?0:e.length:st(re[9]-O,0),!E&&t&(R|I)&&(t&=-25),!t||t==A)var ae=Np(e,t,i);else t==R||t==I?ae=Ap(e,t,E):(t==X||t==(A|X))&&!f.length?ae=Pp(e,t,i,l):ae=Ti.apply(r,re);var ge=J?ml:$l;return Xl(ge(ae,re),e,t)}function Ol(e,t,i,l){return e===r||Qt(e,rr[i])&&!Me.call(l,i)?t:e}function jl(e,t,i,l,f,_){return Ye(e)&&Ye(t)&&(_.set(t,e),wi(e,t,r,jl,_),_.delete(t)),e}function Ip(e){return Ur(e)?r:e}function Fl(e,t,i,l,f,_){var b=i&C,E=e.length,N=t.length;if(E!=N&&!(b&&N>E))return!1;var O=_.get(e),F=_.get(t);if(O&&F)return O==t&&F==e;var W=-1,J=!0,re=i&P?new Bn:r;for(_.set(e,t),_.set(t,e);++W<E;){var ae=e[W],ge=t[W];if(l)var le=b?l(ge,ae,W,t,e,_):l(ae,ge,W,e,t,_);if(le!==r){if(le)continue;J=!1;break}if(re){if(!_s(t,function(we,Ce){if(!Tr(re,Ce)&&(ae===we||f(ae,we,i,l,_)))return re.push(Ce)})){J=!1;break}}else if(!(ae===ge||f(ae,ge,i,l,_))){J=!1;break}}return _.delete(e),_.delete(t),J}function Lp(e,t,i,l,f,_,b){switch(i){case ft: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 ui(e),new ui(t)));case Ue:case ke:case ot:return Qt(+e,+t);case Et:return e.name==t.name&&e.message==t.message;case ue:case ye:return e==t+"";case Xe:var E=Es;case pe:var N=l&C;if(E||(E=ii),e.size!=t.size&&!N)return!1;var O=b.get(e);if(O)return O==t;l|=P,b.set(e,t);var F=Fl(E(e),E(t),l,f,_,b);return b.delete(e),F;case ve:if(kr)return kr.call(e)==kr.call(t)}return!1}function Dp(e,t,i,l,f,_){var b=i&C,E=Ys(e),N=E.length,O=Ys(t),F=O.length;if(N!=F&&!b)return!1;for(var W=N;W--;){var J=E[W];if(!(b?J in t:Me.call(t,J)))return!1}var re=_.get(e),ae=_.get(t);if(re&&ae)return re==t&&ae==e;var ge=!0;_.set(e,t),_.set(t,e);for(var le=b;++W<N;){J=E[W];var we=e[J],Ce=t[J];if(l)var Mt=b?l(Ce,we,J,t,e,_):l(we,Ce,J,e,t,_);if(!(Mt===r?we===Ce||f(we,Ce,i,l,_):Mt)){ge=!1;break}le||(le=J=="constructor")}if(ge&&!le){var wt=e.constructor,Ot=t.constructor;wt!=Ot&&"constructor"in e&&"constructor"in t&&!(typeof wt=="function"&&wt instanceof wt&&typeof Ot=="function"&&Ot instanceof Ot)&&(ge=!1)}return _.delete(e),_.delete(t),ge}function dn(e){return no(zl(e,r,Zl),e+"")}function Ys(e){return il(e,ct,Js)}function Vs(e){return il(e,Nt,Bl)}var Ks=gi?function(e){return gi.get(e)}:go;function Pi(e){for(var t=e.name+"",i=sr[t],l=Me.call(sr,t)?i.length:0;l--;){var f=i[l],_=f.func;if(_==null||_==e)return f.name}return t}function cr(e){var t=Me.call(p,"placeholder")?p:e;return t.placeholder}function oe(){var e=p.iteratee||po;return e=e===po?al:e,arguments.length?e(arguments[0],arguments[1]):e}function ki(e,t){var i=e.__data__;return Gp(t)?i[typeof t=="string"?"string":"hash"]:i.map}function Qs(e){for(var t=ct(e),i=t.length;i--;){var l=t[i],f=e[l];t[i]=[l,f,Gl(f)]}return t}function Gn(e,t){var i=qh(e,t);return ol(i)?i:r}function Mp(e){var t=Me.call(e,jn),i=e[jn];try{e[jn]=r;var l=!0}catch{}var f=li.call(e);return l&&(t?e[jn]=i:delete e[jn]),f}var Js=Cs?function(e){return e==null?[]:(e=Be(e),yn(Cs(e),function(t){return qa.call(e,t)}))}:_o,Bl=Cs?function(e){for(var t=[];e;)wn(t,Js(e)),e=fi(e);return t}:_o,_t=bt;(Ts&&_t(new Ts(new ArrayBuffer(1)))!=ft||Nr&&_t(new Nr)!=Xe||Rs&&_t(Rs.resolve())!=L||ir&&_t(new ir)!=pe||Ar&&_t(new Ar)!=vt)&&(_t=function(e){var t=bt(e),i=t==ee?e.constructor:r,l=i?Hn(i):"";if(l)switch(l){case _d:return ft;case xd:return Xe;case vd:return L;case bd:return pe;case yd:return vt}return t});function Op(e,t,i){for(var l=-1,f=i.length;++l<f;){var _=i[l],b=_.size;switch(_.type){case"drop":e+=b;break;case"dropRight":t-=b;break;case"take":t=gt(t,e+b);break;case"takeRight":e=st(e,t-b);break}}return{start:e,end:t}}function jp(e){var t=e.match(Mn);return t?t[1].split(zf):[]}function Ul(e,t,i){t=Rn(t,e);for(var l=-1,f=t.length,_=!1;++l<f;){var b=rn(t[l]);if(!(_=e!=null&&i(e,b)))break;e=e[b]}return _||++l!=f?_:(f=e==null?0:e.length,!!f&&Fi(f)&&pn(b,f)&&(fe(e)||zn(e)))}function Fp(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&Me.call(e,"index")&&(i.index=e.index,i.input=e.input),i}function Wl(e){return typeof e.constructor=="function"&&!Fr(e)?or(fi(e)):{}}function Bp(e,t,i){var l=e.constructor;switch(t){case lt:return qs(e);case Ue:case ke:return new l(+e);case ft:return wp(e,i);case _r:case Vn:case xr:case vr:case Dn:case br:case yr:case wr:case Er:return El(e,i);case Xe:return new l;case ot:case ye:return new l(e);case ue:return Ep(e);case pe:return new l;case ve:return Sp(e)}}function Up(e,t){var i=t.length;if(!i)return e;var l=i-1;return t[l]=(i>1?"& ":"")+t[l],t=t.join(i>2?", ":" "),e.replace(Ft,`{
6
- /* [wrapped with `+t+`] */
7
- `)}function Wp(e){return fe(e)||zn(e)||!!($a&&e&&e[$a])}function pn(e,t){var i=typeof e;return t=t??se,!!t&&(i=="number"||i!="symbol"&&Zf.test(e))&&e>-1&&e%1==0&&e<t}function yt(e,t,i){if(!Ye(i))return!1;var l=typeof t;return(l=="number"?Rt(i)&&pn(t,i.length):l=="string"&&t in i)?Qt(i[t],e):!1}function Zs(e,t){if(fe(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Dt(e)?!0:Qn.test(e)||!bn.test(e)||t!=null&&e in Be(t)}function Gp(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function eo(e){var t=Pi(e),i=p[t];if(typeof i!="function"||!(t in Se.prototype))return!1;if(e===i)return!0;var l=Ks(i);return!!l&&e===l[0]}function Hp(e){return!!Ga&&Ga in e}var zp=oi?mn:xo;function Fr(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||rr;return e===i}function Gl(e){return e===e&&!Ye(e)}function Hl(e,t){return function(i){return i==null?!1:i[e]===t&&(t!==r||e in Be(i))}}function qp(e){var t=Oi(e,function(l){return i.size===g&&i.clear(),l}),i=t.cache;return t}function $p(e,t){var i=e[1],l=t[1],f=i|l,_=f<(A|j|H),b=l==H&&i==R||l==H&&i==G&&e[7].length<=t[8]||l==(H|G)&&t[7].length<=t[8]&&i==R;if(!(_||b))return e;l&A&&(e[2]=t[2],f|=i&A?0:U);var E=t[3];if(E){var N=e[3];e[3]=N?Cl(N,E,t[4]):E,e[4]=N?En(e[3],m):t[4]}return E=t[5],E&&(N=e[5],e[5]=N?Tl(N,E,t[6]):E,e[6]=N?En(e[5],m):t[6]),E=t[7],E&&(e[7]=E),l&H&&(e[8]=e[8]==null?t[8]:gt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=f,e}function Xp(e){var t=[];if(e!=null)for(var i in Be(e))t.push(i);return t}function Yp(e){return li.call(e)}function zl(e,t,i){return t=st(t===r?e.length-1:t,0),function(){for(var l=arguments,f=-1,_=st(l.length-t,0),b=k(_);++f<_;)b[f]=l[t+f];f=-1;for(var E=k(t+1);++f<t;)E[f]=l[f];return E[t]=i(b),kt(e,this,E)}}function ql(e,t){return t.length<2?e:Wn(e,zt(t,0,-1))}function Vp(e,t){for(var i=e.length,l=gt(t.length,i),f=Tt(e);l--;){var _=t[l];e[l]=pn(_,i)?f[_]:r}return e}function to(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var $l=Yl(ml),Br=ud||function(e,t){return ht.setTimeout(e,t)},no=Yl(xp);function Xl(e,t,i){var l=t+"";return no(e,Up(l,Kp(jp(l),i)))}function Yl(e){var t=0,i=0;return function(){var l=pd(),f=de-(l-i);if(i=l,f>0){if(++t>=he)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Ii(e,t){var i=-1,l=e.length,f=l-1;for(t=t===r?l:t;++i<t;){var _=Fs(i,f),b=e[_];e[_]=e[i],e[i]=b}return e.length=t,e}var Vl=qp(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Jr,function(i,l,f,_){t.push(f?_.replace(Xf,"$1"):l||i)}),t});function rn(e){if(typeof e=="string"||Dt(e))return e;var t=e+"";return t=="0"&&1/e==-ie?"-0":t}function Hn(e){if(e!=null){try{return ai.call(e)}catch{}try{return e+""}catch{}}return""}function Kp(e,t){return Ut(Fe,function(i){var l="_."+i[0];t&i[1]&&!ni(e,l)&&e.push(l)}),e.sort()}function Kl(e){if(e instanceof Se)return e.clone();var t=new Gt(e.__wrapped__,e.__chain__);return t.__actions__=Tt(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Qp(e,t,i){(i?yt(e,t,i):t===r)?t=1:t=st(me(t),0);var l=e==null?0:e.length;if(!l||t<1)return[];for(var f=0,_=0,b=k(pi(l/t));f<l;)b[_++]=zt(e,f,f+=t);return b}function Jp(e){for(var t=-1,i=e==null?0:e.length,l=0,f=[];++t<i;){var _=e[t];_&&(f[l++]=_)}return f}function Zp(){var e=arguments.length;if(!e)return[];for(var t=k(e-1),i=arguments[0],l=e;l--;)t[l-1]=arguments[l];return wn(fe(i)?Tt(i):[i],dt(t,1))}var em=_e(function(e,t){return Je(e)?Lr(e,dt(t,1,Je,!0)):[]}),tm=_e(function(e,t){var i=qt(t);return Je(i)&&(i=r),Je(e)?Lr(e,dt(t,1,Je,!0),oe(i,2)):[]}),nm=_e(function(e,t){var i=qt(t);return Je(i)&&(i=r),Je(e)?Lr(e,dt(t,1,Je,!0),r,i):[]});function rm(e,t,i){var l=e==null?0:e.length;return l?(t=i||t===r?1:me(t),zt(e,t<0?0:t,l)):[]}function im(e,t,i){var l=e==null?0:e.length;return l?(t=i||t===r?1:me(t),t=l-t,zt(e,0,t<0?0:t)):[]}function sm(e,t){return e&&e.length?Si(e,oe(t,3),!0,!0):[]}function om(e,t){return e&&e.length?Si(e,oe(t,3),!0):[]}function am(e,t,i,l){var f=e==null?0:e.length;return f?(i&&typeof i!="number"&&yt(e,t,i)&&(i=0,l=f),Zd(e,t,i,l)):[]}function Ql(e,t,i){var l=e==null?0:e.length;if(!l)return-1;var f=i==null?0:me(i);return f<0&&(f=st(l+f,0)),ri(e,oe(t,3),f)}function Jl(e,t,i){var l=e==null?0:e.length;if(!l)return-1;var f=l-1;return i!==r&&(f=me(i),f=i<0?st(l+f,0):gt(f,l-1)),ri(e,oe(t,3),f,!0)}function Zl(e){var t=e==null?0:e.length;return t?dt(e,1):[]}function lm(e){var t=e==null?0:e.length;return t?dt(e,ie):[]}function cm(e,t){var i=e==null?0:e.length;return i?(t=t===r?1:me(t),dt(e,t)):[]}function um(e){for(var t=-1,i=e==null?0:e.length,l={};++t<i;){var f=e[t];l[f[0]]=f[1]}return l}function ec(e){return e&&e.length?e[0]:r}function fm(e,t,i){var l=e==null?0:e.length;if(!l)return-1;var f=i==null?0:me(i);return f<0&&(f=st(l+f,0)),Zn(e,t,f)}function hm(e){var t=e==null?0:e.length;return t?zt(e,0,-1):[]}var dm=_e(function(e){var t=$e(e,Hs);return t.length&&t[0]===e[0]?Ls(t):[]}),pm=_e(function(e){var t=qt(e),i=$e(e,Hs);return t===qt(i)?t=r:i.pop(),i.length&&i[0]===e[0]?Ls(i,oe(t,2)):[]}),mm=_e(function(e){var t=qt(e),i=$e(e,Hs);return t=typeof t=="function"?t:r,t&&i.pop(),i.length&&i[0]===e[0]?Ls(i,r,t):[]});function gm(e,t){return e==null?"":hd.call(e,t)}function qt(e){var t=e==null?0:e.length;return t?e[t-1]:r}function _m(e,t,i){var l=e==null?0:e.length;if(!l)return-1;var f=l;return i!==r&&(f=me(i),f=f<0?st(l+f,0):gt(f,l-1)),t===t?Kh(e,t,f):ri(e,Da,f,!0)}function xm(e,t){return e&&e.length?fl(e,me(t)):r}var vm=_e(tc);function tc(e,t){return e&&e.length&&t&&t.length?js(e,t):e}function bm(e,t,i){return e&&e.length&&t&&t.length?js(e,t,oe(i,2)):e}function ym(e,t,i){return e&&e.length&&t&&t.length?js(e,t,r,i):e}var wm=dn(function(e,t){var i=e==null?0:e.length,l=As(e,t);return pl(e,$e(t,function(f){return pn(f,i)?+f:f}).sort(Sl)),l});function Em(e,t){var i=[];if(!(e&&e.length))return i;var l=-1,f=[],_=e.length;for(t=oe(t,3);++l<_;){var b=e[l];t(b,l,e)&&(i.push(b),f.push(l))}return pl(e,f),i}function ro(e){return e==null?e:gd.call(e)}function Sm(e,t,i){var l=e==null?0:e.length;return l?(i&&typeof i!="number"&&yt(e,t,i)?(t=0,i=l):(t=t==null?0:me(t),i=i===r?l:me(i)),zt(e,t,i)):[]}function Cm(e,t){return Ei(e,t)}function Tm(e,t,i){return Us(e,t,oe(i,2))}function Rm(e,t){var i=e==null?0:e.length;if(i){var l=Ei(e,t);if(l<i&&Qt(e[l],t))return l}return-1}function Nm(e,t){return Ei(e,t,!0)}function Am(e,t,i){return Us(e,t,oe(i,2),!0)}function Pm(e,t){var i=e==null?0:e.length;if(i){var l=Ei(e,t,!0)-1;if(Qt(e[l],t))return l}return-1}function km(e){return e&&e.length?gl(e):[]}function Im(e,t){return e&&e.length?gl(e,oe(t,2)):[]}function Lm(e){var t=e==null?0:e.length;return t?zt(e,1,t):[]}function Dm(e,t,i){return e&&e.length?(t=i||t===r?1:me(t),zt(e,0,t<0?0:t)):[]}function Mm(e,t,i){var l=e==null?0:e.length;return l?(t=i||t===r?1:me(t),t=l-t,zt(e,t<0?0:t,l)):[]}function Om(e,t){return e&&e.length?Si(e,oe(t,3),!1,!0):[]}function jm(e,t){return e&&e.length?Si(e,oe(t,3)):[]}var Fm=_e(function(e){return Tn(dt(e,1,Je,!0))}),Bm=_e(function(e){var t=qt(e);return Je(t)&&(t=r),Tn(dt(e,1,Je,!0),oe(t,2))}),Um=_e(function(e){var t=qt(e);return t=typeof t=="function"?t:r,Tn(dt(e,1,Je,!0),r,t)});function Wm(e){return e&&e.length?Tn(e):[]}function Gm(e,t){return e&&e.length?Tn(e,oe(t,2)):[]}function Hm(e,t){return t=typeof t=="function"?t:r,e&&e.length?Tn(e,r,t):[]}function io(e){if(!(e&&e.length))return[];var t=0;return e=yn(e,function(i){if(Je(i))return t=st(i.length,t),!0}),ys(t,function(i){return $e(e,xs(i))})}function nc(e,t){if(!(e&&e.length))return[];var i=io(e);return t==null?i:$e(i,function(l){return kt(t,r,l)})}var zm=_e(function(e,t){return Je(e)?Lr(e,t):[]}),qm=_e(function(e){return Gs(yn(e,Je))}),$m=_e(function(e){var t=qt(e);return Je(t)&&(t=r),Gs(yn(e,Je),oe(t,2))}),Xm=_e(function(e){var t=qt(e);return t=typeof t=="function"?t:r,Gs(yn(e,Je),r,t)}),Ym=_e(io);function Vm(e,t){return bl(e||[],t||[],Ir)}function Km(e,t){return bl(e||[],t||[],Or)}var Qm=_e(function(e){var t=e.length,i=t>1?e[t-1]:r;return i=typeof i=="function"?(e.pop(),i):r,nc(e,i)});function rc(e){var t=p(e);return t.__chain__=!0,t}function Jm(e,t){return t(e),e}function Li(e,t){return t(e)}var Zm=dn(function(e){var t=e.length,i=t?e[0]:0,l=this.__wrapped__,f=function(_){return As(_,e)};return t>1||this.__actions__.length||!(l instanceof Se)||!pn(i)?this.thru(f):(l=l.slice(i,+i+(t?1:0)),l.__actions__.push({func:Li,args:[f],thisArg:r}),new Gt(l,this.__chain__).thru(function(_){return t&&!_.length&&_.push(r),_}))});function eg(){return rc(this)}function tg(){return new Gt(this.value(),this.__chain__)}function ng(){this.__values__===r&&(this.__values__=_c(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function rg(){return this}function ig(e){for(var t,i=this;i instanceof xi;){var l=Kl(i);l.__index__=0,l.__values__=r,t?f.__wrapped__=l:t=l;var f=l;i=i.__wrapped__}return f.__wrapped__=e,t}function sg(){var e=this.__wrapped__;if(e instanceof Se){var t=e;return this.__actions__.length&&(t=new Se(this)),t=t.reverse(),t.__actions__.push({func:Li,args:[ro],thisArg:r}),new Gt(t,this.__chain__)}return this.thru(ro)}function og(){return vl(this.__wrapped__,this.__actions__)}var ag=Ci(function(e,t,i){Me.call(e,i)?++e[i]:fn(e,i,1)});function lg(e,t,i){var l=fe(e)?Ia:Jd;return i&&yt(e,t,i)&&(t=r),l(e,oe(t,3))}function cg(e,t){var i=fe(e)?yn:nl;return i(e,oe(t,3))}var ug=Pl(Ql),fg=Pl(Jl);function hg(e,t){return dt(Di(e,t),1)}function dg(e,t){return dt(Di(e,t),ie)}function pg(e,t,i){return i=i===r?1:me(i),dt(Di(e,t),i)}function ic(e,t){var i=fe(e)?Ut:Cn;return i(e,oe(t,3))}function sc(e,t){var i=fe(e)?Lh:tl;return i(e,oe(t,3))}var mg=Ci(function(e,t,i){Me.call(e,i)?e[i].push(t):fn(e,i,[t])});function gg(e,t,i,l){e=Rt(e)?e:fr(e),i=i&&!l?me(i):0;var f=e.length;return i<0&&(i=st(f+i,0)),Bi(e)?i<=f&&e.indexOf(t,i)>-1:!!f&&Zn(e,t,i)>-1}var _g=_e(function(e,t,i){var l=-1,f=typeof t=="function",_=Rt(e)?k(e.length):[];return Cn(e,function(b){_[++l]=f?kt(t,b,i):Dr(b,t,i)}),_}),xg=Ci(function(e,t,i){fn(e,i,t)});function Di(e,t){var i=fe(e)?$e:ll;return i(e,oe(t,3))}function vg(e,t,i,l){return e==null?[]:(fe(t)||(t=t==null?[]:[t]),i=l?r:i,fe(i)||(i=i==null?[]:[i]),hl(e,t,i))}var bg=Ci(function(e,t,i){e[i?0:1].push(t)},function(){return[[],[]]});function yg(e,t,i){var l=fe(e)?gs:Oa,f=arguments.length<3;return l(e,oe(t,4),i,f,Cn)}function wg(e,t,i){var l=fe(e)?Dh:Oa,f=arguments.length<3;return l(e,oe(t,4),i,f,tl)}function Eg(e,t){var i=fe(e)?yn:nl;return i(e,ji(oe(t,3)))}function Sg(e){var t=fe(e)?Qa:gp;return t(e)}function Cg(e,t,i){(i?yt(e,t,i):t===r)?t=1:t=me(t);var l=fe(e)?Xd:_p;return l(e,t)}function Tg(e){var t=fe(e)?Yd:vp;return t(e)}function Rg(e){if(e==null)return 0;if(Rt(e))return Bi(e)?tr(e):e.length;var t=_t(e);return t==Xe||t==pe?e.size:Ms(e).length}function Ng(e,t,i){var l=fe(e)?_s:bp;return i&&yt(e,t,i)&&(t=r),l(e,oe(t,3))}var Ag=_e(function(e,t){if(e==null)return[];var i=t.length;return i>1&&yt(e,t[0],t[1])?t=[]:i>2&&yt(t[0],t[1],t[2])&&(t=[t[0]]),hl(e,dt(t,1),[])}),Mi=cd||function(){return ht.Date.now()};function Pg(e,t){if(typeof t!="function")throw new Wt(d);return e=me(e),function(){if(--e<1)return t.apply(this,arguments)}}function oc(e,t,i){return t=i?r:t,t=e&&t==null?e.length:t,hn(e,H,r,r,r,r,t)}function ac(e,t){var i;if(typeof t!="function")throw new Wt(d);return e=me(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var so=_e(function(e,t,i){var l=A;if(i.length){var f=En(i,cr(so));l|=X}return hn(e,l,t,i,f)}),lc=_e(function(e,t,i){var l=A|j;if(i.length){var f=En(i,cr(lc));l|=X}return hn(t,l,e,i,f)});function cc(e,t,i){t=i?r:t;var l=hn(e,R,r,r,r,r,r,t);return l.placeholder=cc.placeholder,l}function uc(e,t,i){t=i?r:t;var l=hn(e,I,r,r,r,r,r,t);return l.placeholder=uc.placeholder,l}function fc(e,t,i){var l,f,_,b,E,N,O=0,F=!1,W=!1,J=!0;if(typeof e!="function")throw new Wt(d);t=$t(t)||0,Ye(i)&&(F=!!i.leading,W="maxWait"in i,_=W?st($t(i.maxWait)||0,t):_,J="trailing"in i?!!i.trailing:J);function re(Ze){var Jt=l,_n=f;return l=f=r,O=Ze,b=e.apply(_n,Jt),b}function ae(Ze){return O=Ze,E=Br(we,t),F?re(Ze):b}function ge(Ze){var Jt=Ze-N,_n=Ze-O,Pc=t-Jt;return W?gt(Pc,_-_n):Pc}function le(Ze){var Jt=Ze-N,_n=Ze-O;return N===r||Jt>=t||Jt<0||W&&_n>=_}function we(){var Ze=Mi();if(le(Ze))return Ce(Ze);E=Br(we,ge(Ze))}function Ce(Ze){return E=r,J&&l?re(Ze):(l=f=r,b)}function Mt(){E!==r&&yl(E),O=0,l=N=f=E=r}function wt(){return E===r?b:Ce(Mi())}function Ot(){var Ze=Mi(),Jt=le(Ze);if(l=arguments,f=this,N=Ze,Jt){if(E===r)return ae(N);if(W)return yl(E),E=Br(we,t),re(N)}return E===r&&(E=Br(we,t)),b}return Ot.cancel=Mt,Ot.flush=wt,Ot}var kg=_e(function(e,t){return el(e,1,t)}),Ig=_e(function(e,t,i){return el(e,$t(t)||0,i)});function Lg(e){return hn(e,M)}function Oi(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Wt(d);var i=function(){var l=arguments,f=t?t.apply(this,l):l[0],_=i.cache;if(_.has(f))return _.get(f);var b=e.apply(this,l);return i.cache=_.set(f,b)||_,b};return i.cache=new(Oi.Cache||un),i}Oi.Cache=un;function ji(e){if(typeof e!="function")throw new Wt(d);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 Dg(e){return ac(2,e)}var Mg=yp(function(e,t){t=t.length==1&&fe(t[0])?$e(t[0],It(oe())):$e(dt(t,1),It(oe()));var i=t.length;return _e(function(l){for(var f=-1,_=gt(l.length,i);++f<_;)l[f]=t[f].call(this,l[f]);return kt(e,this,l)})}),oo=_e(function(e,t){var i=En(t,cr(oo));return hn(e,X,r,t,i)}),hc=_e(function(e,t){var i=En(t,cr(hc));return hn(e,$,r,t,i)}),Og=dn(function(e,t){return hn(e,G,r,r,r,t)});function jg(e,t){if(typeof e!="function")throw new Wt(d);return t=t===r?t:me(t),_e(e,t)}function Fg(e,t){if(typeof e!="function")throw new Wt(d);return t=t==null?0:st(me(t),0),_e(function(i){var l=i[t],f=Nn(i,0,t);return l&&wn(f,l),kt(e,this,f)})}function Bg(e,t,i){var l=!0,f=!0;if(typeof e!="function")throw new Wt(d);return Ye(i)&&(l="leading"in i?!!i.leading:l,f="trailing"in i?!!i.trailing:f),fc(e,t,{leading:l,maxWait:t,trailing:f})}function Ug(e){return oc(e,1)}function Wg(e,t){return oo(zs(t),e)}function Gg(){if(!arguments.length)return[];var e=arguments[0];return fe(e)?e:[e]}function Hg(e){return Ht(e,S)}function zg(e,t){return t=typeof t=="function"?t:r,Ht(e,S,t)}function qg(e){return Ht(e,x|S)}function $g(e,t){return t=typeof t=="function"?t:r,Ht(e,x|S,t)}function Xg(e,t){return t==null||Za(e,t,ct(t))}function Qt(e,t){return e===t||e!==e&&t!==t}var Yg=Ai(Is),Vg=Ai(function(e,t){return e>=t}),zn=sl((function(){return arguments})())?sl:function(e){return Ke(e)&&Me.call(e,"callee")&&!qa.call(e,"callee")},fe=k.isArray,Kg=Ta?It(Ta):ip;function Rt(e){return e!=null&&Fi(e.length)&&!mn(e)}function Je(e){return Ke(e)&&Rt(e)}function Qg(e){return e===!0||e===!1||Ke(e)&&bt(e)==Ue}var An=fd||xo,Jg=Ra?It(Ra):sp;function Zg(e){return Ke(e)&&e.nodeType===1&&!Ur(e)}function e0(e){if(e==null)return!0;if(Rt(e)&&(fe(e)||typeof e=="string"||typeof e.splice=="function"||An(e)||ur(e)||zn(e)))return!e.length;var t=_t(e);if(t==Xe||t==pe)return!e.size;if(Fr(e))return!Ms(e).length;for(var i in e)if(Me.call(e,i))return!1;return!0}function t0(e,t){return Mr(e,t)}function n0(e,t,i){i=typeof i=="function"?i:r;var l=i?i(e,t):r;return l===r?Mr(e,t,r,i):!!l}function ao(e){if(!Ke(e))return!1;var t=bt(e);return t==Et||t==pt||typeof e.message=="string"&&typeof e.name=="string"&&!Ur(e)}function r0(e){return typeof e=="number"&&Xa(e)}function mn(e){if(!Ye(e))return!1;var t=bt(e);return t==Pe||t==St||t==ut||t==K}function dc(e){return typeof e=="number"&&e==me(e)}function Fi(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=se}function Ye(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Ke(e){return e!=null&&typeof e=="object"}var pc=Na?It(Na):ap;function i0(e,t){return e===t||Ds(e,t,Qs(t))}function s0(e,t,i){return i=typeof i=="function"?i:r,Ds(e,t,Qs(t),i)}function o0(e){return mc(e)&&e!=+e}function a0(e){if(zp(e))throw new ce(a);return ol(e)}function l0(e){return e===null}function c0(e){return e==null}function mc(e){return typeof e=="number"||Ke(e)&&bt(e)==ot}function Ur(e){if(!Ke(e)||bt(e)!=ee)return!1;var t=fi(e);if(t===null)return!0;var i=Me.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&ai.call(i)==sd}var lo=Aa?It(Aa):lp;function u0(e){return dc(e)&&e>=-se&&e<=se}var gc=Pa?It(Pa):cp;function Bi(e){return typeof e=="string"||!fe(e)&&Ke(e)&&bt(e)==ye}function Dt(e){return typeof e=="symbol"||Ke(e)&&bt(e)==ve}var ur=ka?It(ka):up;function f0(e){return e===r}function h0(e){return Ke(e)&&_t(e)==vt}function d0(e){return Ke(e)&&bt(e)==at}var p0=Ai(Os),m0=Ai(function(e,t){return e<=t});function _c(e){if(!e)return[];if(Rt(e))return Bi(e)?Vt(e):Tt(e);if(Rr&&e[Rr])return Xh(e[Rr]());var t=_t(e),i=t==Xe?Es:t==pe?ii:fr;return i(e)}function gn(e){if(!e)return e===0?e:0;if(e=$t(e),e===ie||e===-ie){var t=e<0?-1:1;return t*be}return e===e?e:0}function me(e){var t=gn(e),i=t%1;return t===t?i?t-i:t:0}function xc(e){return e?Un(me(e),0,ne):0}function $t(e){if(typeof e=="number")return e;if(Dt(e))return xe;if(Ye(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ye(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=ja(e);var i=Kf.test(e);return i||Jf.test(e)?Ph(e.slice(2),i?2:8):Vf.test(e)?xe:+e}function vc(e){return nn(e,Nt(e))}function g0(e){return e?Un(me(e),-se,se):e===0?e:0}function Le(e){return e==null?"":Lt(e)}var _0=ar(function(e,t){if(Fr(t)||Rt(t)){nn(t,ct(t),e);return}for(var i in t)Me.call(t,i)&&Ir(e,i,t[i])}),bc=ar(function(e,t){nn(t,Nt(t),e)}),Ui=ar(function(e,t,i,l){nn(t,Nt(t),e,l)}),x0=ar(function(e,t,i,l){nn(t,ct(t),e,l)}),v0=dn(As);function b0(e,t){var i=or(e);return t==null?i:Ja(i,t)}var y0=_e(function(e,t){e=Be(e);var i=-1,l=t.length,f=l>2?t[2]:r;for(f&&yt(t[0],t[1],f)&&(l=1);++i<l;)for(var _=t[i],b=Nt(_),E=-1,N=b.length;++E<N;){var O=b[E],F=e[O];(F===r||Qt(F,rr[O])&&!Me.call(e,O))&&(e[O]=_[O])}return e}),w0=_e(function(e){return e.push(r,jl),kt(yc,r,e)});function E0(e,t){return La(e,oe(t,3),tn)}function S0(e,t){return La(e,oe(t,3),ks)}function C0(e,t){return e==null?e:Ps(e,oe(t,3),Nt)}function T0(e,t){return e==null?e:rl(e,oe(t,3),Nt)}function R0(e,t){return e&&tn(e,oe(t,3))}function N0(e,t){return e&&ks(e,oe(t,3))}function A0(e){return e==null?[]:yi(e,ct(e))}function P0(e){return e==null?[]:yi(e,Nt(e))}function co(e,t,i){var l=e==null?r:Wn(e,t);return l===r?i:l}function k0(e,t){return e!=null&&Ul(e,t,ep)}function uo(e,t){return e!=null&&Ul(e,t,tp)}var I0=Il(function(e,t,i){t!=null&&typeof t.toString!="function"&&(t=li.call(t)),e[t]=i},ho(At)),L0=Il(function(e,t,i){t!=null&&typeof t.toString!="function"&&(t=li.call(t)),Me.call(e,t)?e[t].push(i):e[t]=[i]},oe),D0=_e(Dr);function ct(e){return Rt(e)?Ka(e):Ms(e)}function Nt(e){return Rt(e)?Ka(e,!0):fp(e)}function M0(e,t){var i={};return t=oe(t,3),tn(e,function(l,f,_){fn(i,t(l,f,_),l)}),i}function O0(e,t){var i={};return t=oe(t,3),tn(e,function(l,f,_){fn(i,f,t(l,f,_))}),i}var j0=ar(function(e,t,i){wi(e,t,i)}),yc=ar(function(e,t,i,l){wi(e,t,i,l)}),F0=dn(function(e,t){var i={};if(e==null)return i;var l=!1;t=$e(t,function(_){return _=Rn(_,e),l||(l=_.length>1),_}),nn(e,Vs(e),i),l&&(i=Ht(i,x|y|S,Ip));for(var f=t.length;f--;)Ws(i,t[f]);return i});function B0(e,t){return wc(e,ji(oe(t)))}var U0=dn(function(e,t){return e==null?{}:dp(e,t)});function wc(e,t){if(e==null)return{};var i=$e(Vs(e),function(l){return[l]});return t=oe(t),dl(e,i,function(l,f){return t(l,f[0])})}function W0(e,t,i){t=Rn(t,e);var l=-1,f=t.length;for(f||(f=1,e=r);++l<f;){var _=e==null?r:e[rn(t[l])];_===r&&(l=f,_=i),e=mn(_)?_.call(e):_}return e}function G0(e,t,i){return e==null?e:Or(e,t,i)}function H0(e,t,i,l){return l=typeof l=="function"?l:r,e==null?e:Or(e,t,i,l)}var Ec=Ml(ct),Sc=Ml(Nt);function z0(e,t,i){var l=fe(e),f=l||An(e)||ur(e);if(t=oe(t,4),i==null){var _=e&&e.constructor;f?i=l?new _:[]:Ye(e)?i=mn(_)?or(fi(e)):{}:i={}}return(f?Ut:tn)(e,function(b,E,N){return t(i,b,E,N)}),i}function q0(e,t){return e==null?!0:Ws(e,t)}function $0(e,t,i){return e==null?e:xl(e,t,zs(i))}function X0(e,t,i,l){return l=typeof l=="function"?l:r,e==null?e:xl(e,t,zs(i),l)}function fr(e){return e==null?[]:ws(e,ct(e))}function Y0(e){return e==null?[]:ws(e,Nt(e))}function V0(e,t,i){return i===r&&(i=t,t=r),i!==r&&(i=$t(i),i=i===i?i:0),t!==r&&(t=$t(t),t=t===t?t:0),Un($t(e),t,i)}function K0(e,t,i){return t=gn(t),i===r?(i=t,t=0):i=gn(i),e=$t(e),np(e,t,i)}function Q0(e,t,i){if(i&&typeof i!="boolean"&&yt(e,t,i)&&(t=i=r),i===r&&(typeof t=="boolean"?(i=t,t=r):typeof e=="boolean"&&(i=e,e=r)),e===r&&t===r?(e=0,t=1):(e=gn(e),t===r?(t=e,e=0):t=gn(t)),e>t){var l=e;e=t,t=l}if(i||e%1||t%1){var f=Ya();return gt(e+f*(t-e+Ah("1e-"+((f+"").length-1))),t)}return Fs(e,t)}var J0=lr(function(e,t,i){return t=t.toLowerCase(),e+(i?Cc(t):t)});function Cc(e){return fo(Le(e).toLowerCase())}function Tc(e){return e=Le(e),e&&e.replace(eh,Gh).replace(vh,"")}function Z0(e,t,i){e=Le(e),t=Lt(t);var l=e.length;i=i===r?l:Un(me(i),0,l);var f=i;return i-=t.length,i>=0&&e.slice(i,f)==t}function e_(e){return e=Le(e),e&&rt.test(e)?e.replace(je,Hh):e}function t_(e){return e=Le(e),e&&qe.test(e)?e.replace(Cr,"\\$&"):e}var n_=lr(function(e,t,i){return e+(i?"-":"")+t.toLowerCase()}),r_=lr(function(e,t,i){return e+(i?" ":"")+t.toLowerCase()}),i_=Al("toLowerCase");function s_(e,t,i){e=Le(e),t=me(t);var l=t?tr(e):0;if(!t||l>=t)return e;var f=(t-l)/2;return Ni(mi(f),i)+e+Ni(pi(f),i)}function o_(e,t,i){e=Le(e),t=me(t);var l=t?tr(e):0;return t&&l<t?e+Ni(t-l,i):e}function a_(e,t,i){e=Le(e),t=me(t);var l=t?tr(e):0;return t&&l<t?Ni(t-l,i)+e:e}function l_(e,t,i){return i||t==null?t=0:t&&(t=+t),md(Le(e).replace(mt,""),t||0)}function c_(e,t,i){return(i?yt(e,t,i):t===r)?t=1:t=me(t),Bs(Le(e),t)}function u_(){var e=arguments,t=Le(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var f_=lr(function(e,t,i){return e+(i?"_":"")+t.toLowerCase()});function h_(e,t,i){return i&&typeof i!="number"&&yt(e,t,i)&&(t=i=r),i=i===r?ne:i>>>0,i?(e=Le(e),e&&(typeof t=="string"||t!=null&&!lo(t))&&(t=Lt(t),!t&&er(e))?Nn(Vt(e),0,i):e.split(t,i)):[]}var d_=lr(function(e,t,i){return e+(i?" ":"")+fo(t)});function p_(e,t,i){return e=Le(e),i=i==null?0:Un(me(i),0,e.length),t=Lt(t),e.slice(i,i+t.length)==t}function m_(e,t,i){var l=p.templateSettings;i&&yt(e,t,i)&&(t=r),e=Le(e),t=Ui({},t,l,Ol);var f=Ui({},t.imports,l.imports,Ol),_=ct(f),b=ws(f,_),E,N,O=0,F=t.interpolate||Zr,W="__p += '",J=Ss((t.escape||Zr).source+"|"+F.source+"|"+(F===Ct?Yf:Zr).source+"|"+(t.evaluate||Zr).source+"|$","g"),re="//# sourceURL="+(Me.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Sh+"]")+`
8
- `;e.replace(J,function(le,we,Ce,Mt,wt,Ot){return Ce||(Ce=Mt),W+=e.slice(O,Ot).replace(th,zh),we&&(E=!0,W+=`' +
9
- __e(`+we+`) +
10
- '`),wt&&(N=!0,W+=`';
11
- `+wt+`;
12
- __p += '`),Ce&&(W+=`' +
13
- ((__t = (`+Ce+`)) == null ? '' : __t) +
14
- '`),O=Ot+le.length,le}),W+=`';
15
- `;var ae=Me.call(t,"variable")&&t.variable;if(!ae)W=`with (obj) {
16
- `+W+`
17
- }
18
- `;else if($f.test(ae))throw new ce(v);W=(N?W.replace(os,""):W).replace(as,"$1").replace(Sr,"$1;"),W="function("+(ae||"obj")+`) {
19
- `+(ae?"":`obj || (obj = {});
20
- `)+"var __t, __p = ''"+(E?", __e = _.escape":"")+(N?`, __j = Array.prototype.join;
21
- function print() { __p += __j.call(arguments, '') }
22
- `:`;
23
- `)+W+`return __p
24
- }`;var ge=Nc(function(){return Ie(_,re+"return "+W).apply(r,b)});if(ge.source=W,ao(ge))throw ge;return ge}function g_(e){return Le(e).toLowerCase()}function __(e){return Le(e).toUpperCase()}function x_(e,t,i){if(e=Le(e),e&&(i||t===r))return ja(e);if(!e||!(t=Lt(t)))return e;var l=Vt(e),f=Vt(t),_=Fa(l,f),b=Ba(l,f)+1;return Nn(l,_,b).join("")}function v_(e,t,i){if(e=Le(e),e&&(i||t===r))return e.slice(0,Wa(e)+1);if(!e||!(t=Lt(t)))return e;var l=Vt(e),f=Ba(l,Vt(t))+1;return Nn(l,0,f).join("")}function b_(e,t,i){if(e=Le(e),e&&(i||t===r))return e.replace(mt,"");if(!e||!(t=Lt(t)))return e;var l=Vt(e),f=Fa(l,Vt(t));return Nn(l,f).join("")}function y_(e,t){var i=Y,l=B;if(Ye(t)){var f="separator"in t?t.separator:f;i="length"in t?me(t.length):i,l="omission"in t?Lt(t.omission):l}e=Le(e);var _=e.length;if(er(e)){var b=Vt(e);_=b.length}if(i>=_)return e;var E=i-tr(l);if(E<1)return l;var N=b?Nn(b,0,E).join(""):e.slice(0,E);if(f===r)return N+l;if(b&&(E+=N.length-E),lo(f)){if(e.slice(E).search(f)){var O,F=N;for(f.global||(f=Ss(f.source,Le(sa.exec(f))+"g")),f.lastIndex=0;O=f.exec(F);)var W=O.index;N=N.slice(0,W===r?E:W)}}else if(e.indexOf(Lt(f),E)!=E){var J=N.lastIndexOf(f);J>-1&&(N=N.slice(0,J))}return N+l}function w_(e){return e=Le(e),e&&Ne.test(e)?e.replace(z,Qh):e}var E_=lr(function(e,t,i){return e+(i?" ":"")+t.toUpperCase()}),fo=Al("toUpperCase");function Rc(e,t,i){return e=Le(e),t=i?r:t,t===r?$h(e)?ed(e):jh(e):e.match(t)||[]}var Nc=_e(function(e,t){try{return kt(e,r,t)}catch(i){return ao(i)?i:new ce(i)}}),S_=dn(function(e,t){return Ut(t,function(i){i=rn(i),fn(e,i,so(e[i],e))}),e});function C_(e){var t=e==null?0:e.length,i=oe();return e=t?$e(e,function(l){if(typeof l[1]!="function")throw new Wt(d);return[i(l[0]),l[1]]}):[],_e(function(l){for(var f=-1;++f<t;){var _=e[f];if(kt(_[0],this,l))return kt(_[1],this,l)}})}function T_(e){return Qd(Ht(e,x))}function ho(e){return function(){return e}}function R_(e,t){return e==null||e!==e?t:e}var N_=kl(),A_=kl(!0);function At(e){return e}function po(e){return al(typeof e=="function"?e:Ht(e,x))}function P_(e){return cl(Ht(e,x))}function k_(e,t){return ul(e,Ht(t,x))}var I_=_e(function(e,t){return function(i){return Dr(i,e,t)}}),L_=_e(function(e,t){return function(i){return Dr(e,i,t)}});function mo(e,t,i){var l=ct(t),f=yi(t,l);i==null&&!(Ye(t)&&(f.length||!l.length))&&(i=t,t=e,e=this,f=yi(t,ct(t)));var _=!(Ye(i)&&"chain"in i)||!!i.chain,b=mn(e);return Ut(f,function(E){var N=t[E];e[E]=N,b&&(e.prototype[E]=function(){var O=this.__chain__;if(_||O){var F=e(this.__wrapped__),W=F.__actions__=Tt(this.__actions__);return W.push({func:N,args:arguments,thisArg:e}),F.__chain__=O,F}return N.apply(e,wn([this.value()],arguments))})}),e}function D_(){return ht._===this&&(ht._=od),this}function go(){}function M_(e){return e=me(e),_e(function(t){return fl(t,e)})}var O_=$s($e),j_=$s(Ia),F_=$s(_s);function Ac(e){return Zs(e)?xs(rn(e)):pp(e)}function B_(e){return function(t){return e==null?r:Wn(e,t)}}var U_=Ll(),W_=Ll(!0);function _o(){return[]}function xo(){return!1}function G_(){return{}}function H_(){return""}function z_(){return!0}function q_(e,t){if(e=me(e),e<1||e>se)return[];var i=ne,l=gt(e,ne);t=oe(t),e-=ne;for(var f=ys(l,t);++i<e;)t(i);return f}function $_(e){return fe(e)?$e(e,rn):Dt(e)?[e]:Tt(Vl(Le(e)))}function X_(e){var t=++id;return Le(e)+t}var Y_=Ri(function(e,t){return e+t},0),V_=Xs("ceil"),K_=Ri(function(e,t){return e/t},1),Q_=Xs("floor");function J_(e){return e&&e.length?bi(e,At,Is):r}function Z_(e,t){return e&&e.length?bi(e,oe(t,2),Is):r}function ex(e){return Ma(e,At)}function tx(e,t){return Ma(e,oe(t,2))}function nx(e){return e&&e.length?bi(e,At,Os):r}function rx(e,t){return e&&e.length?bi(e,oe(t,2),Os):r}var ix=Ri(function(e,t){return e*t},1),sx=Xs("round"),ox=Ri(function(e,t){return e-t},0);function ax(e){return e&&e.length?bs(e,At):0}function lx(e,t){return e&&e.length?bs(e,oe(t,2)):0}return p.after=Pg,p.ary=oc,p.assign=_0,p.assignIn=bc,p.assignInWith=Ui,p.assignWith=x0,p.at=v0,p.before=ac,p.bind=so,p.bindAll=S_,p.bindKey=lc,p.castArray=Gg,p.chain=rc,p.chunk=Qp,p.compact=Jp,p.concat=Zp,p.cond=C_,p.conforms=T_,p.constant=ho,p.countBy=ag,p.create=b0,p.curry=cc,p.curryRight=uc,p.debounce=fc,p.defaults=y0,p.defaultsDeep=w0,p.defer=kg,p.delay=Ig,p.difference=em,p.differenceBy=tm,p.differenceWith=nm,p.drop=rm,p.dropRight=im,p.dropRightWhile=sm,p.dropWhile=om,p.fill=am,p.filter=cg,p.flatMap=hg,p.flatMapDeep=dg,p.flatMapDepth=pg,p.flatten=Zl,p.flattenDeep=lm,p.flattenDepth=cm,p.flip=Lg,p.flow=N_,p.flowRight=A_,p.fromPairs=um,p.functions=A0,p.functionsIn=P0,p.groupBy=mg,p.initial=hm,p.intersection=dm,p.intersectionBy=pm,p.intersectionWith=mm,p.invert=I0,p.invertBy=L0,p.invokeMap=_g,p.iteratee=po,p.keyBy=xg,p.keys=ct,p.keysIn=Nt,p.map=Di,p.mapKeys=M0,p.mapValues=O0,p.matches=P_,p.matchesProperty=k_,p.memoize=Oi,p.merge=j0,p.mergeWith=yc,p.method=I_,p.methodOf=L_,p.mixin=mo,p.negate=ji,p.nthArg=M_,p.omit=F0,p.omitBy=B0,p.once=Dg,p.orderBy=vg,p.over=O_,p.overArgs=Mg,p.overEvery=j_,p.overSome=F_,p.partial=oo,p.partialRight=hc,p.partition=bg,p.pick=U0,p.pickBy=wc,p.property=Ac,p.propertyOf=B_,p.pull=vm,p.pullAll=tc,p.pullAllBy=bm,p.pullAllWith=ym,p.pullAt=wm,p.range=U_,p.rangeRight=W_,p.rearg=Og,p.reject=Eg,p.remove=Em,p.rest=jg,p.reverse=ro,p.sampleSize=Cg,p.set=G0,p.setWith=H0,p.shuffle=Tg,p.slice=Sm,p.sortBy=Ag,p.sortedUniq=km,p.sortedUniqBy=Im,p.split=h_,p.spread=Fg,p.tail=Lm,p.take=Dm,p.takeRight=Mm,p.takeRightWhile=Om,p.takeWhile=jm,p.tap=Jm,p.throttle=Bg,p.thru=Li,p.toArray=_c,p.toPairs=Ec,p.toPairsIn=Sc,p.toPath=$_,p.toPlainObject=vc,p.transform=z0,p.unary=Ug,p.union=Fm,p.unionBy=Bm,p.unionWith=Um,p.uniq=Wm,p.uniqBy=Gm,p.uniqWith=Hm,p.unset=q0,p.unzip=io,p.unzipWith=nc,p.update=$0,p.updateWith=X0,p.values=fr,p.valuesIn=Y0,p.without=zm,p.words=Rc,p.wrap=Wg,p.xor=qm,p.xorBy=$m,p.xorWith=Xm,p.zip=Ym,p.zipObject=Vm,p.zipObjectDeep=Km,p.zipWith=Qm,p.entries=Ec,p.entriesIn=Sc,p.extend=bc,p.extendWith=Ui,mo(p,p),p.add=Y_,p.attempt=Nc,p.camelCase=J0,p.capitalize=Cc,p.ceil=V_,p.clamp=V0,p.clone=Hg,p.cloneDeep=qg,p.cloneDeepWith=$g,p.cloneWith=zg,p.conformsTo=Xg,p.deburr=Tc,p.defaultTo=R_,p.divide=K_,p.endsWith=Z0,p.eq=Qt,p.escape=e_,p.escapeRegExp=t_,p.every=lg,p.find=ug,p.findIndex=Ql,p.findKey=E0,p.findLast=fg,p.findLastIndex=Jl,p.findLastKey=S0,p.floor=Q_,p.forEach=ic,p.forEachRight=sc,p.forIn=C0,p.forInRight=T0,p.forOwn=R0,p.forOwnRight=N0,p.get=co,p.gt=Yg,p.gte=Vg,p.has=k0,p.hasIn=uo,p.head=ec,p.identity=At,p.includes=gg,p.indexOf=fm,p.inRange=K0,p.invoke=D0,p.isArguments=zn,p.isArray=fe,p.isArrayBuffer=Kg,p.isArrayLike=Rt,p.isArrayLikeObject=Je,p.isBoolean=Qg,p.isBuffer=An,p.isDate=Jg,p.isElement=Zg,p.isEmpty=e0,p.isEqual=t0,p.isEqualWith=n0,p.isError=ao,p.isFinite=r0,p.isFunction=mn,p.isInteger=dc,p.isLength=Fi,p.isMap=pc,p.isMatch=i0,p.isMatchWith=s0,p.isNaN=o0,p.isNative=a0,p.isNil=c0,p.isNull=l0,p.isNumber=mc,p.isObject=Ye,p.isObjectLike=Ke,p.isPlainObject=Ur,p.isRegExp=lo,p.isSafeInteger=u0,p.isSet=gc,p.isString=Bi,p.isSymbol=Dt,p.isTypedArray=ur,p.isUndefined=f0,p.isWeakMap=h0,p.isWeakSet=d0,p.join=gm,p.kebabCase=n_,p.last=qt,p.lastIndexOf=_m,p.lowerCase=r_,p.lowerFirst=i_,p.lt=p0,p.lte=m0,p.max=J_,p.maxBy=Z_,p.mean=ex,p.meanBy=tx,p.min=nx,p.minBy=rx,p.stubArray=_o,p.stubFalse=xo,p.stubObject=G_,p.stubString=H_,p.stubTrue=z_,p.multiply=ix,p.nth=xm,p.noConflict=D_,p.noop=go,p.now=Mi,p.pad=s_,p.padEnd=o_,p.padStart=a_,p.parseInt=l_,p.random=Q0,p.reduce=yg,p.reduceRight=wg,p.repeat=c_,p.replace=u_,p.result=W0,p.round=sx,p.runInContext=T,p.sample=Sg,p.size=Rg,p.snakeCase=f_,p.some=Ng,p.sortedIndex=Cm,p.sortedIndexBy=Tm,p.sortedIndexOf=Rm,p.sortedLastIndex=Nm,p.sortedLastIndexBy=Am,p.sortedLastIndexOf=Pm,p.startCase=d_,p.startsWith=p_,p.subtract=ox,p.sum=ax,p.sumBy=lx,p.template=m_,p.times=q_,p.toFinite=gn,p.toInteger=me,p.toLength=xc,p.toLower=g_,p.toNumber=$t,p.toSafeInteger=g0,p.toString=Le,p.toUpper=__,p.trim=x_,p.trimEnd=v_,p.trimStart=b_,p.truncate=y_,p.unescape=w_,p.uniqueId=X_,p.upperCase=E_,p.upperFirst=fo,p.each=ic,p.eachRight=sc,p.first=ec,mo(p,(function(){var e={};return tn(p,function(t,i){Me.call(p.prototype,i)||(e[i]=t)}),e})(),{chain:!1}),p.VERSION=o,Ut(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ut(["drop","take"],function(e,t){Se.prototype[e]=function(i){i=i===r?1:st(me(i),0);var l=this.__filtered__&&!t?new Se(this):this.clone();return l.__filtered__?l.__takeCount__=gt(i,l.__takeCount__):l.__views__.push({size:gt(i,ne),type:e+(l.__dir__<0?"Right":"")}),l},Se.prototype[e+"Right"]=function(i){return this.reverse()[e](i).reverse()}}),Ut(["filter","map","takeWhile"],function(e,t){var i=t+1,l=i==q||i==Q;Se.prototype[e]=function(f){var _=this.clone();return _.__iteratees__.push({iteratee:oe(f,3),type:i}),_.__filtered__=_.__filtered__||l,_}}),Ut(["head","last"],function(e,t){var i="take"+(t?"Right":"");Se.prototype[e]=function(){return this[i](1).value()[0]}}),Ut(["initial","tail"],function(e,t){var i="drop"+(t?"":"Right");Se.prototype[e]=function(){return this.__filtered__?new Se(this):this[i](1)}}),Se.prototype.compact=function(){return this.filter(At)},Se.prototype.find=function(e){return this.filter(e).head()},Se.prototype.findLast=function(e){return this.reverse().find(e)},Se.prototype.invokeMap=_e(function(e,t){return typeof e=="function"?new Se(this):this.map(function(i){return Dr(i,e,t)})}),Se.prototype.reject=function(e){return this.filter(ji(oe(e)))},Se.prototype.slice=function(e,t){e=me(e);var i=this;return i.__filtered__&&(e>0||t<0)?new Se(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==r&&(t=me(t),i=t<0?i.dropRight(-t):i.take(t-e)),i)},Se.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Se.prototype.toArray=function(){return this.take(ne)},tn(Se.prototype,function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),l=/^(?:head|last)$/.test(t),f=p[l?"take"+(t=="last"?"Right":""):t],_=l||/^find/.test(t);f&&(p.prototype[t]=function(){var b=this.__wrapped__,E=l?[1]:arguments,N=b instanceof Se,O=E[0],F=N||fe(b),W=function(we){var Ce=f.apply(p,wn([we],E));return l&&J?Ce[0]:Ce};F&&i&&typeof O=="function"&&O.length!=1&&(N=F=!1);var J=this.__chain__,re=!!this.__actions__.length,ae=_&&!J,ge=N&&!re;if(!_&&F){b=ge?b:new Se(this);var le=e.apply(b,E);return le.__actions__.push({func:Li,args:[W],thisArg:r}),new Gt(le,J)}return ae&&ge?e.apply(this,E):(le=this.thru(W),ae?l?le.value()[0]:le.value():le)})}),Ut(["pop","push","shift","sort","splice","unshift"],function(e){var t=si[e],i=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",l=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var f=arguments;if(l&&!this.__chain__){var _=this.value();return t.apply(fe(_)?_:[],f)}return this[i](function(b){return t.apply(fe(b)?b:[],f)})}}),tn(Se.prototype,function(e,t){var i=p[t];if(i){var l=i.name+"";Me.call(sr,l)||(sr[l]=[]),sr[l].push({name:t,func:i})}}),sr[Ti(r,j).name]=[{name:"wrapper",func:r}],Se.prototype.clone=wd,Se.prototype.reverse=Ed,Se.prototype.value=Sd,p.prototype.at=Zm,p.prototype.chain=eg,p.prototype.commit=tg,p.prototype.next=ng,p.prototype.plant=ig,p.prototype.reverse=sg,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=og,p.prototype.first=p.prototype.head,Rr&&(p.prototype[Rr]=rg),p}),nr=td();On?((On.exports=nr)._=nr,ds._=nr):ht._=nr}).call(o1)})(zr,zr.exports)),zr.exports}var ef=a1();const l1=cx(ef);function c1(s,n){const[r,o]=w.useState(s),u=w.useRef(l1.debounce(o,n)),a=w.useCallback(d=>{u.current(d)},[]);return[r,a]}const u1=()=>{try{const s=localStorage.getItem("sidebar-collapsed");return s!==null?JSON.parse(s):!1}catch(s){return console.warn("Failed to load sidebar collapsed state:",s),!1}};function f1({devices:s,currentDeviceId:n,onSelectDevice:r,onOpenConfig:o,onConnectWifi:u,onDisconnectWifi:a}){const d=Yr(),[v,h]=w.useState(u1),[g,m]=w.useState(!1),[x,y]=w.useState(""),[S,C]=w.useState("5555"),[P,A]=w.useState(""),[j,U]=w.useState(""),[R,I]=w.useState("direct"),[X,$]=w.useState(""),[H,G]=w.useState(""),[M,Y]=w.useState("5555"),[B,he]=w.useState(""),[de,q]=w.useState(!1),[V,Q]=w.useState([]),[ie,se]=c1(!1,300),[be,xe]=w.useState(""),[ne,Re]=w.useState(null),[Ae,Fe]=w.useState(!1),Oe=w.useRef(null);w.useEffect(()=>{localStorage.setItem("sidebar-collapsed",JSON.stringify(v))},[v]),w.useEffect(()=>{const L=K=>{(K.metaKey||K.ctrlKey)&&K.key==="b"&&(K.preventDefault(),h(!v))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[v]);const nt=()=>{h(!v)},ut=L=>/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(L)?L.split(".").every(pe=>{const ye=parseInt(pe,10);return ye>=0&&ye<=255}):!1,Ue=L=>{const K=parseInt(L,10);return!isNaN(K)&&K>=1&&K<=65535},ke=L=>/^\d{6}$/.test(L),pt=async()=>{A(""),U("");let L=!1;if(ut(x)||(A(d.deviceSidebar.invalidIpError),L=!0),Ue(S)||(U(d.deviceSidebar.invalidPortError),L=!0),!L){q(!0);try{const K=await kc({ip:x,port:parseInt(S,10)});K.success?(m(!1),y(""),C("5555")):A(K.message||d.toasts.wifiManualConnectError)}catch{A(d.toasts.wifiManualConnectError)}finally{q(!1)}}},Et=async()=>{he(""),A(""),U("");let L=!1;if(ut(x)||(A(d.deviceSidebar.invalidIpError),L=!0),Ue(H)||(U(d.deviceSidebar.invalidPortError),L=!0),Ue(M)||(U(d.deviceSidebar.invalidPortError),L=!0),ke(X)||(he(d.deviceSidebar.invalidPairingCodeError),L=!0),!L){q(!0);try{const K=await px({ip:x,pairing_port:parseInt(H,10),pairing_code:X,connection_port:parseInt(M,10)});K.success?(m(!1),y(""),C("5555"),$(""),G(""),Y("5555"),I("direct")):K.error==="invalid_pairing_code"?he(K.message):K.error==="invalid_ip"?A(K.message):A(K.message||d.toasts.wifiPairError)}catch{A(d.toasts.wifiPairError)}finally{q(!1)}}},Pe=w.useCallback(()=>{Oe.current!==null&&(clearInterval(Oe.current),Oe.current=null)},[]),St=w.useCallback(L=>{Pe(),Oe.current=window.setInterval(async()=>{try{const K=await ux(L);Re(ue=>ue?{...ue,status:K.status}:null),["connected","timeout","error"].includes(K.status)&&(Pe(),K.status==="connected"&&setTimeout(()=>{m(!1),Re(null)},2e3))}catch(K){console.error("[QR Pairing] Status poll failed:",K)}},1e3)},[Pe]),Xe=w.useCallback(async()=>{Fe(!0);try{const L=await fx();L.success&&L.qr_payload&&L.session_id&&(Re({sessionId:L.session_id,payload:L.qr_payload,status:"listening",expiresAt:L.expires_at??Date.now()+12e4}),St(L.session_id))}catch(L){console.error("[QR Pairing] Generation failed:",L)}finally{Fe(!1)}},[St]),ot=w.useCallback(async()=>{if(ne)try{await hx(ne.sessionId),Re(null),Pe()}catch(L){console.error("[QR Pairing] Cancel failed:",L)}},[ne,Pe]);w.useEffect(()=>{(!g||R!=="pair")&&(ne&&ne.status==="listening"&&ot(),Pe())},[g,R,ne,Pe,ot]),w.useEffect(()=>()=>{Pe()},[Pe]),w.useEffect(()=>{g&&R==="pair"&&!ne&&!Ae&&Xe()},[g,R,ne,Ae,Xe]);const Z=w.useCallback(async()=>{se(!0),xe("");try{const L=await dx();L.success?Q(L.devices):(xe(L.error||d.deviceSidebar.scanError.replace("{error}","Unknown error")),Q([]))}catch(L){xe(d.deviceSidebar.scanError.replace("{error}",String(L))),Q([])}finally{se(!1)}},[d.deviceSidebar.scanError,se]),ee=async(L,K)=>{if(!K&&!L.has_pairing){q(!0),A("");try{const ue=await kc({ip:L.ip,port:L.port});ue.success?m(!1):A(ue.message||d.toasts.wifiManualConnectError)}catch(ue){A(d.toasts.wifiManualConnectError),console.error("[DeviceSidebar] Error connecting:",ue)}finally{q(!1)}}else K&&L.has_pairing&&(y(L.ip),G(L.pairing_port?String(L.pairing_port):""),Y(String(L.port)),setTimeout(()=>{document.getElementById("pairing-code")?.focus()},100))};return w.useEffect(()=>{if(g){Z();const L=setInterval(()=>{Z()},5e3);return()=>{clearInterval(L)}}},[g,Z]),c.jsxs(c.Fragment,{children:[v&&c.jsx(De,{variant:"outline",size:"icon",onClick:nt,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:c.jsx(Su,{className:"h-4 w-4"})}),c.jsxs("div",{className:`
25
- ${v?"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:[c.jsxs("div",{className:"flex items-center justify-between p-4",children:[c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-bold text-slate-900 dark:text-slate-100",children:"AutoGLM"}),c.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[s.length," ",(s.length===1,d.deviceSidebar.devices)]})]})}),c.jsx(De,{variant:"ghost",size:"icon",onClick:nt,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:c.jsx(Eu,{className:"h-4 w-4"})})]}),c.jsx(Wr,{className:"mx-4"}),c.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:s.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800",children:c.jsx(fv,{className:"h-8 w-8 text-slate-400"})}),c.jsx("p",{className:"mt-4 font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.noDevicesConnected}),c.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.clickToRefresh})]}):s.map(L=>c.jsx(Nv,{id:L.id,model:L.model,status:L.status,connectionType:L.connection_type,agent:L.agent,isActive:n===L.id,onClick:()=>r(L.id),onConnectWifi:async()=>{await u(L.id)},onDisconnectWifi:async()=>{await a(L.id)}},L.id))}),c.jsx(Wr,{className:"mx-4"}),c.jsxs("div",{className:"p-3 space-y-2",children:[c.jsxs(De,{variant:"outline",onClick:()=>m(!0),className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[c.jsx(Dx,{className:"h-4 w-4"}),d.deviceSidebar.addDevice]}),c.jsxs(De,{variant:"outline",onClick:o,className:"w-full justify-start gap-2 rounded-full border-slate-200 dark:border-slate-700",children:[c.jsx(Cu,{className:"h-4 w-4"}),d.deviceSidebar.settings]})]}),c.jsx(_u,{open:g,onOpenChange:m,children:c.jsxs(xu,{className:"sm:max-w-md max-h-[80vh] overflow-y-auto",children:[c.jsxs(vu,{children:[c.jsx(bu,{children:d.deviceSidebar.manualConnectTitle}),c.jsx(yu,{children:d.deviceSidebar.manualConnectDescription})]}),c.jsxs(Vv,{value:R,onValueChange:I,className:"w-full",children:[c.jsxs(Kv,{className:"grid w-full grid-cols-2",children:[c.jsx(jc,{value:"direct",children:d.deviceSidebar.directConnectTab}),c.jsx(jc,{value:"pair",children:d.deviceSidebar.pairTab})]}),c.jsxs(Fc,{value:"direct",className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.discoveredDevices}),c.jsx(De,{variant:"outline",size:"sm",onClick:Z,disabled:ie,className:"h-8",children:ie?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),d.deviceSidebar.scanning]}):d.deviceSidebar.scanAgain})]}),be&&c.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:c.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:be})}),(()=>{const L=V.filter(K=>!K.has_pairing);return!ie&&L.length===0?c.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[c.jsx(Mo,{className:"mx-auto h-8 w-8 text-slate-400"}),c.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.noDirectDevices})]}):L.length>0?c.jsx("div",{className:"space-y-2",children:L.map(K=>c.jsx("button",{onClick:()=>ee(K,!1),disabled:de,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:c.jsx("div",{className:"flex items-start justify-between",children:c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Do,{className:"h-4 w-4 text-[#1d9bf0]"}),c.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:K.name})]}),c.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[K.ip,":",K.port]})]})})},`${K.ip}:${K.port}`))}):null})(),P&&R==="direct"&&c.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:c.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:P})}),c.jsxs("div",{className:"relative my-4",children:[c.jsx(Wr,{}),c.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:d.deviceSidebar.orManualConnect})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"rounded-lg bg-amber-50 dark:bg-amber-950/20 p-3 text-sm",children:c.jsx("p",{className:"text-amber-800 dark:text-amber-200",children:d.deviceSidebar.directConnectNote})}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"ip",children:d.deviceSidebar.ipAddress}),c.jsx(xn,{id:"ip",placeholder:"192.168.1.100",value:x,onChange:L=>y(L.target.value),onKeyDown:L=>L.key==="Enter"&&pt(),className:P?"border-red-500":""})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"port",children:d.deviceSidebar.port}),c.jsx(xn,{id:"port",type:"number",value:S,onChange:L=>C(L.target.value),onKeyDown:L=>L.key==="Enter"&&pt(),className:j?"border-red-500":""}),j&&c.jsx("p",{className:"text-sm text-red-500",children:j})]}),c.jsx(De,{onClick:pt,disabled:de,className:"w-full",children:de?d.common.loading:d.deviceSidebar.connect})]})]}),c.jsxs(Fc,{value:"pair",className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:d.deviceSidebar.discoveredDevices}),c.jsx(De,{variant:"outline",size:"sm",onClick:Z,disabled:ie,className:"h-8",children:ie?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"mr-2 h-3 w-3 animate-spin rounded-full border-2 border-slate-400 border-t-transparent"}),d.deviceSidebar.scanning]}):d.deviceSidebar.scanAgain})]}),be&&c.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-950/20 p-3",children:c.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:be})}),(()=>{const L=V.filter(K=>K.has_pairing);return!ie&&L.length===0?c.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-900 p-4 text-center",children:[c.jsx(Mo,{className:"mx-auto h-8 w-8 text-slate-400"}),c.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:d.deviceSidebar.noPairingDevices})]}):L.length>0?c.jsx("div",{className:"space-y-2",children:L.map(K=>c.jsx("button",{onClick:()=>ee(K,!0),disabled:de,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:c.jsx("div",{className:"flex items-start justify-between",children:c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Do,{className:"h-4 w-4 text-[#1d9bf0]"}),c.jsx("span",{className:"font-medium text-slate-900 dark:text-slate-100",children:K.name})]}),c.jsxs("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:[K.ip,":",K.port]}),c.jsxs("div",{className:"mt-2 flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[c.jsx(qn,{className:"h-3 w-3"}),c.jsx("span",{children:d.deviceSidebar.pairingRequired})]})]})})},`${K.ip}:${K.port}`))}):null})(),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"relative my-4",children:[c.jsx(Wr,{}),c.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:d.deviceSidebar.orQrPair})]}),c.jsxs("div",{className:"rounded-lg bg-purple-50 dark:bg-purple-950/20 p-3 text-sm",children:[c.jsx("p",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:d.deviceSidebar.qrPairingTitle}),c.jsxs("ol",{className:"space-y-1 text-purple-700 dark:text-purple-300 text-xs",children:[c.jsx("li",{children:d.deviceSidebar.qrStep1}),c.jsx("li",{children:d.deviceSidebar.qrStep2}),c.jsx("li",{children:d.deviceSidebar.qrStep3})]})]}),ne&&c.jsx("div",{className:"rounded-lg border border-slate-200 dark:border-slate-700 p-4 bg-white dark:bg-slate-900",children:c.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[c.jsx("div",{className:"bg-white p-4 rounded-lg",children:c.jsx(Zu,{value:ne.payload,size:200,level:"M"})}),c.jsxs("div",{className:"flex items-center gap-2",children:[ne.status==="listening"&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse"}),c.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:d.deviceSidebar.qrWaitingForScan})]}),ne.status==="pairing"&&c.jsxs(c.Fragment,{children:[c.jsx(kn,{className:"h-4 w-4 animate-spin text-blue-500"}),c.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:d.deviceSidebar.qrPairing})]}),ne.status==="connected"&&c.jsxs(c.Fragment,{children:[c.jsx(Xx,{className:"h-4 w-4 text-green-500"}),c.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:d.deviceSidebar.qrConnected})]}),ne.status==="timeout"&&c.jsxs(c.Fragment,{children:[c.jsx(Lo,{className:"h-4 w-4 text-amber-500"}),c.jsx("span",{className:"text-sm text-amber-600 dark:text-amber-400",children:d.deviceSidebar.qrTimeout})]}),ne.status==="error"&&c.jsxs(c.Fragment,{children:[c.jsx(Lo,{className:"h-4 w-4 text-red-500"}),c.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:d.deviceSidebar.qrError})]})]}),c.jsxs("div",{className:"flex gap-2 w-full",children:[(ne.status==="timeout"||ne.status==="error")&&c.jsx(De,{variant:"outline",onClick:Xe,className:"flex-1",children:d.deviceSidebar.qrRegenerate}),ne.status==="listening"&&c.jsx(De,{variant:"outline",onClick:ot,className:"flex-1",children:d.common.cancel}),ne.status==="connected"&&c.jsx(De,{onClick:()=>m(!1),className:"flex-1",children:d.common.confirm})]})]})}),!ne&&Ae&&c.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-slate-600 dark:text-slate-400",children:[c.jsx(kn,{className:"h-4 w-4 animate-spin"}),c.jsx("span",{className:"text-sm",children:d.common.loading})]})]}),c.jsxs("div",{className:"relative my-4",children:[c.jsx(Wr,{}),c.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-slate-950 px-2 text-sm text-slate-500",children:d.deviceSidebar.orManualPair})]}),c.jsxs("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/20 p-3 text-sm",children:[c.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:d.deviceSidebar.pairingInstructions}),c.jsxs("ol",{className:"space-y-1 text-blue-700 dark:text-blue-300 text-xs",children:[c.jsx("li",{children:d.deviceSidebar.pairingStep1}),c.jsx("li",{children:d.deviceSidebar.pairingStep2}),c.jsx("li",{children:d.deviceSidebar.pairingStep3}),c.jsx("li",{children:d.deviceSidebar.pairingStep4})]}),c.jsx("p",{className:"mt-2 text-xs text-blue-600 dark:text-blue-400",children:d.deviceSidebar.pairingNote})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"pair-ip",children:d.deviceSidebar.ipAddress}),c.jsx(xn,{id:"pair-ip",placeholder:"192.168.1.100",value:x,onChange:L=>y(L.target.value),className:P?"border-red-500":""}),P&&R==="pair"&&c.jsx("p",{className:"text-sm text-red-500",children:P})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"pairing-port",children:d.deviceSidebar.pairingPort}),c.jsx(xn,{id:"pairing-port",type:"number",placeholder:"37831",value:H,onChange:L=>G(L.target.value),className:j?"border-red-500":""}),j&&c.jsx("p",{className:"text-sm text-red-500",children:j})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"pairing-code",children:d.deviceSidebar.pairingCode}),c.jsx(xn,{id:"pairing-code",type:"text",placeholder:"123456",maxLength:6,value:X,onChange:L=>$(L.target.value.replace(/\D/g,"")),onKeyDown:L=>L.key==="Enter"&&Et(),className:B?"border-red-500":""}),B&&c.jsx("p",{className:"text-sm text-red-500",children:B})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"connection-port",children:d.deviceSidebar.connectionPort}),c.jsx(xn,{id:"connection-port",type:"number",value:M,onChange:L=>Y(L.target.value),onKeyDown:L=>L.key==="Enter"&&Et()})]}),c.jsx(De,{onClick:Et,disabled:de,className:"w-full",children:de?d.common.loading:d.deviceSidebar.pairAndConnect})]})]})]}),c.jsx(wu,{children:c.jsx(De,{variant:"outline",onClick:()=>{m(!1),A(""),U(""),he(""),xe(""),y(""),C("5555"),$(""),G(""),Y("5555"),I("direct"),Q([])},children:d.common.cancel})})]})})]})]})}const an=Object.create(null);an.open="0";an.close="1";an.ping="2";an.pong="3";an.message="4";an.upgrade="5";an.noop="6";const qi=Object.create(null);Object.keys(an).forEach(s=>{qi[an[s]]=s});const Bo={type:"error",data:"parser error"},tf=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",nf=typeof ArrayBuffer=="function",rf=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Vo=({type:s,data:n},r,o)=>tf&&n instanceof Blob?r?o(n):Wc(n,o):nf&&(n instanceof ArrayBuffer||rf(n))?r?o(n):Wc(new Blob([n]),o):o(an[s]+(n||"")),Wc=(s,n)=>{const r=new FileReader;return r.onload=function(){const o=r.result.split(",")[1];n("b"+(o||""))},r.readAsDataURL(s)};function Gc(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let bo;function h1(s,n){if(tf&&s.data instanceof Blob)return s.data.arrayBuffer().then(Gc).then(n);if(nf&&(s.data instanceof ArrayBuffer||rf(s.data)))return n(Gc(s.data));Vo(s,!1,r=>{bo||(bo=new TextEncoder),n(bo.encode(r))})}const Hc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<Hc.length;s++)qr[Hc.charCodeAt(s)]=s;const d1=s=>{let n=s.length*.75,r=s.length,o,u=0,a,d,v,h;s[s.length-1]==="="&&(n--,s[s.length-2]==="="&&n--);const g=new ArrayBuffer(n),m=new Uint8Array(g);for(o=0;o<r;o+=4)a=qr[s.charCodeAt(o)],d=qr[s.charCodeAt(o+1)],v=qr[s.charCodeAt(o+2)],h=qr[s.charCodeAt(o+3)],m[u++]=a<<2|d>>4,m[u++]=(d&15)<<4|v>>2,m[u++]=(v&3)<<6|h&63;return g},p1=typeof ArrayBuffer=="function",Ko=(s,n)=>{if(typeof s!="string")return{type:"message",data:sf(s,n)};const r=s.charAt(0);return r==="b"?{type:"message",data:m1(s.substring(1),n)}:qi[r]?s.length>1?{type:qi[r],data:s.substring(1)}:{type:qi[r]}:Bo},m1=(s,n)=>{if(p1){const r=d1(s);return sf(r,n)}else return{base64:!0,data:s}},sf=(s,n)=>{switch(n){case"blob":return s instanceof Blob?s:new Blob([s]);case"arraybuffer":default:return s instanceof ArrayBuffer?s:s.buffer}},of="",g1=(s,n)=>{const r=s.length,o=new Array(r);let u=0;s.forEach((a,d)=>{Vo(a,!1,v=>{o[d]=v,++u===r&&n(o.join(of))})})},_1=(s,n)=>{const r=s.split(of),o=[];for(let u=0;u<r.length;u++){const a=Ko(r[u],n);if(o.push(a),a.type==="error")break}return o};function x1(){return new TransformStream({transform(s,n){h1(s,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 a=new DataView(u.buffer);a.setUint8(0,126),a.setUint16(1,o)}else{u=new Uint8Array(9);const a=new DataView(u.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(o))}s.data&&typeof s.data!="string"&&(u[0]|=128),n.enqueue(u),n.enqueue(r)})}})}let yo;function Hi(s){return s.reduce((n,r)=>n+r.length,0)}function zi(s,n){if(s[0].length===n)return s.shift();const r=new Uint8Array(n);let o=0;for(let u=0;u<n;u++)r[u]=s[0][o++],o===s[0].length&&(s.shift(),o=0);return s.length&&o<s[0].length&&(s[0]=s[0].slice(o)),r}function v1(s,n){yo||(yo=new TextDecoder);const r=[];let o=0,u=-1,a=!1;return new TransformStream({transform(d,v){for(r.push(d);;){if(o===0){if(Hi(r)<1)break;const h=zi(r,1);a=(h[0]&128)===128,u=h[0]&127,u<126?o=3:u===126?o=1:o=2}else if(o===1){if(Hi(r)<2)break;const h=zi(r,2);u=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),o=3}else if(o===2){if(Hi(r)<8)break;const h=zi(r,8),g=new DataView(h.buffer,h.byteOffset,h.length),m=g.getUint32(0);if(m>Math.pow(2,21)-1){v.enqueue(Bo);break}u=m*Math.pow(2,32)+g.getUint32(4),o=3}else{if(Hi(r)<u)break;const h=zi(r,u);v.enqueue(Ko(a?h:yo.decode(h),n)),o=0}if(u===0||u>s){v.enqueue(Bo);break}}}})}const af=4;function tt(s){if(s)return b1(s)}function b1(s){for(var n in tt.prototype)s[n]=tt.prototype[n];return s}tt.prototype.on=tt.prototype.addEventListener=function(s,n){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(n),this};tt.prototype.once=function(s,n){function r(){this.off(s,r),n.apply(this,arguments)}return r.fn=n,this.on(s,r),this};tt.prototype.off=tt.prototype.removeListener=tt.prototype.removeAllListeners=tt.prototype.removeEventListener=function(s,n){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+s];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var 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["$"+s],this};tt.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var n=new Array(arguments.length-1),r=this._callbacks["$"+s],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};tt.prototype.emitReserved=tt.prototype.emit;tt.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]};tt.prototype.hasListeners=function(s){return!!this.listeners(s).length};const es=typeof Promise=="function"&&typeof Promise.resolve=="function"?n=>Promise.resolve().then(n):(n,r)=>r(n,0),Xt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),y1="arraybuffer";function lf(s,...n){return n.reduce((r,o)=>(s.hasOwnProperty(o)&&(r[o]=s[o]),r),{})}const w1=Xt.setTimeout,E1=Xt.clearTimeout;function ts(s,n){n.useNativeTimers?(s.setTimeoutFn=w1.bind(Xt),s.clearTimeoutFn=E1.bind(Xt)):(s.setTimeoutFn=Xt.setTimeout.bind(Xt),s.clearTimeoutFn=Xt.clearTimeout.bind(Xt))}const S1=1.33;function C1(s){return typeof s=="string"?T1(s):Math.ceil((s.byteLength||s.size)*S1)}function T1(s){let n=0,r=0;for(let o=0,u=s.length;o<u;o++)n=s.charCodeAt(o),n<128?r+=1:n<2048?r+=2:n<55296||n>=57344?r+=3:(o++,r+=4);return r}function cf(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function R1(s){let n="";for(let r in s)s.hasOwnProperty(r)&&(n.length&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s[r]));return n}function N1(s){let n={},r=s.split("&");for(let o=0,u=r.length;o<u;o++){let a=r[o].split("=");n[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return n}class A1 extends Error{constructor(n,r,o){super(n),this.description=r,this.context=o,this.type="TransportError"}}class Qo extends tt{constructor(n){super(),this.writable=!1,ts(this,n),this.opts=n,this.query=n.query,this.socket=n.socket,this.supportsBinary=!n.forceBase64}onError(n,r,o){return super.emitReserved("error",new A1(n,r,o)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(n){this.readyState==="open"&&this.write(n)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(n){const r=Ko(n,this.socket.binaryType);this.onPacket(r)}onPacket(n){super.emitReserved("packet",n)}onClose(n){this.readyState="closed",super.emitReserved("close",n)}pause(n){}createUri(n,r={}){return n+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_hostname(){const n=this.opts.hostname;return n.indexOf(":")===-1?n:"["+n+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(n){const r=R1(n);return r.length?"?"+r:""}}class P1 extends Qo{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)};_1(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,g1(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]=cf()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(n,r)}}let uf=!1;try{uf=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const k1=uf;function I1(){}class L1 extends P1{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,a)=>{this.onError("xhr post error",u,a)})}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 on extends tt{constructor(n,r,o){super(),this.createRequest=n,ts(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=lf(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=on.requestsCount++,on.requests[this._index]=this)}_onError(n){this.emitReserved("error",n,this._xhr),this._cleanup(!0)}_cleanup(n){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=I1,n)try{this._xhr.abort()}catch{}typeof document<"u"&&delete on.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()}}on.requestsCount=0;on.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",zc);else if(typeof addEventListener=="function"){const s="onpagehide"in Xt?"pagehide":"unload";addEventListener(s,zc,!1)}}function zc(){for(let s in on.requests)on.requests.hasOwnProperty(s)&&on.requests[s].abort()}const D1=(function(){const s=ff({xdomain:!1});return s&&s.responseType!==null})();class M1 extends L1{constructor(n){super(n);const r=n&&n.forceBase64;this.supportsBinary=D1&&!r}request(n={}){return Object.assign(n,{xd:this.xd},this.opts),new on(ff,this.uri(),n)}}function ff(s){const n=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!n||k1))return new XMLHttpRequest}catch{}if(!n)try{return new Xt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const hf=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class O1 extends Qo{get name(){return"websocket"}doOpen(){const n=this.uri(),r=this.opts.protocols,o=hf?{}:lf(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;Vo(o,this.supportsBinary,a=>{try{this.doWrite(o,a)}catch{}u&&es(()=>{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]=cf()),this.supportsBinary||(r.b64=1),this.createUri(n,r)}}const wo=Xt.WebSocket||Xt.MozWebSocket;class j1 extends O1{createSocket(n,r,o){return hf?new wo(n,r,o):r?new wo(n,r):new wo(n)}doWrite(n,r){this.ws.send(r)}}class F1 extends Qo{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=v1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),o=n.readable.pipeThrough(r).getReader(),u=x1();u.readable.pipeTo(n.writable),this._writer=u.writable.getWriter();const a=()=>{o.read().then(({done:v,value:h})=>{v||(this.onPacket(h),a())}).catch(v=>{})};a();const d={type:"open"};this.query.sid&&(d.data=`{"sid":"${this.query.sid}"}`),this._writer.write(d).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&&es(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var n;(n=this._transport)===null||n===void 0||n.close()}}const B1={websocket:j1,webtransport:F1,polling:M1},U1=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,W1=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Uo(s){if(s.length>8e3)throw"URI too long";const n=s,r=s.indexOf("["),o=s.indexOf("]");r!=-1&&o!=-1&&(s=s.substring(0,r)+s.substring(r,o).replace(/:/g,";")+s.substring(o,s.length));let u=U1.exec(s||""),a={},d=14;for(;d--;)a[W1[d]]=u[d]||"";return r!=-1&&o!=-1&&(a.source=n,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=G1(a,a.path),a.queryKey=H1(a,a.query),a}function G1(s,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 H1(s,n){const r={};return n.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,u,a){u&&(r[u]=a)}),r}const Wo=typeof addEventListener=="function"&&typeof removeEventListener=="function",$i=[];Wo&&addEventListener("offline",()=>{$i.forEach(s=>s())},!1);class In extends tt{constructor(n,r){if(super(),this.binaryType=y1,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=Uo(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=Uo(r.host).host);ts(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=N1(this.opts.query)),Wo&&(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"})},$i.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&&In.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(n);r.open(),this.setTransport(r)}setTransport(n){this.transport&&this.transport.removeAllListeners(),this.transport=n,n.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",In.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",n),this.emitReserved("heartbeat"),n.type){case"open":this.onHandshake(JSON.parse(n.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const r=new Error("server error");r.code=n.data,this._onError(r);break;case"message":this.emitReserved("data",n.data),this.emitReserved("message",n.data);break}}onHandshake(n){this.emitReserved("handshake",n),this.id=n.sid,this.transport.query.sid=n.sid,this._pingInterval=n.pingInterval,this._pingTimeout=n.pingTimeout,this._maxPayload=n.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const n=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+n,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},n),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const n=this._getWritablePackets();this.transport.send(n),this._prevBufferLen=n.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let r=1;for(let o=0;o<this.writeBuffer.length;o++){const u=this.writeBuffer[o].data;if(u&&(r+=C1(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,es(()=>{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 a={type:n,data:r,options:o};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),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(In.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",n),this._onClose("transport error",n)}_onClose(n,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Wo&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const o=$i.indexOf(this._offlineEventListener);o!==-1&&$i.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",n,r),this.writeBuffer=[],this._prevBufferLen=0}}}In.protocol=af;class z1 extends In{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let n=0;n<this._upgrades.length;n++)this._probe(this._upgrades[n])}_probe(n){let r=this.createTransport(n),o=!1;In.priorWebsocketSuccess=!1;const u=()=>{o||(r.send([{type:"ping",data:"probe"}]),r.once("packet",x=>{if(!o)if(x.type==="pong"&&x.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;In.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{o||this.readyState!=="closed"&&(m(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const y=new Error("probe error");y.transport=r.name,this.emitReserved("upgradeError",y)}}))};function a(){o||(o=!0,m(),r.close(),r=null)}const d=x=>{const y=new Error("probe error: "+x);y.transport=r.name,a(),this.emitReserved("upgradeError",y)};function v(){d("transport closed")}function h(){d("socket closed")}function g(x){r&&x.name!==r.name&&a()}const m=()=>{r.removeListener("open",u),r.removeListener("error",d),r.removeListener("close",v),this.off("close",h),this.off("upgrading",g)};r.once("open",u),r.once("error",d),r.once("close",v),this.once("close",h),this.once("upgrading",g),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 q1=class extends z1{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=>B1[u]).filter(u=>!!u)),super(n,o)}};function $1(s,n="",r){let o=s;r=r||typeof location<"u"&&location,s==null&&(s=r.protocol+"//"+r.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=r.protocol+s:s=r.host+s),/^(https?|wss?):\/\//.test(s)||(typeof r<"u"?s=r.protocol+"//"+s:s="https://"+s),o=Uo(s)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const a=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+a+":"+o.port+n,o.href=o.protocol+"://"+a+(r&&r.port===o.port?"":":"+o.port),o}const X1=typeof ArrayBuffer=="function",Y1=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,df=Object.prototype.toString,V1=typeof Blob=="function"||typeof Blob<"u"&&df.call(Blob)==="[object BlobConstructor]",K1=typeof File=="function"||typeof File<"u"&&df.call(File)==="[object FileConstructor]";function Jo(s){return X1&&(s instanceof ArrayBuffer||Y1(s))||V1&&s instanceof Blob||K1&&s instanceof File}function Xi(s,n){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let r=0,o=s.length;r<o;r++)if(Xi(s[r]))return!0;return!1}if(Jo(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return Xi(s.toJSON(),!0);for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)&&Xi(s[r]))return!0;return!1}function Q1(s){const n=[],r=s.data,o=s;return o.data=Go(r,n),o.attachments=n.length,{packet:o,buffers:n}}function Go(s,n){if(!s)return s;if(Jo(s)){const r={_placeholder:!0,num:n.length};return n.push(s),r}else if(Array.isArray(s)){const r=new Array(s.length);for(let o=0;o<s.length;o++)r[o]=Go(s[o],n);return r}else if(typeof s=="object"&&!(s instanceof Date)){const r={};for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=Go(s[o],n));return r}return s}function J1(s,n){return s.data=Ho(s.data,n),delete s.attachments,s}function Ho(s,n){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<n.length)return n[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let r=0;r<s.length;r++)s[r]=Ho(s[r],n);else if(typeof s=="object")for(const r in s)Object.prototype.hasOwnProperty.call(s,r)&&(s[r]=Ho(s[r],n));return s}const Z1=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],eb=5;var Te;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(Te||(Te={}));class tb{constructor(n){this.replacer=n}encode(n){return(n.type===Te.EVENT||n.type===Te.ACK)&&Xi(n)?this.encodeAsBinary({type:n.type===Te.EVENT?Te.BINARY_EVENT:Te.BINARY_ACK,nsp:n.nsp,data:n.data,id:n.id}):[this.encodeAsString(n)]}encodeAsString(n){let r=""+n.type;return(n.type===Te.BINARY_EVENT||n.type===Te.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=Q1(n),o=this.encodeAsString(r.packet),u=r.buffers;return u.unshift(o),u}}function qc(s){return Object.prototype.toString.call(s)==="[object Object]"}class Zo extends tt{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===Te.BINARY_EVENT;o||r.type===Te.BINARY_ACK?(r.type=o?Te.EVENT:Te.ACK,this.reconstructor=new nb(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Jo(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(Te[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===Te.BINARY_EVENT||o.type===Te.BINARY_ACK){const a=r+1;for(;n.charAt(++r)!=="-"&&r!=n.length;);const d=n.substring(a,r);if(d!=Number(d)||n.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(d)}if(n.charAt(r+1)==="/"){const a=r+1;for(;++r&&!(n.charAt(r)===","||r===n.length););o.nsp=n.substring(a,r)}else o.nsp="/";const u=n.charAt(r+1);if(u!==""&&Number(u)==u){const a=r+1;for(;++r;){const d=n.charAt(r);if(d==null||Number(d)!=d){--r;break}if(r===n.length)break}o.id=Number(n.substring(a,r+1))}if(n.charAt(++r)){const a=this.tryParse(n.substr(r));if(Zo.isPayloadValid(o.type,a))o.data=a;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 Te.CONNECT:return qc(r);case Te.DISCONNECT:return r===void 0;case Te.CONNECT_ERROR:return typeof r=="string"||qc(r);case Te.EVENT:case Te.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&Z1.indexOf(r[0])===-1);case Te.ACK:case Te.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class nb{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=J1(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const rb=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Zo,Encoder:tb,get PacketType(){return Te},protocol:eb},Symbol.toStringTag,{value:"Module"}));function Zt(s,n,r){return s.on(n,r),function(){s.off(n,r)}}const ib=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class pf extends tt{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=[Zt(n,"open",this.onopen.bind(this)),Zt(n,"packet",this.onpacket.bind(this)),Zt(n,"error",this.onerror.bind(this)),Zt(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,a;if(ib.hasOwnProperty(n))throw new Error('"'+n.toString()+'" is a reserved event name');if(r.unshift(n),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const d={type:Te.EVENT,data:r};if(d.options={},d.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const m=this.ids++,x=r.pop();this._registerAckCallback(m,x),d.id=m}const v=(u=(o=this.io.engine)===null||o===void 0?void 0:o.transport)===null||u===void 0?void 0:u.writable,h=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!v||(h?(this.notifyOutgoingListeners(d),this.packet(d)):this.sendBuffer.push(d)),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 a=this.io.setTimeoutFn(()=>{delete this.acks[n];for(let v=0;v<this.sendBuffer.length;v++)this.sendBuffer[v].id===n&&this.sendBuffer.splice(v,1);r.call(this,new Error("operation has timed out"))},u),d=(...v)=>{this.io.clearTimeoutFn(a),r.apply(this,v)};d.withError=!0,this.acks[n]=d}emitWithAck(n,...r){return new Promise((o,u)=>{const a=(d,v)=>d?u(d):o(v);a.withError=!0,r.push(a),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,...a)=>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,...a)),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:Te.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 Te.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 Te.EVENT:case Te.BINARY_EVENT:this.onevent(n);break;case Te.ACK:case Te.BINARY_ACK:this.onack(n);break;case Te.DISCONNECT:this.ondisconnect();break;case Te.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:Te.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:Te.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 gr(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}gr.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var n=Math.random(),r=Math.floor(n*this.jitter*s);s=(Math.floor(n*10)&1)==0?s-r:s+r}return Math.min(s,this.max)|0};gr.prototype.reset=function(){this.attempts=0};gr.prototype.setMin=function(s){this.ms=s};gr.prototype.setMax=function(s){this.max=s};gr.prototype.setJitter=function(s){this.jitter=s};class zo extends tt{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,ts(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 gr({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||rb;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 q1(this.uri,this.opts);const r=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;const u=Zt(r,"open",function(){o.onopen(),n&&n()}),a=v=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",v),n?n(v):this.maybeReconnectOnOpen()},d=Zt(r,"error",a);if(this._timeout!==!1){const v=this._timeout,h=this.setTimeoutFn(()=>{u(),a(new Error("timeout")),r.close()},v);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(u),this.subs.push(d),this}connect(n){return this.open(n)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const n=this.engine;this.subs.push(Zt(n,"ping",this.onping.bind(this)),Zt(n,"data",this.ondata.bind(this)),Zt(n,"error",this.onerror.bind(this)),Zt(n,"close",this.onclose.bind(this)),Zt(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){es(()=>{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 pf(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 Gr={};function Yi(s,n){typeof s=="object"&&(n=s,s=void 0),n=n||{};const r=$1(s,n.path||"/socket.io"),o=r.source,u=r.id,a=r.path,d=Gr[u]&&a in Gr[u].nsps,v=n.forceNew||n["force new connection"]||n.multiplex===!1||d;let h;return v?h=new zo(o,n):(Gr[u]||(Gr[u]=new zo(o,n)),h=Gr[u]),r.query&&!n.query&&(n.query=r.queryKey),h.socket(r.path,n)}Object.assign(Yi,{Manager:zo,Socket:pf,io:Yi,connect:Yi});function sb(s,n){return(s[n]|s[n+1]<<8|s[n+2]<<16|s[n+3]<<24)>>>0}const Vi={H264:1748121140,H265:1748121141,AV1:6387249},{WritableStream:ob}=globalThis;class ab{#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 lb={SequenceHeader:1,TemporalDelimiter:2,FrameHeader:3,TileGroup:4,Metadata:5,Frame:6,RedundantFrameHeader:7,TileList:8,Padding:15},cb={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,GenericFilm:8,Bt2020:9,Xyz:10,Smpte431:11,Smpte432:12,Ebu3213:22},ub={Bt709:1,Unspecified:2,Bt470M:4,Bt470BG:5,Bt601:6,Smpte240:7,Linear:8,Log100:9,Log100Sqrt10:10,Iec61966:11,Bt1361:12,Srgb:13,Bt2020Ten:14,Bt2020Twelve:15,Smpte2084:16,Smpte428:17,Hlg:18},fb={Identity:0,Bt709:1,Unspecified:2,Fcc:4,Bt470BG:5,Bt601:6,Smpte240:7,YCgCo:8,Bt2020Ncl:9,Bt2020Cl:10,Smpte2085:11,ChromatNcl:12,ChromatCl:13,ICtCp:14};class xt extends ab{static ObuType=lb;static ColorPrimaries=cb;static TransferCharacteristics=ub;static MatrixCoefficients=fb;#e=0;uvlc(){let n=0;for(;!this.f1();)n+=1;return n>=32?2**32-1:this.f(n)+(1<<n>>>0)-1}leb128(){if(!this.byteAligned)throw new Error("LEB128 must be byte-aligned");let n=0n;this.#e=0;for(let r=0n;r<8n;r+=1n){const o=this.f(8);if(n|=BigInt(o&127)<<7n*r,this.#e+=1,(o&128)==0)break}return n}*annexBBitstream(){for(;!this.ended;){const n=this.leb128();yield*this.temporalUnit(n)}}*temporalUnit(n){for(;n>0;){const r=this.leb128();n-=BigInt(this.#e),yield*this.frameUnit(r),n-=r}}*frameUnit(n){for(;n>0;){const r=this.leb128();n-=BigInt(this.#e);const o=this.openBitstreamUnit(r);o&&(yield o),n-=r}}#t=0;openBitstreamUnit(n){const r=this.obuHeader();let o;if(r.obu_has_size_field)o=this.leb128();else if(n!==void 0)o=n-1n-(r.obu_extension_flag?1n:0n);else throw new Error("obu_has_size_field must be true");const u=this.getPosition();if(r.obu_type!==xt.ObuType.SequenceHeader&&r.obu_type!==xt.ObuType.TemporalDelimiter&&this.#t!==0&&r.obu_extension_header){const h=!!(this.#t&1<<r.obu_extension_header.temporal_id),g=!!(this.#t&1<<r.obu_extension_header.spatial_id+8);if(!h||!g){this.skip(Number(o));return}}let a;switch(r.obu_type){case xt.ObuType.SequenceHeader:a=this.sequenceHeaderObu();break}const d=this.getPosition(),v=(d[0]-u[0])*8+(u[1]-d[1]);return o>0&&this.skip(Number(o)*8-v),{obu_header:r,obu_size:o,sequence_header_obu:a}}obuHeader(){if(!!this.f1())throw new Error("Invalid data");const r=this.f(4),o=!!this.f1(),u=!!this.f1();this.f1();let a;return o&&(a=this.obuExtensionHeader()),{obu_type:r,obu_extension_flag:o,obu_has_size_field:u,obu_extension_header:a}}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,a,d=!1,v,h=!1,g=0;const m=[],x=[],y=[],S=[],C=[];let P,A;if(o)m[0]=0,x[0]=this.f(5),y[0]=0,S[0]=!1,C[0]=!1;else{u=!!this.f1(),u&&(a=this.timingInfo(),d=!!this.f1(),d&&(v=this.decoderModelInfo(),P=[])),h=!!this.f1(),h&&(A=[]),g=this.f(5);for(let ke=0;ke<=g;ke+=1)m[ke]=this.f(12),x[ke]=this.f(5),x[ke]>7?y[ke]=this.f1():y[ke]=0,d?(S[ke]=!!this.f1(),S[ke]&&(P[ke]=this.operatingParametersInfo(v))):S[ke]=!1,h&&(C[ke]=!!this.f1(),C[ke]&&(A[ke]=this.f(4)))}const j=this.chooseOperatingPoint();this.#t=m[j];const U=this.f(4),R=this.f(4),I=this.f(U+1),X=this.f(R+1);let $=!1,H,G;o||($=!!this.f1(),$&&(H=this.f(4),G=this.f(3)));const M=!!this.f1(),Y=!!this.f1(),B=!!this.f1();let he=!1,de=!1,q=!1,V=!1,Q=!1,ie=!1,se=!1,be=!1,xe=xt.SelectScreenContentTools,ne=!1,Re=xt.SelectIntegerMv,Ae;o||(he=!!this.f1(),de=!!this.f1(),q=!!this.f1(),V=!!this.f1(),Q=!!this.f1(),Q&&(ie=!!this.f1(),se=!!this.f1()),be=!!this.f1(),be||(xe=this.f1()),xe>0&&(ne=!!this.f1(),ne||(Re=this.f1())),Q&&(Ae=this.f(3)));const Fe=!!this.f1(),Oe=!!this.f1(),nt=!!this.f1(),ut=this.colorConfig(n),Ue=!!this.f1();return{seq_profile:n,still_picture:r,reduced_still_picture_header:o,timing_info_present_flag:u,timing_info:a,decoder_model_info_present_flag:d,decoder_model_info:v,initial_display_delay_present_flag:h,initial_display_delay_minus_1:A,operating_points_cnt_minus_1:g,operating_point_idc:m,seq_level_idx:x,seq_tier:y,decoder_model_present_for_this_op:S,operating_parameters_info:P,initial_display_delay_present_for_this_op:C,frame_width_bits_minus_1:U,frame_height_bits_minus_1:R,max_frame_width_minus_1:I,max_frame_height_minus_1:X,frame_id_numbers_present_flag:$,delta_frame_id_length_minus_2:H,additional_frame_id_length_minus_1:G,use_128x128_superblock:M,enable_filter_intra:Y,enable_intra_edge_filter:B,enable_interintra_compound:he,enable_masked_compound:de,enable_warped_motion:q,enable_dual_filter:V,enable_order_hint:Q,enable_jnt_comp:ie,enable_ref_frame_mvs:se,seq_choose_screen_content_tools:be,seq_force_screen_content_tools:xe,seq_choose_integer_mv:ne,seq_force_integer_mv:Re,order_hint_bits_minus_1:Ae,enable_superres:Fe,enable_cdef:Oe,enable_restoration:nt,color_config:ut,film_grain_params_present:Ue}}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),a=!!this.f1();return{decoder_buffer_delay:o,encoder_buffer_delay:u,low_delay_mode_flag:a}}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 a=!1;n===1&&(a=!!this.f1());const d=!!this.f1();let v=xt.ColorPrimaries.Unspecified,h=xt.TransferCharacteristics.Unspecified,g=xt.MatrixCoefficients.Unspecified;d&&(v=this.f(8),h=this.f(8),g=this.f(8));let m=!1,x,y,S=0,C=!1;if(a)m=!!this.f1(),x=!0,y=!0;else{if(v===xt.ColorPrimaries.Bt709&&h===xt.TransferCharacteristics.Srgb&&g===xt.MatrixCoefficients.Identity)m=!0,x=!1,y=!1;else{switch(m=!!this.f1(),n){case 0:x=!0,y=!0;break;case 1:x=!1,y=!1;break;default:u==12?(x=!!this.f1(),x?y=!!this.f1():y=!1):(x=!0,y=!1);break}x&&y&&(S=this.f(2))}C=!!this.f1()}return{high_bitdepth:r,twelve_bit:o,BitDepth:u,mono_chrome:a,color_description_present_flag:d,color_primaries:v,transfer_characteristics:h,matrix_coefficients:g,color_range:m,subsampling_x:x,subsampling_y:y,chroma_sample_position:S,separate_uv_delta_q:C}}}function*mf(s){let n=-1,r=0,o=!1;for(let u=0;u<s.length;u+=1){const a=s[u];if(o){if(a>3)throw new Error("Invalid data");o=!1;continue}if(a===0){r+=1;continue}const d=r;if(r=0,n===-1){if(d>=2&&a===1){n=u+1;continue}throw new Error("Invalid data")}if(!(d<2)){if(a===1){yield s.subarray(n,u-d),n=u+1;continue}if(d>2)throw new Error("Invalid data");switch(a){case 2:throw new Error("Invalid data");case 3:o=!0;break}}}if(o)throw new Error("Invalid data");yield s.subarray(n,s.length)}class ns{#e;#t;#n;#r=0;#s=0;#i=7;#o=0;get byteLength(){return this.#t}get stopBitIndex(){return this.#n}get bytePosition(){return this.#s}get bitPosition(){return this.#i}get ended(){return this.#s>=this.#t&&this.#i<=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.#s],this.#r===2&&this.#o===3){this.#r=0,this.#s+=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.#i&1;return this.#i-=1,this.#i<0&&(this.#s+=1,this.#i=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.#s>=this.#t&&this.#i<this.#n)throw new Error("Bit index out of bounds")}skip(n){if(n<=this.#i+1){this.#i-=n,this.#c();return}for(n-=this.#i+1,this.#s+=1,this.#i=7,this.#l(),this.#c();n>=8;n-=8)this.#s+=1,this.#l(),this.#c();this.#i=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.#s,bitPosition:this.#i,byte:this.#o}}#a(n){this.#r=n.zeroCount,this.#s=n.bytePosition,this.#i=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 hb(s){const n=new ns(s);if(n.next()!==0)throw new Error("Invalid data");const r=n.read(2);if(n.read(5)!==7)throw new Error("Invalid data");if(r===0)throw new Error("Invalid data");const u=n.read(8),a=n.peek(8),d=!!n.next(),v=!!n.next(),h=!!n.next(),g=!!n.next(),m=!!n.next(),x=!!n.next();if(n.read(2)!==0)throw new Error("Invalid data");const y=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 H=n.decodeExponentialGolombNumber();if(H===3&&n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber(),n.next(),!!n.next())for(let M=0;M<(H!==3?8:12);M+=1)n.next()}n.decodeExponentialGolombNumber();const C=n.decodeExponentialGolombNumber();if(C===0)n.decodeExponentialGolombNumber();else if(C===1){n.next(),n.decodeExponentialGolombNumber(),n.decodeExponentialGolombNumber();const H=n.decodeExponentialGolombNumber();for(let G=0;G<H;G+=1)n.decodeExponentialGolombNumber()}n.decodeExponentialGolombNumber(),n.next();const P=n.decodeExponentialGolombNumber(),A=n.decodeExponentialGolombNumber(),j=n.next();j||n.next(),n.next();const U=!!n.next();let R,I,X,$;return U?(R=n.decodeExponentialGolombNumber(),I=n.decodeExponentialGolombNumber(),X=n.decodeExponentialGolombNumber(),$=n.decodeExponentialGolombNumber()):(R=0,I=0,X=0,$=0),n.next(),{profile_idc:u,constraint_set:a,constraint_set0_flag:d,constraint_set1_flag:v,constraint_set2_flag:h,constraint_set3_flag:g,constraint_set4_flag:m,constraint_set5_flag:x,level_idc:y,seq_parameter_set_id:S,pic_width_in_mbs_minus1:P,pic_height_in_map_units_minus1:A,frame_mbs_only_flag:j,frame_cropping_flag:U,frame_crop_left_offset:R,frame_crop_right_offset:I,frame_crop_top_offset:X,frame_crop_bottom_offset:$}}function db(s){let n,r;for(const o of mf(s))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 pb(s){const{sequenceParameterSet:n,pictureParameterSet:r}=db(s),{profile_idc:o,constraint_set:u,level_idc:a,pic_width_in_mbs_minus1:d,pic_height_in_map_units_minus1:v,frame_mbs_only_flag:h,frame_crop_left_offset:g,frame_crop_right_offset:m,frame_crop_top_offset:x,frame_crop_bottom_offset:y}=hb(n),S=(d+1)*16,C=(v+1)*(2-h)*16,P=g*2,A=m*2,j=x*2,U=y*2,R=S-P-A,I=C-j-U;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:u,levelIndex:a,encodedWidth:S,encodedHeight:C,cropLeft:P,cropRight:A,cropTop:j,cropBottom:U,croppedWidth:R,croppedHeight:I}}function mb(s){switch(s){case 0:case 3:return 1;case 1:case 2:return 2;default:throw new Error("Invalid chroma_format_idc")}}function gb(s){switch(s){case 0:case 2:case 3:return 1;case 1:return 2;default:throw new Error("Invalid chroma_format_idc")}}function _b(s){const n=new ns(s);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 xb(s){const n=new ns(s),r=n.read(4),o=!!n.next(),u=!!n.next(),a=n.read(6),d=n.read(3),v=!!n.next();n.skip(16);const h=gf(n,!0,d),g=!!n.next(),m=[],x=[],y=[];for(let Y=g?0:d;Y<=d;Y+=1)m[Y]=n.decodeExponentialGolombNumber(),x[Y]=n.decodeExponentialGolombNumber(),y[Y]=n.decodeExponentialGolombNumber();const S=n.read(6),C=n.decodeExponentialGolombNumber(),P=[];for(let Y=1;Y<=C;Y+=1){P[Y]=[];for(let B=0;B<=S;B+=1)P[Y][B]=!!n.next()}const A=!!n.next();let j,U,R,I,X,$,H,G;if(A){j=n.read(32),U=n.read(32),R=!!n.next(),R&&(I=n.decodeExponentialGolombNumber()),X=n.decodeExponentialGolombNumber(),$=[],H=[!0],G=[];for(let Y=0;Y<X;Y+=1)$[Y]=n.decodeExponentialGolombNumber(),Y>0&&(H[Y]=!!n.next()),G[Y]=_f(n,H[Y],d)}const M=!!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:a,vps_max_sub_layers_minus1:d,vps_temporal_id_nesting_flag:v,profileTierLevel:h,vps_sub_layer_ordering_info_present_flag:g,vps_max_dec_pic_buffering_minus1:m,vps_max_num_reorder_pics:x,vps_max_latency_increase_plus1:y,vps_max_layer_id:S,vps_num_layer_sets_minus1:C,layer_id_included_flag:P,vps_timing_info_present_flag:A,vps_num_units_in_tick:j,vps_time_scale:U,vps_poc_proportional_to_timing_flag:R,vps_num_ticks_poc_diff_one_minus1:I,vps_num_hrd_parameters:X,hrd_layer_set_idx:$,cprms_present_flag:H,hrdParameters:G,vps_extension_flag:M}}function vb(s){const n=new ns(s),r=n.read(4),o=n.read(3),u=!!n.next(),a=gf(n,!0,o),d=n.decodeExponentialGolombNumber(),v=n.decodeExponentialGolombNumber();let h;v===3&&(h=!!n.next());const g=n.decodeExponentialGolombNumber(),m=n.decodeExponentialGolombNumber(),x=!!n.next();let y,S,C,P;x&&(y=n.decodeExponentialGolombNumber(),S=n.decodeExponentialGolombNumber(),C=n.decodeExponentialGolombNumber(),P=n.decodeExponentialGolombNumber());const A=n.decodeExponentialGolombNumber(),j=n.decodeExponentialGolombNumber(),U=n.decodeExponentialGolombNumber(),R=[],I=[],X=[],$=!!n.next();for(let ve=$?0:o;ve<=o;ve+=1)R[ve]=n.decodeExponentialGolombNumber(),I[ve]=n.decodeExponentialGolombNumber(),X[ve]=n.decodeExponentialGolombNumber();const H=n.decodeExponentialGolombNumber(),G=n.decodeExponentialGolombNumber(),M=n.decodeExponentialGolombNumber(),Y=n.decodeExponentialGolombNumber(),B=n.decodeExponentialGolombNumber(),he=n.decodeExponentialGolombNumber(),de=!!n.next();let q,V;de&&(q=!!n.next(),q&&(V=bb(n)));const Q=!!n.next(),ie=!!n.next(),se=!!n.next();let be,xe,ne,Re,Ae;se&&(be=n.read(4),xe=n.read(4),ne=n.read(4),Re=n.read(4),Ae=!!n.next());const Fe=n.decodeExponentialGolombNumber(),Oe=[];for(let ve=0;ve<Fe;ve+=1)Oe[ve]=yb(n,ve,Fe,Oe);const nt=!!n.next();let ut,Ue,ke;if(nt){ut=n.decodeExponentialGolombNumber(),Ue=[],ke=[];for(let ve=0;ve<ut;ve+=1)Ue[ve]=n.read(U+4),ke[ve]=!!n.next()}const pt=!!n.next(),Et=!!n.next(),Pe=!!n.next();let St;Pe&&(St=wb(n,o));const Xe=!!n.next();let ot,Z,ee,L,K;if(Xe&&(ot=!!n.next(),Z=!!n.next(),ee=!!n.next(),L=!!n.next(),K=n.read(4)),ot)throw new Error("Not implemented");let ue;Z&&(ue=Sb(n));let pe;if(ee&&(pe=Cb(n)),L)throw new Error("Not implemented");let ye;if(K){ye=[];let ve=0;for(;!n.ended;)ye[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:a,sps_seq_parameter_set_id:d,chroma_format_idc:v,separate_colour_plane_flag:h,pic_width_in_luma_samples:g,pic_height_in_luma_samples:m,conformance_window_flag:x,conf_win_left_offset:y,conf_win_right_offset:S,conf_win_top_offset:C,conf_win_bottom_offset:P,bit_depth_luma_minus8:A,bit_depth_chroma_minus8:j,log2_max_pic_order_cnt_lsb_minus4:U,sps_sub_layer_ordering_info_present_flag:$,sps_max_dec_pic_buffering_minus1:R,sps_max_num_reorder_pics:I,sps_max_latency_increase_plus1:X,log2_min_luma_coding_block_size_minus3:H,log2_diff_max_min_luma_coding_block_size:G,log2_min_luma_transform_block_size_minus2:M,log2_diff_max_min_luma_transform_block_size:Y,max_transform_hierarchy_depth_inter:B,max_transform_hierarchy_depth_intra:he,scaling_list_enabled_flag:de,sps_scaling_list_data_present_flag:q,scalingListData:V,amp_enabled_flag:Q,sample_adaptive_offset_enabled_flag:ie,pcm_enabled_flag:se,pcm_sample_bit_depth_luma_minus1:be,pcm_sample_bit_depth_chroma_minus1:xe,log2_min_pcm_luma_coding_block_size_minus3:ne,log2_diff_max_min_pcm_luma_coding_block_size:Re,pcm_loop_filter_disabled_flag:Ae,num_short_term_ref_pic_sets:Fe,shortTermRefPicSets:Oe,long_term_ref_pics_present_flag:nt,num_long_term_ref_pics_sps:ut,lt_ref_pic_poc_lsb_sps:Ue,used_by_curr_pic_lt_sps_flag:ke,sps_temporal_mvp_enabled_flag:pt,strong_intra_smoothing_enabled_flag:Et,vui_parameters_present_flag:Pe,vuiParameters:St,sps_extension_present_flag:Xe,sps_range_extension_flag:ot,sps_multilayer_extension_flag:Z,sps_3d_extension_flag:ee,sps_scc_extension_flag:L,sps_extension_4bits:K,spsMultilayerExtension:ue,sps3dExtension:pe,sps_extension_data_flag:ye}}function $c(s){const n=s.read(2),r=!!s.next(),o=s.read(5),u=s.peekBytes(4),a=[];for(let $=0;$<32;$+=1)a[$]=!!s.next();const d=s.peekBytes(6),v=!!s.next(),h=!!s.next(),g=!!s.next(),m=!!s.next();let x,y,S,C,P,A,j,U,R,I;o===4||a[4]||o===5||a[5]||o===6||a[6]||o===7||a[7]||o===8||a[8]||o===9||a[9]||o===10||a[10]||o===11||a[11]?(x=!!s.next(),y=!!s.next(),S=!!s.next(),C=!!s.next(),P=!!s.next(),A=!!s.next(),j=!!s.next(),U=!!s.next(),R=!!s.next(),o===5||a[5]||o===9||a[9]||o===10||a[10]||o===11||a[11]?(I=!!s.next(),s.skip(33)):s.skip(34)):o===2||a[2]?(s.skip(7),U=!!s.next(),s.skip(35)):s.skip(43);let X;return o===1||a[1]||o===2||a[2]||o===3||a[3]||o===4||a[4]||o===5||a[5]||o===9||a[9]||o===11||a[11]?X=!!s.next():s.skip(1),{profile_space:n,tier_flag:r,profile_idc:o,profileCompatibilitySet:u,profile_compatibility_flag:a,constraintSet:d,progressive_source_flag:v,interlaced_source_flag:h,non_packed_constraint_flag:g,frame_only_constraint_flag:m,max_12bit_constraint_flag:x,max_10bit_constraint_flag:y,max_8bit_constraint_flag:S,max_422chroma_constraint_flag:C,max_420chroma_constraint_flag:P,max_monochrome_constraint_flag:A,intra_constraint_flag:j,one_picture_only_constraint_flag:U,lower_bit_rate_constraint_flag:R,max_14bit_constraint_flag:I,inbld_flag:X}}function gf(s,n,r){let o;o=$c(s);const u=s.read(8),a=[],d=[];for(let g=0;g<r;g+=1)a[g]=!!s.next(),d[g]=!!s.next();if(r>0)for(let g=r;g<8;g+=1)s.read(2);const v=[],h=[];for(let g=0;g<r;g+=1)a[g]&&(v[g]=$c(s)),d[g]&&(h[g]=s.read(8));return{generalProfileTier:o,general_level_idc:u,sub_layer_profile_present_flag:a,sub_layer_level_present_flag:d,subLayerProfileTier:v,sub_layer_level_idc:h}}function bb(s){const n=[];for(let r=0;r<4;r+=1){n[r]=[];for(let o=0;o<6;o+=r===3?3:1)if(!!!s.next())s.decodeExponentialGolombNumber();else{let a=8;const d=Math.min(64,1<<4+(r<<1));r>1&&(a=s.decodeExponentialGolombNumber()+8),n[r][o]=[];for(let v=0;v<d;v+=1){const h=s.decodeExponentialGolombNumber();a=(a+h+256)%256,n[r][o][v]=a}}}return n}function yb(s,n,r,o){let u=!1;n!==0&&(u=!!s.next());let a=0,d=!1,v=0;const h=[],g=[];let m=0,x=0;const y=[],S=[],C=[],P=[];if(u){n===r&&(a=s.decodeExponentialGolombNumber()),d=!!s.next(),v=s.decodeExponentialGolombNumber();const A=n-(a+1),j=o[A],U=j.num_negative_pics+j.num_positive_pics;for(let B=0;B<=U;B+=1)h[B]=!!s.next(),h[B]?g[B]=!0:g[B]=!!s.next();const R=(1-2*Number(d))*(v+1),I=[],X=[],$=[],H=[];let G=0;for(let B=0;B<j.num_negative_pics;B+=1)G-=j.delta_poc_s0_minus1[B]+1,I[B]=G;G=0;for(let B=0;B<j.num_positive_pics;B+=1)G+=j.delta_poc_s1_minus1[B]+1,X[B]=G;let M=0;if(j.num_positive_pics>0)for(let B=j.num_positive_pics-1;B>=0;B-=1)G=X[B]+R,G<0&&g[j.num_negative_pics+B]&&($[M]=G,S[M]=h[j.num_negative_pics+B],M+=1);R<0&&g[U]&&($[M]=R,S[M]=h[U],M+=1);for(let B=0;B<j.num_negative_pics;B+=1)G=I[B]+R,G<0&&g[B]&&($[M]=G,S[M]=h[B],M+=1);m=M;let Y=0;for(M=0;M<m;M+=1){const B=$[M];y[M]=-(B-Y-1),Y=B}if(M=0,j.num_negative_pics>0)for(let B=j.num_negative_pics-1;B>=0;B-=1)G=I[B]+R,G>0&&g[B]&&(H[M]=G,P[M]=h[B],M+=1);R>0&&g[U]&&(H[M]=R,P[M]=h[U],M+=1);for(let B=0;B<j.num_positive_pics;B+=1)G=X[B]+R,G>0&&g[j.num_negative_pics+B]&&(H[M]=G,P[M]=h[j.num_negative_pics+B],M+=1);for(x=M,Y=0,M=0;M<x;M+=1){const B=H[M];C[M]=B-Y-1,Y=B}}else{m=s.decodeExponentialGolombNumber(),x=s.decodeExponentialGolombNumber();for(let A=0;A<m;A+=1)y[A]=s.decodeExponentialGolombNumber(),S[A]=!!s.next();for(let A=0;A<x;A+=1)C[A]=s.decodeExponentialGolombNumber(),P[A]=!!s.next()}return{stRpsIdx:n,num_short_term_ref_pic_sets:r,inter_ref_pic_set_prediction_flag:u,delta_idx_minus1:a,delta_rps_sign:d,abs_delta_rps_minus1:v,used_by_curr_pic_flag:h,use_delta_flag:g,num_negative_pics:m,num_positive_pics:x,delta_poc_s0_minus1:y,used_by_curr_pic_s0_flag:S,delta_poc_s1_minus1:C,used_by_curr_pic_s1_flag:P}}function wb(s,n){const r=!!s.next();let o,u,a;r&&(o=s.read(8),o===255&&(u=s.read(16),a=s.read(16)));const d=!!s.next();let v;d&&(v=!!s.next());const h=!!s.next();let g,m,x,y,S,C;h&&(g=s.read(3),m=!!s.next(),x=!!s.next(),x&&(y=s.read(8),S=s.read(8),C=s.read(8)));const P=!!s.next();let A,j;P&&(A=s.decodeExponentialGolombNumber(),j=s.decodeExponentialGolombNumber());const U=!!s.next(),R=!!s.next(),I=!!s.next(),X=!!s.next();let $,H,G,M;X&&($=s.decodeExponentialGolombNumber(),H=s.decodeExponentialGolombNumber(),G=s.decodeExponentialGolombNumber(),M=s.decodeExponentialGolombNumber());const Y=!!s.next();let B,he,de,q,V,Q;Y&&(B=s.read(32),he=s.read(32),de=!!s.next(),de&&(q=s.decodeExponentialGolombNumber()),V=!!s.next(),V&&(Q=_f(s,!0,n)));const ie=!!s.next();let se,be,xe,ne,Re,Ae,Fe,Oe;return ie&&(se=!!s.next(),be=!!s.next(),xe=!!s.next(),ne=s.decodeExponentialGolombNumber(),Re=s.decodeExponentialGolombNumber(),Ae=s.decodeExponentialGolombNumber(),Fe=s.decodeExponentialGolombNumber(),Oe=s.decodeExponentialGolombNumber()),{aspect_ratio_info_present_flag:r,aspect_ratio_idc:o,sar_width:u,sar_height:a,overscan_info_present_flag:d,overscan_appropriate_flag:v,video_signal_type_present_flag:h,video_format:g,video_full_range_flag:m,colour_description_present_flag:x,colour_primaries:y,transfer_characteristics:S,matrix_coeffs:C,chroma_loc_info_present_flag:P,chroma_sample_loc_type_top_field:A,chroma_sample_loc_type_bottom_field:j,neutral_chroma_indication_flag:U,field_seq_flag:R,frame_field_info_present_flag:I,default_display_window_flag:X,def_disp_win_left_offset:$,def_disp_win_right_offset:H,def_disp_win_top_offset:G,def_disp_win_bottom_offset:M,vui_timing_info_present_flag:Y,vui_num_units_in_tick:B,vui_time_scale:he,vui_poc_proportional_to_timing_flag:de,vui_num_ticks_poc_diff_one_minus1:q,vui_hrd_parameters_present_flag:V,vui_hrd_parameters:Q,bitstream_restriction_flag:ie,tiles_fixed_structure_flag:se,motion_vectors_over_pic_boundaries_flag:be,restricted_ref_pic_lists_flag:xe,min_spatial_segmentation_idc:ne,max_bytes_per_pic_denom:Re,max_bits_per_min_cu_denom:Ae,log2_max_mv_length_horizontal:Fe,log2_max_mv_length_vertical:Oe}}function _f(s,n,r){let o,u,a,d,v,h,g,m,x,y,S,C,P;n&&(o=!!s.next(),u=!!s.next(),(o||u)&&(a=!!s.next(),a&&(d=s.read(8),v=s.read(5),h=!!s.next(),g=s.read(5)),m=s.read(4),x=s.read(4),a&&(y=s.read(4)),S=s.read(5),C=s.read(5),P=s.read(5)));const A=[],j=[],U=[],R=[],I=[],X=[],$=[];for(let H=0;H<=r;H+=1)A[H]=!!s.next(),A[H]||(j[H]=!!s.next()),j[H]?U[H]=s.decodeExponentialGolombNumber():R[H]=!!s.next(),R[H]||(I[H]=s.decodeExponentialGolombNumber()),o&&(X[H]=Xc(s,H,Yc(I[H]))),u&&($[H]=Xc(s,H,Yc(I[H])));return{nal_hrd_parameters_present_flag:o,vcl_hrd_parameters_present_flag:u,sub_pic_hrd_params_present_flag:a,tick_divisor_minus2:d,du_cpb_removal_delay_increment_length_minus1:v,sub_pic_cpb_params_in_pic_timing_sei_flag:h,dpb_output_delay_du_length_minus1:g,bit_rate_scale:m,cpb_size_scale:x,cpb_size_du_scale:y,initial_cpb_removal_delay_length_minus1:S,au_cpb_removal_delay_length_minus1:C,dpb_output_delay_length_minus1:P,fixed_pic_rate_general_flag:A,fixed_pic_rate_within_cvs_flag:j,elemental_duration_in_tc_minus1:U,low_delay_hrd_flag:R,cpb_cnt_minus1:I,nalHrdParameters:X,vclHrdParameters:$}}function Xc(s,n,r){const o=[],u=[],a=[],d=[],v=[];for(let h=0;h<r;h+=1)o[h]=s.decodeExponentialGolombNumber(),u[h]=s.decodeExponentialGolombNumber(),n>0&&(v[h]=!!s.next());return{bit_rate_value_minus1:o,cpb_size_value_minus1:u,cpb_size_du_value_minus1:a,bit_rate_du_value_minus1:d,cbr_flag:v}}function Yc(s){return s+1}function Eb(s){let n,r,o,u=0;for(const a of mf(s)){const d=_b(a),v={...d,data:a,rbsp:a.subarray(2)};switch(d.nal_unit_type){case 32:n=v;break;case 33:r=v;break;case 34:o=v;break;default:continue}if(u+=1,u===3)return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}}throw new Error("Invalid data")}function Sb(s){return{inter_view_mv_vert_constraint_flag:!!s.next()}}function Cb(s){const n=[],r=[];n[0]=!!s.next(),r[0]=!!s.next();const o=s.decodeExponentialGolombNumber(),u=!!s.next(),a=!!s.next(),d=!!s.next(),v=!!s.next();n[1]=!!s.next(),r[1]=!!s.next();const h=!!s.next(),g=s.decodeExponentialGolombNumber(),m=!!s.next(),x=!!s.next(),y=!!s.next(),S=!!s.next(),C=!!s.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:a,vsp_mc_enabled_flag:d,dbbp_enabled_flag:v,tex_mc_enabled_flag:h,log2_texmc_sub_pb_size_minus3:g,intra_contour_enabled_flag:m,intra_dc_only_wedge_enabled_flag:x,cqt_cu_part_pred_enabled_flag:y,inter_dc_only_enabled_flag:S,skip_intra_enabled_flag:C}}function Tb(s){const{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o}=Eb(s),{profileTierLevel:{generalProfileTier:{profile_space:u,tier_flag:a,profile_idc:d,profileCompatibilitySet:v,constraintSet:h},general_level_idc:g}}=xb(n.rbsp),{chroma_format_idc:m,pic_width_in_luma_samples:x,pic_height_in_luma_samples:y,conf_win_left_offset:S=0,conf_win_right_offset:C=0,conf_win_top_offset:P=0,conf_win_bottom_offset:A=0}=vb(r.rbsp),j=mb(m),U=gb(m),R=x-j*(S+C),I=y-U*(P+A);return{videoParameterSet:n,sequenceParameterSet:r,pictureParameterSet:o,generalProfileSpace:u,generalProfileIndex:d,generalProfileCompatibilitySet:v,generalTierFlag:a,generalLevelIndex:g,generalConstraintSet:h,encodedWidth:x,encodedHeight:y,cropLeft:S,cropRight:C,cropTop:P,cropBottom:A,croppedWidth:R,croppedHeight:I}}function Vc(s){return s.toString(16).toUpperCase()}function Eo(s){return s.toString(16).toUpperCase().padStart(2,"0")}function Hr(s){return s.toString(10).padStart(2,"0")}class Rb{#e;#t;constructor(n,r){this.#e=n,this.#t=r}#n(n){const o=new xt(n).searchSequenceHeaderObu();if(!o)return;const{seq_profile:u,seq_level_idx:[a=0],max_frame_width_minus_1:d,max_frame_height_minus_1:v,color_config:{BitDepth:h,mono_chrome:g,subsampling_x:m,subsampling_y:x,chroma_sample_position:y,color_description_present_flag:S}}=o;let C,P,A,j;S?{color_primaries:C,transfer_characteristics:P,matrix_coefficients:A,color_range:j}=o.color_config:(C=xt.ColorPrimaries.Bt709,P=xt.TransferCharacteristics.Bt709,A=xt.MatrixCoefficients.Bt709,j=!1);const U=d+1,R=v+1;this.#t(U,R);const I=["av01",u.toString(16),Hr(a)+(o.seq_tier[0]?"H":"M"),Hr(h),g?"1":"0",(m?"1":"0")+(x?"1":"0")+y.toString(),Hr(C),Hr(P),Hr(A),j?"1":"0"].join(".");this.#e.configure({codec:I,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 xf{#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 Nb extends xf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{profileIndex:r,constraintSet:o,levelIndex:u,croppedWidth:a,croppedHeight:d}=pb(n);this.#t(a,d);const v="avc1."+Eo(r)+Eo(o)+Eo(u);this.#e.configure({codec:v,optimizeForLatency:!0})}}class Ab extends xf{#e;#t;constructor(n,r){super(n),this.#e=n,this.#t=r}configure(n){const{generalProfileSpace:r,generalProfileIndex:o,generalProfileCompatibilitySet:u,generalTierFlag:a,generalLevelIndex:d,generalConstraintSet:v,croppedWidth:h,croppedHeight:g}=Tb(n);this.#t(h,g);const m=["hev1",["","A","B","C"][r]+o.toString(),Vc(sb(u,0)),(a?"H":"L")+d.toString(),...Array.from(v,Vc)].join(".");this.#e.configure({codec:m,codedWidth:h,codedHeight:g,optimizeForLatency:!0})}}class Pb{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;#s=0;#i;constructor(n,r){this.#r=n,this.#i=r}async borrow(){return(await this.#n.read()).value}return(n){this.#s<this.#i&&(this.#e.enqueue(n),this.#s+=1)}}class Ib{#e;#t;constructor(){typeof OffscreenCanvas<"u"?this.#e=new OffscreenCanvas(1,1):(this.#e=document.createElement("canvas"),this.#e.width=1,this.#e.height=1),this.#t=this.#e.getContext("bitmaprenderer",{alpha:!1})}async capture(n){this.#e.width=n.displayWidth,this.#e.height=n.displayHeight;const r=await createImageBitmap(n);return this.#t.transferFromImageBitmap(r),this.#e instanceof OffscreenCanvas?await this.#e.convertToBlob({type:"image/png"}):new Promise((o,u)=>{this.#e.toBlob(a=>{a?o(a):u(new Error("Failed to convert canvas to blob"))},"image/png")})}}const Kc=new kb(()=>new Ib,4);class Qc{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;#s;#i;get renderer(){return this.#i}#o=0;#l=0;get framesRendered(){return this.#l}#c=0;get framesSkipped(){return this.#c}#f=new Pb;get sizeChanged(){return this.#f.event}#a;#p=!1;#u;#h;#m=0;constructor({codec:n,renderer:r}){switch(this.#e=n,this.#i=r,this.#a=new VideoDecoder({output:o=>{if(this.#h?.close(),this.#h=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 Vi.H264:this.#t=new Nb(this.#a,this.#d);break;case Vi.H265:this.#t=new Ab(this.#a,this.#d);break;case Vi.AV1:this.#t=new Rb(this.#a,this.#d);break;default:throw new Error(`Unsupported codec: ${this.#e}`)}this.#n=new ob({start:o=>{this.#r?o.error(this.#r):this.#s=o},write:o=>{this.#t.decode(o)}}),this.#x()}#g(n){if(this.#s)try{this.#s.error(n)}catch{}else this.#r=n}async#_(n){try{if(this.#p=!0,this.#d(n.displayWidth,n.displayHeight),await this.#i.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)}}#d=(n,r)=>{this.#i.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.#h;if(!n)return;const r=await Kc.borrow(),o=await r.capture(n);return Kc.return(r),o}dispose(){cancelAnimationFrame(this.#m),this.#a.state!=="closed"&&this.#a.close(),this.#u?.close(),this.#h?.close()}}var So={exports:{}},Co={exports:{}},Jc;function ea(){return Jc||(Jc=1,(function(){function s(n,r){throw new Error("abstract")}s.prototype.drawFrame=function(n){throw new Error("abstract")},s.prototype.clear=function(){throw new Error("abstract")},Co.exports=s})()),Co.exports}var To={exports:{}},Ro={exports:{}},No={exports:{}},Zc;function Lb(){return Zc||(Zc=1,(function(){function s(n){for(var r=0,o=n>>1;o!=0;)o=o>>1,r++;if(n!==1<<r)throw"chroma plane dimensions must be power of 2 ratio to luma plane dimensions; got "+n;return r}No.exports=s})()),No.exports}var eu;function Db(){return eu||(eu=1,(function(){var s=Lb();function n(r,o){var u=r.format.width|0,a=r.format.height|0,d=s(r.format.width/r.format.chromaWidth)|0,v=s(r.format.height/r.format.chromaHeight)|0,h=r.y.bytes,g=r.u.bytes,m=r.v.bytes,x=r.y.stride|0,y=r.u.stride|0,S=r.v.stride|0,C=u<<2,P=0,A=0,j=0,U=0,R=0,I=0,X=0,$=0,H=0,G=0,M=0,Y=0,B=0,he=0,de=0,q=0,V=0,Q=0;if(d==1&&v==1)for(X=0,$=C,Q=0,q=0;q<a;q+=2){for(A=q*x|0,j=A+x|0,U=Q*y|0,R=Q*S|0,de=0;de<u;de+=2)H=g[U++]|0,G=m[R++]|0,Y=(409*G|0)-57088|0,B=(100*H|0)+(208*G|0)-34816|0,he=(516*H|0)-70912|0,M=298*h[A++]|0,o[X]=M+Y>>8,o[X+1]=M-B>>8,o[X+2]=M+he>>8,X+=4,M=298*h[A++]|0,o[X]=M+Y>>8,o[X+1]=M-B>>8,o[X+2]=M+he>>8,X+=4,M=298*h[j++]|0,o[$]=M+Y>>8,o[$+1]=M-B>>8,o[$+2]=M+he>>8,$+=4,M=298*h[j++]|0,o[$]=M+Y>>8,o[$+1]=M-B>>8,o[$+2]=M+he>>8,$+=4;X+=C,$+=C,Q++}else for(I=0,q=0;q<a;q++)for(V=0,Q=q>>v,P=q*x|0,U=Q*y|0,R=Q*S|0,de=0;de<u;de++)V=de>>d,H=g[U+V]|0,G=m[R+V]|0,Y=(409*G|0)-57088|0,B=(100*H|0)+(208*G|0)-34816|0,he=(516*H|0)-70912|0,M=298*h[P++]|0,o[I]=M+Y>>8,o[I+1]=M-B>>8,o[I+2]=M+he>>8,I+=4}Ro.exports={convertYCbCr:n}})()),Ro.exports}var tu;function Mb(){return tu||(tu=1,(function(){var s=ea(),n=Db();function r(o){var u=this,a=o.getContext("2d"),d=null,v=null,h=null;function g(x,y){d=a.createImageData(x,y);for(var S=d.data,C=x*y*4,P=0;P<C;P+=4)S[P+3]=255}function m(x,y){v=document.createElement("canvas"),v.width=x,v.height=y,h=v.getContext("2d")}return u.drawFrame=function(y){var S=y.format;(o.width!==S.displayWidth||o.height!==S.displayHeight)&&(o.width=S.displayWidth,o.height=S.displayHeight),(d===null||d.width!=S.width||d.height!=S.height)&&g(S.width,S.height),n.convertYCbCr(y,d.data);var C=S.cropWidth!=S.displayWidth||S.cropHeight!=S.displayHeight,P;C?(v||m(S.cropWidth,S.cropHeight),P=h):P=a,P.putImageData(d,-S.cropLeft,-S.cropTop,S.cropLeft,S.cropTop,S.cropWidth,S.cropHeight),C&&a.drawImage(v,0,0,S.displayWidth,S.displayHeight)},u.clear=function(){a.clearRect(0,0,o.width,o.height)},u}r.prototype=Object.create(s.prototype),To.exports=r})()),To.exports}var Ao={exports:{}},Po,nu;function Ob(){return nu||(nu=1,Po={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
- `}),Po}var ru;function jb(){return ru||(ru=1,(function(){var s=ea(),n=Ob();function r(o){var u=this,a=r.contextForCanvas(o);if(a===null)throw new Error("WebGL unavailable");function d(q,V){var Q=a.createShader(q);if(a.shaderSource(Q,V),a.compileShader(Q),!a.getShaderParameter(Q,a.COMPILE_STATUS)){var ie=a.getShaderInfoLog(Q);throw a.deleteShader(Q),new Error("GL shader compilation for "+q+" failed: "+ie)}return Q}var v,h,g=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),m={},x={},y={},S,C,P,A,j,U,R,I,X,$;function H(q,V){return(!m[q]||V)&&(m[q]=a.createTexture()),m[q]}function G(q,V,Q,ie,se){var be=!m[q]||V,xe=H(q,V);if(a.activeTexture(a.TEXTURE0),r.stripe){var ne=!m[q+"_temp"]||V,Re=H(q+"_temp",V);a.bindTexture(a.TEXTURE_2D,Re),ne?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,Q/4,ie,0,a.RGBA,a.UNSIGNED_BYTE,se)):a.texSubImage2D(a.TEXTURE_2D,0,0,0,Q/4,ie,a.RGBA,a.UNSIGNED_BYTE,se);var Ae=m[q+"_stripe"],Fe=!Ae||V;Fe&&(Ae=H(q+"_stripe",V)),a.bindTexture(a.TEXTURE_2D,Ae),Fe&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,Q,1,0,a.RGBA,a.UNSIGNED_BYTE,B(Q)))}else a.bindTexture(a.TEXTURE_2D,xe),be?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texImage2D(a.TEXTURE_2D,0,a.ALPHA,Q,ie,0,a.ALPHA,a.UNSIGNED_BYTE,se)):a.texSubImage2D(a.TEXTURE_2D,0,0,0,Q,ie,a.ALPHA,a.UNSIGNED_BYTE,se)}function M(q,V,Q,ie){var se=m[q];a.useProgram(h);var be=x[q];(!be||V)&&(a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,se),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,Q,ie,0,a.RGBA,a.UNSIGNED_BYTE,null),be=x[q]=a.createFramebuffer()),a.bindFramebuffer(a.FRAMEBUFFER,be),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,se,0);var xe=m[q+"_temp"];a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,xe),a.uniform1i(U,1);var ne=m[q+"_stripe"];a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,ne),a.uniform1i(j,2),a.bindBuffer(a.ARRAY_BUFFER,S),a.enableVertexAttribArray(C),a.vertexAttribPointer(C,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,P),a.enableVertexAttribArray(A),a.vertexAttribPointer(A,2,a.FLOAT,!1,0,0),a.viewport(0,0,Q,ie),a.drawArrays(a.TRIANGLES,0,g.length/2),a.bindFramebuffer(a.FRAMEBUFFER,null)}function Y(q,V,Q){a.activeTexture(V),a.bindTexture(a.TEXTURE_2D,m[q]),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.uniform1i(a.getUniformLocation(v,q),Q)}function B(q){if(y[q])return y[q];for(var V=q,Q=new Uint32Array(V),ie=0;ie<V;ie+=4)Q[ie]=255,Q[ie+1]=65280,Q[ie+2]=16711680,Q[ie+3]=4278190080;return y[q]=new Uint8Array(Q.buffer)}function he(q,V){var Q=d(a.VERTEX_SHADER,q),ie=d(a.FRAGMENT_SHADER,V),se=a.createProgram();if(a.attachShader(se,Q),a.attachShader(se,ie),a.linkProgram(se),!a.getProgramParameter(se,a.LINK_STATUS)){var be=a.getProgramInfoLog(se);throw a.deleteProgram(se),new Error("GL program linking failed: "+be)}return se}function de(){if(r.stripe){h=he(n.vertexStripe,n.fragmentStripe),a.getAttribLocation(h,"aPosition"),P=a.createBuffer();var q=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);a.bindBuffer(a.ARRAY_BUFFER,P),a.bufferData(a.ARRAY_BUFFER,q,a.STATIC_DRAW),A=a.getAttribLocation(h,"aTexturePosition"),j=a.getUniformLocation(h,"uStripe"),U=a.getUniformLocation(h,"uTexture")}v=he(n.vertex,n.fragment),S=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,S),a.bufferData(a.ARRAY_BUFFER,g,a.STATIC_DRAW),C=a.getAttribLocation(v,"aPosition"),R=a.createBuffer(),I=a.getAttribLocation(v,"aLumaPosition"),X=a.createBuffer(),$=a.getAttribLocation(v,"aChromaPosition")}return u.drawFrame=function(q){var V=q.format,Q=!v||o.width!==V.displayWidth||o.height!==V.displayHeight;if(Q&&(o.width=V.displayWidth,o.height=V.displayHeight,u.clear()),v||de(),Q){var ie=function(se,be,xe){var ne=V.cropLeft/xe,Re=(V.cropLeft+V.cropWidth)/xe,Ae=(V.cropTop+V.cropHeight)/V.height,Fe=V.cropTop/V.height,Oe=new Float32Array([ne,Ae,Re,Ae,ne,Fe,ne,Fe,Re,Ae,Re,Fe]);a.bindBuffer(a.ARRAY_BUFFER,se),a.bufferData(a.ARRAY_BUFFER,Oe,a.STATIC_DRAW)};ie(R,I,q.y.stride),ie(X,$,q.u.stride*V.width/V.chromaWidth)}G("uTextureY",Q,q.y.stride,V.height,q.y.bytes),G("uTextureCb",Q,q.u.stride,V.chromaHeight,q.u.bytes),G("uTextureCr",Q,q.v.stride,V.chromaHeight,q.v.bytes),r.stripe&&(M("uTextureY",Q,q.y.stride,V.height),M("uTextureCb",Q,q.u.stride,V.chromaHeight),M("uTextureCr",Q,q.v.stride,V.chromaHeight)),a.useProgram(v),a.viewport(0,0,o.width,o.height),Y("uTextureY",a.TEXTURE0,0),Y("uTextureCb",a.TEXTURE1,1),Y("uTextureCr",a.TEXTURE2,2),a.bindBuffer(a.ARRAY_BUFFER,S),a.enableVertexAttribArray(C),a.vertexAttribPointer(C,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,R),a.enableVertexAttribArray(I),a.vertexAttribPointer(I,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,X),a.enableVertexAttribArray($),a.vertexAttribPointer($,2,a.FLOAT,!1,0,0),a.drawArrays(a.TRIANGLES,0,g.length/2)},u.clear=function(){a.viewport(0,0,o.width,o.height),a.clearColor(0,0,0,0),a.clear(a.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 a=u.TEXTURE0,d=4,v=4,h=u.createTexture(),g=new Uint8Array(d*v),m=r.stripe?d/4:d,x=r.stripe?u.RGBA:u.ALPHA,y=r.stripe?u.NEAREST:u.LINEAR;u.activeTexture(a),u.bindTexture(u.TEXTURE_2D,h),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,y),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,y),u.texImage2D(u.TEXTURE_2D,0,x,m,v,0,x,u.UNSIGNED_BYTE,g);var S=u.getError();return!S}else return!1},r.prototype=Object.create(s.prototype),Ao.exports=r})()),Ao.exports}var iu;function Fb(){return iu||(iu=1,(function(){var s=ea(),n=Mb(),r=jb(),o={FrameSink:s,SoftwareFrameSink:n,WebGLFrameSink:r,attach:function(u,a){a=a||{};var d="webGL"in a?a.webGL:r.isAvailable();return d?new r(u,a):new n(u,a)}};So.exports=o})()),So.exports}Fb();function vf(){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 bf{#e;get canvas(){return this.#e}constructor(n){n?this.#e=n:this.#e=vf()}setSize(n,r){(this.#e.width!==n||this.#e.height!==r)&&(this.#e.width=n,this.#e.height=r)}}class Bb extends bf{#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 Ub=Promise.resolve();function su(s,n){const r={powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n};return s.getContext("webgl2",r)||s.getContext("webgl",r)}class Xr extends bf{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=vf();return!!su(n)}#e;constructor(n,r){super(n);const o=su(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,Xr.vertexShaderSource),o.compileShader(u),!o.getShaderParameter(u,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(u));const a=o.createShader(o.FRAGMENT_SHADER);if(o.shaderSource(a,Xr.fragmentShaderSource),o.compileShader(a),!o.getShaderParameter(a,o.COMPILE_STATUS))throw new Error(o.getShaderInfoLog(a));const d=o.createProgram();if(o.attachShader(d,u),o.attachShader(d,a),o.linkProgram(d),!o.getProgramParameter(d,o.LINK_STATUS))throw new Error(o.getProgramInfoLog(d));o.useProgram(d);const v=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,v),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),o.STATIC_DRAW);const h=o.getAttribLocation(d,"xy");o.vertexAttribPointer(h,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(h);const g=o.createTexture();o.bindTexture(o.TEXTURE_2D,g),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),Ub}}const ou=50,Wb=300;function Gb({deviceId:s,className:n,onFallback:r,fallbackTimeout:o=5e3,enableControl:u=!1,onTapSuccess:a,onTapError:d,onSwipeSuccess:v,onSwipeError:h,onStreamReady:g}){const m=w.useRef(null),x=w.useRef(null),y=w.useRef(null),S=w.useRef(null),C=w.useRef(null),P=w.useRef(null),A=w.useRef(null),j=w.useRef(!1),U=w.useRef(!1),R=w.useRef(r),I=w.useRef(o),X=w.useRef(g),[$,H]=w.useState("connecting"),[G,M]=w.useState(null),[Y,B]=w.useState(null),[he,de]=w.useState(null),q=w.useRef(!1),V=w.useRef(null),Q=w.useRef(!1),ie=w.useRef(0),se=w.useRef(null),be=w.useRef(null),xe=w.useRef(null),ne=w.useRef(null);w.useEffect(()=>{R.current=r,I.current=o,X.current=g},[r,o,g]),w.useEffect(()=>{(async()=>{try{const ee=await pu(s);ee.success&&de({width:ee.width,height:ee.height})}catch(ee){console.error("[ScrcpyPlayer] Failed to fetch device resolution:",ee)}})()},[s]);const Re=w.useCallback(()=>{const Z=S.current,ee=y.current;if(!Z||!ee||!Y)return;const L=ee.clientWidth,K=ee.clientHeight,{width:ue,height:pe}=Y,ye=ue/pe;let ve=L,Ve=L/ye;Ve>K&&(Ve=K,ve=K*ye),Z.width=ue,Z.height=pe,Z.style.width=`${ve}px`,Z.style.height=`${Ve}px`},[Y]);w.useEffect(()=>{const Z=()=>Re();return window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[Re]),w.useEffect(()=>{Re()},[Y,Re]);const Ae=w.useCallback(async()=>{if(Xr.isSupported){const ee=new Xr;return{renderer:ee,element:ee.canvas}}const Z=new Bb;return{renderer:Z,element:Z.canvas}},[]),Fe=w.useCallback(async Z=>{if(!Qc.isSupported)throw new Error("Current browser does not support WebCodecs API. Please use the latest Chrome/Edge.");const{renderer:ee,element:L}=await Ae();return S.current=L,y.current&&!L.parentElement&&y.current.appendChild(L),new Qc({codec:Z,renderer:ee})},[Ae]),Oe=w.useCallback(()=>{j.current||(j.current=!0,C.current&&(clearTimeout(C.current),C.current=null))},[]),nt=w.useCallback(Z=>{let ee=!1,L=[];const K=new TransformStream({transform(pe,ye){if(pe.type==="configuration"){ye.enqueue(pe),ee=!0,L.length>0&&(L.forEach(ve=>ye.enqueue(ve)),L=[]);return}if(pe.type==="data"&&!ee){L.push(pe);return}ye.enqueue(pe)}});return new ReadableStream({start(pe){let ye=!1;const ve=lt=>{if(!ye)try{Oe();const ft={...lt,data:lt.data instanceof Uint8Array?lt.data:new Uint8Array(lt.data)};pe.enqueue(ft)}catch(ft){console.error("[ScrcpyPlayer] Video enqueue error:",ft),ye=!0,at()}},Ve=lt=>{ye||(pe.error(new Error(lt?.message||"Socket error")),ye=!0,at())},vt=()=>{ye||(pe.close(),ye=!0,at())},at=()=>{m.current?.off("video-data",ve),m.current?.off("error",Ve),m.current?.off("disconnect",vt)};return m.current?.on("video-data",ve),m.current?.on("error",Ve),m.current?.on("disconnect",vt),()=>{ye=!0,at()}}}).pipeThrough(K)},[Oe]),ut=w.useCallback((Z=!1)=>{if(Z&&(U.current=!0),x.current){try{x.current.dispose()}catch(ee){console.error("[ScrcpyPlayer] Failed to dispose decoder:",ee)}x.current=null}S.current=null,m.current&&(m.current.disconnect(),m.current=null),X.current?.(null),P.current&&(clearTimeout(P.current),P.current=null),C.current&&(clearTimeout(C.current),C.current=null),H("disconnected"),B(null),M(null)},[]),Ue=w.useCallback(()=>{ut(!0),j.current=!1,H("connecting"),M(null);const Z=Yi({path:"/socket.io",transports:["websocket"],timeout:1e4});m.current=Z,Z.on("connect",()=>{Z.emit("connect-device",{device_id:s,maxSize:1280,bitRate:4e6}),C.current=setTimeout(()=>{j.current||(H("error"),M("Video stream timeout"),U.current=!0,Z.close(),R.current?.())},I.current)}),Z.on("video-metadata",async ee=>{try{x.current&&(x.current.dispose(),x.current=null);const L=ee?.codec?ee.codec:Vi.H264;x.current=await Fe(L),x.current.sizeChanged(({width:ue,height:pe})=>{B({width:ue,height:pe})}),nt(ee).pipeTo(x.current.writable).catch(ue=>{console.error("[ScrcpyPlayer] Video stream error:",ue)}),H("connected"),X.current?.({close:()=>Z.close()})}catch(L){console.error("[ScrcpyPlayer] Decoder initialization failed:",L),H("error"),M("Decoder initialization failed"),U.current=!0,Z.close(),R.current?.()}}),Z.on("error",ee=>{console.error("[ScrcpyPlayer] Socket error:",ee),H("error"),M(ee?.message||"Socket error")}),Z.on("disconnect",()=>{if(U.current){U.current=!1;return}H("disconnected"),X.current?.(null),P.current||(P.current=setTimeout(()=>{P.current=null,A.current?.()},3e3))})},[s,ut,Fe,nt]);w.useEffect(()=>{A.current=Ue},[Ue]),w.useEffect(()=>(queueMicrotask(()=>{Ue()}),()=>{be.current&&(clearTimeout(be.current),be.current=null),xe.current&&(clearTimeout(xe.current),xe.current=null),ut(!0)}),[Ue,ut]);const ke=()=>{if(Y)return{width:Y.width,height:Y.height};const Z=S.current;return Z?{width:Z.width,height:Z.height}:null},pt=(Z,ee)=>{const L=S.current,K=ke();if(!L||!K)return null;const ue=L.getBoundingClientRect();if(Z<ue.left||Z>ue.right||ee<ue.top||ee>ue.bottom)return null;const pe=Z-ue.left,ye=ee-ue.top,ve=Math.round(pe/ue.width*K.width),Ve=Math.round(ye/ue.height*K.height),vt=he?he.width/K.width:1,at=he?he.height/K.height:1;return{x:Math.round(ve*vt),y:Math.round(Ve*at)}},Et=async Z=>{if(!u||$!=="connected")return;const ee=pt(Z.clientX,Z.clientY);if(ee){q.current=!0,Q.current=!1,V.current={x:Z.clientX,y:Z.clientY};try{await gx(ee.x,ee.y,s)}catch(L){console.error("[ScrcpyPlayer] Touch down failed:",L)}}},Pe=Z=>{if(!q.current||$!=="connected")return;const ee=Date.now(),L=pt(Z.clientX,Z.clientY);if(L){if(V.current){const K=Z.clientX-V.current.x,ue=Z.clientY-V.current.y;Math.hypot(K,ue)>4&&(Q.current=!0)}if(se.current=L,ee-ie.current<ou){be.current||(be.current=setTimeout(()=>{be.current=null,se.current&&(Lc(se.current.x,se.current.y,s).catch(K=>{console.error("[ScrcpyPlayer] Touch move failed:",K)}),se.current=null,ie.current=Date.now())},ou));return}ie.current=ee,Lc(L.x,L.y,s).catch(K=>{console.error("[ScrcpyPlayer] Touch move failed:",K)})}},St=async Z=>{if(!q.current||$!=="connected")return;const ee=pt(Z.clientX,Z.clientY);if(q.current=!1,V.current=null,!!ee)try{await Ic(ee.x,ee.y,s),Q.current?v?.():a?.()}catch(L){const K=String(L);Q.current?h?.(K):d?.(K)}},Xe=async Z=>{if(!q.current||$!=="connected")return;const ee=pt(Z.clientX,Z.clientY);if(q.current=!1,V.current=null,!!ee)try{await Ic(ee.x,ee.y,s)}catch(L){console.error("[ScrcpyPlayer] Touch cancel failed:",L)}},ot=Z=>{if(!u||$!=="connected")return;Z.preventDefault();const ee=Z.deltaY;ne.current||(ne.current={deltaY:0}),ne.current.deltaY+=ee,xe.current&&clearTimeout(xe.current),xe.current=setTimeout(async()=>{const L=ne.current;if(ne.current=null,!L)return;const K=S.current,ue=ke();if(!K||!ue)return;const pe=K.getBoundingClientRect(),ye=pe.left+pe.width/2,ve=pe.top+pe.height/2,Ve=pt(ye,ve);if(!Ve)return;const vt=Math.max(Math.min(L.deltaY,600),-600),at=ve+vt,lt=pt(ye,at);if(lt)try{const ft=await mx(Ve.x,Ve.y,lt.x,lt.y,300,s);ft.success?v?.():h?.(ft.error||"Scroll failed")}catch(ft){h?.(String(ft))}},Wb)};return c.jsx("div",{className:`relative w-full h-full flex items-center justify-center ${n||""}`,children:c.jsx("div",{ref:y,className:"relative w-full h-full flex items-center justify-center bg-slate-50 dark:bg-slate-900",onMouseDown:Et,onMouseMove:Pe,onMouseUp:St,onMouseLeave:Xe,onWheel:ot,children:$!=="connected"&&c.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-slate-400",children:[$==="connecting"&&"Connecting...",$==="error"&&(G||"Connection error"),$==="disconnected"&&"Disconnected"]})})})}var rs="Popover",[yf]=Vr(rs,[mu]),Qr=mu(),[Hb,Ln]=yf(rs),wf=s=>{const{__scopePopover:n,children:r,open:o,defaultOpen:u,onOpenChange:a,modal:d=!1}=s,v=Qr(n),h=w.useRef(null),[g,m]=w.useState(!1),[x,y]=$o({prop:o,defaultProp:u??!1,onChange:a,caller:rs});return c.jsx(_x,{...v,children:c.jsx(Hb,{scope:n,contentId:qo(),triggerRef:h,open:x,onOpenChange:y,onOpenToggle:w.useCallback(()=>y(S=>!S),[y]),hasCustomAnchor:g,onCustomAnchorAdd:w.useCallback(()=>m(!0),[]),onCustomAnchorRemove:w.useCallback(()=>m(!1),[]),modal:d,children:r})})};wf.displayName=rs;var Ef="PopoverAnchor",zb=w.forwardRef((s,n)=>{const{__scopePopover:r,...o}=s,u=Ln(Ef,r),a=Qr(r),{onCustomAnchorAdd:d,onCustomAnchorRemove:v}=u;return w.useEffect(()=>(d(),()=>v()),[d,v]),c.jsx(gu,{...a,...o,ref:n})});zb.displayName=Ef;var Sf="PopoverTrigger",Cf=w.forwardRef((s,n)=>{const{__scopePopover:r,...o}=s,u=Ln(Sf,r),a=Qr(r),d=en(n,u.triggerRef),v=c.jsx(jt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":u.open,"aria-controls":u.contentId,"data-state":Pf(u.open),...o,ref:d,onClick:et(s.onClick,u.onOpenToggle)});return u.hasCustomAnchor?v:c.jsx(gu,{asChild:!0,...a,children:v})});Cf.displayName=Sf;var ta="PopoverPortal",[qb,$b]=yf(ta,{forceMount:void 0}),Tf=s=>{const{__scopePopover:n,forceMount:r,children:o,container:u}=s,a=Ln(ta,n);return c.jsx(qb,{scope:n,forceMount:r,children:c.jsx(Xn,{present:r||a.open,children:c.jsx(xx,{asChild:!0,container:u,children:o})})})};Tf.displayName=ta;var pr="PopoverContent",Rf=w.forwardRef((s,n)=>{const r=$b(pr,s.__scopePopover),{forceMount:o=r.forceMount,...u}=s,a=Ln(pr,s.__scopePopover);return c.jsx(Xn,{present:o||a.open,children:a.modal?c.jsx(Yb,{...u,ref:n}):c.jsx(Vb,{...u,ref:n})})});Rf.displayName=pr;var Xb=ko("PopoverContent.RemoveScroll"),Yb=w.forwardRef((s,n)=>{const r=Ln(pr,s.__scopePopover),o=w.useRef(null),u=en(n,o),a=w.useRef(!1);return w.useEffect(()=>{const d=o.current;if(d)return Mx(d)},[]),c.jsx(Ox,{as:Xb,allowPinchZoom:!0,children:c.jsx(Nf,{...s,ref:u,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:et(s.onCloseAutoFocus,d=>{d.preventDefault(),a.current||r.triggerRef.current?.focus()}),onPointerDownOutside:et(s.onPointerDownOutside,d=>{const v=d.detail.originalEvent,h=v.button===0&&v.ctrlKey===!0,g=v.button===2||h;a.current=g},{checkForDefaultPrevented:!1}),onFocusOutside:et(s.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})}),Vb=w.forwardRef((s,n)=>{const r=Ln(pr,s.__scopePopover),o=w.useRef(!1),u=w.useRef(!1);return c.jsx(Nf,{...s,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{s.onCloseAutoFocus?.(a),a.defaultPrevented||(o.current||r.triggerRef.current?.focus(),a.preventDefault()),o.current=!1,u.current=!1},onInteractOutside:a=>{s.onInteractOutside?.(a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(u.current=!0));const d=a.target;r.triggerRef.current?.contains(d)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&u.current&&a.preventDefault()}})}),Nf=w.forwardRef((s,n)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:u,onCloseAutoFocus:a,disableOutsidePointerEvents:d,onEscapeKeyDown:v,onPointerDownOutside:h,onFocusOutside:g,onInteractOutside:m,...x}=s,y=Ln(pr,r),S=Qr(r);return jx(),c.jsx(Fx,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:u,onUnmountAutoFocus:a,children:c.jsx(vx,{asChild:!0,disableOutsidePointerEvents:d,onInteractOutside:m,onEscapeKeyDown:v,onPointerDownOutside:h,onFocusOutside:g,onDismiss:()=>y.onOpenChange(!1),children:c.jsx(bx,{"data-state":Pf(y.open),role:"dialog",id:y.contentId,...S,...x,ref:n,style:{...x.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)"}})})})}),Af="PopoverClose",Kb=w.forwardRef((s,n)=>{const{__scopePopover:r,...o}=s,u=Ln(Af,r);return c.jsx(jt.button,{type:"button",...o,ref:n,onClick:et(s.onClick,()=>u.onOpenChange(!1))})});Kb.displayName=Af;var Qb="PopoverArrow",Jb=w.forwardRef((s,n)=>{const{__scopePopover:r,...o}=s,u=Qr(r);return c.jsx(yx,{...u,...o,ref:n})});Jb.displayName=Qb;function Pf(s){return s?"open":"closed"}var Zb=wf,ey=Cf,ty=Tf,ny=Rf;function au({...s}){return c.jsx(Zb,{"data-slot":"popover",...s})}function lu({...s}){return c.jsx(ey,{"data-slot":"popover-trigger",...s})}function cu({className:s,align:n="center",sideOffset:r=4,...o}){return c.jsx(ty,{children:c.jsx(ny,{"data-slot":"popover-content",align:n,sideOffset:r,className:Yn("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",s),...o})})}function ry(s,[n,r]){return Math.min(r,Math.max(n,s))}function iy(s,n){return w.useReducer((r,o)=>n[r][o]??r,s)}var na="ScrollArea",[kf]=Vr(na),[sy,Yt]=kf(na),If=w.forwardRef((s,n)=>{const{__scopeScrollArea:r,type:o="hover",dir:u,scrollHideDelay:a=600,...d}=s,[v,h]=w.useState(null),[g,m]=w.useState(null),[x,y]=w.useState(null),[S,C]=w.useState(null),[P,A]=w.useState(null),[j,U]=w.useState(0),[R,I]=w.useState(0),[X,$]=w.useState(!1),[H,G]=w.useState(!1),M=en(n,B=>h(B)),Y=Xo(u);return c.jsx(sy,{scope:r,type:o,dir:Y,scrollHideDelay:a,scrollArea:v,viewport:g,onViewportChange:m,content:x,onContentChange:y,scrollbarX:S,onScrollbarXChange:C,scrollbarXEnabled:X,onScrollbarXEnabledChange:$,scrollbarY:P,onScrollbarYChange:A,scrollbarYEnabled:H,onScrollbarYEnabledChange:G,onCornerWidthChange:U,onCornerHeightChange:I,children:c.jsx(jt.div,{dir:Y,...d,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":R+"px",...s.style}})})});If.displayName=na;var Lf="ScrollAreaViewport",Df=w.forwardRef((s,n)=>{const{__scopeScrollArea:r,children:o,nonce:u,...a}=s,d=Yt(Lf,r),v=w.useRef(null),h=en(n,v,d.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(jt.div,{"data-radix-scroll-area-viewport":"",...a,ref:h,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...s.style},children:c.jsx("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});Df.displayName=Lf;var ln="ScrollAreaScrollbar",Mf=w.forwardRef((s,n)=>{const{forceMount:r,...o}=s,u=Yt(ln,s.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:d}=u,v=s.orientation==="horizontal";return w.useEffect(()=>(v?a(!0):d(!0),()=>{v?a(!1):d(!1)}),[v,a,d]),u.type==="hover"?c.jsx(oy,{...o,ref:n,forceMount:r}):u.type==="scroll"?c.jsx(ay,{...o,ref:n,forceMount:r}):u.type==="auto"?c.jsx(Of,{...o,ref:n,forceMount:r}):u.type==="always"?c.jsx(ra,{...o,ref:n}):null});Mf.displayName=ln;var oy=w.forwardRef((s,n)=>{const{forceMount:r,...o}=s,u=Yt(ln,s.__scopeScrollArea),[a,d]=w.useState(!1);return w.useEffect(()=>{const v=u.scrollArea;let h=0;if(v){const g=()=>{window.clearTimeout(h),d(!0)},m=()=>{h=window.setTimeout(()=>d(!1),u.scrollHideDelay)};return v.addEventListener("pointerenter",g),v.addEventListener("pointerleave",m),()=>{window.clearTimeout(h),v.removeEventListener("pointerenter",g),v.removeEventListener("pointerleave",m)}}},[u.scrollArea,u.scrollHideDelay]),c.jsx(Xn,{present:r||a,children:c.jsx(Of,{"data-state":a?"visible":"hidden",...o,ref:n})})}),ay=w.forwardRef((s,n)=>{const{forceMount:r,...o}=s,u=Yt(ln,s.__scopeScrollArea),a=s.orientation==="horizontal",d=ss(()=>h("SCROLL_END"),100),[v,h]=iy("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(v==="idle"){const g=window.setTimeout(()=>h("HIDE"),u.scrollHideDelay);return()=>window.clearTimeout(g)}},[v,u.scrollHideDelay,h]),w.useEffect(()=>{const g=u.viewport,m=a?"scrollLeft":"scrollTop";if(g){let x=g[m];const y=()=>{const S=g[m];x!==S&&(h("SCROLL"),d()),x=S};return g.addEventListener("scroll",y),()=>g.removeEventListener("scroll",y)}},[u.viewport,a,h,d]),c.jsx(Xn,{present:r||v!=="hidden",children:c.jsx(ra,{"data-state":v==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:et(s.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:et(s.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),Of=w.forwardRef((s,n)=>{const r=Yt(ln,s.__scopeScrollArea),{forceMount:o,...u}=s,[a,d]=w.useState(!1),v=s.orientation==="horizontal",h=ss(()=>{if(r.viewport){const g=r.viewport.offsetWidth<r.viewport.scrollWidth,m=r.viewport.offsetHeight<r.viewport.scrollHeight;d(v?g:m)}},10);return mr(r.viewport,h),mr(r.content,h),c.jsx(Xn,{present:o||a,children:c.jsx(ra,{"data-state":a?"visible":"hidden",...u,ref:n})})}),ra=w.forwardRef((s,n)=>{const{orientation:r="vertical",...o}=s,u=Yt(ln,s.__scopeScrollArea),a=w.useRef(null),d=w.useRef(0),[v,h]=w.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),g=Wf(v.viewport,v.content),m={...o,sizes:v,onSizesChange:h,hasThumb:g>0&&g<1,onThumbChange:y=>a.current=y,onThumbPointerUp:()=>d.current=0,onThumbPointerDown:y=>d.current=y};function x(y,S){return dy(y,d.current,v,S)}return r==="horizontal"?c.jsx(ly,{...m,ref:n,onThumbPositionChange:()=>{if(u.viewport&&a.current){const y=u.viewport.scrollLeft,S=uu(y,v,u.dir);a.current.style.transform=`translate3d(${S}px, 0, 0)`}},onWheelScroll:y=>{u.viewport&&(u.viewport.scrollLeft=y)},onDragScroll:y=>{u.viewport&&(u.viewport.scrollLeft=x(y,u.dir))}}):r==="vertical"?c.jsx(cy,{...m,ref:n,onThumbPositionChange:()=>{if(u.viewport&&a.current){const y=u.viewport.scrollTop,S=uu(y,v);a.current.style.transform=`translate3d(0, ${S}px, 0)`}},onWheelScroll:y=>{u.viewport&&(u.viewport.scrollTop=y)},onDragScroll:y=>{u.viewport&&(u.viewport.scrollTop=x(y))}}):null}),ly=w.forwardRef((s,n)=>{const{sizes:r,onSizesChange:o,...u}=s,a=Yt(ln,s.__scopeScrollArea),[d,v]=w.useState(),h=w.useRef(null),g=en(n,h,a.onScrollbarXChange);return w.useEffect(()=>{h.current&&v(getComputedStyle(h.current))},[h]),c.jsx(Ff,{"data-orientation":"horizontal",...u,ref:g,sizes:r,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":is(r)+"px",...s.style},onThumbPointerDown:m=>s.onThumbPointerDown(m.x),onDragScroll:m=>s.onDragScroll(m.x),onWheelScroll:(m,x)=>{if(a.viewport){const y=a.viewport.scrollLeft+m.deltaX;s.onWheelScroll(y),Hf(y,x)&&m.preventDefault()}},onResize:()=>{h.current&&a.viewport&&d&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Ji(d.paddingLeft),paddingEnd:Ji(d.paddingRight)}})}})}),cy=w.forwardRef((s,n)=>{const{sizes:r,onSizesChange:o,...u}=s,a=Yt(ln,s.__scopeScrollArea),[d,v]=w.useState(),h=w.useRef(null),g=en(n,h,a.onScrollbarYChange);return w.useEffect(()=>{h.current&&v(getComputedStyle(h.current))},[h]),c.jsx(Ff,{"data-orientation":"vertical",...u,ref:g,sizes:r,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":is(r)+"px",...s.style},onThumbPointerDown:m=>s.onThumbPointerDown(m.y),onDragScroll:m=>s.onDragScroll(m.y),onWheelScroll:(m,x)=>{if(a.viewport){const y=a.viewport.scrollTop+m.deltaY;s.onWheelScroll(y),Hf(y,x)&&m.preventDefault()}},onResize:()=>{h.current&&a.viewport&&d&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Ji(d.paddingTop),paddingEnd:Ji(d.paddingBottom)}})}})}),[uy,jf]=kf(ln),Ff=w.forwardRef((s,n)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:u,onThumbChange:a,onThumbPointerUp:d,onThumbPointerDown:v,onThumbPositionChange:h,onDragScroll:g,onWheelScroll:m,onResize:x,...y}=s,S=Yt(ln,r),[C,P]=w.useState(null),A=en(n,M=>P(M)),j=w.useRef(null),U=w.useRef(""),R=S.viewport,I=o.content-o.viewport,X=Pn(m),$=Pn(h),H=ss(x,10);function G(M){if(j.current){const Y=M.clientX-j.current.left,B=M.clientY-j.current.top;g({x:Y,y:B})}}return w.useEffect(()=>{const M=Y=>{const B=Y.target;C?.contains(B)&&X(Y,I)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[R,C,I,X]),w.useEffect($,[o,$]),mr(C,H),mr(S.content,H),c.jsx(uy,{scope:r,scrollbar:C,hasThumb:u,onThumbChange:Pn(a),onThumbPointerUp:Pn(d),onThumbPositionChange:$,onThumbPointerDown:Pn(v),children:c.jsx(jt.div,{...y,ref:A,style:{position:"absolute",...y.style},onPointerDown:et(s.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),j.current=C.getBoundingClientRect(),U.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),G(M))}),onPointerMove:et(s.onPointerMove,G),onPointerUp:et(s.onPointerUp,M=>{const Y=M.target;Y.hasPointerCapture(M.pointerId)&&Y.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=U.current,S.viewport&&(S.viewport.style.scrollBehavior=""),j.current=null})})})}),Qi="ScrollAreaThumb",Bf=w.forwardRef((s,n)=>{const{forceMount:r,...o}=s,u=jf(Qi,s.__scopeScrollArea);return c.jsx(Xn,{present:r||u.hasThumb,children:c.jsx(fy,{ref:n,...o})})}),fy=w.forwardRef((s,n)=>{const{__scopeScrollArea:r,style:o,...u}=s,a=Yt(Qi,r),d=jf(Qi,r),{onThumbPositionChange:v}=d,h=en(n,x=>d.onThumbChange(x)),g=w.useRef(void 0),m=ss(()=>{g.current&&(g.current(),g.current=void 0)},100);return w.useEffect(()=>{const x=a.viewport;if(x){const y=()=>{if(m(),!g.current){const S=py(x,v);g.current=S,v()}};return v(),x.addEventListener("scroll",y),()=>x.removeEventListener("scroll",y)}},[a.viewport,m,v]),c.jsx(jt.div,{"data-state":d.hasThumb?"visible":"hidden",...u,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:et(s.onPointerDownCapture,x=>{const S=x.target.getBoundingClientRect(),C=x.clientX-S.left,P=x.clientY-S.top;d.onThumbPointerDown({x:C,y:P})}),onPointerUp:et(s.onPointerUp,d.onThumbPointerUp)})});Bf.displayName=Qi;var ia="ScrollAreaCorner",Uf=w.forwardRef((s,n)=>{const r=Yt(ia,s.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?c.jsx(hy,{...s,ref:n}):null});Uf.displayName=ia;var hy=w.forwardRef((s,n)=>{const{__scopeScrollArea:r,...o}=s,u=Yt(ia,r),[a,d]=w.useState(0),[v,h]=w.useState(0),g=!!(a&&v);return mr(u.scrollbarX,()=>{const m=u.scrollbarX?.offsetHeight||0;u.onCornerHeightChange(m),h(m)}),mr(u.scrollbarY,()=>{const m=u.scrollbarY?.offsetWidth||0;u.onCornerWidthChange(m),d(m)}),g?c.jsx(jt.div,{...o,ref:n,style:{width:a,height:v,position:"absolute",right:u.dir==="ltr"?0:void 0,left:u.dir==="rtl"?0:void 0,bottom:0,...s.style}}):null});function Ji(s){return s?parseInt(s,10):0}function Wf(s,n){const r=s/n;return isNaN(r)?0:r}function is(s){const n=Wf(s.viewport,s.content),r=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=(s.scrollbar.size-r)*n;return Math.max(o,18)}function dy(s,n,r,o="ltr"){const u=is(r),a=u/2,d=n||a,v=u-d,h=r.scrollbar.paddingStart+d,g=r.scrollbar.size-r.scrollbar.paddingEnd-v,m=r.content-r.viewport,x=o==="ltr"?[0,m]:[m*-1,0];return Gf([h,g],x)(s)}function uu(s,n,r="ltr"){const o=is(n),u=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,a=n.scrollbar.size-u,d=n.content-n.viewport,v=a-o,h=r==="ltr"?[0,d]:[d*-1,0],g=ry(s,h);return Gf([0,d],[0,v])(g)}function Gf(s,n){return r=>{if(s[0]===s[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(s[1]-s[0]);return n[0]+o*(r-s[0])}}function Hf(s,n){return s>0&&s<n}var py=(s,n=()=>{})=>{let r={left:s.scrollLeft,top:s.scrollTop},o=0;return(function u(){const a={left:s.scrollLeft,top:s.scrollTop},d=r.left!==a.left,v=r.top!==a.top;(d||v)&&n(),r=a,o=window.requestAnimationFrame(u)})(),()=>window.cancelAnimationFrame(o)};function ss(s,n){const r=Pn(s),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 mr(s,n){const r=Pn(n);wx(()=>{let o=0;if(s){const u=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return u.observe(s),()=>{window.cancelAnimationFrame(o),u.unobserve(s)}}},[s,r])}var my=If,gy=Df,_y=Uf;function fu({className:s,children:n,...r}){return c.jsxs(my,{"data-slot":"scroll-area",className:Yn("relative",s),...r,children:[c.jsx(gy,{"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}),c.jsx(xy,{}),c.jsx(_y,{})]})}function xy({className:s,orientation:n="vertical",...r}){return c.jsx(Mf,{"data-slot":"scroll-area-scrollbar",orientation:n,className:Yn("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",s),...r,children:c.jsx(Bf,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const vy=100,by=20;function hu(s,n,r,o){return{id:Date.now().toString(),deviceId:s||"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(s,n){try{const r=`history-${s}`,o=localStorage.getItem(r),u=o?JSON.parse(o):[];u.unshift(n);const a=u.slice(0,vy);localStorage.setItem(r,JSON.stringify(a))}catch(r){if(r instanceof Error&&r.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old history");try{const o=`history-${s}`,u=localStorage.getItem(o),d=(u?JSON.parse(u):[]).slice(0,by);d.unshift(n),localStorage.setItem(o,JSON.stringify(d))}catch(o){console.error("Failed to save history even after reduction:",o)}}else console.warn("Failed to save history:",r)}}function yy(s){try{const n=`history-${s}`,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 wy(s,n){try{const r=`history-${s}`,o=localStorage.getItem(r);if(!o)return;const a=JSON.parse(o).filter(d=>d.id!==n);localStorage.setItem(r,JSON.stringify(a))}catch(r){console.warn("Failed to delete history item:",r)}}function Ey(s){try{const n=`history-${s}`;localStorage.removeItem(n)}catch(n){console.warn("Failed to clear history:",n)}}function Sy(s){const r=new Date().getTime()-s.getTime(),o=Math.floor(r/6e4),u=Math.floor(r/36e5),a=Math.floor(r/864e5);return o<1?"Just now":o<60?`${o}m ago`:u<24?`${u}h ago`:a<7?`${a}d ago`:s.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Cy(s){const n=Math.floor(s/1e3),r=Math.floor(n/60),o=n%60;return r===0?`${o}s`:`${r}m ${o}s`}function Ty({item:s,onSelect:n,onDelete:r}){const o=Yr(),u=a=>{a.stopPropagation(),confirm(o.history.deleteConfirm)&&r(s.id)};return c.jsx(Io,{className:"hover:bg-slate-50 dark:hover:bg-slate-800/50 transition-colors cursor-pointer group",onClick:()=>n(s),children:c.jsxs("div",{className:"p-3 space-y-2",children:[c.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2",children:s.taskText}),c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-slate-400",children:[c.jsx("span",{children:Sy(s.startTime)}),c.jsx("span",{children:"•"}),c.jsxs("span",{children:[s.steps," ",s.steps===1?"step":"steps"]}),c.jsx("span",{children:"•"}),c.jsx("span",{children:Cy(s.duration)})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx($r,{variant:s.success?"success":"destructive",className:"shrink-0",children:s.success?c.jsxs(c.Fragment,{children:[c.jsx(dr,{className:"w-3 h-3 mr-1"}),o.history.success]}):c.jsxs(c.Fragment,{children:[c.jsx(qn,{className:"w-3 h-3 mr-1"}),o.history.failed]})}),c.jsx(De,{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:c.jsx(Bx,{className:"w-3 h-3"})})]})]})]})})}function Ry({deviceId:s,deviceSerial:n,deviceName:r,config:o,isConfigured:u}){const a=Yr(),[d,v]=w.useState([]),[h,g]=w.useState(""),[m,x]=w.useState(!1),[y,S]=w.useState(!1),[C,P]=w.useState(null),[A,j]=w.useState(!1),[U,R]=w.useState(null),[I,X]=w.useState(!0),[$,H]=w.useState(!1),[G,M]=w.useState("auto"),[Y,B]=w.useState(null),[he,de]=w.useState("success"),[q,V]=w.useState(!1),[Q,ie]=w.useState([]),[se,be]=w.useState([]),[xe,ne]=w.useState(!1),Re=w.useRef(null),Ae=(z,je=2e3,Ne="success")=>{Re.current&&clearTimeout(Re.current),de(Ne),B(z),Re.current=setTimeout(()=>{B(null)},je)};w.useEffect(()=>()=>{Re.current&&clearTimeout(Re.current)},[]);const[Fe,Oe]=w.useState(!1),[nt,ut]=w.useState(!1),Ue=w.useRef(null),ke=()=>{Ue.current&&clearTimeout(Ue.current),Oe(!0)},pt=()=>{Ue.current=setTimeout(()=>{Oe(!1)},500)};w.useEffect(()=>()=>{Ue.current&&clearTimeout(Ue.current)},[]);const Et=()=>{ut(z=>!z)},Pe=w.useRef(null),St=w.useRef(null),Xe=w.useRef(null),ot=w.useRef(null),Z=w.useRef(!1),ee=w.useRef(!1),L=w.useRef(null),K=w.useRef(0),ue=w.useRef(null),[pe,ye]=w.useState(!0),[ve,Ve]=w.useState(!1),vt=w.useRef(ef.throttle(()=>{const z=ot.current;if(!z)return;const je=80,Ne=z.scrollHeight-z.scrollTop-z.clientHeight,rt=Ne<=1;ye(rt),Ne<=je&&Ve(!1)},100));w.useEffect(()=>{const z=vt.current;return()=>{z.cancel()}},[]);const at=w.useCallback(async()=>{if(o)try{await Ex({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:s}}),j(!0),P(null)}catch(z){const je=z instanceof Error?z.message:"Initialization failed";P(je)}},[s,o]);w.useEffect(()=>{u&&o&&!A&&!ee.current&&(ee.current=!0,at())},[u,o,A,at]),w.useEffect(()=>{if(q){const z=yy(n);ie(z)}},[q,n]);const lt=z=>{const je={id:`${z.id}-user`,role:"user",content:z.taskText,timestamp:z.startTime},Ne={id:`${z.id}-agent`,role:"agent",content:z.finalMessage,timestamp:z.endTime,steps:z.steps,success:z.success,thinking:z.thinking,actions:z.actions,isStreaming:!1},rt=[je,Ne];v(rt),K.current=rt.length,ue.current=[Ne.id,Ne.content?.length??0,Ne.currentThinking?.length??0,Ne.thinking?JSON.stringify(Ne.thinking).length:0,Ne.steps??"",Ne.isStreaming?1:0].join("|"),Ve(!1),ye(!0),V(!1)},ft=()=>{confirm(a.history.clearAllConfirm)&&(Ey(n),ie([]))},_r=z=>{wy(n,z),ie(je=>je.filter(Ne=>Ne.id!==z))};w.useEffect(()=>{if(!A||!o)return;const z=L.current;z&&(z.base_url!==o.base_url||z.model_name!==o.model_name||z.api_key!==o.api_key)&&(console.log(`[DevicePanel] Config changed for device ${s}, re-initializing...`),at()),L.current=o},[o,A,s,at]);const Vn=w.useCallback(async()=>{const z=h.trim();if(!z||m)return;A||await at();const je={id:Date.now().toString(),role:"user",content:z,timestamp:new Date};v(qe=>[...qe,je]),g(""),x(!0),P(null);const Ne=[],rt=[];let vn="";const Kn=[];let Ct=null;const bn=(Date.now()+1).toString(),Qn={id:bn,role:"agent",content:"",timestamp:new Date,thinking:[],actions:[],isStreaming:!0,currentThinking:""};v(qe=>[...qe,Qn]);const Jr=()=>{if(Kn.length>0){const qe=Kn.join("");Kn.length=0,vn+=qe,v(mt=>mt.map(Pt=>Pt.id===bn?{...Pt,currentThinking:vn}:Pt))}Ct=null},Cr=Sx(je.content,s,qe=>{Kn.push(qe.chunk),Ct===null&&(Ct=setTimeout(Jr,50))},qe=>{Ct!==null&&(clearTimeout(Ct),Jr());const mt=qe.thinking&&qe.thinking.length>0?qe.thinking:vn;mt&&Ne.push(mt),vn="",rt.push(qe.action),v(Pt=>Pt.map(Ft=>Ft.id===bn?{...Ft,thinking:[...Ne],actions:[...rt],steps:qe.step,currentThinking:""}:Ft))},qe=>{Ct!==null&&clearTimeout(Ct);const mt={...Qn,content:qe.message,success:qe.success,isStreaming:!1,steps:qe.steps,thinking:[...Ne],actions:[...rt],timestamp:new Date,currentThinking:void 0};v(Ft=>Ft.map(Mn=>Mn.id===bn?mt:Mn)),x(!1),Pe.current=null;const Pt=hu(n,r,je,mt);du(n,Pt)},qe=>{Ct!==null&&clearTimeout(Ct);const mt={...Qn,content:`Error: ${qe.message}`,success:!1,isStreaming:!1,thinking:[...Ne],actions:[...rt],timestamp:new Date,currentThinking:void 0};v(Ft=>Ft.map(Mn=>Mn.id===bn?mt:Mn)),x(!1),P(qe.message),Pe.current=null;const Pt=hu(n,r,je,mt);du(n,Pt)},qe=>{Ct!==null&&clearTimeout(Ct);const mt={...Qn,content:qe.message||"Chat aborted by user",success:!1,isStreaming:!1,thinking:[...Ne],actions:[...rt],timestamp:new Date,currentThinking:void 0};v(Pt=>Pt.map(Ft=>Ft.id===bn?mt:Ft)),x(!1),Pe.current=null,B(a.chat.aborted),de("success"),setTimeout(()=>B(null),2e3)});Pe.current=Cr},[h,m,A,s,n,r,at,a,B,de]),xr=w.useCallback(async()=>{Pe.current&&Pe.current.close(),v([]),x(!1),P(null),Ve(!1),ye(!0),Pe.current=null,K.current=0,ue.current=null,await Cx(s)},[s]),vr=w.useCallback(async()=>{if(Pe.current){S(!0);try{Pe.current.close(),Pe.current=null,await Tx(s),B(a.chat.aborted),de("success"),setTimeout(()=>B(null),2e3)}catch(z){console.error("Failed to abort chat:",z),B(a.chat.abortFailed),de("error"),setTimeout(()=>B(null),2e3)}finally{x(!1),S(!1)}}},[s,a]),Dn=w.useCallback(()=>{Xe.current?.scrollIntoView({behavior:"smooth"})},[]);w.useEffect(()=>{const z=d[d.length-1],je=z?.thinking?JSON.stringify(z.thinking).length:0,Ne=z?[z.id,z.content?.length??0,z.currentThinking?.length??0,je,z.steps??"",z.isStreaming?1:0].join("|"):null,rt=d.length>K.current,vn=Ne!==ue.current&&d.length>0;if(K.current=d.length,ue.current=Ne,pe){Dn(),Ve(!1);return}if(d.length===0){Ve(!1);return}(rt||vn)&&Ve(!0)},[d,pe,Dn]),w.useEffect(()=>()=>{Pe.current&&Pe.current.close(),St.current&&St.current.close()},[s]),w.useEffect(()=>{(async()=>{try{const je=await Nx();be(je.workflows)}catch(je){console.error("Failed to load workflows:",je)}})()},[]);const br=z=>{g(z.text),ne(!1)},yr=()=>{vt.current()},wr=()=>{Dn(),Ve(!1),ye(!0)};w.useEffect(()=>{if(!s||!(G==="screenshot"||G==="auto"&&$))return;const je=async()=>{if(!Z.current){Z.current=!0;try{const rt=await pu(s);rt.success&&R(rt)}catch(rt){console.error("Failed to fetch screenshot:",rt)}finally{Z.current=!1}}};je();const Ne=setInterval(je,500);return()=>clearInterval(Ne)},[s,$,G]);const Er=z=>{(z.metaKey||z.ctrlKey)&&z.key==="Enter"&&(z.preventDefault(),Vn())},os=w.useCallback(z=>{St.current=z},[]),as=w.useCallback(()=>{H(!0),X(!1)},[]),Sr=z=>{M(z)};return c.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[c.jsxs(Io,{className:"flex-1 flex flex-col min-h-0 max-w-2xl",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:c.jsx(Gi,{className:"h-5 w-5 text-[#1d9bf0]"})}),c.jsxs("div",{children:[c.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:r}),c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:s})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(au,{open:q,onOpenChange:V,children:[c.jsx(lu,{asChild:!0,children:c.jsx(De,{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:a.history.title,children:c.jsx(Dc,{className:"h-4 w-4"})})}),c.jsxs(cu,{className:"w-96 p-0",align:"end",sideOffset:8,children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[c.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:a.history.title}),Q.length>0&&c.jsx(De,{variant:"ghost",size:"sm",onClick:ft,className:"h-7 text-xs",children:a.history.clearAll})]}),c.jsx(fu,{className:"h-[400px]",children:c.jsx("div",{className:"p-4 space-y-2",children:Q.length>0?Q.map(z=>c.jsx(Ty,{item:z,onSelect:lt,onDelete:_r},z.id)):c.jsxs("div",{className:"text-center py-8",children:[c.jsx(Dc,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),c.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:a.history.noHistory}),c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:a.history.noHistoryDescription})]})})})]})]}),u?A?c.jsxs($r,{variant:"success",children:[c.jsx(dr,{className:"w-3 h-3 mr-1"}),a.devicePanel.ready]}):c.jsx(De,{onClick:at,disabled:!u||!o,size:"sm",variant:"twitter",children:a.devicePanel.initializing}):c.jsxs($r,{variant:"warning",children:[c.jsx(qn,{className:"w-3 h-3 mr-1"}),a.devicePanel.noConfig]}),c.jsx(De,{variant:"ghost",size:"icon",onClick:xr,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:c.jsx(dv,{className:"h-4 w-4"})})]})]}),C&&c.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:[c.jsx(qn,{className:"w-4 h-4 flex-shrink-0"}),C]}),c.jsxs("div",{className:"flex-1 min-h-0 relative",children:[c.jsxs("div",{className:"h-full overflow-y-auto p-4",ref:ot,onScroll:yr,children:[d.length===0?c.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center min-h-[calc(100%-1rem)]",children:[c.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mb-4",children:c.jsx(Gi,{className:"h-8 w-8 text-slate-400"})}),c.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:a.devicePanel.readyToHelp}),c.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400",children:a.devicePanel.describeTask})]}):d.map(z=>c.jsx("div",{className:`flex ${z.role==="user"?"justify-end":"justify-start"}`,children:z.role==="agent"?c.jsxs("div",{className:"max-w-[85%] space-y-3",children:[z.thinking?.map((je,Ne)=>c.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:c.jsx(Gi,{className:"h-3 w-3 text-[#1d9bf0]"})}),c.jsxs("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:["Step ",Ne+1]})]}),c.jsx("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:je}),z.actions?.[Ne]&&c.jsxs("details",{className:"mt-2 text-xs",children:[c.jsx("summary",{className:"cursor-pointer text-[#1d9bf0] hover:text-[#1a8cd8]",children:"View action"}),c.jsx("pre",{className:"mt-2 p-2 bg-slate-900 text-slate-200 rounded-lg overflow-x-auto text-xs",children:JSON.stringify(z.actions[Ne],null,2)})]})]},Ne)),z.currentThinking&&c.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 rounded-2xl rounded-tl-sm px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-[#1d9bf0]/10",children:c.jsx(Gi,{className:"h-3 w-3 text-[#1d9bf0] animate-pulse"})}),c.jsx("span",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:"Thinking..."})]}),c.jsxs("p",{className:"text-sm whitespace-pre-wrap text-slate-700 dark:text-slate-300",children:[z.currentThinking,c.jsx("span",{className:"inline-block w-1 h-4 ml-0.5 bg-[#1d9bf0] animate-pulse"})]})]}),z.content&&c.jsxs("div",{className:`
122
- rounded-2xl px-4 py-3 flex items-start gap-2
123
- ${z.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:[c.jsx(dr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${z.success===!1?"text-red-500":"text-green-500"}`}),c.jsxs("div",{children:[c.jsx("p",{className:"whitespace-pre-wrap",children:z.content}),z.steps!==void 0&&c.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[z.steps," steps completed"]})]})]}),z.isStreaming&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[c.jsx(kn,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):c.jsxs("div",{className:"max-w-[75%]",children:[c.jsx("div",{className:"chat-bubble-user px-4 py-3",children:c.jsx("p",{className:"whitespace-pre-wrap",children:z.content})}),c.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:z.timestamp.toLocaleTimeString()})]})},z.id)),c.jsx("div",{ref:Xe})]}),ve&&c.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:c.jsx(De,{onClick:wr,size:"sm",className:"pointer-events-auto shadow-lg bg-[#1d9bf0] text-white hover:bg-[#1a8cd8]","aria-label":a.devicePanel.newMessages,children:a.devicePanel.newMessages})})]}),c.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:c.jsxs("div",{className:"flex items-end gap-3",children:[c.jsx(Ux,{value:h,onChange:z=>g(z.target.value),onKeyDown:Er,placeholder:u?A?a.devicePanel.whatToDo:a.devicePanel.initDeviceFirst:a.devicePanel.configureFirst,disabled:m,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),c.jsxs(au,{open:xe,onOpenChange:ne,children:[c.jsx(lu,{asChild:!0,children:c.jsx(De,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:c.jsx(Rx,{className:"w-4 h-4"})})}),c.jsx(cu,{align:"start",className:"w-72 p-3",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("h4",{className:"font-medium text-sm",children:a.workflows.selectWorkflow}),se.length===0?c.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[c.jsx("p",{children:a.workflows.empty}),c.jsxs("p",{children:["前往"," ",c.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):c.jsx(fu,{className:"h-64",children:c.jsx("div",{className:"space-y-1",children:se.map(z=>c.jsxs("button",{onClick:()=>br(z),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[c.jsx("div",{className:"font-medium text-sm",children:z.name}),c.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:z.text})]},z.uuid))})})]})})]}),m&&c.jsx(De,{onClick:vr,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:a.chat.abortChat,children:y?c.jsx(kn,{className:"h-4 w-4 animate-spin"}):c.jsx(wv,{className:"h-4 w-4"})}),!m&&c.jsx(De,{onClick:Vn,disabled:!h.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:c.jsx(mv,{className:"h-4 w-4"})})]})})]}),c.jsxs(Io,{className:"w-[320px] flex-shrink-0 relative min-h-0 overflow-hidden bg-background",onMouseEnter:ke,onMouseLeave:pt,children:[c.jsx("div",{className:`absolute top-4 right-4 z-10 transition-opacity duration-200 ${Fe?"opacity-100":"opacity-0 pointer-events-none"}`,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.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 ${nt?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none"}`,children:[c.jsx(De,{variant:"ghost",size:"sm",onClick:()=>Sr("auto"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${G==="auto"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:a.devicePanel.auto}),c.jsxs(De,{variant:"ghost",size:"sm",onClick:()=>Sr("video"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${G==="video"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[c.jsx(Sv,{className:"w-3 h-3 mr-1"}),a.devicePanel.video]}),c.jsxs(De,{variant:"ghost",size:"sm",onClick:()=>Sr("screenshot"),className:`h-7 px-3 text-xs rounded-lg transition-colors ${G==="screenshot"?"bg-primary text-primary-foreground":"text-foreground hover:bg-accent hover:text-accent-foreground"}`,children:[c.jsx(Mc,{className:"w-3 h-3 mr-1"}),a.devicePanel.image]})]}),c.jsx(De,{variant:"ghost",size:"icon",onClick:Et,className:"h-8 w-8 rounded-full bg-popover/90 backdrop-blur border border-border shadow-lg hover:bg-accent",title:nt?"Hide controls":"Show controls",children:nt?c.jsx(Su,{className:"w-4 h-4"}):c.jsx(Eu,{className:"w-4 h-4"})})]})}),c.jsx("div",{className:"absolute bottom-4 left-4 z-10",children:c.jsxs($r,{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:[G==="auto"&&a.devicePanel.auto,G==="video"&&c.jsxs(c.Fragment,{children:[c.jsx(cv,{className:"w-3 h-3 mr-1"}),a.devicePanel.video]}),G==="screenshot"&&c.jsxs(c.Fragment,{children:[c.jsx(Mc,{className:"w-3 h-3 mr-1"}),a.devicePanel.imageRefresh]})]})}),Y&&c.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:[he==="error"&&c.jsx(qn,{className:"w-4 h-4"}),he==="tap"&&c.jsx(sv,{className:"w-4 h-4"}),he==="swipe"&&c.jsx(Gx,{className:"w-4 h-4"}),he==="success"&&c.jsx(dr,{className:"w-4 h-4"}),c.jsx("span",{children:Y})]}),G==="video"||G==="auto"&&I&&!$?c.jsx(Gb,{deviceId:s,className:"w-full h-full",enableControl:!0,onFallback:as,onTapSuccess:()=>Ae(a.devicePanel.tapped,2e3,"tap"),onTapError:z=>Ae(a.devicePanel.tapError.replace("{error}",z),3e3,"error"),onSwipeSuccess:()=>Ae(a.devicePanel.swiped,2e3,"swipe"),onSwipeError:z=>Ae(a.devicePanel.swipeError.replace("{error}",z),3e3,"error"),onStreamReady:os,fallbackTimeout:1e5}):c.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/30 min-h-0",children:U&&U.success?c.jsxs("div",{className:"relative w-full h-full flex items-center justify-center min-h-0",children:[c.jsx("img",{src:`data:image/png;base64,${U.image}`,alt:"Device Screenshot",className:"max-w-full max-h-full object-contain",style:{width:U.width>U.height?"100%":"auto",height:U.width>U.height?"auto":"100%"}}),U.is_sensitive&&c.jsx("div",{className:"absolute top-12 right-2 px-2 py-1 bg-yellow-500 text-white text-xs rounded-lg",children:a.devicePanel.sensitiveContent})]}):U?.error?c.jsxs("div",{className:"text-center text-destructive",children:[c.jsx(qn,{className:"w-8 h-8 mx-auto mb-2"}),c.jsx("p",{className:"font-medium",children:a.devicePanel.screenshotFailed}),c.jsx("p",{className:"text-xs mt-1 opacity-60",children:U.error})]}):c.jsxs("div",{className:"text-center text-muted-foreground",children:[c.jsx(kn,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),c.jsx("p",{className:"text-sm",children:a.devicePanel.loading})]})})]})]})}function Ny({message:s,type:n="info",onClose:r,duration:o=3e3}){w.useEffect(()=>{const d=setTimeout(()=>{r()},o);return()=>clearTimeout(d)},[o,r]);const u={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500"},a={success:c.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:c.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:c.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.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 c.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:c.jsxs("div",{className:`${u[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[a[n],c.jsx("span",{className:"font-medium",children:s}),c.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:c.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const Ay=[{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 My(){const s=Yr(),[n,r]=w.useState([]),[o,u]=w.useState(""),[a,d]=w.useState({message:"",type:"info",visible:!1}),v=(R,I="info")=>{d({message:R,type:I,visible:!0})},[h,g]=w.useState(null),[m,x]=w.useState(!1),[y,S]=w.useState(!1),[C,P]=w.useState({base_url:"",model_name:"",api_key:""});w.useEffect(()=>{(async()=>{try{const I=await Ax();g({base_url:I.base_url,model_name:I.model_name,api_key:I.api_key||void 0}),P({base_url:I.base_url,model_name:I.model_name,api_key:I.api_key||""}),I.base_url||x(!0)}catch(I){console.error("Failed to load config:",I),x(!0)}})()},[]),w.useEffect(()=>{const R=async()=>{try{const X=await Px(),$=new Map,H=new Map;for(const M of X.devices)if(M.serial){const Y=H.get(M.serial)||[];Y.push(M),H.set(M.serial,Y)}else $.set(M.id,M);Array.from(H.values()).forEach(M=>{const B=M.find(he=>he.connection_type==="remote")||M[0];$.set(B.id,B)});const G=Array.from($.values());r(G),G.length>0&&!o&&u(G[0].id),o&&!G.find(M=>M.id===o)&&u(G[0]?.id||"")}catch(X){console.error("Failed to load devices:",X)}};R();const I=setInterval(R,3e3);return()=>clearInterval(I)},[o]);const A=async()=>{if(!C.base_url){v(s.chat.baseUrlRequired,"error");return}try{await kx({base_url:C.base_url,model_name:C.model_name||"autoglm-phone-9b",api_key:C.api_key||void 0}),g({base_url:C.base_url,model_name:C.model_name,api_key:C.api_key||void 0}),x(!1),v(s.toasts.configSaved,"success")}catch(R){console.error("Failed to save config:",R),v(`Failed to save: ${R instanceof Error?R.message:"Unknown error"}`,"error")}},j=async R=>{try{const I=await Lx({device_id:R});I.success&&I.device_id?(u(I.device_id),v(s.toasts.wifiConnected,"success")):I.success||v(I.message||I.error||s.toasts.connectionFailed,"error")}catch(I){v(s.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",I)}},U=async R=>{try{const I=await Ix(R);I.success?v(s.toasts.wifiDisconnected,"success"):v(I.message||I.error||s.toasts.disconnectFailed,"error")}catch(I){v(s.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",I)}};return c.jsxs("div",{className:"h-full flex relative min-h-0",children:[a.visible&&c.jsx(Ny,{message:a.message,type:a.type,onClose:()=>d(R=>({...R,visible:!1}))}),c.jsx(_u,{open:m,onOpenChange:x,children:c.jsxs(xu,{className:"sm:max-w-md",children:[c.jsxs(vu,{children:[c.jsxs(bu,{className:"flex items-center gap-2",children:[c.jsx(Cu,{className:"w-5 h-5 text-[#1d9bf0]"}),s.chat.configuration]}),c.jsx(yu,{children:s.chat.configureApi})]}),c.jsxs("div",{className:"space-y-4 py-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{className:"text-sm font-medium",children:s.chat.selectPreset}),c.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ay.map(R=>c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>P({base_url:R.config.base_url,model_name:R.config.model_name,api_key:R.config.api_key}),className:`w-full text-left p-3 rounded-lg border transition-all ${C.base_url===R.config.base_url&&(R.name!=="custom"||R.name==="custom"&&C.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:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_v,{className:`w-4 h-4 ${C.base_url===R.config.base_url&&(R.name!=="custom"||R.name==="custom"&&C.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),c.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:s.presetConfigs[R.name].name})]}),c.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:s.presetConfigs[R.name].description})]}),"apiKeyUrl"in R&&c.jsx("a",{href:R.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:I=>I.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:s.chat.getApiKey||"获取 API Key",children:c.jsx(Zx,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},R.name))})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs(sn,{htmlFor:"base_url",children:[s.chat.baseUrl," *"]}),c.jsx(xn,{id:"base_url",value:C.base_url,onChange:R=>P({...C,base_url:R.target.value}),placeholder:"http://localhost:8080/v1"}),!C.base_url&&c.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[c.jsx(qn,{className:"w-3 h-3"}),s.chat.baseUrlRequired]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"api_key",children:s.chat.apiKey}),c.jsxs("div",{className:"relative",children:[c.jsx(xn,{id:"api_key",type:y?"text":"password",value:C.api_key,onChange:R=>P({...C,api_key:R.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),c.jsx(De,{type:"button",variant:"ghost",size:"icon",onClick:()=>S(!y),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:y?c.jsx(tv,{className:"w-4 h-4 text-slate-400"}):c.jsx(rv,{className:"w-4 h-4 text-slate-400"})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(sn,{htmlFor:"model_name",children:s.chat.modelName}),c.jsx(xn,{id:"model_name",value:C.model_name,onChange:R=>P({...C,model_name:R.target.value}),placeholder:"autoglm-phone-9b"})]})]}),c.jsxs(wu,{className:"sm:justify-between gap-2",children:[c.jsx(De,{variant:"outline",onClick:()=>{x(!1),h&&P({base_url:h.base_url,model_name:h.model_name,api_key:h.api_key||""})},children:s.chat.cancel}),c.jsxs(De,{onClick:A,variant:"twitter",children:[c.jsx(dr,{className:"w-4 h-4 mr-2"}),s.chat.saveConfig]})]})]})}),c.jsx(f1,{devices:n,currentDeviceId:o,onSelectDevice:u,onOpenConfig:()=>x(!0),onConnectWifi:j,onDisconnectWifi:U}),c.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4",children:n.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:c.jsxs("div",{className:"text-center",children:[c.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:c.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.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"})})}),c.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:s.chat.welcomeTitle}),c.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:s.chat.connectDevice})]})}):n.map(R=>c.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${R.id===o?"":"hidden"}`,children:c.jsx(Ry,{deviceId:R.id,deviceSerial:R.serial,deviceName:R.model,config:h,isVisible:R.id===o,isConfigured:!!h?.base_url})},R.serial))})]})}export{My as component};