@xenon-device-management/xenon 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json +1 -1
- package/lib/public/assets/{ApiKeyGate-BSN8crwz.js → ApiKeyGate-DBl_AZ8N.js} +1 -1
- package/lib/public/assets/{BugReportButton-DNja1wQ1.js → BugReportButton-Cz4aeGCX.js} +1 -1
- package/lib/public/assets/{DeviceMosaicView-DVk1IpIR.js → DeviceMosaicView-DP4AanNV.js} +1 -1
- package/lib/public/assets/{EmptyState-CqQ21n-H.js → EmptyState-BwaAbjZt.js} +1 -1
- package/lib/public/assets/{FieldGroup-DE3u01Nu.js → FieldGroup-CGdoHDQ3.js} +1 -1
- package/lib/public/assets/{Modal-BJcFdiBP.js → Modal-OY-an2g6.js} +1 -1
- package/lib/public/assets/{SegmentedControl-CSHjmrvy.js → SegmentedControl-C_gsCi2P.js} +1 -1
- package/lib/public/assets/{SettingCard-M-lFn_Wm.js → SettingCard-CRlStb6_.js} +1 -1
- package/lib/public/assets/{Table-B3EUgBi6.js → Table-CbmGiPJe.js} +1 -1
- package/lib/public/assets/{activity-DK3R5GAb.js → activity-BhRPBZ3G.js} +1 -1
- package/lib/public/assets/{ai-settings-AKMDh8pd.js → ai-settings-DteGlf4r.js} +1 -1
- package/lib/public/assets/{api-keys-B5Q1EkGN.js → api-keys-BmikiaSF.js} +1 -1
- package/lib/public/assets/{apps-CWWrkTZW.js → apps-BfEC5qsb.js} +1 -1
- package/lib/public/assets/apps-DS59NYjg.css +1 -0
- package/lib/public/assets/{arrow-left-9933DNlF.js → arrow-left-y_SSjJz-.js} +1 -1
- package/lib/public/assets/{arrow-up-right-B7q_1mXs.js → arrow-up-right-NQ8ZGfd3.js} +1 -1
- package/lib/public/assets/{builds-page-DgWXOgh5.js → builds-page-DkLt4J8-.js} +2 -2
- package/lib/public/assets/{button-lkxVyarW.js → button-wz7ra9cW.js} +1 -1
- package/lib/public/assets/{check-BkT38An9.js → check-CV94AcJF.js} +1 -1
- package/lib/public/assets/{chevron-right-WELZ1Z8v.js → chevron-right-_iIkyWqd.js} +1 -1
- package/lib/public/assets/{circle-check--2DSsfaI.js → circle-check-0COJnxUq.js} +1 -1
- package/lib/public/assets/{circle-x-x7R8vTBo.js → circle-x-DGNoObyH.js} +1 -1
- package/lib/public/assets/{clock-DIpGd4Pn.js → clock-DwtXByAH.js} +1 -1
- package/lib/public/assets/{copy-CEcFYYHm.js → copy-DL_iD5Dh.js} +1 -1
- package/lib/public/assets/device-explorer-CKcXaWmZ.css +1 -0
- package/lib/public/assets/device-explorer-CpC-MZNT.js +210 -0
- package/lib/public/assets/{download-CaKkGvKw.js → download-aeG6Qqs8.js} +1 -1
- package/lib/public/assets/{forgot-password-CsAF11d2.js → forgot-password-Cu05XOKH.js} +1 -1
- package/lib/public/assets/{funnel-D2rLIKlM.js → funnel-ChogDM6h.js} +1 -1
- package/lib/public/assets/{index-BrVV0Kla.js → index-CkwQBzCl.js} +2 -2
- package/lib/public/assets/index-gXUPv-oo.css +1 -0
- package/lib/public/assets/{layers-DZwF8z_0.js → layers-a5nj78PI.js} +1 -1
- package/lib/public/assets/{lock-CVUUnm1V.js → lock-CqQvL12G.js} +1 -1
- package/lib/public/assets/{login-BavGkTli.js → login-DoaCgEPu.js} +1 -1
- package/lib/public/assets/{maintenance-settings-Vr_u8hoR.js → maintenance-settings-CBnV_5Rl.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-n4xUMxHJ.js → mouse-pointer-2-De_oynWc.js} +1 -1
- package/lib/public/assets/{overview-DVgoOoYF.js → overview-DvyGTzku.js} +1 -1
- package/lib/public/assets/{page-header-C0pnt4xz.js → page-header-BeUDGs-O.js} +1 -1
- package/lib/public/assets/{plus-BObE-_z6.js → plus-BM5UAzcK.js} +1 -1
- package/lib/public/assets/{profile-page-DNKD4MS2.js → profile-page-Cner_Muq.js} +1 -1
- package/lib/public/assets/{reset-password-C2gSMy8a.js → reset-password-BKWBemnU.js} +1 -1
- package/lib/public/assets/{runbook-page-BRxjWJVQ.js → runbook-page-CXZdhAjc.js} +1 -1
- package/lib/public/assets/{selector-detail-page-DcV8jQuX.js → selector-detail-page-C6yA7Lwl.js} +1 -1
- package/lib/public/assets/{selector-health-DraY2a4b.js → selector-health-BWOVdnlp.js} +1 -1
- package/lib/public/assets/{selector-health-page-tb5e3CXy.js → selector-health-page-CrR7bh4f.js} +2 -2
- package/lib/public/assets/{session-detail-page-CEtQr37W.js → session-detail-page-DzW5PcxL.js} +1 -1
- package/lib/public/assets/{settings-Cr-YjLbX.js → settings-COrR3YcC.js} +1 -1
- package/lib/public/assets/{shield-BBc4qisQ.js → shield-CAA9vrIs.js} +1 -1
- package/lib/public/assets/{shield-alert-BfoPJ8q_.js → shield-alert-Dm3Oz4Kc.js} +1 -1
- package/lib/public/assets/{status-pill-outline-Cc4PF7Mg.js → status-pill-outline-3FA5raqd.js} +1 -1
- package/lib/public/assets/{tablet-CaOqzQv_.js → tablet-CWU6hxZF.js} +1 -1
- package/lib/public/assets/{teams-B3Tt_9i2.js → teams-xa_B0pyz.js} +1 -1
- package/lib/public/assets/{trash-2-CE5TRHb2.js → trash-2-DUWA0N9n.js} +1 -1
- package/lib/public/assets/{useSocket-Bkt5i-U6.js → useSocket-lsg6f_Dn.js} +1 -1
- package/lib/public/assets/{users-BIvjvjM6.js → users-DJDpKaGy.js} +1 -1
- package/lib/public/assets/{webhook-settings-dAp8wwEB.js → webhook-settings-BPf_iC_h.js} +1 -1
- package/lib/public/assets/{zap-BzdRuL9F.js → zap-D8JQHaNH.js} +1 -1
- package/lib/public/index.html +2 -2
- package/lib/src/app/routers/auth.js +19 -2
- package/lib/src/scripts/run-migrations.js +14 -3
- package/lib/test/unit/auth-me-auth-disabled.test.js +77 -0
- package/lib/test/unit/run-migrations-fail-fast.test.js +87 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/lib/public/assets/apps-Dt5dUIag.css +0 -1
- package/lib/public/assets/device-explorer-3H1hf8ld.css +0 -1
- package/lib/public/assets/device-explorer-nV6L3w7x.js +0 -210
- package/lib/public/assets/index-Dz1K6OJU.css +0 -1
package/lib/public/assets/{selector-health-page-tb5e3CXy.js → selector-health-page-CrR7bh4f.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as H,u as z,A as Q,j as e,r as h,q as le,n as P,C as re,X as k,v as A,m as oe,H as W,p as ce,I as de}from"./index-
|
|
1
|
+
import{g as H,u as z,A as Q,j as e,r as h,q as le,n as P,C as re,X as k,v as A,m as oe,H as W,p as ce,I as de}from"./index-CkwQBzCl.js";import{Z as he}from"./zap-D8JQHaNH.js";import{H as B,V as R,f as w,E as ue}from"./selector-health-BWOVdnlp.js";import{C as Y}from"./circle-check-0COJnxUq.js";import{M as me}from"./Modal-OY-an2g6.js";import{C as pe}from"./check-CV94AcJF.js";import{C as ge}from"./copy-DL_iD5Dh.js";import{u as Z}from"./useSocket-lsg6f_Dn.js";import{E as fe}from"./EmptyState-BwaAbjZt.js";import{P as ve}from"./page-header-BeUDGs-O.js";import{S as xe}from"./SegmentedControl-C_gsCi2P.js";import{F as G}from"./funnel-ChogDM6h.js";import{C as be}from"./chevron-right-_iIkyWqd.js";import{A as J}from"./arrow-up-right-NQ8ZGfd3.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{g as H,u as z,A as Q,j as e,r as h,q as le,n as P,C as re,X as k,v as A,m
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ne=[["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"}]],we=H("send",Ne),Se=[{id:"active",label:"Active",icon:he},{id:"pending",label:"Pending",icon:B,color:"var(--accent, #60a5fa)"},{id:"resolved",label:"Resolved",icon:Y,color:"var(--green, #4ade80)"},{id:"muted",label:"Muted",icon:R,color:"var(--text-muted)"}];function Ce({current:s,counts:r={}}){const i=z(),[a]=Q(),n=l=>{const c=new URLSearchParams(a);c.set("tab",l),i({search:c.toString()})};return e.jsx("nav",{className:"sh-tab-nav",role:"tablist","aria-label":"Selector Health tabs",children:Se.map(l=>{const c=r[l.id],o=l.icon;return e.jsxs("button",{type:"button",role:"tab","aria-selected":s===l.id,onClick:()=>n(l.id),className:`sh-tab ${s===l.id?"sh-tab--active":""}`,children:[e.jsx("span",{className:"sh-tab__icon","aria-hidden":"true",style:l.color?{color:l.color}:void 0,children:e.jsx(o,{size:14})}),e.jsx("span",{className:"sh-tab__label",children:l.label}),typeof c=="number"&&e.jsx("span",{className:"sh-tab__count","aria-label":`${c} ${l.label}`,children:c})]},l.id)})})}const $e={javascript:{"accessibility id":s=>`await driver.findElement('accessibility id', '${s}')`,xpath:s=>`await driver.findElement('xpath', '${s}')`,id:s=>`await driver.findElement('id', '${s}')`,name:s=>`await driver.findElement('name', '${s}')`,"class name":s=>`await driver.findElement('class name', '${s}')`,"-android uiautomator":s=>`await driver.findElement('-android uiautomator', '${s}')`,"-ios predicate string":s=>`await driver.findElement('-ios predicate string', '${s}')`,"-ios class chain":s=>`await driver.findElement('-ios class chain', '${s}')`},java:{"accessibility id":s=>`driver.findElement(AppiumBy.accessibilityId("${s}"))`,xpath:s=>`driver.findElement(AppiumBy.xpath("${s}"))`,id:s=>`driver.findElement(AppiumBy.id("${s}"))`,name:s=>`driver.findElement(AppiumBy.name("${s}"))`,"class name":s=>`driver.findElement(AppiumBy.className("${s}"))`,"-android uiautomator":s=>`driver.findElement(AppiumBy.androidUIAutomator("${s}"))`,"-ios predicate string":s=>`driver.findElement(AppiumBy.iOSNsPredicateString("${s}"))`,"-ios class chain":s=>`driver.findElement(AppiumBy.iOSClassChain("${s}"))`},python:{"accessibility id":s=>`driver.find_element(AppiumBy.ACCESSIBILITY_ID, '${s}')`,xpath:s=>`driver.find_element(AppiumBy.XPATH, '${s}')`,id:s=>`driver.find_element(AppiumBy.ID, '${s}')`,name:s=>`driver.find_element(AppiumBy.NAME, '${s}')`,"class name":s=>`driver.find_element(AppiumBy.CLASS_NAME, '${s}')`,"-android uiautomator":s=>`driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, '${s}')`,"-ios predicate string":s=>`driver.find_element(AppiumBy.IOS_PREDICATE, '${s}')`,"-ios class chain":s=>`driver.find_element(AppiumBy.IOS_CLASS_CHAIN, '${s}')`},csharp:{"accessibility id":s=>`driver.FindElement(MobileBy.AccessibilityId("${s}"))`,xpath:s=>`driver.FindElement(By.XPath("${s}"))`,id:s=>`driver.FindElement(By.Id("${s}"))`,name:s=>`driver.FindElement(By.Name("${s}"))`,"class name":s=>`driver.FindElement(By.ClassName("${s}"))`},ruby:{"accessibility id":s=>`driver.find_element(:accessibility_id, '${s}')`,xpath:s=>`driver.find_element(:xpath, '${s}')`,id:s=>`driver.find_element(:id, '${s}')`,name:s=>`driver.find_element(:name, '${s}')`,"class name":s=>`driver.find_element(:class_name, '${s}')`}};function ke(s,r){const i=s==="java"||s==="csharp",a=r.replace(/\\/g,"\\\\");return i?a.replace(/"/g,'\\"'):a.replace(/'/g,"\\'")}function ee(s,r,i){var n;if(r==="xenon:visual")return"/* Visual AI (coordinates) — no portable Appium snippet. Use snapshot view to find a stable native locator. */";const a=(n=$e[s])==null?void 0:n[r];return a?a(ke(s,i)):`${(r??"").toString().toUpperCase()}: ${i}`}const O=[{value:"javascript",short:"JS",label:"JavaScript (WebdriverIO)"},{value:"java",short:"Java",label:"Java (Appium-Java)"},{value:"python",short:"Py",label:"Python (Appium-Python)"},{value:"csharp",short:"C#",label:"C# (.NET)"},{value:"ruby",short:"Rb",label:"Ruby"}],se="xenon.copyLang";function Ae(){try{const s=localStorage.getItem(se);return s&&O.find(r=>r.value===s)?s:null}catch{return null}}function Me(s){try{localStorage.setItem(se,s)}catch{}}function D(s){var r;return((r=O.find(i=>i.value===s))==null?void 0:r.short)??s}function Ee({open:s,initialLang:r,strategy:i,value:a,onCopy:n,onClose:l}){const[c,o]=h.useState(r??"javascript"),[d,g]=h.useState(!0),x=ee(c,i,a),m=async()=>{try{await navigator.clipboard.writeText(x)}catch{}d&&Me(c),n(c,x),l()};return e.jsxs(me,{open:s,onClose:l,title:"Choose your default copy language",width:520,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn",onClick:l,children:"Cancel"}),e.jsxs("button",{type:"button",className:"sh-action-btn sh-action-btn--primary",onClick:m,children:["Copy as ",D(c)]})]}),children:[e.jsx("p",{className:"sh-copy-modal__hint",children:"Snippets will be copied in this language until you change it."}),e.jsx("ul",{className:"sh-copy-modal__lang-list",children:O.map(b=>e.jsx("li",{children:e.jsxs("label",{className:"sh-copy-modal__lang-row",children:[e.jsx("input",{type:"radio",name:"copy-lang",value:b.value,checked:c===b.value,onChange:()=>o(b.value)}),b.label]})},b.value))}),e.jsx("div",{className:"sh-copy-modal__preview-label",children:"Preview"}),e.jsx("pre",{className:"sh-copy-modal__preview",children:e.jsx("code",{children:x})}),e.jsxs("label",{className:"sh-copy-modal__remember",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:b=>g(b.target.checked)}),"Remember my choice"]})]})}function Ie({hotspot:s,onCopied:r}){const[i,a]=h.useState(!1),[n,l]=h.useState(!1),c=Ae(),o=s.suggestedStrategy??s.originalStrategy??"",d=s.suggestedRewrite??"",g=o==="xenon:visual",x=async()=>{if(!c){a(!0);return}const m=ee(c,o,d);try{await navigator.clipboard.writeText(m)}catch{}l(!0),r(c),setTimeout(()=>l(!1),1500)};return e.jsxs("span",{className:"sh-copy-group",children:[e.jsxs("button",{type:"button",className:`sh-action-btn sh-copy-btn ${n?"sh-copy-btn--copied":""}`,onClick:m=>{m.stopPropagation(),x()},disabled:g&&!d,title:g?"Visual AI heals are coordinate-based — no portable Appium snippet":c?`Copy as ${D(c)}`:"Pick a language and copy",children:[n?e.jsx(pe,{size:11}):e.jsx(ge,{size:11}),c&&!n&&e.jsx("span",{className:"sh-copy-btn__lang",children:D(c)})]}),e.jsx("button",{type:"button",className:"sh-action-btn sh-copy-chevron",onClick:m=>{m.stopPropagation(),a(!0)},title:"Choose copy language","aria-label":"Choose copy language",children:e.jsx(le,{size:11})}),e.jsx(Ee,{open:i,initialLang:c??void 0,strategy:o,value:d,onCopy:m=>{l(!0),r(m),setTimeout(()=>l(!1),1500)},onClose:()=>a(!1)})]})}function N(s){if(!s)return"";const r=Date.parse(s);if(!Number.isFinite(r))return"";const i=Math.max(0,Date.now()-r),a=Math.floor(i/1e3);if(a<60)return`${a}s ago`;const n=Math.floor(a/60);if(n<60)return`${n}m ago`;const l=Math.floor(n/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Te({hotspot:s,onCancel:r,onMute:i,onOpen:a}){const n=s.state??null,l=(n==null?void 0:n.clean_builds_count)??0,c=(n==null?void 0:n.fixed_at)??null,o=(n==null?void 0:n.fixed_by_api_key)??null;return e.jsx("div",{className:"sh-table__row sh-table__row--pending",role:"button",tabIndex:0,onClick:()=>a(s.originalSelector),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),a(s.originalSelector))},children:e.jsxs("div",{className:"sh-pending-row",children:[e.jsxs("div",{className:"sh-pending-row__head",children:[e.jsx(B,{size:14,className:"sh-pending-row__icon"}),e.jsx("span",{className:"sh-strategy-badge",children:w(s.originalStrategy)}),e.jsx("code",{className:"sh-pending-row__selector",title:s.originalSelector,children:s.originalSelector})]}),e.jsxs("div",{className:"sh-pending-row__meta",children:["Marked fixed ",N(c),o?` by ${o}`:""," • verifying…"]}),e.jsxs("div",{className:"sh-pending-progress",children:[e.jsx("div",{className:"sh-pending-progress__dots","aria-label":`${l} of 3 clean builds`,children:[0,1,2].map(d=>e.jsx("span",{className:`sh-pending-progress__dot ${d<l?"sh-pending-progress__dot--filled":""}`},d))}),e.jsxs("div",{className:"sh-pending-progress__legend",children:[l," of 3 clean CI builds since fix"]}),e.jsx("div",{className:"sh-pending-progress__hint",children:"Only sessions with a build_id count toward verification — local runs do not."})]}),e.jsxs("div",{className:"sh-pending-row__actions",children:[e.jsxs("button",{type:"button",className:"sh-action-btn",onClick:d=>{d.stopPropagation(),r(s)},title:"Revert to Active without waiting for verification",children:[e.jsx(P,{size:11})," Cancel verification"]}),e.jsx("button",{type:"button",className:"sh-action-btn",onClick:d=>{d.stopPropagation(),i(s)},title:"Mute this selector instead of verifying it",children:"Mute"})]})]})})}function Le({hotspot:s,onMute:r,onOpen:i}){const a=s.state??null,n=(a==null?void 0:a.fixed_at)??null,l=(a==null?void 0:a.resolved_at)??null,c=(a==null?void 0:a.clean_builds_count)??0,o=(a==null?void 0:a.regression_count)??0;return e.jsx("div",{className:"sh-table__row sh-table__row--resolved",role:"button",tabIndex:0,onClick:()=>i(s.originalSelector),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),i(s.originalSelector))},children:e.jsxs("div",{className:"sh-resolved-row",children:[e.jsxs("div",{className:"sh-resolved-row__head",children:[e.jsx(Y,{size:14,className:"sh-resolved-row__icon"}),e.jsx("span",{className:"sh-strategy-badge",children:w(s.originalStrategy)}),e.jsx("code",{className:"sh-resolved-row__selector",title:s.originalSelector,children:s.originalSelector}),o>0&&e.jsxs("span",{className:"sh-resolved-row__regression",title:"This selector regressed at least once before being resolved again",children:[e.jsx(re,{size:11})," Previously regressed ",o,"×"]})]}),e.jsxs("div",{className:"sh-resolved-row__meta",children:["Resolved ",N(l)," • ",c," clean build",c===1?"":"s"," since fix"]}),e.jsxs("div",{className:"sh-resolved-row__history",children:["Marked fixed ",N(n)," • Verified ",N(l)]}),e.jsx("div",{className:"sh-resolved-row__actions",children:e.jsx("button",{type:"button",className:"sh-action-btn",onClick:d=>{d.stopPropagation(),r(s)},title:"Hide this selector entirely (e.g. if it regresses again later)",children:"Mute"})})]})})}function Pe({onUnmute:s}){const[r,i]=h.useState(null),[a,n]=h.useState(!0),l=h.useCallback(async()=>{n(!0);try{const o=await k.getMutedSelectors({limit:200});i(o??null)}catch{i({muted:[],total:0,limit:200,offset:0})}finally{n(!1)}},[]);h.useEffect(()=>{l()},[l]);const c=async o=>{window.confirm(`Unmute "${o.original_selector}"?`)&&(await s(o.original_strategy,o.original_selector),l())};return a?e.jsxs("div",{className:"sh-empty",children:[e.jsx(A,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading muted selectors…"})]}):!r||r.muted.length===0?e.jsxs("div",{className:"sh-empty sh-empty--clean",children:[e.jsx(R,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"sh-empty__title",children:"Nothing muted"}),e.jsx("div",{className:"sh-empty__subtitle",children:"Selectors silenced from Hotspots, the CI gate, and digests will appear here."})]})]}):e.jsx("ul",{className:"sh-muted-list",children:r.muted.map(o=>e.jsxs("li",{className:"sh-muted-list__item",children:[e.jsxs("div",{className:"sh-muted-list__head",children:[e.jsx(R,{size:13,className:"sh-muted-list__icon"}),e.jsx("span",{className:"sh-strategy-badge",children:w(o.original_strategy)}),e.jsx("code",{className:"sh-muted-list__selector",title:o.original_selector,children:o.original_selector})]}),e.jsxs("div",{className:"sh-muted-list__meta",children:["Muted ",N(o.muted_at),o.muted_by_api_key?` by ${o.muted_by_api_key}`:"",o.last_healed_at?` • Last healed ${N(o.last_healed_at)}`:" • Never healed (pre-emptively muted)",o.regression_count>0?` • ${o.regression_count} regression${o.regression_count===1?"":"s"} on record`:""]}),e.jsx("div",{className:"sh-muted-list__actions",children:e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>c(o),children:"Unmute"})})]},`${o.original_strategy}:${o.original_selector}`))})}const Re=3e4,De=5*6e4;function He(){const{on:s}=Z(),r=z(),[i,a]=h.useState([]);if(h.useEffect(()=>{const c=s("selector_regressed",o=>{a(d=>{const g=Date.now()-De;return[...d.filter(m=>m.receivedAt>=g),{original_strategy:(o==null?void 0:o.original_strategy)??"",original_selector:(o==null?void 0:o.original_selector)??"",resolved_at:(o==null?void 0:o.resolved_at)??null,regression_count:o==null?void 0:o.regression_count,receivedAt:Date.now()}]})});return()=>{c&&c()}},[s]),h.useEffect(()=>{if(i.length===0)return;const c=setTimeout(()=>a([]),Re);return()=>clearTimeout(c)},[i]),i.length===0)return null;const n=()=>a([]),l=()=>{r("/selector-health?tab=active"),a([])};if(i.length===1){const c=i[0];return e.jsxs("div",{className:"sh-regression-banner",role:"alert",children:[e.jsx(A,{size:14,className:"sh-regression-banner__icon"}),e.jsxs("span",{children:["A previously-fixed selector regressed:"," ",e.jsxs("strong",{children:[w(c.original_strategy),": ",c.original_selector]})," ","healed again."]}),e.jsx("button",{type:"button",className:"sh-regression-banner__action",onClick:l,children:"Show in Active →"}),e.jsx("button",{type:"button",className:"sh-regression-banner__close",onClick:n,"aria-label":"Dismiss",children:e.jsx(P,{size:13})})]})}return e.jsxs("div",{className:"sh-regression-banner",role:"alert",children:[e.jsx(A,{size:14,className:"sh-regression-banner__icon"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[i.length," selectors"]})," have regressed in the last 5 minutes."]}),e.jsx("button",{type:"button",className:"sh-regression-banner__action",onClick:l,children:"Show all →"}),e.jsx("button",{type:"button",className:"sh-regression-banner__close",onClick:n,"aria-label":"Dismiss",children:e.jsx(P,{size:13})})]})}const ze=[{value:7,label:"7d"},{value:30,label:"30d"},{value:90,label:"90d"}],Be=["","LLM","Visual AI","OCR","Fuzzy XML","Resilio","Native"],Oe=["","ios","android","tvos"];function Fe(s){const r=Date.parse(s);if(!Number.isFinite(r))return"";const i=Math.max(0,Date.now()-r),a=Math.floor(i/1e3);if(a<60)return`${a}s ago`;const n=Math.floor(a/60);if(n<60)return`${n}m ago`;const l=Math.floor(n/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Ue(s){return s===0?"$0":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:s<100?`$${s.toFixed(2)}`:`$${Math.round(s)}`}function Ve(s){return s>=10?"severe":s>=5?"warn":"mild"}const E=({current:s,prior:r,invertColor:i=!1})=>{if(r===0&&s===0)return e.jsxs("span",{className:"sh-delta neutral",children:[e.jsx(q,{size:11}),"no change"]});if(r===0)return e.jsxs("span",{className:`sh-delta ${i?"good":"bad"}`,children:[e.jsx(J,{size:11}),"new"]});const a=Math.round((s-r)/r*100);if(a===0)return e.jsxs("span",{className:"sh-delta neutral",children:[e.jsx(q,{size:11}),"flat"]});const n=a>0,l=i?n:!n;return e.jsxs("span",{className:`sh-delta ${l?"good":"bad"}`,children:[n?e.jsx(J,{size:11}):e.jsx(je,{size:11}),Math.abs(a),"%"]})},y=({label:s,value:r,sub:i,delta:a,tone:n="neutral",size:l="md",hint:c})=>e.jsxs("div",{className:`sh-kpi sh-kpi--${n} sh-kpi--${l}`,children:[e.jsxs("div",{className:"sh-kpi__label",children:[s,c&&e.jsx("span",{className:"sh-kpi__info",title:c,"aria-label":c,role:"img",children:e.jsx(de,{size:11})})]}),e.jsx("div",{className:"sh-kpi__value",children:r}),(i||a)&&e.jsxs("div",{className:"sh-kpi__foot",children:[i&&e.jsx("span",{className:"sh-kpi__sub",children:i}),a&&e.jsx("span",{className:"sh-kpi__delta",children:a})]})]}),I={brittle:"Distinct selectors that needed at least one heal in the window. Lower is better.",totalHeals:"Number of times Xenon's self-heal kicked in within the selected window.",llm:"Heals that escalated all the way to an LLM. The most expensive tier — keep this small.",cost:"Estimated dollar spend on LLM heals in the window."},Ke=({summary:s,loading:r})=>{var c;const i=(s==null?void 0:s.current)??{totalHeals:0,distinctSelectors:0,sessionsTouched:0,byTier:{},estCostUsd:0},a=(s==null?void 0:s.prior)??{totalHeals:0,distinctSelectors:0,sessionsTouched:0,estCostUsd:0},n=((c=i.byTier)==null?void 0:c.LLM)??0,l=i.totalHeals>0?Math.round(n/i.totalHeals*100):0;return e.jsxs("div",{className:"sh-kpi-strip",children:[e.jsx(y,{size:"hero",label:"Brittle selectors",hint:I.brittle,value:r?"—":i.distinctSelectors.toLocaleString(),sub:"distinct selectors needing attention",delta:!r&&e.jsx(E,{current:i.distinctSelectors,prior:a.distinctSelectors}),tone:i.distinctSelectors>50?"warn":"neutral"}),e.jsx(y,{label:"Total heals",hint:I.totalHeals,value:r?"—":i.totalHeals.toLocaleString(),sub:`${(s==null?void 0:s.windowDays)??30}d window`,delta:!r&&e.jsx(E,{current:i.totalHeals,prior:a.totalHeals}),tone:i.totalHeals>a.totalHeals&&a.totalHeals>0?"warn":"neutral"}),e.jsx(y,{label:"Sessions touched",value:r?"—":i.sessionsTouched.toLocaleString(),sub:"by self-heal",delta:!r&&e.jsx(E,{current:i.sessionsTouched,prior:a.sessionsTouched})}),e.jsx(y,{label:"LLM heals",hint:I.llm,value:r?"—":n.toLocaleString(),sub:`${l}% of total`,tone:l>30?"critical":l>10?"warn":"neutral"}),e.jsx(y,{label:"Est. cost",hint:I.cost,value:r?"—":Ue(i.estCostUsd),sub:"this window",delta:!r&&e.jsx(E,{current:Math.round(i.estCostUsd*100),prior:Math.round(a.estCostUsd*100)})}),e.jsx(y,{label:"Resolved",value:r?"—":((s==null?void 0:s.resolvedCount)??0).toLocaleString(),sub:`last ${(s==null?void 0:s.windowDays)??30}d`,delta:!r&&typeof(s==null?void 0:s.pendingCount)=="number"?e.jsxs("span",{className:"sh-kpi__delta sh-kpi__delta--with-icon",children:[e.jsx(B,{size:11,style:{color:"var(--accent, #60a5fa)"}}),s.pendingCount," pending"]}):void 0,tone:"neutral"})]})},rs=()=>{const s=z(),{on:r}=Z(),{toast:i}=oe(),[a]=Q(),n=a.get("tab")??"active",[l,c]=h.useState(30),[o,d]=h.useState(""),[g,x]=h.useState(""),[m,b]=h.useState(null),[S,te]=h.useState([]),[M,F]=h.useState(!1),[U,ae]=h.useState(!1),[Xe,V]=h.useState(null),[T,K]=h.useState(!1),_=h.useCallback(async()=>{F(!0);try{const[t,u]=await Promise.all([k.getHealingSummary(l),k.getHealingHotspots({windowDays:l,limit:50,tier:o||void 0,platform:g||void 0,status:n})]);b(t??null),te(Array.isArray(u==null?void 0:u.hotspots)?u.hotspots:[])}catch{}finally{F(!1),ae(!0)}},[l,o,g,n]);h.useEffect(()=>{_()},[_]),h.useEffect(()=>{const u=["healing_event","selector_fixed","selector_resolved","selector_regressed","selector_cancelled","selector_muted","selector_unmuted","selector_progress"].map(f=>r(f,()=>_()));return()=>{u.forEach(f=>f&&f())}},[r,_]);const C=t=>{s(`/selector-health/detail?value=${encodeURIComponent(t)}&windowDays=${l}`)},j=h.useCallback(async(t,u)=>{const f=(()=>{switch(t){case"mark_fixed":return"Mark this selector as fixed? Xenon will move it to Pending Verification and watch for 3 clean CI builds.";case"mute":return"Mute this selector? It will be hidden from Hotspots, the CI gate, and digests until you unmute.";case"unmute":return"Unmute this selector?";case"cancel_verification":return"Cancel verification? The selector returns to Active and the clean-build counter resets."}})();if(window.confirm(f))try{await k.postSelectorStateAction({original_strategy:u.originalStrategy??"",original_selector:u.originalSelector,action:t});const p=(()=>{switch(t){case"mark_fixed":return"Marked fixed. Watching for clean builds.";case"mute":return"Muted.";case"unmute":return"Unmuted.";case"cancel_verification":return"Verification cancelled."}})();i(p,"success"),_()}catch(p){const $=p!=null&&p.currentStatus?` (currently ${p.currentStatus})`:"";i(`${(p==null?void 0:p.message)??"Action failed"}${$}`,"error")}},[_,i]),ie=async()=>{K(!0);try{const t=await k.sendHealingDigest({windowDays:l,limit:5,minHealCount:2}),u=(t==null?void 0:t.sent)??0,f=(t==null?void 0:t.hotspotsIncluded)??0;u===0?i("No webhook is subscribed to selector_health_digest yet. Add one in Notifications.","error"):i(`Digest sent to ${u} webhook${u===1?"":"s"} (${f} hotspot${f===1?"":"s"} included).`,"success")}catch{i("Failed to send digest. Check the server logs.","error")}finally{K(!1)}},L=!!o||!!g,ne=h.useMemo(()=>"Surface the selectors your suite quietly relies on auto-heal for. Rewrite the worst offenders to keep tests fast, cheap, and portable.",[]);return e.jsxs("div",{className:"selector-health-page",children:[e.jsx(ve,{icon:W,eyebrow:"Test Quality",title:"Selector Health",subtitle:ne,action:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-ghost-btn",onClick:ie,disabled:T,title:T?"Sending digest…":"Send digest to subscribed webhooks","aria-label":"Send digest",children:e.jsx(we,{size:14,className:T?"animate-spin":""})}),e.jsx("button",{type:"button",className:"sh-ghost-btn",onClick:_,disabled:M,title:"Refresh hotspots","aria-label":"Refresh",children:e.jsx(A,{size:14,className:M?"animate-spin":""})})]})}),e.jsxs("div",{className:"sh-content",children:[e.jsx(He,{}),e.jsx(Ke,{summary:m,loading:M&&!U}),e.jsx(Ce,{current:n,counts:{[n]:S.length}}),n==="muted"?e.jsx(Pe,{onUnmute:async(t,u)=>{await j("unmute",{originalStrategy:t,originalSelector:u})}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sh-filter-bar",children:[e.jsx("span",{className:"sh-filter-bar__lead",children:"Filter results"}),e.jsxs("div",{className:"sh-filter-bar__group",children:[e.jsx("span",{className:"sh-filter-bar__label",children:"Window"}),e.jsx(xe,{size:"sm",value:String(l),onChange:t=>c(parseInt(t,10)),segments:ze.map(t=>({value:String(t.value),label:t.label}))})]}),e.jsxs("div",{className:"sh-filter-bar__group",children:[e.jsx("span",{className:"sh-filter-bar__label",children:"Tier"}),e.jsx("select",{className:"sh-select",value:o,onChange:t=>d(t.target.value),children:Be.map(t=>e.jsx("option",{value:t,children:t||"All tiers"},t||"all"))})]}),e.jsxs("div",{className:"sh-filter-bar__group",children:[e.jsx("span",{className:"sh-filter-bar__label",children:"Platform"}),e.jsx("select",{className:"sh-select",value:g,onChange:t=>x(t.target.value),children:Oe.map(t=>e.jsx("option",{value:t,children:t?t.toUpperCase():"All platforms"},t||"all"))})]}),L&&e.jsxs("button",{type:"button",className:"sh-filter-bar__clear",onClick:()=>{d(""),x("")},children:[e.jsx(G,{size:11})," Clear filters"]})]}),M&&!U?e.jsxs("div",{className:"sh-empty",children:[e.jsx(A,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading hotspots…"})]}):S.length===0?e.jsx(fe,{icon:e.jsx(W,{size:32,color:n==="active"?"var(--green)":"var(--text-dim)"}),title:n==="pending"?"Nothing pending":n==="resolved"?"Nothing resolved yet":"Locator hygiene is clean",description:n==="pending"?"When you mark a selector fixed, it shows here while we watch for 3 clean CI builds.":n==="resolved"?"Fix a hot selector and Xenon will track its verification here.":`No selectors required healing in the last ${l} days${L?" for the active filters":""}.`,action:e.jsxs("div",{className:"sh-empty-actions",children:[L&&n==="active"&&e.jsxs("button",{type:"button",className:"sh-ghost-btn sh-ghost-btn--inline",onClick:()=>{d(""),x("")},children:[e.jsx(G,{size:12})," Reset filters"]}),e.jsxs("a",{href:"/xenon/api-docs",target:"_blank",rel:"noreferrer",className:"sh-ghost-btn sh-ghost-btn--inline",children:[e.jsx(ue,{size:12})," View API docs"]})]})}):n==="pending"?e.jsx("div",{className:"sh-pending-list",children:S.map(t=>e.jsx(Te,{hotspot:t,onCancel:u=>j("cancel_verification",u),onMute:u=>j("mute",u),onOpen:C},`${t.originalStrategy??""}\0${t.originalSelector}`))}):n==="resolved"?e.jsx("div",{className:"sh-pending-list",children:S.map(t=>e.jsx(Le,{hotspot:t,onMute:u=>j("mute",u),onOpen:C},`${t.originalStrategy??""} ${t.originalSelector}`))}):e.jsxs("div",{className:"sh-table",children:[e.jsxs("div",{className:"sh-table__head",children:[e.jsx("div",{className:"sh-th sh-th--rank",children:"#"}),e.jsx("div",{className:"sh-th sh-th--selector",children:"Original selector"}),e.jsx("div",{className:"sh-th sh-th--count",children:"Heals"}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Sessions"}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Top tier"}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Avg conf."}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Last seen"}),e.jsx("div",{className:"sh-th sh-th--rewrite",children:"Suggested rewrite"}),e.jsx("div",{className:"sh-th sh-th--actions"})]}),S.map((t,u)=>{const f=Ve(t.healCount),p=t.suggestedRewriteShare!==null?Math.round(t.suggestedRewriteShare*100):null,$=`${u}-${t.originalSelector}`;return e.jsxs("div",{className:"sh-table__row",onClick:()=>C(t.originalSelector),role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),C(t.originalSelector))},children:[e.jsx("div",{className:"sh-td sh-td--rank",children:u+1}),e.jsxs("div",{className:"sh-td sh-td--selector",children:[e.jsx("span",{className:"sh-strategy-badge",children:w(t.originalStrategy)}),e.jsx("code",{title:t.originalSelector,children:t.originalSelector})]}),e.jsx("div",{className:"sh-td sh-td--count",children:e.jsxs("span",{className:`sh-count-badge ${f}`,children:[e.jsx(ce,{size:10}),t.healCount]})}),e.jsx("div",{className:"sh-td sh-td--meta",children:t.sessionCount}),e.jsx("div",{className:"sh-td sh-td--meta",children:t.topTier?e.jsx("span",{className:"sh-tier-pill",children:t.topTier}):"—"}),e.jsx("div",{className:"sh-td sh-td--meta",children:t.averageConfidence!==null?`${Math.round(t.averageConfidence*100)}%`:"—"}),e.jsx("div",{className:"sh-td sh-td--meta",children:Fe(t.lastHealedAt)}),e.jsx("div",{className:"sh-td sh-td--rewrite",children:t.suggestedRewrite?e.jsxs(e.Fragment,{children:[p!==null&&e.jsxs("span",{className:"sh-rewrite-share",title:"Share of heals that landed on this selector",children:[p,"%"]}),t.suggestedStrategy&&e.jsx("span",{className:"sh-strategy-badge sh-strategy-badge--rewrite",title:"Strategy of the suggested rewrite",children:w(t.suggestedStrategy)}),e.jsx("code",{className:"sh-rewrite-value",title:t.suggestedRewrite,children:t.suggestedRewrite})]}):e.jsx("span",{className:"sh-rewrite-empty",children:"—"})}),e.jsxs("div",{className:"sh-td sh-td--actions",children:[t.suggestedRewrite&&e.jsx(Ie,{hotspot:t,onCopied:v=>{V($),setTimeout(()=>V(X=>X===$?null:X),1500),i(`Copied as ${v}`,"success")}}),n==="active"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn sh-action-btn--primary",onClick:v=>{v.stopPropagation(),j("mark_fixed",t)},title:"Move to Pending Verification",children:"Mark Fixed"}),e.jsx("button",{type:"button",className:"sh-action-btn sh-action-btn--ghost",onClick:v=>{v.stopPropagation(),j("mute",t)},title:"Hide from Hotspots, CI gate, and digests",children:"Mute"})]}),e.jsx("button",{type:"button",className:"sh-icon-btn",onClick:v=>{v.stopPropagation(),C(t.originalSelector)},"aria-label":"Open selector detail",title:"Drill in",children:e.jsx(be,{size:12})})]})]},$)})]})]})]})]})};export{rs as default};
|
|
16
|
+
*/const Ne=[["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"}]],we=H("send",Ne),Se=[{id:"active",label:"Active",icon:he},{id:"pending",label:"Pending",icon:B,color:"var(--accent, #60a5fa)"},{id:"resolved",label:"Resolved",icon:Y,color:"var(--green, #4ade80)"},{id:"muted",label:"Muted",icon:R,color:"var(--text-muted)"}];function Ce({current:s,counts:r={}}){const i=z(),[a]=Q(),n=l=>{const c=new URLSearchParams(a);c.set("tab",l),i({search:c.toString()})};return e.jsx("nav",{className:"sh-tab-nav",role:"tablist","aria-label":"Selector Health tabs",children:Se.map(l=>{const c=r[l.id],o=l.icon;return e.jsxs("button",{type:"button",role:"tab","aria-selected":s===l.id,onClick:()=>n(l.id),className:`sh-tab ${s===l.id?"sh-tab--active":""}`,children:[e.jsx("span",{className:"sh-tab__icon","aria-hidden":"true",style:l.color?{color:l.color}:void 0,children:e.jsx(o,{size:14})}),e.jsx("span",{className:"sh-tab__label",children:l.label}),typeof c=="number"&&e.jsx("span",{className:"sh-tab__count","aria-label":`${c} ${l.label}`,children:c})]},l.id)})})}const $e={javascript:{"accessibility id":s=>`await driver.findElement('accessibility id', '${s}')`,xpath:s=>`await driver.findElement('xpath', '${s}')`,id:s=>`await driver.findElement('id', '${s}')`,name:s=>`await driver.findElement('name', '${s}')`,"class name":s=>`await driver.findElement('class name', '${s}')`,"-android uiautomator":s=>`await driver.findElement('-android uiautomator', '${s}')`,"-ios predicate string":s=>`await driver.findElement('-ios predicate string', '${s}')`,"-ios class chain":s=>`await driver.findElement('-ios class chain', '${s}')`},java:{"accessibility id":s=>`driver.findElement(AppiumBy.accessibilityId("${s}"))`,xpath:s=>`driver.findElement(AppiumBy.xpath("${s}"))`,id:s=>`driver.findElement(AppiumBy.id("${s}"))`,name:s=>`driver.findElement(AppiumBy.name("${s}"))`,"class name":s=>`driver.findElement(AppiumBy.className("${s}"))`,"-android uiautomator":s=>`driver.findElement(AppiumBy.androidUIAutomator("${s}"))`,"-ios predicate string":s=>`driver.findElement(AppiumBy.iOSNsPredicateString("${s}"))`,"-ios class chain":s=>`driver.findElement(AppiumBy.iOSClassChain("${s}"))`},python:{"accessibility id":s=>`driver.find_element(AppiumBy.ACCESSIBILITY_ID, '${s}')`,xpath:s=>`driver.find_element(AppiumBy.XPATH, '${s}')`,id:s=>`driver.find_element(AppiumBy.ID, '${s}')`,name:s=>`driver.find_element(AppiumBy.NAME, '${s}')`,"class name":s=>`driver.find_element(AppiumBy.CLASS_NAME, '${s}')`,"-android uiautomator":s=>`driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, '${s}')`,"-ios predicate string":s=>`driver.find_element(AppiumBy.IOS_PREDICATE, '${s}')`,"-ios class chain":s=>`driver.find_element(AppiumBy.IOS_CLASS_CHAIN, '${s}')`},csharp:{"accessibility id":s=>`driver.FindElement(MobileBy.AccessibilityId("${s}"))`,xpath:s=>`driver.FindElement(By.XPath("${s}"))`,id:s=>`driver.FindElement(By.Id("${s}"))`,name:s=>`driver.FindElement(By.Name("${s}"))`,"class name":s=>`driver.FindElement(By.ClassName("${s}"))`},ruby:{"accessibility id":s=>`driver.find_element(:accessibility_id, '${s}')`,xpath:s=>`driver.find_element(:xpath, '${s}')`,id:s=>`driver.find_element(:id, '${s}')`,name:s=>`driver.find_element(:name, '${s}')`,"class name":s=>`driver.find_element(:class_name, '${s}')`}};function ke(s,r){const i=s==="java"||s==="csharp",a=r.replace(/\\/g,"\\\\");return i?a.replace(/"/g,'\\"'):a.replace(/'/g,"\\'")}function ee(s,r,i){var n;if(r==="xenon:visual")return"/* Visual AI (coordinates) — no portable Appium snippet. Use snapshot view to find a stable native locator. */";const a=(n=$e[s])==null?void 0:n[r];return a?a(ke(s,i)):`${(r??"").toString().toUpperCase()}: ${i}`}const O=[{value:"javascript",short:"JS",label:"JavaScript (WebdriverIO)"},{value:"java",short:"Java",label:"Java (Appium-Java)"},{value:"python",short:"Py",label:"Python (Appium-Python)"},{value:"csharp",short:"C#",label:"C# (.NET)"},{value:"ruby",short:"Rb",label:"Ruby"}],se="xenon.copyLang";function Ae(){try{const s=localStorage.getItem(se);return s&&O.find(r=>r.value===s)?s:null}catch{return null}}function Me(s){try{localStorage.setItem(se,s)}catch{}}function D(s){var r;return((r=O.find(i=>i.value===s))==null?void 0:r.short)??s}function Ee({open:s,initialLang:r,strategy:i,value:a,onCopy:n,onClose:l}){const[c,o]=h.useState(r??"javascript"),[d,g]=h.useState(!0),x=ee(c,i,a),m=async()=>{try{await navigator.clipboard.writeText(x)}catch{}d&&Me(c),n(c,x),l()};return e.jsxs(me,{open:s,onClose:l,title:"Choose your default copy language",width:520,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn",onClick:l,children:"Cancel"}),e.jsxs("button",{type:"button",className:"sh-action-btn sh-action-btn--primary",onClick:m,children:["Copy as ",D(c)]})]}),children:[e.jsx("p",{className:"sh-copy-modal__hint",children:"Snippets will be copied in this language until you change it."}),e.jsx("ul",{className:"sh-copy-modal__lang-list",children:O.map(b=>e.jsx("li",{children:e.jsxs("label",{className:"sh-copy-modal__lang-row",children:[e.jsx("input",{type:"radio",name:"copy-lang",value:b.value,checked:c===b.value,onChange:()=>o(b.value)}),b.label]})},b.value))}),e.jsx("div",{className:"sh-copy-modal__preview-label",children:"Preview"}),e.jsx("pre",{className:"sh-copy-modal__preview",children:e.jsx("code",{children:x})}),e.jsxs("label",{className:"sh-copy-modal__remember",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:b=>g(b.target.checked)}),"Remember my choice"]})]})}function Ie({hotspot:s,onCopied:r}){const[i,a]=h.useState(!1),[n,l]=h.useState(!1),c=Ae(),o=s.suggestedStrategy??s.originalStrategy??"",d=s.suggestedRewrite??"",g=o==="xenon:visual",x=async()=>{if(!c){a(!0);return}const m=ee(c,o,d);try{await navigator.clipboard.writeText(m)}catch{}l(!0),r(c),setTimeout(()=>l(!1),1500)};return e.jsxs("span",{className:"sh-copy-group",children:[e.jsxs("button",{type:"button",className:`sh-action-btn sh-copy-btn ${n?"sh-copy-btn--copied":""}`,onClick:m=>{m.stopPropagation(),x()},disabled:g&&!d,title:g?"Visual AI heals are coordinate-based — no portable Appium snippet":c?`Copy as ${D(c)}`:"Pick a language and copy",children:[n?e.jsx(pe,{size:11}):e.jsx(ge,{size:11}),c&&!n&&e.jsx("span",{className:"sh-copy-btn__lang",children:D(c)})]}),e.jsx("button",{type:"button",className:"sh-action-btn sh-copy-chevron",onClick:m=>{m.stopPropagation(),a(!0)},title:"Choose copy language","aria-label":"Choose copy language",children:e.jsx(le,{size:11})}),e.jsx(Ee,{open:i,initialLang:c??void 0,strategy:o,value:d,onCopy:m=>{l(!0),r(m),setTimeout(()=>l(!1),1500)},onClose:()=>a(!1)})]})}function N(s){if(!s)return"";const r=Date.parse(s);if(!Number.isFinite(r))return"";const i=Math.max(0,Date.now()-r),a=Math.floor(i/1e3);if(a<60)return`${a}s ago`;const n=Math.floor(a/60);if(n<60)return`${n}m ago`;const l=Math.floor(n/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Te({hotspot:s,onCancel:r,onMute:i,onOpen:a}){const n=s.state??null,l=(n==null?void 0:n.clean_builds_count)??0,c=(n==null?void 0:n.fixed_at)??null,o=(n==null?void 0:n.fixed_by_api_key)??null;return e.jsx("div",{className:"sh-table__row sh-table__row--pending",role:"button",tabIndex:0,onClick:()=>a(s.originalSelector),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),a(s.originalSelector))},children:e.jsxs("div",{className:"sh-pending-row",children:[e.jsxs("div",{className:"sh-pending-row__head",children:[e.jsx(B,{size:14,className:"sh-pending-row__icon"}),e.jsx("span",{className:"sh-strategy-badge",children:w(s.originalStrategy)}),e.jsx("code",{className:"sh-pending-row__selector",title:s.originalSelector,children:s.originalSelector})]}),e.jsxs("div",{className:"sh-pending-row__meta",children:["Marked fixed ",N(c),o?` by ${o}`:""," • verifying…"]}),e.jsxs("div",{className:"sh-pending-progress",children:[e.jsx("div",{className:"sh-pending-progress__dots","aria-label":`${l} of 3 clean builds`,children:[0,1,2].map(d=>e.jsx("span",{className:`sh-pending-progress__dot ${d<l?"sh-pending-progress__dot--filled":""}`},d))}),e.jsxs("div",{className:"sh-pending-progress__legend",children:[l," of 3 clean CI builds since fix"]}),e.jsx("div",{className:"sh-pending-progress__hint",children:"Only sessions with a build_id count toward verification — local runs do not."})]}),e.jsxs("div",{className:"sh-pending-row__actions",children:[e.jsxs("button",{type:"button",className:"sh-action-btn",onClick:d=>{d.stopPropagation(),r(s)},title:"Revert to Active without waiting for verification",children:[e.jsx(P,{size:11})," Cancel verification"]}),e.jsx("button",{type:"button",className:"sh-action-btn",onClick:d=>{d.stopPropagation(),i(s)},title:"Mute this selector instead of verifying it",children:"Mute"})]})]})})}function Le({hotspot:s,onMute:r,onOpen:i}){const a=s.state??null,n=(a==null?void 0:a.fixed_at)??null,l=(a==null?void 0:a.resolved_at)??null,c=(a==null?void 0:a.clean_builds_count)??0,o=(a==null?void 0:a.regression_count)??0;return e.jsx("div",{className:"sh-table__row sh-table__row--resolved",role:"button",tabIndex:0,onClick:()=>i(s.originalSelector),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),i(s.originalSelector))},children:e.jsxs("div",{className:"sh-resolved-row",children:[e.jsxs("div",{className:"sh-resolved-row__head",children:[e.jsx(Y,{size:14,className:"sh-resolved-row__icon"}),e.jsx("span",{className:"sh-strategy-badge",children:w(s.originalStrategy)}),e.jsx("code",{className:"sh-resolved-row__selector",title:s.originalSelector,children:s.originalSelector}),o>0&&e.jsxs("span",{className:"sh-resolved-row__regression",title:"This selector regressed at least once before being resolved again",children:[e.jsx(re,{size:11})," Previously regressed ",o,"×"]})]}),e.jsxs("div",{className:"sh-resolved-row__meta",children:["Resolved ",N(l)," • ",c," clean build",c===1?"":"s"," since fix"]}),e.jsxs("div",{className:"sh-resolved-row__history",children:["Marked fixed ",N(n)," • Verified ",N(l)]}),e.jsx("div",{className:"sh-resolved-row__actions",children:e.jsx("button",{type:"button",className:"sh-action-btn",onClick:d=>{d.stopPropagation(),r(s)},title:"Hide this selector entirely (e.g. if it regresses again later)",children:"Mute"})})]})})}function Pe({onUnmute:s}){const[r,i]=h.useState(null),[a,n]=h.useState(!0),l=h.useCallback(async()=>{n(!0);try{const o=await k.getMutedSelectors({limit:200});i(o??null)}catch{i({muted:[],total:0,limit:200,offset:0})}finally{n(!1)}},[]);h.useEffect(()=>{l()},[l]);const c=async o=>{window.confirm(`Unmute "${o.original_selector}"?`)&&(await s(o.original_strategy,o.original_selector),l())};return a?e.jsxs("div",{className:"sh-empty",children:[e.jsx(A,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading muted selectors…"})]}):!r||r.muted.length===0?e.jsxs("div",{className:"sh-empty sh-empty--clean",children:[e.jsx(R,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"sh-empty__title",children:"Nothing muted"}),e.jsx("div",{className:"sh-empty__subtitle",children:"Selectors silenced from Hotspots, the CI gate, and digests will appear here."})]})]}):e.jsx("ul",{className:"sh-muted-list",children:r.muted.map(o=>e.jsxs("li",{className:"sh-muted-list__item",children:[e.jsxs("div",{className:"sh-muted-list__head",children:[e.jsx(R,{size:13,className:"sh-muted-list__icon"}),e.jsx("span",{className:"sh-strategy-badge",children:w(o.original_strategy)}),e.jsx("code",{className:"sh-muted-list__selector",title:o.original_selector,children:o.original_selector})]}),e.jsxs("div",{className:"sh-muted-list__meta",children:["Muted ",N(o.muted_at),o.muted_by_api_key?` by ${o.muted_by_api_key}`:"",o.last_healed_at?` • Last healed ${N(o.last_healed_at)}`:" • Never healed (pre-emptively muted)",o.regression_count>0?` • ${o.regression_count} regression${o.regression_count===1?"":"s"} on record`:""]}),e.jsx("div",{className:"sh-muted-list__actions",children:e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>c(o),children:"Unmute"})})]},`${o.original_strategy}:${o.original_selector}`))})}const Re=3e4,De=5*6e4;function He(){const{on:s}=Z(),r=z(),[i,a]=h.useState([]);if(h.useEffect(()=>{const c=s("selector_regressed",o=>{a(d=>{const g=Date.now()-De;return[...d.filter(m=>m.receivedAt>=g),{original_strategy:(o==null?void 0:o.original_strategy)??"",original_selector:(o==null?void 0:o.original_selector)??"",resolved_at:(o==null?void 0:o.resolved_at)??null,regression_count:o==null?void 0:o.regression_count,receivedAt:Date.now()}]})});return()=>{c&&c()}},[s]),h.useEffect(()=>{if(i.length===0)return;const c=setTimeout(()=>a([]),Re);return()=>clearTimeout(c)},[i]),i.length===0)return null;const n=()=>a([]),l=()=>{r("/selector-health?tab=active"),a([])};if(i.length===1){const c=i[0];return e.jsxs("div",{className:"sh-regression-banner",role:"alert",children:[e.jsx(A,{size:14,className:"sh-regression-banner__icon"}),e.jsxs("span",{children:["A previously-fixed selector regressed:"," ",e.jsxs("strong",{children:[w(c.original_strategy),": ",c.original_selector]})," ","healed again."]}),e.jsx("button",{type:"button",className:"sh-regression-banner__action",onClick:l,children:"Show in Active →"}),e.jsx("button",{type:"button",className:"sh-regression-banner__close",onClick:n,"aria-label":"Dismiss",children:e.jsx(P,{size:13})})]})}return e.jsxs("div",{className:"sh-regression-banner",role:"alert",children:[e.jsx(A,{size:14,className:"sh-regression-banner__icon"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[i.length," selectors"]})," have regressed in the last 5 minutes."]}),e.jsx("button",{type:"button",className:"sh-regression-banner__action",onClick:l,children:"Show all →"}),e.jsx("button",{type:"button",className:"sh-regression-banner__close",onClick:n,"aria-label":"Dismiss",children:e.jsx(P,{size:13})})]})}const ze=[{value:7,label:"7d"},{value:30,label:"30d"},{value:90,label:"90d"}],Be=["","LLM","Visual AI","OCR","Fuzzy XML","Resilio","Native"],Oe=["","ios","android","tvos"];function Fe(s){const r=Date.parse(s);if(!Number.isFinite(r))return"";const i=Math.max(0,Date.now()-r),a=Math.floor(i/1e3);if(a<60)return`${a}s ago`;const n=Math.floor(a/60);if(n<60)return`${n}m ago`;const l=Math.floor(n/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Ue(s){return s===0?"$0":s<.01?"<$0.01":s<1?`$${s.toFixed(2)}`:s<100?`$${s.toFixed(2)}`:`$${Math.round(s)}`}function Ve(s){return s>=10?"severe":s>=5?"warn":"mild"}const E=({current:s,prior:r,invertColor:i=!1})=>{if(r===0&&s===0)return e.jsxs("span",{className:"sh-delta neutral",children:[e.jsx(q,{size:11}),"no change"]});if(r===0)return e.jsxs("span",{className:`sh-delta ${i?"good":"bad"}`,children:[e.jsx(J,{size:11}),"new"]});const a=Math.round((s-r)/r*100);if(a===0)return e.jsxs("span",{className:"sh-delta neutral",children:[e.jsx(q,{size:11}),"flat"]});const n=a>0,l=i?n:!n;return e.jsxs("span",{className:`sh-delta ${l?"good":"bad"}`,children:[n?e.jsx(J,{size:11}):e.jsx(je,{size:11}),Math.abs(a),"%"]})},y=({label:s,value:r,sub:i,delta:a,tone:n="neutral",size:l="md",hint:c})=>e.jsxs("div",{className:`sh-kpi sh-kpi--${n} sh-kpi--${l}`,children:[e.jsxs("div",{className:"sh-kpi__label",children:[s,c&&e.jsx("span",{className:"sh-kpi__info",title:c,"aria-label":c,role:"img",children:e.jsx(de,{size:11})})]}),e.jsx("div",{className:"sh-kpi__value",children:r}),(i||a)&&e.jsxs("div",{className:"sh-kpi__foot",children:[i&&e.jsx("span",{className:"sh-kpi__sub",children:i}),a&&e.jsx("span",{className:"sh-kpi__delta",children:a})]})]}),I={brittle:"Distinct selectors that needed at least one heal in the window. Lower is better.",totalHeals:"Number of times Xenon's self-heal kicked in within the selected window.",llm:"Heals that escalated all the way to an LLM. The most expensive tier — keep this small.",cost:"Estimated dollar spend on LLM heals in the window."},Ke=({summary:s,loading:r})=>{var c;const i=(s==null?void 0:s.current)??{totalHeals:0,distinctSelectors:0,sessionsTouched:0,byTier:{},estCostUsd:0},a=(s==null?void 0:s.prior)??{totalHeals:0,distinctSelectors:0,sessionsTouched:0,estCostUsd:0},n=((c=i.byTier)==null?void 0:c.LLM)??0,l=i.totalHeals>0?Math.round(n/i.totalHeals*100):0;return e.jsxs("div",{className:"sh-kpi-strip",children:[e.jsx(y,{size:"hero",label:"Brittle selectors",hint:I.brittle,value:r?"—":i.distinctSelectors.toLocaleString(),sub:"distinct selectors needing attention",delta:!r&&e.jsx(E,{current:i.distinctSelectors,prior:a.distinctSelectors}),tone:i.distinctSelectors>50?"warn":"neutral"}),e.jsx(y,{label:"Total heals",hint:I.totalHeals,value:r?"—":i.totalHeals.toLocaleString(),sub:`${(s==null?void 0:s.windowDays)??30}d window`,delta:!r&&e.jsx(E,{current:i.totalHeals,prior:a.totalHeals}),tone:i.totalHeals>a.totalHeals&&a.totalHeals>0?"warn":"neutral"}),e.jsx(y,{label:"Sessions touched",value:r?"—":i.sessionsTouched.toLocaleString(),sub:"by self-heal",delta:!r&&e.jsx(E,{current:i.sessionsTouched,prior:a.sessionsTouched})}),e.jsx(y,{label:"LLM heals",hint:I.llm,value:r?"—":n.toLocaleString(),sub:`${l}% of total`,tone:l>30?"critical":l>10?"warn":"neutral"}),e.jsx(y,{label:"Est. cost",hint:I.cost,value:r?"—":Ue(i.estCostUsd),sub:"this window",delta:!r&&e.jsx(E,{current:Math.round(i.estCostUsd*100),prior:Math.round(a.estCostUsd*100)})}),e.jsx(y,{label:"Resolved",value:r?"—":((s==null?void 0:s.resolvedCount)??0).toLocaleString(),sub:`last ${(s==null?void 0:s.windowDays)??30}d`,delta:!r&&typeof(s==null?void 0:s.pendingCount)=="number"?e.jsxs("span",{className:"sh-kpi__delta sh-kpi__delta--with-icon",children:[e.jsx(B,{size:11,style:{color:"var(--accent, #60a5fa)"}}),s.pendingCount," pending"]}):void 0,tone:"neutral"})]})},rs=()=>{const s=z(),{on:r}=Z(),{toast:i}=oe(),[a]=Q(),n=a.get("tab")??"active",[l,c]=h.useState(30),[o,d]=h.useState(""),[g,x]=h.useState(""),[m,b]=h.useState(null),[S,te]=h.useState([]),[M,F]=h.useState(!1),[U,ae]=h.useState(!1),[Xe,V]=h.useState(null),[T,K]=h.useState(!1),_=h.useCallback(async()=>{F(!0);try{const[t,u]=await Promise.all([k.getHealingSummary(l),k.getHealingHotspots({windowDays:l,limit:50,tier:o||void 0,platform:g||void 0,status:n})]);b(t??null),te(Array.isArray(u==null?void 0:u.hotspots)?u.hotspots:[])}catch{}finally{F(!1),ae(!0)}},[l,o,g,n]);h.useEffect(()=>{_()},[_]),h.useEffect(()=>{const u=["healing_event","selector_fixed","selector_resolved","selector_regressed","selector_cancelled","selector_muted","selector_unmuted","selector_progress"].map(f=>r(f,()=>_()));return()=>{u.forEach(f=>f&&f())}},[r,_]);const C=t=>{s(`/selector-health/detail?value=${encodeURIComponent(t)}&windowDays=${l}`)},j=h.useCallback(async(t,u)=>{const f=(()=>{switch(t){case"mark_fixed":return"Mark this selector as fixed? Xenon will move it to Pending Verification and watch for 3 clean CI builds.";case"mute":return"Mute this selector? It will be hidden from Hotspots, the CI gate, and digests until you unmute.";case"unmute":return"Unmute this selector?";case"cancel_verification":return"Cancel verification? The selector returns to Active and the clean-build counter resets."}})();if(window.confirm(f))try{await k.postSelectorStateAction({original_strategy:u.originalStrategy??"",original_selector:u.originalSelector,action:t});const p=(()=>{switch(t){case"mark_fixed":return"Marked fixed. Watching for clean builds.";case"mute":return"Muted.";case"unmute":return"Unmuted.";case"cancel_verification":return"Verification cancelled."}})();i(p,"success"),_()}catch(p){const $=p!=null&&p.currentStatus?` (currently ${p.currentStatus})`:"";i(`${(p==null?void 0:p.message)??"Action failed"}${$}`,"error")}},[_,i]),ie=async()=>{K(!0);try{const t=await k.sendHealingDigest({windowDays:l,limit:5,minHealCount:2}),u=(t==null?void 0:t.sent)??0,f=(t==null?void 0:t.hotspotsIncluded)??0;u===0?i("No webhook is subscribed to selector_health_digest yet. Add one in Notifications.","error"):i(`Digest sent to ${u} webhook${u===1?"":"s"} (${f} hotspot${f===1?"":"s"} included).`,"success")}catch{i("Failed to send digest. Check the server logs.","error")}finally{K(!1)}},L=!!o||!!g,ne=h.useMemo(()=>"Surface the selectors your suite quietly relies on auto-heal for. Rewrite the worst offenders to keep tests fast, cheap, and portable.",[]);return e.jsxs("div",{className:"selector-health-page",children:[e.jsx(ve,{icon:W,eyebrow:"Test Quality",title:"Selector Health",subtitle:ne,action:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-ghost-btn",onClick:ie,disabled:T,title:T?"Sending digest…":"Send digest to subscribed webhooks","aria-label":"Send digest",children:e.jsx(we,{size:14,className:T?"animate-spin":""})}),e.jsx("button",{type:"button",className:"sh-ghost-btn",onClick:_,disabled:M,title:"Refresh hotspots","aria-label":"Refresh",children:e.jsx(A,{size:14,className:M?"animate-spin":""})})]})}),e.jsxs("div",{className:"sh-content",children:[e.jsx(He,{}),e.jsx(Ke,{summary:m,loading:M&&!U}),e.jsx(Ce,{current:n,counts:{[n]:S.length}}),n==="muted"?e.jsx(Pe,{onUnmute:async(t,u)=>{await j("unmute",{originalStrategy:t,originalSelector:u})}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sh-filter-bar",children:[e.jsx("span",{className:"sh-filter-bar__lead",children:"Filter results"}),e.jsxs("div",{className:"sh-filter-bar__group",children:[e.jsx("span",{className:"sh-filter-bar__label",children:"Window"}),e.jsx(xe,{size:"sm",value:String(l),onChange:t=>c(parseInt(t,10)),segments:ze.map(t=>({value:String(t.value),label:t.label}))})]}),e.jsxs("div",{className:"sh-filter-bar__group",children:[e.jsx("span",{className:"sh-filter-bar__label",children:"Tier"}),e.jsx("select",{className:"sh-select",value:o,onChange:t=>d(t.target.value),children:Be.map(t=>e.jsx("option",{value:t,children:t||"All tiers"},t||"all"))})]}),e.jsxs("div",{className:"sh-filter-bar__group",children:[e.jsx("span",{className:"sh-filter-bar__label",children:"Platform"}),e.jsx("select",{className:"sh-select",value:g,onChange:t=>x(t.target.value),children:Oe.map(t=>e.jsx("option",{value:t,children:t?t.toUpperCase():"All platforms"},t||"all"))})]}),L&&e.jsxs("button",{type:"button",className:"sh-filter-bar__clear",onClick:()=>{d(""),x("")},children:[e.jsx(G,{size:11})," Clear filters"]})]}),M&&!U?e.jsxs("div",{className:"sh-empty",children:[e.jsx(A,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading hotspots…"})]}):S.length===0?e.jsx(fe,{icon:e.jsx(W,{size:32,color:n==="active"?"var(--green)":"var(--text-dim)"}),title:n==="pending"?"Nothing pending":n==="resolved"?"Nothing resolved yet":"Locator hygiene is clean",description:n==="pending"?"When you mark a selector fixed, it shows here while we watch for 3 clean CI builds.":n==="resolved"?"Fix a hot selector and Xenon will track its verification here.":`No selectors required healing in the last ${l} days${L?" for the active filters":""}.`,action:e.jsxs("div",{className:"sh-empty-actions",children:[L&&n==="active"&&e.jsxs("button",{type:"button",className:"sh-ghost-btn sh-ghost-btn--inline",onClick:()=>{d(""),x("")},children:[e.jsx(G,{size:12})," Reset filters"]}),e.jsxs("a",{href:"/xenon/api-docs",target:"_blank",rel:"noreferrer",className:"sh-ghost-btn sh-ghost-btn--inline",children:[e.jsx(ue,{size:12})," View API docs"]})]})}):n==="pending"?e.jsx("div",{className:"sh-pending-list",children:S.map(t=>e.jsx(Te,{hotspot:t,onCancel:u=>j("cancel_verification",u),onMute:u=>j("mute",u),onOpen:C},`${t.originalStrategy??""} ${t.originalSelector}`))}):n==="resolved"?e.jsx("div",{className:"sh-pending-list",children:S.map(t=>e.jsx(Le,{hotspot:t,onMute:u=>j("mute",u),onOpen:C},`${t.originalStrategy??""} ${t.originalSelector}`))}):e.jsxs("div",{className:"sh-table",children:[e.jsxs("div",{className:"sh-table__head",children:[e.jsx("div",{className:"sh-th sh-th--rank",children:"#"}),e.jsx("div",{className:"sh-th sh-th--selector",children:"Original selector"}),e.jsx("div",{className:"sh-th sh-th--count",children:"Heals"}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Sessions"}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Top tier"}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Avg conf."}),e.jsx("div",{className:"sh-th sh-th--meta",children:"Last seen"}),e.jsx("div",{className:"sh-th sh-th--rewrite",children:"Suggested rewrite"}),e.jsx("div",{className:"sh-th sh-th--actions"})]}),S.map((t,u)=>{const f=Ve(t.healCount),p=t.suggestedRewriteShare!==null?Math.round(t.suggestedRewriteShare*100):null,$=`${u}-${t.originalSelector}`;return e.jsxs("div",{className:"sh-table__row",onClick:()=>C(t.originalSelector),role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),C(t.originalSelector))},children:[e.jsx("div",{className:"sh-td sh-td--rank",children:u+1}),e.jsxs("div",{className:"sh-td sh-td--selector",children:[e.jsx("span",{className:"sh-strategy-badge",children:w(t.originalStrategy)}),e.jsx("code",{title:t.originalSelector,children:t.originalSelector})]}),e.jsx("div",{className:"sh-td sh-td--count",children:e.jsxs("span",{className:`sh-count-badge ${f}`,children:[e.jsx(ce,{size:10}),t.healCount]})}),e.jsx("div",{className:"sh-td sh-td--meta",children:t.sessionCount}),e.jsx("div",{className:"sh-td sh-td--meta",children:t.topTier?e.jsx("span",{className:"sh-tier-pill",children:t.topTier}):"—"}),e.jsx("div",{className:"sh-td sh-td--meta",children:t.averageConfidence!==null?`${Math.round(t.averageConfidence*100)}%`:"—"}),e.jsx("div",{className:"sh-td sh-td--meta",children:Fe(t.lastHealedAt)}),e.jsx("div",{className:"sh-td sh-td--rewrite",children:t.suggestedRewrite?e.jsxs(e.Fragment,{children:[p!==null&&e.jsxs("span",{className:"sh-rewrite-share",title:"Share of heals that landed on this selector",children:[p,"%"]}),t.suggestedStrategy&&e.jsx("span",{className:"sh-strategy-badge sh-strategy-badge--rewrite",title:"Strategy of the suggested rewrite",children:w(t.suggestedStrategy)}),e.jsx("code",{className:"sh-rewrite-value",title:t.suggestedRewrite,children:t.suggestedRewrite})]}):e.jsx("span",{className:"sh-rewrite-empty",children:"—"})}),e.jsxs("div",{className:"sh-td sh-td--actions",children:[t.suggestedRewrite&&e.jsx(Ie,{hotspot:t,onCopied:v=>{V($),setTimeout(()=>V(X=>X===$?null:X),1500),i(`Copied as ${v}`,"success")}}),n==="active"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn sh-action-btn--primary",onClick:v=>{v.stopPropagation(),j("mark_fixed",t)},title:"Move to Pending Verification",children:"Mark Fixed"}),e.jsx("button",{type:"button",className:"sh-action-btn sh-action-btn--ghost",onClick:v=>{v.stopPropagation(),j("mute",t)},title:"Hide from Hotspots, CI gate, and digests",children:"Mute"})]}),e.jsx("button",{type:"button",className:"sh-icon-btn",onClick:v=>{v.stopPropagation(),C(t.originalSelector)},"aria-label":"Open selector detail",title:"Drill in",children:e.jsx(be,{size:12})})]})]},$)})]})]})]})]})};export{rs as default};
|
package/lib/public/assets/{session-detail-page-CEtQr37W.js → session-detail-page-DzW5PcxL.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as z,r as d,X as _,m as D,j as e,L as B,p as G,c as Y,u as Q}from"./index-
|
|
1
|
+
import{g as z,r as d,X as _,m as D,j as e,L as B,p as G,c as Y,u as Q}from"./index-CkwQBzCl.js";import{u as q,h as Z,a as ee,d as te,p as re,o as se,f as ae,S as ne}from"./status-pill-outline-3FA5raqd.js";import{B as ie,P as j}from"./BugReportButton-Cz4aeGCX.js";import{A as oe}from"./arrow-left-y_SSjJz-.js";import{C as $}from"./chevron-right-_iIkyWqd.js";import{C as L}from"./copy-DL_iD5Dh.js";import{A as le}from"./arrow-up-right-NQ8ZGfd3.js";import{E}from"./EmptyState-BwaAbjZt.js";import{T as ce,a as de,b as M,c as S,d as xe,e as R}from"./Table-CbmGiPJe.js";import{u as ue}from"./useSocket-lsg6f_Dn.js";import{M as me}from"./Modal-OY-an2g6.js";import{D as fe}from"./download-aeG6Qqs8.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as R,r as c,X as m,j as e,v as F,C as T,L as B,y as P}from"./index-
|
|
1
|
+
import{m as R,r as c,X as m,j as e,v as F,C as T,L as B,y as P}from"./index-CkwQBzCl.js";/* empty css */import{S as x,A as q}from"./SettingCard-CRlStb6_.js";import{P as X}from"./page-header-BeUDGs-O.js";import{u as V}from"./useSocket-lsg6f_Dn.js";import{S as G,C as O}from"./shield-CAA9vrIs.js";import{C as _}from"./circle-check-0COJnxUq.js";import{C as U}from"./clock-DwtXByAH.js";import{M as W,F as K}from"./mouse-pointer-2-De_oynWc.js";import{C as J}from"./check-CV94AcJF.js";import{A as Q}from"./activity-BhRPBZ3G.js";import{A as Y}from"./arrow-up-right-NQ8ZGfd3.js";const f={healthCheckIntervalMs:3e4,healthCheckSchedule:"",enableSelfHealing:!0},j=5e3,Z=[{label:"Battery Saver (2 AM)",value:"0 2 * * *"},{label:"Standard (Hourly)",value:"0 * * * *"},{label:"Operational Coverage (30m)",value:"*/30 * * * *"},{label:"High Performance (10m)",value:"*/10 * * * *"}],S=5;function ee(t){const s=Date.parse(t);if(!Number.isFinite(s))return"";const n=Math.max(0,Date.now()-s),l=Math.floor(n/1e3);if(l<60)return`${l}s ago`;const o=Math.floor(l/60);if(o<60)return`${o}m ago`;const h=Math.floor(o/60);return h<24?`${h}h ago`:`${Math.floor(h/24)}d ago`}function A(t){var h,u;const s=(h=t.originalSelector)==null?void 0:h.trim(),n=(u=t.healedSelector)==null?void 0:u.trim(),l=t.tier&&t.commandName?`${t.commandName}: `:"";if(s&&n&&s!==n)return`${l}${s} → ${n}`;if(n)return`${l}Recovered locator ${n}`;if(s)return`${l}Recovered locator ${s}`;const o=typeof t.confidence=="number"?` (${Math.round(t.confidence*100)}%)`:"";return`${l||""}Self-healed${o}`}function ae(t){return t.tier?t.tier:t.commandName?t.commandName:t.deviceName?t.deviceName:"Self-heal"}const se=(t,s)=>t.healthCheckIntervalMs===s.healthCheckIntervalMs&&t.healthCheckSchedule===s.healthCheckSchedule&&t.enableSelfHealing===s.enableSelfHealing,ge=()=>{const{toast:t}=R(),[s,n]=c.useState(f),[l,o]=c.useState(f),[h,u]=c.useState(!0),[N,C]=c.useState(!1),[b,y]=c.useState([]),[E,H]=c.useState(!1),{on:k}=V();c.useEffect(()=>{I()},[]),c.useEffect(()=>{let a=!1;return m.getRecentHealingEvents(S).then(i=>{if(a||!i)return;const d=Array.isArray(i.events)?i.events.slice(0,S):[];y(d)}).catch(()=>{}).finally(()=>{a||H(!0)}),()=>{a=!0}},[]),c.useEffect(()=>{const a=k("healing_event",i=>{const d=i;!d||!d.id||y(p=>p.some(D=>D.id===d.id)?p:[d,...p].slice(0,S))});return()=>{a&&a()}},[k]);const I=async()=>{u(!0);try{const a=await m.getGlobalConfig(),i={healthCheckIntervalMs:a.healthCheckIntervalMs||3e4,healthCheckSchedule:a.healthCheckSchedule||"",enableSelfHealing:a.enableSelfHealing!==void 0?a.enableSelfHealing:!0};n(i),o(i)}catch(a){console.error("Failed to load settings",a),t("Failed to access infrastructure parameters.","error")}finally{u(!1)}},g=!se(s,l),r=Number.isNaN(s.healthCheckIntervalMs)||s.healthCheckIntervalMs<j?`Below minimum safe value of ${j}ms.`:null,w=g&&!r,v={interval:s.healthCheckIntervalMs!==l.healthCheckIntervalMs,schedule:s.healthCheckSchedule!==l.healthCheckSchedule,healing:s.enableSelfHealing!==l.enableSelfHealing},M=async a=>{const i=a??s;if(!a&&r){t(r,"error");return}C(!0);try{await m.updateGlobalConfig(i),o(i),n(i),t("Infrastructure parameters synchronized across fleet.","success")}catch(d){console.error("Failed to save settings",d),t("Synchronization failed. Check network integrity.","error")}finally{C(!1)}},$=async()=>{n(f),await M(f);try{await m.resetMetrics()}catch(a){console.error("Failed to reset metrics",a)}},z=()=>{n(l)},L=s.healthCheckSchedule!=="";return h?e.jsxs("div",{className:"settings-loading",children:[e.jsx(F,{className:"animate-spin",size:32}),e.jsx("span",{children:"Synchronizing Global Infrastructure..."})]}):e.jsxs("div",{className:"settings-container",children:[e.jsx(X,{icon:G,title:"Infrastructure Control",subtitle:"Manage core farm parameters, heartbeat frequency, and maintenance orchestrations across the global registry."}),e.jsx("div",{className:"settings-content",children:e.jsxs("div",{className:"settings-grid settings-grid--three",children:[e.jsxs(x,{icon:e.jsx(U,{size:16}),title:e.jsxs("span",{className:"card-title-row",children:["Idle Health Frequency",v.interval&&e.jsx("span",{className:"modified-dot","aria-label":"Modified"})]}),description:"Frequency of passive health pings when the system is in idle state.",hint:"Minimum safe value: 5000ms. Note: This frequency is overridden when a schedule is active.",children:[e.jsx("div",{className:"card-spacer"}),e.jsxs("div",{className:`input-group ${r?"has-error":""}`,children:[e.jsx("input",{type:"number",value:s.healthCheckIntervalMs,onChange:a=>n({...s,healthCheckIntervalMs:parseInt(a.target.value,10)}),min:j,step:5e3,"aria-invalid":!!r,"aria-describedby":r?"interval-error":"interval-status"}),e.jsx("span",{className:"code-font",children:"MS"})]}),r?e.jsxs("div",{id:"interval-error",className:"input-status input-status--error",role:"alert",children:[e.jsx(T,{size:12}),e.jsx("span",{children:r})]}):e.jsxs("div",{id:"interval-status",className:"input-status input-status--ok",children:[e.jsx(_,{size:12}),e.jsx("span",{children:"Valid frequency"})]})]}),e.jsxs(x,{icon:e.jsx(O,{size:16}),title:e.jsxs("span",{className:"card-title-row",children:["Deep Diagnostic Schedule",v.schedule&&e.jsx("span",{className:"modified-dot","aria-label":"Modified"})]}),titleExtra:L?e.jsxs("span",{className:"active-pill",children:[e.jsx(Q,{size:11}),e.jsx("span",{children:"Active"})]}):null,description:"Execute intensive reliability bursts (WDA restarts, Cache purges) using standardized Cron syntax.",children:[e.jsx("div",{className:"setting-input-wrapper",children:e.jsx("input",{type:"text",placeholder:"e.g. 0 * * * * (At internal min 0)",value:s.healthCheckSchedule,onChange:a=>n({...s,healthCheckSchedule:a.target.value})})}),e.jsxs("div",{className:"cron-presets",children:[e.jsxs("div",{className:"presets-label",children:[e.jsx(W,{size:12}),e.jsx("span",{children:"Intent-Based Presets"})]}),e.jsx("div",{className:"presets-grid presets-grid--stacked",children:Z.map(a=>{const i=s.healthCheckSchedule===a.value;return e.jsxs("button",{type:"button",className:`preset-chip ${i?"active":""}`,onClick:()=>n({...s,healthCheckSchedule:a.value}),"aria-pressed":i,children:[i&&e.jsx(J,{size:11,className:"preset-chip__check"}),e.jsx("span",{children:a.label})]},a.label)})})]})]}),e.jsxs(x,{icon:e.jsx(P,{size:16}),title:e.jsxs("span",{className:"card-title-row",children:["AI Self-Healing",v.healing&&e.jsx("span",{className:"modified-dot","aria-label":"Modified"})]}),titleExtra:e.jsxs("label",{className:"switch switch--header",children:[e.jsx("input",{type:"checkbox",checked:s.enableSelfHealing,onChange:a=>n({...s,enableSelfHealing:a.target.checked}),"aria-label":"Toggle AI Self-Healing"}),e.jsx("span",{className:"slider round"})]}),children:[e.jsx("div",{className:`healing-state ${s.enableSelfHealing?"is-on":"is-off"}`,children:s.enableSelfHealing?"ENABLED":"DISABLED"}),e.jsx("p",{className:"setting-card-description",children:"Automatically intercept and recover from failing locators using Xenon's 5-tier strategy. When enabled, Xenon will attempt to find elements via Fuzzy XML, OCR, Visual AI, and LLM before failing a test."}),s.enableSelfHealing&&e.jsxs("div",{className:"healing-events",children:[e.jsxs("div",{className:"healing-events__header",children:[e.jsx(K,{size:11}),e.jsx("span",{children:"Recent Healing Events"}),e.jsxs(B,{to:"/selector-health",className:"healing-events__link",children:["Selector Health ",e.jsx(Y,{size:10})]})]}),b.length>0?e.jsx("ul",{className:"healing-events__list",children:b.map(a=>e.jsxs("li",{className:"healing-event",children:[e.jsx(_,{size:14,className:"healing-event__icon"}),e.jsxs("div",{className:"healing-event__body",children:[e.jsxs("div",{className:"healing-event__row",children:[e.jsx("span",{className:"healing-event__kind",children:ae(a)}),e.jsx("span",{className:"healing-event__when",children:ee(a.createdAt)})]}),e.jsx("div",{className:"healing-event__message",title:A(a),children:A(a)})]})]},a.id))}):e.jsx("div",{className:"healing-events__empty",children:E?"No healing events recorded yet — the dashboard will populate as locators are recovered.":"Loading recent events…"})]})]})]})}),(g||N)&&e.jsx(q,{onSave:()=>M(),onDiscard:z,onRestoreDefaults:$,isSaving:N,isValidating:!!r,isDirty:g,saveLabel:w?"Save Configuration":"Resolve errors to save"})]})};export{ge as Settings};
|
package/lib/public/assets/{status-pill-outline-Cc4PF7Mg.js → status-pill-outline-3FA5raqd.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,X as g,j as x}from"./index-
|
|
1
|
+
import{r as s,X as g,j as x}from"./index-CkwQBzCl.js";import{u as y}from"./useSocket-lsg6f_Dn.js";const $=3e3;function N(){const[e,t]=s.useState([]),[r,a]=s.useState([]),[o,i]=s.useState(null),[c,m]=s.useState(""),[v,p]=s.useState(!0),[b,S]=s.useState(null),l=s.useRef(!0),{on:d}=y(),u=s.useCallback(async()=>{try{const[n,f]=await Promise.all([g.getBuilds(),o?g.getSessions({buildId:o,query:c}):Promise.resolve([])]);if(!l.current)return;t(Array.isArray(n)?n:[]),a(Array.isArray(f)?f:[]),S(null)}catch(n){if(!l.current)return;S(n instanceof Error?n.message:String(n))}finally{l.current&&p(!1)}},[o,c]);return s.useEffect(()=>{l.current=!0,u();const n=setInterval(u,$);return()=>{l.current=!1,clearInterval(n)}},[u]),s.useEffect(()=>{const n=()=>u(),f=[d("session_started",n),d("session_stopped",n),d("device_added",n),d("device_removed",n)];return()=>{for(const h of f)h()}},[d,u]),{builds:e,selectedBuildId:o,sessions:r,loading:v,error:b,selectBuild:i,searchQuery:c,setSearchQuery:m,refresh:u}}function A(e){const t={all:e.length,passed:0,failed:0,running:0};for(const r of e)r.status==="ended"||r.status==="passed"?t.passed+=1:r.status==="failed"?t.failed+=1:r.status==="running"&&(t.running+=1);return t}function w(e){var r;const t=(r=e.device_name)==null?void 0:r.trim();return t&&t.length>0?t:"Unknown Device"}function F(e){const t=e.device_platform??"";if(!t)return"—";const r=t.toLowerCase();return r==="ios"?"iOS":r==="tvos"?"tvOS":r.charAt(0).toUpperCase()+r.slice(1)}function I(e){return e.device_version?`v${e.device_version}`:""}function L(e){if(!e)return"—";const t=typeof e=="string"?new Date(e):e;if(Number.isNaN(t.getTime()))return"—";const r=String(t.getDate()).padStart(2,"0"),a=String(t.getMonth()+1).padStart(2,"0"),o=t.getFullYear(),i=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0"),m=String(t.getSeconds()).padStart(2,"0");return`${r}/${a}/${o}, ${i}:${c}:${m}`}function M(e){if(!e.startTime)return null;const t=Date.parse(e.startTime);if(!Number.isFinite(t))return null;const r=e.endTime?Date.parse(e.endTime):Date.now();return Number.isFinite(r)?Math.max(0,r-t):null}function T(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3,r=Math.floor(t/3600),a=Math.floor(t%3600/60),i=(t-r*3600-a*60).toFixed(1);return r>0?`${r}h ${a}m ${i}s`:a>0?`${a}m ${i}s`:`${i}s`}function k(e,t=10,r=4){return e?e.length<=t+r+1?e:`${e.slice(0,t)}…${e.slice(-r)}`:""}const D={ready:"border-[var(--green)]/40 text-[var(--green)]",passed:"border-[var(--green)]/40 text-[var(--green)]",running:"border-[var(--amber)]/40 text-[var(--amber)]",failed:"border-[var(--red)]/40 text-[var(--red)]",offline:"border-[var(--text-dim)]/40 text-[var(--text-dim)]"},B=({label:e,tone:t})=>x.jsx("span",{className:`inline-flex items-center justify-center h-6 px-2.5 rounded border text-[10px] font-mono font-semibold tracking-wider ${D[t]}`,children:e});export{B as S,M as a,A as b,w as d,L as f,T as h,I as o,F as p,k as s,N as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as D,r as n,j as e,v as z,z as f,S as B}from"./index-BrVV0Kla.js";/* empty css */import{T as E,a as M,b as T,c as u,d as R,e as j}from"./Table-B3EUgBi6.js";import{F as G}from"./FieldGroup-DE3u01Nu.js";import{P as U}from"./page-header-C0pnt4xz.js";import{M as Y}from"./Modal-BJcFdiBP.js";import{l as K}from"./users-cwrwUhwo.js";import{S as Q}from"./shield-alert-BfoPJ8q_.js";import{P as N}from"./plus-BObE-_z6.js";import{A as V}from"./arrow-left-9933DNlF.js";import{T as L}from"./trash-2-CE5TRHb2.js";const P={SUPER_ADMIN:"Super Admin",ADMIN:"Admin",MEMBER:"Member"};async function p(i,r){const t=await fetch(i,{credentials:"include",...r});if(!t.ok){const l=await t.json().catch(()=>({}));throw Object.assign(new Error(l.error||`HTTP ${t.status}`),{status:t.status})}return t.json()}const me=()=>{const{toast:i}=D(),[r,t]=n.useState([]),[l,m]=n.useState(!0),[c,h]=n.useState(!1),[x,d]=n.useState(!1),[_,S]=n.useState(null),v=async()=>{m(!0);try{const a=await p("/xenon/api/teams");t(a),h(!1)}catch(a){a.status===403?h(!0):i(`Failed to load teams: ${a.message}`,"error")}finally{m(!1)}};if(n.useEffect(()=>{v()},[]),l)return e.jsxs("div",{className:"settings-loading",children:[e.jsx(z,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading teams…"})]});if(c)return e.jsx("div",{className:"settings-container",children:e.jsx(U,{icon:Q,title:"Teams",subtitle:e.jsxs(e.Fragment,{children:["Your key lacks the ",e.jsx("code",{children:"admin"})," scope. Ask an administrator to promote your key before you can manage teams."]})})});if(_)return e.jsx(Z,{team:_,onBack:()=>{S(null),v()}});const C=r.reduce((a,o)=>a+o.deviceCount,0),y=r.reduce((a,o)=>a+o.memberCount,0);return e.jsxs("div",{className:"settings-container",children:[e.jsx(U,{icon:f,title:"Teams",subtitle:"Group devices and members by team. Devices with no team assignment stay in the shared pool — visible to every authenticated user.",action:r.length>0?e.jsxs("button",{type:"button",className:"page-header-action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"New team"})]}):void 0}),e.jsxs("div",{className:"settings-content",children:[r.length>0&&e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value stat-strip__value--accent",children:r.length}),e.jsx("div",{className:"stat-strip__label",children:"Teams"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:y}),e.jsx("div",{className:"stat-strip__label",children:"Members"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:C}),e.jsx("div",{className:"stat-strip__label",children:"Devices assigned"})]})]}),r.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state__icon",children:e.jsx(f,{size:28})}),e.jsx("h3",{className:"empty-state__title",children:"No teams yet"}),e.jsx("p",{className:"empty-state__copy",children:"Every device is in the shared pool until you create a team and assign it. Teams let you scope an API key to a subset of devices — useful for separating CI runners, staging fleets, or per-team device pools."}),e.jsxs("button",{type:"button",className:"page-header-action empty-state__action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"Create your first team"})]})]}):e.jsx("div",{className:"team-grid",children:r.map(a=>e.jsxs("button",{type:"button",className:"team-card",onClick:()=>S(a),children:[e.jsxs("div",{className:"team-card__header",children:[e.jsx("div",{className:"team-card__icon",children:e.jsx(f,{size:16})}),e.jsxs("div",{className:"team-card__title",children:[e.jsx("div",{className:"team-card__name",children:a.name}),e.jsx("div",{className:"team-card__id",children:a.id.slice(0,8)})]}),e.jsx("span",{className:"team-card__delete",role:"button",tabIndex:0,onClick:o=>o.stopPropagation(),children:e.jsx(X,{team:a,onDeleted:v})})]}),e.jsxs("div",{className:"team-card__metrics",children:[e.jsxs("div",{className:"team-card__metric",children:[e.jsx(B,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.deviceCount}),e.jsx("span",{className:"team-card__metric-label",children:"devices"})]}),e.jsxs("div",{className:"team-card__metric",children:[e.jsx(f,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.memberCount}),e.jsx("span",{className:"team-card__metric-label",children:"members"})]})]}),e.jsxs("div",{className:"team-card__footer",children:["Created ",new Date(a.createdAt).toLocaleDateString()]})]},a.id))})]}),x&&e.jsx(W,{onClose:()=>d(!1),onCreated:()=>{d(!1),v()}})]})},W=({onClose:i,onCreated:r})=>{const{toast:t}=D(),[l,m]=n.useState(""),[c,h]=n.useState(!1),x=async()=>{if(!l.trim())return t("Name required","error");h(!0);try{await p("/xenon/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.trim()})}),t("Team created","success"),r()}catch(d){t(d.message,"error")}finally{h(!1)}};return e.jsx(Y,{open:!0,onClose:i,title:"New team",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"reset-btn",onClick:i,disabled:c,children:"Cancel"}),e.jsxs("button",{className:"save-btn",onClick:x,disabled:c,children:[c?e.jsx(z,{className:"animate-spin",size:18}):e.jsx(N,{size:18}),c?"Creating…":"Create"]})]}),children:e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:e.jsx(G,{label:"Name",htmlFor:"team-name",children:e.jsx("input",{id:"team-name",type:"text",value:l,onChange:d=>m(d.target.value),placeholder:"android-team, qa-ios, …",style:A,autoFocus:!0})})})})},X=({team:i,onDeleted:r})=>{const{toast:t}=D(),[l,m]=n.useState(!1),c=async h=>{if(h.stopPropagation(),!!window.confirm(`Delete team "${i.name}"? It must have no devices and no members.`)){m(!0);try{await p(`/xenon/api/teams/${i.id}`,{method:"DELETE"}),t("Team deleted","success"),r()}catch(x){t(x.message,"error")}finally{m(!1)}}};return e.jsxs("button",{className:"reset-btn",disabled:l,onClick:c,style:{color:"var(--status-error-fg)"},children:[e.jsx(L,{size:14}),l?"Deleting…":"Delete"]})},Z=({team:i,onBack:r})=>{const{toast:t}=D(),[l,m]=n.useState([]),[c,h]=n.useState([]),[x,d]=n.useState([]),[_,S]=n.useState([]),[v,C]=n.useState(!0),[y,a]=n.useState(""),[o,k]=n.useState(""),b=async()=>{C(!0);try{const[s,g,q]=await Promise.all([p(`/xenon/api/teams/${i.id}/members`),K(),p("/xenon/api/device")]);m(s),h(g);const I=q;d(I.filter(w=>w.teamId===i.id)),S(I.filter(w=>!w.teamId))}catch(s){t(`Failed to load team detail: ${s.message}`,"error")}finally{C(!1)}};n.useEffect(()=>{b()},[i.id]);const $=async()=>{if(y)try{await p(`/xenon/api/teams/${i.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:y})}),t("Member added","success"),a(""),b()}catch(s){t(s.message,"error")}},F=async s=>{if(window.confirm("Remove this member from the team?"))try{await p(`/xenon/api/teams/${i.id}/members/${encodeURIComponent(s)}`,{method:"DELETE"}),t("Member removed","success"),b()}catch(g){t(g.message,"error")}},O=async()=>{if(o)try{await p(`/xenon/api/device/${encodeURIComponent(o)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:i.id})}),t("Device assigned","success"),k(""),b()}catch(s){t(s.message,"error")}},H=async s=>{if(window.confirm("Return this device to the shared pool?"))try{await p(`/xenon/api/device/${encodeURIComponent(s)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:null})}),t("Device unassigned","success"),b()}catch(g){t(g.message,"error")}},J=c.filter(s=>!l.some(g=>g.userId===s.id));return e.jsxs("div",{className:"settings-container mesh-gradient-infra",children:[e.jsxs("div",{className:"settings-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("button",{onClick:r,className:"reset-btn",style:{padding:"4px 8px"},"aria-label":"Back",children:e.jsx(V,{size:18})}),e.jsxs("div",{className:"settings-title-group",children:[e.jsx(f,{className:"settings-icon infra-icon",size:28}),e.jsx("h2",{children:i.name})]})]}),e.jsx("p",{className:"settings-subtitle",children:'Manage members and devices assigned to this team. To add a device, go to Devices and use "Assign to team."'})]}),v?e.jsx("div",{className:"settings-loading",children:e.jsx(z,{className:"animate-spin",size:32})}):e.jsxs("div",{className:"settings-content",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Members (",l.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs("select",{value:y,onChange:s=>a(s.target.value),style:{...A,flex:1},children:[e.jsx("option",{value:"",children:"Select a user to add…"}),J.map(s=>e.jsxs("option",{value:s.id,children:[s.name," (",s.email,") — ",P[s.role]]},s.id))]}),e.jsxs("button",{className:"save-btn",onClick:$,disabled:!y,children:[e.jsx(N,{size:16})," Add"]})]}),l.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No members yet. Add a user above."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Email"}),e.jsx(u,{children:"Role"}),e.jsx(u,{children:"Added"}),e.jsx(u,{style:{textAlign:"right"},children:"Action"})]})}),e.jsx(R,{children:l.map(s=>e.jsxs(T,{children:[e.jsx(j,{children:s.name}),e.jsx(j,{children:e.jsx("code",{style:{fontSize:"11px",color:"var(--text-muted)"},children:s.email})}),e.jsx(j,{children:P[s.role]}),e.jsx(j,{children:new Date(s.addedAt).toLocaleDateString()}),e.jsx(j,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>F(s.userId),style:{color:"var(--status-error-fg)"},"aria-label":"Remove member",title:"Remove member",children:e.jsx(L,{size:14})})})]},s.userId))})]})]})]}),e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Devices (",x.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs("select",{value:o,onChange:s=>k(s.target.value),style:{...A,flex:1},children:[e.jsx("option",{value:"",children:"Select a shared-pool device to assign…"}),_.map(s=>e.jsxs("option",{value:s.udid,children:[s.name," (",s.platform,") — ",s.udid.slice(0,12),"…"]},s.udid))]}),e.jsxs("button",{className:"save-btn",onClick:O,disabled:!o,children:[e.jsx(N,{size:16})," Assign"]})]}),x.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No devices assigned. Use the Devices page to move devices into this team."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Platform"}),e.jsx(u,{children:"UDID"}),e.jsx(u,{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx(R,{children:x.map(s=>e.jsxs(T,{children:[e.jsxs(j,{children:[e.jsx(B,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),s.name]}),e.jsx(j,{children:s.platform}),e.jsx(j,{children:e.jsxs("code",{style:{fontSize:"11px"},children:[s.udid.slice(0,14),"…"]})}),e.jsx(j,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>H(s.udid),children:"Return to shared pool"})})]},s.udid))})]})]})]})]})]})},A={width:"100%",padding:"8px 12px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"inherit",fontSize:"0.95em",boxSizing:"border-box"};export{me as Teams};
|
|
1
|
+
import{m as D,r as n,j as e,v as z,z as f,S as B}from"./index-CkwQBzCl.js";/* empty css */import{T as E,a as M,b as T,c as u,d as R,e as j}from"./Table-CbmGiPJe.js";import{F as G}from"./FieldGroup-CGdoHDQ3.js";import{P as U}from"./page-header-BeUDGs-O.js";import{M as Y}from"./Modal-OY-an2g6.js";import{l as K}from"./users-cwrwUhwo.js";import{S as Q}from"./shield-alert-Dm3Oz4Kc.js";import{P as N}from"./plus-BM5UAzcK.js";import{A as V}from"./arrow-left-y_SSjJz-.js";import{T as L}from"./trash-2-DUWA0N9n.js";const P={SUPER_ADMIN:"Super Admin",ADMIN:"Admin",MEMBER:"Member"};async function p(i,r){const t=await fetch(i,{credentials:"include",...r});if(!t.ok){const l=await t.json().catch(()=>({}));throw Object.assign(new Error(l.error||`HTTP ${t.status}`),{status:t.status})}return t.json()}const me=()=>{const{toast:i}=D(),[r,t]=n.useState([]),[l,m]=n.useState(!0),[c,h]=n.useState(!1),[x,d]=n.useState(!1),[_,S]=n.useState(null),v=async()=>{m(!0);try{const a=await p("/xenon/api/teams");t(a),h(!1)}catch(a){a.status===403?h(!0):i(`Failed to load teams: ${a.message}`,"error")}finally{m(!1)}};if(n.useEffect(()=>{v()},[]),l)return e.jsxs("div",{className:"settings-loading",children:[e.jsx(z,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading teams…"})]});if(c)return e.jsx("div",{className:"settings-container",children:e.jsx(U,{icon:Q,title:"Teams",subtitle:e.jsxs(e.Fragment,{children:["Your key lacks the ",e.jsx("code",{children:"admin"})," scope. Ask an administrator to promote your key before you can manage teams."]})})});if(_)return e.jsx(Z,{team:_,onBack:()=>{S(null),v()}});const C=r.reduce((a,o)=>a+o.deviceCount,0),y=r.reduce((a,o)=>a+o.memberCount,0);return e.jsxs("div",{className:"settings-container",children:[e.jsx(U,{icon:f,title:"Teams",subtitle:"Group devices and members by team. Devices with no team assignment stay in the shared pool — visible to every authenticated user.",action:r.length>0?e.jsxs("button",{type:"button",className:"page-header-action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"New team"})]}):void 0}),e.jsxs("div",{className:"settings-content",children:[r.length>0&&e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value stat-strip__value--accent",children:r.length}),e.jsx("div",{className:"stat-strip__label",children:"Teams"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:y}),e.jsx("div",{className:"stat-strip__label",children:"Members"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:C}),e.jsx("div",{className:"stat-strip__label",children:"Devices assigned"})]})]}),r.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state__icon",children:e.jsx(f,{size:28})}),e.jsx("h3",{className:"empty-state__title",children:"No teams yet"}),e.jsx("p",{className:"empty-state__copy",children:"Every device is in the shared pool until you create a team and assign it. Teams let you scope an API key to a subset of devices — useful for separating CI runners, staging fleets, or per-team device pools."}),e.jsxs("button",{type:"button",className:"page-header-action empty-state__action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"Create your first team"})]})]}):e.jsx("div",{className:"team-grid",children:r.map(a=>e.jsxs("button",{type:"button",className:"team-card",onClick:()=>S(a),children:[e.jsxs("div",{className:"team-card__header",children:[e.jsx("div",{className:"team-card__icon",children:e.jsx(f,{size:16})}),e.jsxs("div",{className:"team-card__title",children:[e.jsx("div",{className:"team-card__name",children:a.name}),e.jsx("div",{className:"team-card__id",children:a.id.slice(0,8)})]}),e.jsx("span",{className:"team-card__delete",role:"button",tabIndex:0,onClick:o=>o.stopPropagation(),children:e.jsx(X,{team:a,onDeleted:v})})]}),e.jsxs("div",{className:"team-card__metrics",children:[e.jsxs("div",{className:"team-card__metric",children:[e.jsx(B,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.deviceCount}),e.jsx("span",{className:"team-card__metric-label",children:"devices"})]}),e.jsxs("div",{className:"team-card__metric",children:[e.jsx(f,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.memberCount}),e.jsx("span",{className:"team-card__metric-label",children:"members"})]})]}),e.jsxs("div",{className:"team-card__footer",children:["Created ",new Date(a.createdAt).toLocaleDateString()]})]},a.id))})]}),x&&e.jsx(W,{onClose:()=>d(!1),onCreated:()=>{d(!1),v()}})]})},W=({onClose:i,onCreated:r})=>{const{toast:t}=D(),[l,m]=n.useState(""),[c,h]=n.useState(!1),x=async()=>{if(!l.trim())return t("Name required","error");h(!0);try{await p("/xenon/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.trim()})}),t("Team created","success"),r()}catch(d){t(d.message,"error")}finally{h(!1)}};return e.jsx(Y,{open:!0,onClose:i,title:"New team",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"reset-btn",onClick:i,disabled:c,children:"Cancel"}),e.jsxs("button",{className:"save-btn",onClick:x,disabled:c,children:[c?e.jsx(z,{className:"animate-spin",size:18}):e.jsx(N,{size:18}),c?"Creating…":"Create"]})]}),children:e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:e.jsx(G,{label:"Name",htmlFor:"team-name",children:e.jsx("input",{id:"team-name",type:"text",value:l,onChange:d=>m(d.target.value),placeholder:"android-team, qa-ios, …",style:A,autoFocus:!0})})})})},X=({team:i,onDeleted:r})=>{const{toast:t}=D(),[l,m]=n.useState(!1),c=async h=>{if(h.stopPropagation(),!!window.confirm(`Delete team "${i.name}"? It must have no devices and no members.`)){m(!0);try{await p(`/xenon/api/teams/${i.id}`,{method:"DELETE"}),t("Team deleted","success"),r()}catch(x){t(x.message,"error")}finally{m(!1)}}};return e.jsxs("button",{className:"reset-btn",disabled:l,onClick:c,style:{color:"var(--status-error-fg)"},children:[e.jsx(L,{size:14}),l?"Deleting…":"Delete"]})},Z=({team:i,onBack:r})=>{const{toast:t}=D(),[l,m]=n.useState([]),[c,h]=n.useState([]),[x,d]=n.useState([]),[_,S]=n.useState([]),[v,C]=n.useState(!0),[y,a]=n.useState(""),[o,k]=n.useState(""),b=async()=>{C(!0);try{const[s,g,q]=await Promise.all([p(`/xenon/api/teams/${i.id}/members`),K(),p("/xenon/api/device")]);m(s),h(g);const I=q;d(I.filter(w=>w.teamId===i.id)),S(I.filter(w=>!w.teamId))}catch(s){t(`Failed to load team detail: ${s.message}`,"error")}finally{C(!1)}};n.useEffect(()=>{b()},[i.id]);const $=async()=>{if(y)try{await p(`/xenon/api/teams/${i.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:y})}),t("Member added","success"),a(""),b()}catch(s){t(s.message,"error")}},F=async s=>{if(window.confirm("Remove this member from the team?"))try{await p(`/xenon/api/teams/${i.id}/members/${encodeURIComponent(s)}`,{method:"DELETE"}),t("Member removed","success"),b()}catch(g){t(g.message,"error")}},O=async()=>{if(o)try{await p(`/xenon/api/device/${encodeURIComponent(o)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:i.id})}),t("Device assigned","success"),k(""),b()}catch(s){t(s.message,"error")}},H=async s=>{if(window.confirm("Return this device to the shared pool?"))try{await p(`/xenon/api/device/${encodeURIComponent(s)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:null})}),t("Device unassigned","success"),b()}catch(g){t(g.message,"error")}},J=c.filter(s=>!l.some(g=>g.userId===s.id));return e.jsxs("div",{className:"settings-container mesh-gradient-infra",children:[e.jsxs("div",{className:"settings-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("button",{onClick:r,className:"reset-btn",style:{padding:"4px 8px"},"aria-label":"Back",children:e.jsx(V,{size:18})}),e.jsxs("div",{className:"settings-title-group",children:[e.jsx(f,{className:"settings-icon infra-icon",size:28}),e.jsx("h2",{children:i.name})]})]}),e.jsx("p",{className:"settings-subtitle",children:'Manage members and devices assigned to this team. To add a device, go to Devices and use "Assign to team."'})]}),v?e.jsx("div",{className:"settings-loading",children:e.jsx(z,{className:"animate-spin",size:32})}):e.jsxs("div",{className:"settings-content",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Members (",l.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs("select",{value:y,onChange:s=>a(s.target.value),style:{...A,flex:1},children:[e.jsx("option",{value:"",children:"Select a user to add…"}),J.map(s=>e.jsxs("option",{value:s.id,children:[s.name," (",s.email,") — ",P[s.role]]},s.id))]}),e.jsxs("button",{className:"save-btn",onClick:$,disabled:!y,children:[e.jsx(N,{size:16})," Add"]})]}),l.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No members yet. Add a user above."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Email"}),e.jsx(u,{children:"Role"}),e.jsx(u,{children:"Added"}),e.jsx(u,{style:{textAlign:"right"},children:"Action"})]})}),e.jsx(R,{children:l.map(s=>e.jsxs(T,{children:[e.jsx(j,{children:s.name}),e.jsx(j,{children:e.jsx("code",{style:{fontSize:"11px",color:"var(--text-muted)"},children:s.email})}),e.jsx(j,{children:P[s.role]}),e.jsx(j,{children:new Date(s.addedAt).toLocaleDateString()}),e.jsx(j,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>F(s.userId),style:{color:"var(--status-error-fg)"},"aria-label":"Remove member",title:"Remove member",children:e.jsx(L,{size:14})})})]},s.userId))})]})]})]}),e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Devices (",x.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs("select",{value:o,onChange:s=>k(s.target.value),style:{...A,flex:1},children:[e.jsx("option",{value:"",children:"Select a shared-pool device to assign…"}),_.map(s=>e.jsxs("option",{value:s.udid,children:[s.name," (",s.platform,") — ",s.udid.slice(0,12),"…"]},s.udid))]}),e.jsxs("button",{className:"save-btn",onClick:O,disabled:!o,children:[e.jsx(N,{size:16})," Assign"]})]}),x.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No devices assigned. Use the Devices page to move devices into this team."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Platform"}),e.jsx(u,{children:"UDID"}),e.jsx(u,{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx(R,{children:x.map(s=>e.jsxs(T,{children:[e.jsxs(j,{children:[e.jsx(B,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),s.name]}),e.jsx(j,{children:s.platform}),e.jsx(j,{children:e.jsxs("code",{style:{fontSize:"11px"},children:[s.udid.slice(0,14),"…"]})}),e.jsx(j,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>H(s.udid),children:"Return to shared pool"})})]},s.udid))})]})]})]})]})]})},A={width:"100%",padding:"8px 12px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"inherit",fontSize:"0.95em",boxSizing:"border-box"};export{me as Teams};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as E}from"./index-BrVV0Kla.js";const m=Object.create(null);m.open="0";m.close="1";m.ping="2";m.pong="3";m.message="4";m.upgrade="5";m.noop="6";const R=Object.create(null);Object.keys(m).forEach(n=>{R[m[n]]=n});const q={type:"error",data:"parser error"},j=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",G=typeof ArrayBuffer=="function",Z=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,M=({type:n,data:e},t,s)=>j&&e instanceof Blob?t?s(e):Y(e,s):G&&(e instanceof ArrayBuffer||Z(e))?t?s(e):Y(new Blob([e]),s):s(m[n]+(e||"")),Y=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function z(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let N;function ue(n,e){if(j&&n.data instanceof Blob)return n.data.arrayBuffer().then(z).then(e);if(G&&(n.data instanceof ArrayBuffer||Z(n.data)))return e(z(n.data));M(n,!1,t=>{N||(N=new TextEncoder),e(N.encode(t))})}const J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<J.length;n++)k[J.charCodeAt(n)]=n;const fe=n=>{let e=n.length*.75,t=n.length,s,i=0,r,o,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const l=new ArrayBuffer(e),f=new Uint8Array(l);for(s=0;s<t;s+=4)r=k[n.charCodeAt(s)],o=k[n.charCodeAt(s+1)],a=k[n.charCodeAt(s+2)],c=k[n.charCodeAt(s+3)],f[i++]=r<<2|o>>4,f[i++]=(o&15)<<4|a>>2,f[i++]=(a&3)<<6|c&63;return l},le=typeof ArrayBuffer=="function",H=(n,e)=>{if(typeof n!="string")return{type:"message",data:ee(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:pe(n.substring(1),e)}:R[t]?n.length>1?{type:R[t],data:n.substring(1)}:{type:R[t]}:q},pe=(n,e)=>{if(le){const t=fe(n);return ee(t,e)}else return{base64:!0,data:n}},ee=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},te="",de=(n,e)=>{const t=n.length,s=new Array(t);let i=0;n.forEach((r,o)=>{M(r,!1,a=>{s[o]=a,++i===t&&e(s.join(te))})})},ye=(n,e)=>{const t=n.split(te),s=[];for(let i=0;i<t.length;i++){const r=H(t[i],e);if(s.push(r),r.type==="error")break}return s};function ge(){return new TransformStream({transform(n,e){ue(n,t=>{const s=t.length;let i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);const r=new DataView(i.buffer);r.setUint8(0,126),r.setUint16(1,s)}else{i=new Uint8Array(9);const r=new DataView(i.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(t)})}})}let L;function A(n){return n.reduce((e,t)=>e+t.length,0)}function T(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let i=0;i<e;i++)t[i]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function me(n,e){L||(L=new TextDecoder);const t=[];let s=0,i=-1,r=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(A(t)<1)break;const c=T(t,1);r=(c[0]&128)===128,i=c[0]&127,i<126?s=3:i===126?s=1:s=2}else if(s===1){if(A(t)<2)break;const c=T(t,2);i=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(A(t)<8)break;const c=T(t,8),l=new DataView(c.buffer,c.byteOffset,c.length),f=l.getUint32(0);if(f>Math.pow(2,21)-1){a.enqueue(q);break}i=f*Math.pow(2,32)+l.getUint32(4),s=3}else{if(A(t)<i)break;const c=T(t,i);a.enqueue(H(r?c:L.decode(c),e)),s=0}if(i===0||i>n){a.enqueue(q);break}}}})}const se=4;function u(n){if(n)return _e(n)}function _e(n){for(var e in u.prototype)n[e]=u.prototype[e];return n}u.prototype.on=u.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};u.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};u.prototype.off=u.prototype.removeListener=u.prototype.removeAllListeners=u.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,i=0;i<t.length;i++)if(s=t[i],s===e||s.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+n],this};u.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,i=t.length;s<i;++s)t[s].apply(this,e)}return this};u.prototype.emitReserved=u.prototype.emit;u.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};u.prototype.hasListeners=function(n){return!!this.listeners(n).length};const B=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),p=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),be="arraybuffer";function ne(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const we=p.setTimeout,Ee=p.clearTimeout;function x(n,e){e.useNativeTimers?(n.setTimeoutFn=we.bind(p),n.clearTimeoutFn=Ee.bind(p)):(n.setTimeoutFn=p.setTimeout.bind(p),n.clearTimeoutFn=p.clearTimeout.bind(p))}const ve=1.33;function ke(n){return typeof n=="string"?Ae(n):Math.ceil((n.byteLength||n.size)*ve)}function Ae(n){let e=0,t=0;for(let s=0,i=n.length;s<i;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function ie(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Te(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function Re(n){let e={},t=n.split("&");for(let s=0,i=t.length;s<i;s++){let r=t[s].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}class Oe extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class K extends u{constructor(e){super(),this.writable=!1,x(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new Oe(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=H(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Te(e);return t.length?"?"+t:""}}class Se extends K{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};ye(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,de(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=ie()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let re=!1;try{re=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ce=re;function Be(){}class xe extends Se{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(i,r)=>{this.onError("xhr post error",i,r)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}class g extends u{constructor(e,t,s){super(),this.createRequest=e,x(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=ne(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&s.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var i;s.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=g.requestsCount++,g.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Be,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete g.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}g.requestsCount=0;g.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",X);else if(typeof addEventListener=="function"){const n="onpagehide"in p?"pagehide":"unload";addEventListener(n,X,!1)}}function X(){for(let n in g.requests)g.requests.hasOwnProperty(n)&&g.requests[n].abort()}const Ne=function(){const n=oe({xdomain:!1});return n&&n.responseType!==null}();class Le extends xe{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Ne&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new g(oe,this.uri(),e)}}function oe(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Ce))return new XMLHttpRequest}catch{}if(!e)try{return new p[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ae=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Pe extends K{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=ae?{}:ne(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1;M(s,this.supportsBinary,r=>{try{this.doWrite(s,r)}catch{}i&&B(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=ie()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const P=p.WebSocket||p.MozWebSocket;class qe extends Pe{createSocket(e,t,s){return ae?new P(e,t,s):t?new P(e,t):new P(e)}doWrite(e,t){this.ws.send(t)}}class De extends K{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=me(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),i=ge();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const r=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),r())}).catch(a=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1;this._writer.write(s).then(()=>{i&&B(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Ie={websocket:qe,webtransport:De,polling:Le},Ue=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Fe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function D(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let i=Ue.exec(n||""),r={},o=14;for(;o--;)r[Fe[o]]=i[o]||"";return t!=-1&&s!=-1&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Ve(r,r.path),r.queryKey=Me(r,r.query),r}function Ve(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Me(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,i,r){i&&(t[i]=r)}),t}const I=typeof addEventListener=="function"&&typeof removeEventListener=="function",O=[];I&&addEventListener("offline",()=>{O.forEach(n=>n())},!1);class _ extends u{constructor(e,t){if(super(),this.binaryType=be,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){const s=D(e);t.hostname=s.host,t.secure=s.protocol==="https"||s.protocol==="wss",t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=D(t.host).host);x(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(s=>{const i=s.prototype.name;this.transports.push(i),this._transportsByName[i]=s}),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Re(this.opts.query)),I&&(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"})},O.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=se,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&_.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",_.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),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 e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const i=this.writeBuffer[s].data;if(i&&(t+=ke(i)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,B(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,i){if(typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const r={type:e,data:t,options:s};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(_.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){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(),I&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=O.indexOf(this._offlineEventListener);s!==-1&&O.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}_.protocol=se;class He extends _{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;_.priorWebsocketSuccess=!1;const i=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",d=>{if(!s)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;_.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(f(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const b=new Error("probe error");b.transport=t.name,this.emitReserved("upgradeError",b)}}))};function r(){s||(s=!0,f(),t.close(),t=null)}const o=d=>{const b=new Error("probe error: "+d);b.transport=t.name,r(),this.emitReserved("upgradeError",b)};function a(){o("transport closed")}function c(){o("socket closed")}function l(d){t&&d.name!==t.name&&r()}const f=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};t.once("open",i),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}let Ke=class extends He{constructor(e,t={}){const s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>Ie[i]).filter(i=>!!i)),super(e,s)}};function We(n,e="",t){let s=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),s=D(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const r=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+r+":"+s.port+e,s.href=s.protocol+"://"+r+(t&&t.port===s.port?"":":"+s.port),s}const $e=typeof ArrayBuffer=="function",Ye=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ce=Object.prototype.toString,ze=typeof Blob=="function"||typeof Blob<"u"&&ce.call(Blob)==="[object BlobConstructor]",Je=typeof File=="function"||typeof File<"u"&&ce.call(File)==="[object FileConstructor]";function W(n){return $e&&(n instanceof ArrayBuffer||Ye(n))||ze&&n instanceof Blob||Je&&n instanceof File}function S(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(S(n[t]))return!0;return!1}if(W(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return S(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&S(n[t]))return!0;return!1}function Xe(n){const e=[],t=n.data,s=n;return s.data=U(t,e),s.attachments=e.length,{packet:s,buffers:e}}function U(n,e){if(!n)return n;if(W(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let s=0;s<n.length;s++)t[s]=U(n[s],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=U(n[s],e));return t}return n}function Qe(n,e){return n.data=F(n.data,e),delete n.attachments,n}function F(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=F(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=F(n[t],e));return n}const je=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var h;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(h||(h={}));class Ge{constructor(e){this.replacer=e}encode(e){return(e.type===h.EVENT||e.type===h.ACK)&&S(e)?this.encodeAsBinary({type:e.type===h.EVENT?h.BINARY_EVENT:h.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===h.BINARY_EVENT||e.type===h.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Xe(e),s=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(s),i}}class $ extends u{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===h.BINARY_EVENT;s||t.type===h.BINARY_ACK?(t.type=s?h.EVENT:h.ACK,this.reconstructor=new Ze(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(W(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(h[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===h.BINARY_EVENT||s.type===h.BINARY_ACK){const r=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(r,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){const r=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(r,t)}else s.nsp="/";const i=e.charAt(t+1);if(i!==""&&Number(i)==i){const r=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if($.isPayloadValid(s.type,r))s.data=r;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case h.CONNECT:return Q(t);case h.DISCONNECT:return t===void 0;case h.CONNECT_ERROR:return typeof t=="string"||Q(t);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&je.indexOf(t[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ze{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Qe(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Q(n){return Object.prototype.toString.call(n)==="[object Object]"}const et=Object.freeze(Object.defineProperty({__proto__:null,Decoder:$,Encoder:Ge,get PacketType(){return h}},Symbol.toStringTag,{value:"Module"}));function y(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const tt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class he extends u{constructor(e,t,s){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=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[y(e,"open",this.onopen.bind(this)),y(e,"packet",this.onpacket.bind(this)),y(e,"error",this.onerror.bind(this)),y(e,"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(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,i,r;if(tt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:h.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const f=this.ids++,d=t.pop();this._registerAckCallback(f,d),o.id=f}const a=(i=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||i===void 0?void 0:i.writable,c=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const i=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(r),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,i)=>{const r=(o,a)=>o?i(o):s(a);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...r)=>(this._queue[0],i!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...r)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:h.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case h.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.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 h.EVENT:case h.BINARY_EVENT:this.onevent(e);break;case h.ACK:case h.BINARY_ACK:this.onack(e);break;case h.DISCONNECT:this.ondisconnect();break;case h.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...i){s||(s=!0,t.packet({type:h.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:h.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function w(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}w.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=Math.floor(e*10)&1?n+t:n-t}return Math.min(n,this.max)|0};w.prototype.reset=function(){this.attempts=0};w.prototype.setMin=function(n){this.ms=n};w.prototype.setMax=function(n){this.max=n};w.prototype.setJitter=function(n){this.jitter=n};class V extends u{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,x(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new w({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||et;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Ke(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=y(t,"open",function(){s.onopen(),e&&e()}),r=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=y(t,"error",r);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{i(),r(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(y(e,"ping",this.onping.bind(this)),y(e,"data",this.ondata.bind(this)),y(e,"error",this.onerror.bind(this)),y(e,"close",this.onclose.bind(this)),y(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){B(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new he(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const v={};function C(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=We(n,e.path||"/socket.io"),s=t.source,i=t.id,r=t.path,o=v[i]&&r in v[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new V(s,e):(v[i]||(v[i]=new V(s,e)),c=v[i]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(C,{Manager:V,Socket:he,io:C,connect:C});const it=()=>{const[n,e]=E.useState(null),[t,s]=E.useState(!1),i=E.useRef(new Map);E.useEffect(()=>{const o=window.location.origin,a=C(o,{path:"/socket.io",reconnection:!0,withCredentials:!0});e(a),a.on("connect",()=>{console.log("[Socket] Connected to Hub"),s(!0),a.emit("register_dashboard")}),a.on("disconnect",()=>{console.log("[Socket] Disconnected from Hub"),s(!1)});const c=(l,f)=>{const d=i.current.get(l);d&&d.forEach(b=>b(f))};return a.onAny((l,f)=>{c(l,f)}),()=>{a.close()}},[]);const r=E.useCallback((o,a)=>{var c;return i.current.has(o)||i.current.set(o,[]),(c=i.current.get(o))==null||c.push(a),()=>{const l=i.current.get(o);l&&i.current.set(o,l.filter(f=>f!==a))}},[]);return{socket:n,isConnected:t,on:r}};export{it as u};
|
|
1
|
+
import{r as E}from"./index-CkwQBzCl.js";const m=Object.create(null);m.open="0";m.close="1";m.ping="2";m.pong="3";m.message="4";m.upgrade="5";m.noop="6";const R=Object.create(null);Object.keys(m).forEach(n=>{R[m[n]]=n});const q={type:"error",data:"parser error"},j=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",G=typeof ArrayBuffer=="function",Z=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,M=({type:n,data:e},t,s)=>j&&e instanceof Blob?t?s(e):Y(e,s):G&&(e instanceof ArrayBuffer||Z(e))?t?s(e):Y(new Blob([e]),s):s(m[n]+(e||"")),Y=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function z(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let N;function ue(n,e){if(j&&n.data instanceof Blob)return n.data.arrayBuffer().then(z).then(e);if(G&&(n.data instanceof ArrayBuffer||Z(n.data)))return e(z(n.data));M(n,!1,t=>{N||(N=new TextEncoder),e(N.encode(t))})}const J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<J.length;n++)k[J.charCodeAt(n)]=n;const fe=n=>{let e=n.length*.75,t=n.length,s,i=0,r,o,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const l=new ArrayBuffer(e),f=new Uint8Array(l);for(s=0;s<t;s+=4)r=k[n.charCodeAt(s)],o=k[n.charCodeAt(s+1)],a=k[n.charCodeAt(s+2)],c=k[n.charCodeAt(s+3)],f[i++]=r<<2|o>>4,f[i++]=(o&15)<<4|a>>2,f[i++]=(a&3)<<6|c&63;return l},le=typeof ArrayBuffer=="function",H=(n,e)=>{if(typeof n!="string")return{type:"message",data:ee(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:pe(n.substring(1),e)}:R[t]?n.length>1?{type:R[t],data:n.substring(1)}:{type:R[t]}:q},pe=(n,e)=>{if(le){const t=fe(n);return ee(t,e)}else return{base64:!0,data:n}},ee=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},te="",de=(n,e)=>{const t=n.length,s=new Array(t);let i=0;n.forEach((r,o)=>{M(r,!1,a=>{s[o]=a,++i===t&&e(s.join(te))})})},ye=(n,e)=>{const t=n.split(te),s=[];for(let i=0;i<t.length;i++){const r=H(t[i],e);if(s.push(r),r.type==="error")break}return s};function ge(){return new TransformStream({transform(n,e){ue(n,t=>{const s=t.length;let i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);const r=new DataView(i.buffer);r.setUint8(0,126),r.setUint16(1,s)}else{i=new Uint8Array(9);const r=new DataView(i.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(t)})}})}let L;function A(n){return n.reduce((e,t)=>e+t.length,0)}function T(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let i=0;i<e;i++)t[i]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function me(n,e){L||(L=new TextDecoder);const t=[];let s=0,i=-1,r=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(A(t)<1)break;const c=T(t,1);r=(c[0]&128)===128,i=c[0]&127,i<126?s=3:i===126?s=1:s=2}else if(s===1){if(A(t)<2)break;const c=T(t,2);i=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(A(t)<8)break;const c=T(t,8),l=new DataView(c.buffer,c.byteOffset,c.length),f=l.getUint32(0);if(f>Math.pow(2,21)-1){a.enqueue(q);break}i=f*Math.pow(2,32)+l.getUint32(4),s=3}else{if(A(t)<i)break;const c=T(t,i);a.enqueue(H(r?c:L.decode(c),e)),s=0}if(i===0||i>n){a.enqueue(q);break}}}})}const se=4;function u(n){if(n)return _e(n)}function _e(n){for(var e in u.prototype)n[e]=u.prototype[e];return n}u.prototype.on=u.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};u.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};u.prototype.off=u.prototype.removeListener=u.prototype.removeAllListeners=u.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,i=0;i<t.length;i++)if(s=t[i],s===e||s.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+n],this};u.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,i=t.length;s<i;++s)t[s].apply(this,e)}return this};u.prototype.emitReserved=u.prototype.emit;u.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};u.prototype.hasListeners=function(n){return!!this.listeners(n).length};const B=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),p=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),be="arraybuffer";function ne(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const we=p.setTimeout,Ee=p.clearTimeout;function x(n,e){e.useNativeTimers?(n.setTimeoutFn=we.bind(p),n.clearTimeoutFn=Ee.bind(p)):(n.setTimeoutFn=p.setTimeout.bind(p),n.clearTimeoutFn=p.clearTimeout.bind(p))}const ve=1.33;function ke(n){return typeof n=="string"?Ae(n):Math.ceil((n.byteLength||n.size)*ve)}function Ae(n){let e=0,t=0;for(let s=0,i=n.length;s<i;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function ie(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Te(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function Re(n){let e={},t=n.split("&");for(let s=0,i=t.length;s<i;s++){let r=t[s].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}class Oe extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class K extends u{constructor(e){super(),this.writable=!1,x(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new Oe(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=H(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Te(e);return t.length?"?"+t:""}}class Se extends K{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};ye(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,de(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=ie()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let re=!1;try{re=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ce=re;function Be(){}class xe extends Se{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(i,r)=>{this.onError("xhr post error",i,r)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}class g extends u{constructor(e,t,s){super(),this.createRequest=e,x(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=ne(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&s.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var i;s.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=g.requestsCount++,g.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Be,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete g.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}g.requestsCount=0;g.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",X);else if(typeof addEventListener=="function"){const n="onpagehide"in p?"pagehide":"unload";addEventListener(n,X,!1)}}function X(){for(let n in g.requests)g.requests.hasOwnProperty(n)&&g.requests[n].abort()}const Ne=function(){const n=oe({xdomain:!1});return n&&n.responseType!==null}();class Le extends xe{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=Ne&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new g(oe,this.uri(),e)}}function oe(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Ce))return new XMLHttpRequest}catch{}if(!e)try{return new p[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ae=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Pe extends K{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=ae?{}:ne(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1;M(s,this.supportsBinary,r=>{try{this.doWrite(s,r)}catch{}i&&B(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=ie()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const P=p.WebSocket||p.MozWebSocket;class qe extends Pe{createSocket(e,t,s){return ae?new P(e,t,s):t?new P(e,t):new P(e)}doWrite(e,t){this.ws.send(t)}}class De extends K{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=me(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),i=ge();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const r=()=>{s.read().then(({done:a,value:c})=>{a||(this.onPacket(c),r())}).catch(a=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1;this._writer.write(s).then(()=>{i&&B(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Ie={websocket:qe,webtransport:De,polling:Le},Ue=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Fe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function D(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let i=Ue.exec(n||""),r={},o=14;for(;o--;)r[Fe[o]]=i[o]||"";return t!=-1&&s!=-1&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Ve(r,r.path),r.queryKey=Me(r,r.query),r}function Ve(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Me(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,i,r){i&&(t[i]=r)}),t}const I=typeof addEventListener=="function"&&typeof removeEventListener=="function",O=[];I&&addEventListener("offline",()=>{O.forEach(n=>n())},!1);class _ extends u{constructor(e,t){if(super(),this.binaryType=be,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){const s=D(e);t.hostname=s.host,t.secure=s.protocol==="https"||s.protocol==="wss",t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=D(t.host).host);x(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(s=>{const i=s.prototype.name;this.transports.push(i),this._transportsByName[i]=s}),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},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Re(this.opts.query)),I&&(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"})},O.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=se,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&_.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",_.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),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 e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const i=this.writeBuffer[s].data;if(i&&(t+=ke(i)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,B(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,i){if(typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const r={type:e,data:t,options:s};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(_.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){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(),I&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=O.indexOf(this._offlineEventListener);s!==-1&&O.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}_.protocol=se;class He extends _{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;_.priorWebsocketSuccess=!1;const i=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",d=>{if(!s)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;_.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(f(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const b=new Error("probe error");b.transport=t.name,this.emitReserved("upgradeError",b)}}))};function r(){s||(s=!0,f(),t.close(),t=null)}const o=d=>{const b=new Error("probe error: "+d);b.transport=t.name,r(),this.emitReserved("upgradeError",b)};function a(){o("transport closed")}function c(){o("socket closed")}function l(d){t&&d.name!==t.name&&r()}const f=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};t.once("open",i),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}let Ke=class extends He{constructor(e,t={}){const s=typeof e=="object"?e:t;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(i=>Ie[i]).filter(i=>!!i)),super(e,s)}};function We(n,e="",t){let s=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),s=D(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const r=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+r+":"+s.port+e,s.href=s.protocol+"://"+r+(t&&t.port===s.port?"":":"+s.port),s}const $e=typeof ArrayBuffer=="function",Ye=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ce=Object.prototype.toString,ze=typeof Blob=="function"||typeof Blob<"u"&&ce.call(Blob)==="[object BlobConstructor]",Je=typeof File=="function"||typeof File<"u"&&ce.call(File)==="[object FileConstructor]";function W(n){return $e&&(n instanceof ArrayBuffer||Ye(n))||ze&&n instanceof Blob||Je&&n instanceof File}function S(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(S(n[t]))return!0;return!1}if(W(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return S(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&S(n[t]))return!0;return!1}function Xe(n){const e=[],t=n.data,s=n;return s.data=U(t,e),s.attachments=e.length,{packet:s,buffers:e}}function U(n,e){if(!n)return n;if(W(n)){const t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){const t=new Array(n.length);for(let s=0;s<n.length;s++)t[s]=U(n[s],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){const t={};for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=U(n[s],e));return t}return n}function Qe(n,e){return n.data=F(n.data,e),delete n.attachments,n}function F(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=F(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=F(n[t],e));return n}const je=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var h;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(h||(h={}));class Ge{constructor(e){this.replacer=e}encode(e){return(e.type===h.EVENT||e.type===h.ACK)&&S(e)?this.encodeAsBinary({type:e.type===h.EVENT?h.BINARY_EVENT:h.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===h.BINARY_EVENT||e.type===h.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Xe(e),s=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(s),i}}class $ extends u{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===h.BINARY_EVENT;s||t.type===h.BINARY_ACK?(t.type=s?h.EVENT:h.ACK,this.reconstructor=new Ze(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(W(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(h[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===h.BINARY_EVENT||s.type===h.BINARY_ACK){const r=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(r,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(t+1)==="/"){const r=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(r,t)}else s.nsp="/";const i=e.charAt(t+1);if(i!==""&&Number(i)==i){const r=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if($.isPayloadValid(s.type,r))s.data=r;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case h.CONNECT:return Q(t);case h.DISCONNECT:return t===void 0;case h.CONNECT_ERROR:return typeof t=="string"||Q(t);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&je.indexOf(t[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ze{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Qe(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Q(n){return Object.prototype.toString.call(n)==="[object Object]"}const et=Object.freeze(Object.defineProperty({__proto__:null,Decoder:$,Encoder:Ge,get PacketType(){return h}},Symbol.toStringTag,{value:"Module"}));function y(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const tt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class he extends u{constructor(e,t,s){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=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[y(e,"open",this.onopen.bind(this)),y(e,"packet",this.onpacket.bind(this)),y(e,"error",this.onerror.bind(this)),y(e,"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(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,i,r;if(tt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:h.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const f=this.ids++,d=t.pop();this._registerAckCallback(f,d),o.id=f}const a=(i=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||i===void 0?void 0:i.writable,c=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const i=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(r),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,i)=>{const r=(o,a)=>o?i(o):s(a);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...r)=>(this._queue[0],i!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...r)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:h.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case h.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.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 h.EVENT:case h.BINARY_EVENT:this.onevent(e);break;case h.ACK:case h.BINARY_ACK:this.onack(e);break;case h.DISCONNECT:this.ondisconnect();break;case h.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...i){s||(s=!0,t.packet({type:h.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:h.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function w(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}w.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=Math.floor(e*10)&1?n+t:n-t}return Math.min(n,this.max)|0};w.prototype.reset=function(){this.attempts=0};w.prototype.setMin=function(n){this.ms=n};w.prototype.setMax=function(n){this.max=n};w.prototype.setJitter=function(n){this.jitter=n};class V extends u{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,x(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new w({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||et;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Ke(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=y(t,"open",function(){s.onopen(),e&&e()}),r=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=y(t,"error",r);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{i(),r(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(y(e,"ping",this.onping.bind(this)),y(e,"data",this.ondata.bind(this)),y(e,"error",this.onerror.bind(this)),y(e,"close",this.onclose.bind(this)),y(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){B(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new he(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const v={};function C(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=We(n,e.path||"/socket.io"),s=t.source,i=t.id,r=t.path,o=v[i]&&r in v[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new V(s,e):(v[i]||(v[i]=new V(s,e)),c=v[i]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(C,{Manager:V,Socket:he,io:C,connect:C});const it=()=>{const[n,e]=E.useState(null),[t,s]=E.useState(!1),i=E.useRef(new Map);E.useEffect(()=>{const o=window.location.origin,a=C(o,{path:"/socket.io",reconnection:!0,withCredentials:!0});e(a),a.on("connect",()=>{console.log("[Socket] Connected to Hub"),s(!0),a.emit("register_dashboard")}),a.on("disconnect",()=>{console.log("[Socket] Disconnected from Hub"),s(!1)});const c=(l,f)=>{const d=i.current.get(l);d&&d.forEach(b=>b(f))};return a.onAny((l,f)=>{c(l,f)}),()=>{a.close()}},[]);const r=E.useCallback((o,a)=>{var c;return i.current.has(o)||i.current.set(o,[]),(c=i.current.get(o))==null||c.push(a),()=>{const l=i.current.get(o);l&&i.current.set(o,l.filter(f=>f!==a))}},[]);return{socket:n,isConnected:t,on:r}};export{it as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g,b as w,r as s,j as e,f as S}from"./index-
|
|
1
|
+
import{g,b as w,r as s,j as e,f as S}from"./index-CkwQBzCl.js";import{l as E,d as k,c as M,u as C}from"./users-cwrwUhwo.js";import{P as R}from"./plus-BM5UAzcK.js";import{T as A}from"./trash-2-DUWA0N9n.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|