@xenon-device-management/xenon 1.7.3 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{ApiKeyGate-BousCIQZ.js → ApiKeyGate-DX4HKDBA.js} +1 -1
  3. package/lib/public/assets/{BugReportButton-Gw4lnGnV.js → BugReportButton-N-NBBb3l.js} +1 -1
  4. package/lib/public/assets/{DeviceMosaicView-BX2hfhBf.js → DeviceMosaicView-BEDnJqk5.js} +1 -1
  5. package/lib/public/assets/{EmptyState-CPOfuV3O.js → EmptyState-X7DYPoPj.js} +1 -1
  6. package/lib/public/assets/{FieldGroup-C5UkCHbe.js → FieldGroup-a9gzUh4W.js} +1 -1
  7. package/lib/public/assets/{Modal-MMGhL8eW.js → Modal-Cuva-zxU.js} +1 -1
  8. package/lib/public/assets/{SegmentedControl-CZfAicws.js → SegmentedControl-Bdc4A0UR.js} +1 -1
  9. package/lib/public/assets/{SettingCard-Dp7XIdcl.js → SettingCard-DVZUpQJR.js} +1 -1
  10. package/lib/public/assets/{Table-DsN_IX6J.js → Table-Casq-_Hh.js} +1 -1
  11. package/lib/public/assets/{activity-DCBAvxuo.js → activity-KiLkzk_U.js} +1 -1
  12. package/lib/public/assets/{ai-settings-yNS_bU1m.js → ai-settings-0dEPftlc.js} +1 -1
  13. package/lib/public/assets/{api-keys-CQ9g1g1b.js → api-keys-Cg1cbSUt.js} +1 -1
  14. package/lib/public/assets/{apps-Bqh1eav9.js → apps-CyetRRfI.js} +1 -1
  15. package/lib/public/assets/{arrow-left-GX0vzYtn.js → arrow-left-C1v7ukDM.js} +1 -1
  16. package/lib/public/assets/{arrow-up-right-DePHHOby.js → arrow-up-right-B-YmrLSY.js} +1 -1
  17. package/lib/public/assets/{auth-shell-BBGlC6i3.js → auth-shell-BXwxuIPK.js} +1 -1
  18. package/lib/public/assets/{builds-page-Czf7RsmD.js → builds-page-wquO6Xb2.js} +1 -1
  19. package/lib/public/assets/{button-ybNY3GYx.js → button-xZrEx8cE.js} +1 -1
  20. package/lib/public/assets/{check-BZMx8AhR.js → check-CDOZKQih.js} +1 -1
  21. package/lib/public/assets/{chevron-right-WL_bcB02.js → chevron-right-CnpP0W_l.js} +1 -1
  22. package/lib/public/assets/{circle-check-CI2xUlDo.js → circle-check-DDqpikKW.js} +1 -1
  23. package/lib/public/assets/{circle-x-De3thbcr.js → circle-x-DcBe5J67.js} +1 -1
  24. package/lib/public/assets/{clock-BFVLE7wW.js → clock-CfNmWqai.js} +1 -1
  25. package/lib/public/assets/{copy-ve3lNhva.js → copy-DkXT5Ggc.js} +1 -1
  26. package/lib/public/assets/{device-explorer-vzZxT4-Y.js → device-explorer-B3PK2XW9.js} +1 -1
  27. package/lib/public/assets/{download-BDZj44ke.js → download-B0tbRUtY.js} +1 -1
  28. package/lib/public/assets/{forgot-password-BSYQX2oR.js → forgot-password-DvHMwK0-.js} +1 -1
  29. package/lib/public/assets/{funnel-CptlpFZ9.js → funnel-DfsfiM0o.js} +1 -1
  30. package/lib/public/assets/{index-PtnKslHU.js → index-wbxPcwMM.js} +2 -2
  31. package/lib/public/assets/{layers-DRpwoKhI.js → layers-D-4LYQG3.js} +1 -1
  32. package/lib/public/assets/{lock-CrQhC34I.js → lock-Cf_J2NEl.js} +1 -1
  33. package/lib/public/assets/{login-DaJOt8Qz.js → login-DCIOMQb8.js} +1 -1
  34. package/lib/public/assets/{maintenance-settings-D629C2IC.js → maintenance-settings-CDDl4Q8B.js} +1 -1
  35. package/lib/public/assets/{mouse-pointer-2-Dpcc76zN.js → mouse-pointer-2-DoCqhosb.js} +1 -1
  36. package/lib/public/assets/{overview-CGEKYX62.js → overview-DNeH4FfG.js} +1 -1
  37. package/lib/public/assets/{page-header-CSvuGbSO.js → page-header-DZpQDeCw.js} +1 -1
  38. package/lib/public/assets/{plus-vJJF9g79.js → plus-CTjPrkU5.js} +1 -1
  39. package/lib/public/assets/{profile-page-CF7ZQNQz.js → profile-page-DKiZOb_Y.js} +1 -1
  40. package/lib/public/assets/{reset-password-BgpjbCac.js → reset-password-6rl6YA7S.js} +1 -1
  41. package/lib/public/assets/{runbook-page-Dxuzftyv.js → runbook-page-DTTw_cb3.js} +1 -1
  42. package/lib/public/assets/{selector-detail-page-B_puCd9g.js → selector-detail-page-BVPMp3ZK.js} +1 -1
  43. package/lib/public/assets/{selector-health-BjMHf106.js → selector-health-BVJ8fGyw.js} +1 -1
  44. package/lib/public/assets/{selector-health-page-Du_bGD2p.js → selector-health-page-CZ_AAjtV.js} +1 -1
  45. package/lib/public/assets/{session-detail-page-lQTe5_B1.js → session-detail-page-BApz2wZr.js} +1 -1
  46. package/lib/public/assets/{settings-DhxWGUzy.js → settings-CuYjTdtb.js} +1 -1
  47. package/lib/public/assets/{shield-JGzamJo5.js → shield-DVYhrtS6.js} +1 -1
  48. package/lib/public/assets/{shield-alert-DzE36jcb.js → shield-alert-BhxlmXys.js} +1 -1
  49. package/lib/public/assets/{status-pill-outline-50aN0wRU.js → status-pill-outline-DjKuXDLG.js} +1 -1
  50. package/lib/public/assets/{tablet-DHY88mxw.js → tablet-CxgLRRaU.js} +1 -1
  51. package/lib/public/assets/{teams-EOAIPbZC.js → teams-EuX6i7H2.js} +1 -1
  52. package/lib/public/assets/{trash-2-BrTSfFh5.js → trash-2-8zA1h40t.js} +1 -1
  53. package/lib/public/assets/useSocket-qyqK9PWr.js +1 -0
  54. package/lib/public/assets/{users-Dd44jLAB.js → users-CPafGHcL.js} +1 -1
  55. package/lib/public/assets/{webhook-settings-DBYmqim_.js → webhook-settings-y8EAM79b.js} +1 -1
  56. package/lib/public/assets/{zap-JUbOoK3o.js → zap-C-b2-XlO.js} +1 -1
  57. package/lib/public/index.html +1 -1
  58. package/lib/src/device-managers/IOSDeviceManager.js +24 -3
  59. package/lib/src/device-managers/ios/IOSStreamService.js +39 -1
  60. package/lib/src/device-managers/ios/iosBattery.js +24 -0
  61. package/lib/src/device-managers/ios/iosStreamDiagnostics.js +61 -0
  62. package/lib/src/services/VideoPipelineService.js +51 -43
  63. package/lib/test/unit/iosBattery.spec.js +29 -0
  64. package/lib/test/unit/iosStreamDiagnostics.spec.js +61 -0
  65. package/lib/test/unit/video-pipeline-args.spec.js +46 -0
  66. package/lib/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +1 -1
  68. package/lib/public/assets/useSocket-BRto9a5m.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/overview-CGEKYX62.js","assets/useSocket-BRto9a5m.js","assets/funnel-CptlpFZ9.js","assets/tablet-DHY88mxw.js","assets/activity-DCBAvxuo.js","assets/plus-vJJF9g79.js","assets/device-explorer-vzZxT4-Y.js","assets/page-header-CSvuGbSO.js","assets/button-ybNY3GYx.js","assets/button-DtC0WGPu.css","assets/BugReportButton-Gw4lnGnV.js","assets/BugReportButton-DeF8gwF1.css","assets/Modal-MMGhL8eW.js","assets/Modal-qvYudaqQ.css","assets/FieldGroup-C5UkCHbe.js","assets/FieldGroup-trY-2qmW.css","assets/clock-BFVLE7wW.js","assets/copy-ve3lNhva.js","assets/time-B8FIgwPE.js","assets/mouse-pointer-2-Dpcc76zN.js","assets/layers-DRpwoKhI.js","assets/check-BZMx8AhR.js","assets/zap-JUbOoK3o.js","assets/chevron-right-WL_bcB02.js","assets/shield-alert-DzE36jcb.js","assets/keycodes-bIEJfQzr.js","assets/lock-CrQhC34I.js","assets/trash-2-BrTSfFh5.js","assets/download-BDZj44ke.js","assets/SegmentedControl-CZfAicws.js","assets/SegmentedControl-M7StbYAD.css","assets/device-explorer-elRO7T00.css","assets/builds-page-Czf7RsmD.js","assets/status-pill-outline-50aN0wRU.js","assets/circle-x-De3thbcr.js","assets/circle-check-CI2xUlDo.js","assets/session-detail-page-lQTe5_B1.js","assets/arrow-left-GX0vzYtn.js","assets/arrow-up-right-DePHHOby.js","assets/EmptyState-CPOfuV3O.js","assets/EmptyState-BSDHFxd1.css","assets/Table-DsN_IX6J.js","assets/Table-BIjXN_-_.css","assets/session-detail-page-BikvFUAQ.css","assets/runbook-page-Dxuzftyv.js","assets/runbook-page-BcfSJRZ-.css","assets/apps-Bqh1eav9.js","assets/apps-CTrGClro.css","assets/webhook-settings-DBYmqim_.js","assets/webhook-settings-tW1oXXrJ.css","assets/settings-Cxx_aYWT.css","assets/settings-DhxWGUzy.js","assets/SettingCard-Dp7XIdcl.js","assets/SettingCard-C7wPlNh9.css","assets/shield-JGzamJo5.js","assets/ai-settings-yNS_bU1m.js","assets/maintenance-settings-D629C2IC.js","assets/api-keys-CQ9g1g1b.js","assets/teams-EOAIPbZC.js","assets/users-cwrwUhwo.js","assets/selector-health-page-Du_bGD2p.js","assets/selector-health-BjMHf106.js","assets/selector-health-BwHGcem9.css","assets/selector-detail-page-B_puCd9g.js","assets/DeviceMosaicView-BX2hfhBf.js","assets/profile-page-CF7ZQNQz.js","assets/users-Dd44jLAB.js","assets/login-DaJOt8Qz.js","assets/auth-shell-BBGlC6i3.js","assets/forgot-password-BSYQX2oR.js","assets/reset-password-BgpjbCac.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/overview-DNeH4FfG.js","assets/useSocket-qyqK9PWr.js","assets/funnel-DfsfiM0o.js","assets/tablet-CxgLRRaU.js","assets/activity-KiLkzk_U.js","assets/plus-CTjPrkU5.js","assets/device-explorer-B3PK2XW9.js","assets/page-header-DZpQDeCw.js","assets/button-xZrEx8cE.js","assets/button-DtC0WGPu.css","assets/BugReportButton-N-NBBb3l.js","assets/BugReportButton-DeF8gwF1.css","assets/Modal-Cuva-zxU.js","assets/Modal-qvYudaqQ.css","assets/FieldGroup-a9gzUh4W.js","assets/FieldGroup-trY-2qmW.css","assets/clock-CfNmWqai.js","assets/copy-DkXT5Ggc.js","assets/time-B8FIgwPE.js","assets/mouse-pointer-2-DoCqhosb.js","assets/layers-D-4LYQG3.js","assets/check-CDOZKQih.js","assets/zap-C-b2-XlO.js","assets/chevron-right-CnpP0W_l.js","assets/shield-alert-BhxlmXys.js","assets/keycodes-bIEJfQzr.js","assets/lock-Cf_J2NEl.js","assets/trash-2-8zA1h40t.js","assets/download-B0tbRUtY.js","assets/SegmentedControl-Bdc4A0UR.js","assets/SegmentedControl-M7StbYAD.css","assets/device-explorer-elRO7T00.css","assets/builds-page-wquO6Xb2.js","assets/status-pill-outline-DjKuXDLG.js","assets/circle-x-DcBe5J67.js","assets/circle-check-DDqpikKW.js","assets/session-detail-page-BApz2wZr.js","assets/arrow-left-C1v7ukDM.js","assets/arrow-up-right-B-YmrLSY.js","assets/EmptyState-X7DYPoPj.js","assets/EmptyState-BSDHFxd1.css","assets/Table-Casq-_Hh.js","assets/Table-BIjXN_-_.css","assets/session-detail-page-BikvFUAQ.css","assets/runbook-page-DTTw_cb3.js","assets/runbook-page-BcfSJRZ-.css","assets/apps-CyetRRfI.js","assets/apps-CTrGClro.css","assets/webhook-settings-y8EAM79b.js","assets/webhook-settings-tW1oXXrJ.css","assets/settings-Cxx_aYWT.css","assets/settings-CuYjTdtb.js","assets/SettingCard-DVZUpQJR.js","assets/SettingCard-C7wPlNh9.css","assets/shield-DVYhrtS6.js","assets/ai-settings-0dEPftlc.js","assets/maintenance-settings-CDDl4Q8B.js","assets/api-keys-Cg1cbSUt.js","assets/teams-EuX6i7H2.js","assets/users-cwrwUhwo.js","assets/selector-health-page-CZ_AAjtV.js","assets/selector-health-BVJ8fGyw.js","assets/selector-health-BwHGcem9.css","assets/selector-detail-page-BVPMp3ZK.js","assets/DeviceMosaicView-BEDnJqk5.js","assets/profile-page-DKiZOb_Y.js","assets/users-CPafGHcL.js","assets/login-DCIOMQb8.js","assets/auth-shell-BXwxuIPK.js","assets/forgot-password-DvHMwK0-.js","assets/reset-password-6rl6YA7S.js"])))=>i.map(i=>d[i]);
2
2
  function $c(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const l in r)if(l!=="default"&&!(l in e)){const o=Object.getOwnPropertyDescriptor(r,l);o&&Object.defineProperty(e,l,o.get?o:{enumerable:!0,get:()=>r[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function _a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ca={exports:{}},tr={};/*
3
3
  object-assign
4
4
  (c) Sindre Sorhus
@@ -206,4 +206,4 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
206
206
  *
207
207
  * This source code is licensed under the ISC license.
208
208
  * See the LICENSE file in the root directory of this source tree.
209
- */const Qh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Kh=B("x",Qh),Pt="/xenon/api/auth";async function Fm(e,t){const n=await fetch(`${Pt}/login`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Login failed (${n.status})`)}}async function Xh(){await fetch(`${Pt}/logout`,{method:"POST",credentials:"include"})}async function Yh(){const e=await fetch(`${Pt}/me`,{credentials:"include"});if(e.status===401)return null;if(!e.ok)throw new Error(`Failed to fetch /me (${e.status})`);return e.json()}async function Bm(e,t){const n=await fetch(`${Pt}/change-password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:e,newPassword:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Change password failed (${n.status})`)}}async function Vm(e){const t=await fetch(`${Pt}/forgot-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok&&t.status!==204)throw t.status===429?new Error("Too many attempts — try again later."):new Error(`Request failed (${t.status})`)}async function Wm(e){return(await fetch(`${Pt}/reset-password/check/${encodeURIComponent(e)}`)).ok}async function Hm(e,t){const n=await fetch(`${Pt}/reset-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,newPassword:t})});if(!n.ok&&n.status!==204){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Reset failed (${n.status})`)}}const Ic=y.createContext(null);function Jh({children:e}){const[t,n]=y.useState(!0),[r,l]=y.useState(null);async function o(){try{l(await Yh())}finally{n(!1)}}async function i(){await Xh(),l(null),window.location.href="/xenon/login"}return y.useEffect(()=>{o()},[]),p.jsx(Ic.Provider,{value:{loading:t,me:r,refresh:o,signOut:i},children:e})}function Bi(){const e=y.useContext(Ic);if(!e)throw new Error("useAuth must be used inside AuthProvider");return e}function Zh(){const[e,t]=y.useState(0),[n]=y.useState(()=>Date.now());y.useEffect(()=>{const a=setInterval(()=>t(u=>u+1),5e3);return()=>clearInterval(a)},[]);const r=Math.floor((Date.now()-n)/1e3)+e*0,l=Math.floor(r/60),o=Math.floor(l/60),i=r<10?"Updated just now":r<60?`Updated ${r}s ago`:l<60?`Updated ${l}m ago`:`Updated ${o}h ago`,s=l>=10?"stale":l>=2?"aging":"fresh";return{label:i,staleness:s}}const bh=()=>{const e=sn(),{me:t,signOut:n}=Bi(),{label:r,staleness:l}=Zh(),[o,i]=y.useState(!1),s=y.useRef(null),a=((t==null?void 0:t.name)??"A").split(" ").map(g=>g[0]).slice(0,2).join("").toUpperCase(),u=(t==null?void 0:t.role)==="SUPER_ADMIN"?"Super Admin":(t==null?void 0:t.role)==="ADMIN"?"Admin":"Member";y.useEffect(()=>{const g=h=>{s.current&&!s.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const v=()=>window.dispatchEvent(new CustomEvent("xenon.open-command-palette"));return p.jsx("header",{className:"fixed top-0 left-14 right-0 z-20 h-14 border-b border-[var(--border)] bg-[var(--bg)]/80 backdrop-blur-md",children:p.jsxs("div",{className:"flex items-center h-full px-4 gap-4",children:[p.jsx("button",{type:"button",onClick:()=>e("/overview"),className:"flex items-center gap-3 min-w-0 cursor-pointer","aria-label":"Xenon home",children:p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("img",{src:"/xenon/logo.svg",alt:"Xenon Logo",className:"h-8 w-auto object-contain"})})}),p.jsx("div",{className:"flex-1 max-w-xl mx-auto",children:p.jsxs("button",{type:"button",onClick:v,className:"relative w-full h-9 flex items-center text-left","aria-label":"Open command palette",children:[p.jsx("div",{className:"w-full h-9 pl-9 pr-14 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm text-[var(--text-dim)] hover:border-[var(--border-strong)] hover:text-[var(--text)] transition-colors flex items-center",children:"Search devices, sessions, settings…"}),p.jsx(Lc,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--text-dim)]"}),p.jsx("kbd",{className:"absolute right-3 top-1/2 -translate-y-1/2 font-mono text-[10px] text-[var(--text-dim)] border border-[var(--border)] rounded px-1.5 py-0.5",children:"⌘K"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`hidden md:inline text-xs font-mono transition-colors ${l==="stale"?"text-[var(--red)]":l==="aging"?"text-[var(--amber)]":"text-[var(--text-dim)]"}`,title:l==="stale"?"Data is stale — reconnection may be needed.":l==="aging"?"Data hasn’t updated in a while.":"Live data.",children:r}),p.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-[var(--green)]/10 border border-[var(--green)]/20",children:[p.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--green)] pulse-dot"}),p.jsx("span",{className:"text-[11px] font-medium text-[var(--green)]",children:"Online"})]}),p.jsxs("div",{className:"relative",ref:s,children:[p.jsxs("button",{type:"button",className:"flex items-center gap-2 h-9 pl-1.5 pr-2.5 rounded-md border border-[var(--border)] hover:border-[var(--border-strong)] hover:bg-[var(--surface)] transition-colors",onClick:()=>i(g=>!g),"aria-haspopup":"true","aria-expanded":o,children:[p.jsx("span",{className:"h-6 w-6 rounded-full bg-[var(--green)]/15 text-[var(--green)] text-[11px] font-semibold flex items-center justify-center",children:a}),p.jsxs("span",{className:"flex flex-col items-start leading-tight",children:[p.jsx("span",{className:"text-xs text-[var(--text)]",children:(t==null?void 0:t.name)??"Account"}),p.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:u})]}),p.jsx(ph,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"})]}),o&&p.jsxs("div",{className:"absolute top-full right-0 mt-2 w-64 rounded-md border border-[var(--border)] bg-[var(--surface)] shadow-lg overflow-hidden",children:[p.jsxs("div",{className:"px-3 py-2",children:[p.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-dim)] mb-1",children:"Workspace"}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)]",children:[p.jsx("span",{className:"text-[var(--text-muted)]",children:"Registry"}),p.jsx("span",{children:"Default"})]}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)] mt-1",children:[p.jsx("span",{className:"text-[var(--text-muted)]",children:"Node"}),p.jsx("span",{children:"Root · Primary"})]})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("div",{className:"px-3 py-2",children:[p.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-dim)] mb-1",children:"System"}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)]",children:[p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--green)]"}),"Stable"]}),p.jsxs("span",{className:"font-mono text-[var(--text-muted)]",children:["v","0.3.0"]})]})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("button",{type:"button",onClick:()=>{i(!1),e("/profile")},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--bg)] text-left",children:[p.jsx(qh,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"}),"Profile"]}),p.jsxs("button",{type:"button",onClick:()=>{i(!1),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--red)] hover:bg-[var(--bg)] text-left",children:[p.jsx(Nh,{className:"h-3.5 w-3.5"}),"Logout"]})]})]})]})]})})};class em extends y.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReset=()=>{this.setState({hasError:!1}),window.location.reload()}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?this.props.fallback||p.jsxs("div",{className:"error-boundary-container",style:{padding:"4rem 2rem",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"1.5rem",color:"var(--text)",background:"var(--bg-main)",minHeight:"100vh"},children:[p.jsx("div",{style:{color:"var(--accent-red)",filter:"drop-shadow(0 0 10px rgba(239, 68, 68, 0.3))"},children:p.jsx(Bh,{size:64})}),p.jsx("h2",{style:{fontSize:"2rem",fontWeight:700,margin:0},children:"Component Exception Detected"}),p.jsx("p",{style:{color:"var(--text-muted)",maxWidth:"500px",lineHeight:1.6},children:"An unexpected error occurred while rendering this section. Xenon's isolation engine has contained the fault to prevent a total system crash."}),this.state.error&&p.jsx("pre",{style:{background:"rgba(0,0,0,0.3)",padding:"1rem",borderRadius:"8px",fontSize:"0.8rem",color:"var(--accent-red)",maxWidth:"80%",overflowX:"auto"},children:this.state.error.message}),p.jsxs("button",{onClick:this.handleReset,style:{background:"var(--green)",color:"var(--secondary)",border:"none",padding:"0.75rem 2rem",borderRadius:"8px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",gap:"0.5rem",transition:"all 0.2s"},onMouseOver:t=>t.currentTarget.style.transform="translateY(-2px)",onMouseOut:t=>t.currentTarget.style.transform="translateY(0)",children:[p.jsx(Oc,{size:18}),"Reload Application"]})]}):this.props.children}}const tm=y.lazy(()=>Q(()=>import("./overview-CGEKYX62.js"),__vite__mapDeps([0,1,2,3,4,5]))),ga=y.lazy(()=>Q(()=>import("./device-explorer-vzZxT4-Y.js"),__vite__mapDeps([6,7,8,9,10,11,12,13,14,15,16,5,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,1,31]))),wa=y.lazy(()=>Q(()=>import("./builds-page-Czf7RsmD.js"),__vite__mapDeps([32,33,1,18,4,34,35,16,28,23,3,7]))),nm=y.lazy(()=>Q(()=>import("./session-detail-page-lQTe5_B1.js"),__vite__mapDeps([36,33,1,18,10,11,37,23,17,38,39,40,41,42,12,13,28,43]))),rm=y.lazy(()=>Q(()=>import("./runbook-page-Dxuzftyv.js"),__vite__mapDeps([44,37,45]))),lm=y.lazy(()=>Q(()=>import("./apps-Bqh1eav9.js"),__vite__mapDeps([46,18,8,9,7,21,17,22,28,27,47]))),om=y.lazy(()=>Q(()=>import("./webhook-settings-DBYmqim_.js"),__vite__mapDeps([48,14,15,7,27,5,34,35,22,4,49,50])).then(e=>({default:e.WebhookSettings}))),im=y.lazy(()=>Q(()=>import("./settings-DhxWGUzy.js"),__vite__mapDeps([51,52,53,7,1,54,35,16,19,21,4,38,50])).then(e=>({default:e.Settings}))),sm=y.lazy(()=>Q(()=>import("./ai-settings-yNS_bU1m.js"),__vite__mapDeps([55,52,53,7,26,35,4,50])).then(e=>({default:e.AISettings}))),am=y.lazy(()=>Q(()=>import("./maintenance-settings-D629C2IC.js"),__vite__mapDeps([56,52,53,7,54,27,21,50])).then(e=>({default:e.MaintenanceSettings}))),um=y.lazy(()=>Q(()=>import("./api-keys-CQ9g1g1b.js"),__vite__mapDeps([57,18,41,42,14,15,7,12,13,24,5,27,21,17,50])).then(e=>({default:e.ApiKeys}))),cm=y.lazy(()=>Q(()=>import("./teams-EOAIPbZC.js"),__vite__mapDeps([58,18,41,42,14,15,7,12,13,59,24,5,37,27,50])).then(e=>({default:e.Teams}))),fm=y.lazy(()=>Q(()=>import("./selector-health-page-Du_bGD2p.js"),__vite__mapDeps([60,22,61,62,35,12,13,21,17,18,1,39,40,7,29,30,2,23,38]))),dm=y.lazy(()=>Q(()=>import("./selector-detail-page-B_puCd9g.js"),__vite__mapDeps([63,18,7,61,62,20,35,22,21,17]))),pm=y.lazy(()=>Q(()=>import("./DeviceMosaicView-BX2hfhBf.js"),__vite__mapDeps([64,25]))),hm=y.lazy(()=>Q(()=>import("./profile-page-CF7ZQNQz.js"),__vite__mapDeps([65,7,18,17,27]))),mm=y.lazy(()=>Q(()=>import("./users-Dd44jLAB.js"),__vite__mapDeps([66,59,18,7,5,27]))),vm=()=>p.jsxs("div",{className:"flex items-center justify-center gap-2 h-full text-xs text-[var(--text-dim)]",children:[p.jsx(Oc,{className:"animate-spin",size:14}),p.jsx("span",{children:"Hydrating view…"})]}),ym=()=>p.jsx(em,{children:p.jsx(y.Suspense,{fallback:p.jsx(vm,{}),children:p.jsxs(Nc,{children:[p.jsx($,{path:"/",element:p.jsx(rl,{to:"/overview",replace:!0})}),p.jsx($,{path:"/overview",element:p.jsx(tm,{})}),p.jsx($,{path:"/devices",element:p.jsx(ga,{})}),p.jsx($,{path:"/devices/:udid/control/:tab?",element:p.jsx(ga,{})}),p.jsx($,{path:"/apps",element:p.jsx(lm,{})}),p.jsx($,{path:"/builds",element:p.jsx(wa,{})}),p.jsx($,{path:"/builds/:buildId",element:p.jsx(wa,{})}),p.jsx($,{path:"/builds/:buildId/sessions/:sessionId",element:p.jsx(nm,{})}),p.jsx($,{path:"/notifications",element:p.jsx(om,{})}),p.jsx($,{path:"/settings",element:p.jsx(im,{})}),p.jsx($,{path:"/ai-settings",element:p.jsx(sm,{})}),p.jsx($,{path:"/maintenance",element:p.jsx(am,{})}),p.jsx($,{path:"/api-keys",element:p.jsx(um,{})}),p.jsx($,{path:"/teams",element:p.jsx(cm,{})}),p.jsx($,{path:"/users",element:p.jsx(mm,{})}),p.jsx($,{path:"/selector-health",element:p.jsx(fm,{})}),p.jsx($,{path:"/selector-health/detail",element:p.jsx(dm,{})}),p.jsx($,{path:"/devices/live",element:p.jsx(pm,{})}),p.jsx($,{path:"/runbooks/:category",element:p.jsx(rm,{})}),p.jsx($,{path:"/profile",element:p.jsx(hm,{})}),p.jsx($,{path:"*",element:p.jsx(rl,{to:"/overview",replace:!0})})]})})});let Uo=null;function xa(e){Uo=e}class gm{makeGETRequest(t){return fetch(this.formatUrl(t)).then(this.jsonResult)}makePOSTRequest(t,n,r,l={}){return fetch(this.formatUrl(t),{method:"POST",body:JSON.stringify(r||{}),headers:{"Content-Type":"application/json"},...l}).then(this.jsonResult)}makeDELETERequest(t){return fetch(this.formatUrl(t),{method:"DELETE"}).then(this.jsonResult)}formatUrl(t){return`/xenon/api${t}`}async jsonResult(t){if(t.status===403){const n=await t.clone().json().catch(()=>({})),r=n&&(n.error||n.message)||"You do not have permission for this action.";Uo&&Uo(r,"error")}return t.json()}}const j=new gm,Mc=y.createContext(void 0),qm=()=>{const e=y.useContext(Mc);if(!e)throw new Error("useToast must be used within a ToastProvider");return e},wm=({children:e})=>{const[t,n]=y.useState([]),r=y.useCallback(o=>{n(i=>i.filter(s=>s.id!==o))},[]),l=y.useCallback((o,i="info",s=4e3)=>{const a=Math.random().toString(36).substring(2,9);return n(u=>[...u,{id:a,message:o,type:i,duration:s}]),i!=="loading"&&s>0&&setTimeout(()=>{r(a)},s),a},[r]);return y.useEffect(()=>(xa((o,i="info")=>l(o,i)),()=>xa(null)),[l]),p.jsxs(Mc.Provider,{value:{toast:l,removeToast:r},children:[e,p.jsx("div",{className:"toast-container","aria-live":"polite","aria-atomic":"true",role:"status",children:t.map(o=>p.jsxs("div",{className:`toast-item toast-${o.type} animate-slide-in`,children:[p.jsxs("div",{className:"toast-icon",children:[o.type==="success"&&p.jsx(yh,{size:18}),o.type==="error"&&p.jsx(mh,{size:18}),o.type==="info"&&p.jsx(kh,{size:18}),o.type==="loading"&&p.jsx(jh,{size:18,className:"animate-spin"})]}),p.jsx("div",{className:"toast-message",children:o.message}),p.jsx("button",{className:"toast-close",onClick:()=>r(o.id),"aria-label":`Close ${o.type} notification`,children:p.jsx(Kh,{size:14})})]},o.id))})]})},xm=[{id:"overview",label:"Overview",icon:Ch,path:"/overview"},{id:"devices",label:"Devices",icon:Uh,path:"/devices"},{id:"live-devices",label:"Live Devices",icon:Wh,path:"/devices/live"},{id:"apps",label:"Apps",icon:oh,path:"/apps"},{id:"sessions",label:"Sessions",icon:Oh,path:"/builds"},{id:"selector-health",label:"Selector Health",icon:wh,path:"/selector-health"},{id:"notifications",label:"Notifications",icon:sh,path:"/notifications"},{id:"settings",label:"Settings",icon:Dh,path:"/settings",minRole:"ADMIN"},{id:"ai",label:"AI Engine",icon:fh,path:"/ai-settings",minRole:"ADMIN"},{id:"maintenance",label:"Maintenance",icon:zh,path:"/maintenance",minRole:"ADMIN"},{id:"teams",label:"Teams",icon:ya,path:"/teams",minRole:"ADMIN"},{id:"users",label:"Users",icon:ya,path:"/users",minRole:"ADMIN"},{id:"apikeys",label:"API Keys",icon:Sh,path:"/api-keys",minRole:"ADMIN"}],ka={SUPER_ADMIN:3,ADMIN:2,MEMBER:1};function km(e,t){return t?(e?ka[e]??0:0)>=ka[t]:!0}const Em=()=>{const e=sn(),t=at(),{me:n}=Bi(),r=xm.filter(s=>km(n==null?void 0:n.role,s.minRole)),l=t.pathname.replace(/\/$/,"")||"/",o=r.filter(s=>l===s.path||l.startsWith(s.path+"/")).sort((s,a)=>a.path.length-s.path.length)[0],i=s=>(o==null?void 0:o.path)===s;return p.jsxs("aside",{className:"fixed inset-y-0 left-0 z-30 w-14 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col items-center py-3",children:[p.jsx("nav",{className:"flex-1 flex flex-col gap-1 w-full items-center",children:r.map(s=>{const a=s.icon,u=i(s.path);return p.jsxs("button",{type:"button",onClick:()=>e(s.path),className:`group relative w-full flex justify-center py-2.5 mx-1 rounded-md transition-colors ${u?"bg-[var(--surface-2)]":"hover:bg-[var(--surface-2)]/60"}`,"aria-label":s.label,"aria-current":u?"page":void 0,children:[p.jsx("span",{className:`absolute left-0 top-1 bottom-1 w-[3px] rounded-r transition-all ${u?"bg-[var(--green)]":"bg-transparent"}`}),p.jsx(a,{className:`h-[18px] w-[18px] transition-colors ${u?"text-[var(--green)]":"text-[var(--text-dim)] group-hover:text-[var(--text)]"}`,strokeWidth:u?2.25:2}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:s.label})]},s.id)})}),p.jsxs("button",{type:"button",className:"group relative w-full flex justify-center py-2.5 mt-2","aria-label":"API Docs",onClick:()=>window.open(window.location.origin+"/xenon/api-docs","_blank"),children:[p.jsx(uh,{className:"h-[18px] w-[18px] text-[var(--text-dim)] group-hover:text-[var(--text)] transition-colors"}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:"API Docs"})]})]})};class kr{static getDevices(){return j.makeGETRequest(`/device?t=${Date.now()}`)}static getPendingSessionsCount(){return j.makeGETRequest("/queue/length")}static getPendingSessions(){return j.makeGETRequest("/queue")}static getQueueSummary(){return j.makeGETRequest("/queue/summary")}static getQueueStatus(t){return j.makeGETRequest(`/queue/status/${t}`)}static getBuilds(){return j.makeGETRequest("/build")}static getSessions(t={}){let r=`/session?t=${Date.now()}`;return t.buildId&&(r+=`&buildId=${encodeURIComponent(t.buildId)}`),t.query&&(r+=`&query=${encodeURIComponent(t.query)}`),t.status&&(r+=`&status=${encodeURIComponent(t.status)}`),t.platform&&(r+=`&platform=${encodeURIComponent(t.platform)}`),j.makeGETRequest(r)}static getSession(t){return j.makeGETRequest(`/session/${t}`)}static getSessionLogs(t){return j.makeGETRequest(`/session/${t}/session_log`)}static getDeviceLogs(t){return j.makeGETRequest(`/session/${t}/logs/device`)}static getDebugLogs(t){return j.makeGETRequest(`/session/${t}/logs/debug`)}static getProfilingData(t){return j.makeGETRequest(`/session/${t}/profiling`)}static omniScan(t){return j.makeGETRequest(`/session/${t}/xenon/omni-scan`)}static omniScanControl(t){return j.makeGETRequest(`/control/${t}/omni-scan`)}static testAiLocator(t,n,r){return j.makePOSTRequest(`/session/${t}/xenon/test-locator`,{},{strategy:n,selector:r})}static testAiLocatorControl(t,n,r){return j.makePOSTRequest(`/control/${t}/test-locator`,{},{strategy:n,selector:r})}static blockDevice(t,n){return j.makePOSTRequest("/block",{},{udid:t,host:n})}static unblockDevice(t,n){return j.makePOSTRequest("/unblock",{},{udid:t,host:n})}static updateDeviceTags(t,n,r){return j.makePOSTRequest("/device/tags",{},{udid:t,host:n,tags:r})}static async listTeams(){const t=await fetch("/xenon/api/teams",{credentials:"include"});if(!t.ok)throw new Error(`listTeams failed (${t.status})`);return(await t.json()).map(r=>({id:r.id,name:r.name}))}static async setDeviceTeam(t,n){const r=await fetch(`/xenon/api/grid/device/${encodeURIComponent(t)}/team`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:n})});if(!r.ok&&r.status!==204){const l=await r.json().catch(()=>({}));throw new Error(l.error||`setDeviceTeam failed (${r.status})`)}}static getSessionLiveVideoUrl(t){return j.formatUrl(`/session/${t}/live_video`)}static getReservations(){return j.makeGETRequest("/reservation")}static reserveDevice(t,n,r,l,o){return j.makePOSTRequest("/reservation",{},{udid:t,host:n,reservedBy:r,duration:l,reason:o})}static releaseReservation(t,n){return j.makeDELETERequest(`/reservation/${t}/${encodeURIComponent(n)}`)}static extendReservation(t,n,r){return j.makePOSTRequest(`/reservation/${t}/${encodeURIComponent(n)}/extend`,{},{duration:r})}static getAssetUrl(t){return t?`/xenon/assets/${t.replace(/^\//,"")}`:""}static tap(t,n,r){return j.makePOSTRequest(`/control/${t}/tap`,{},{x:n,y:r})}static swipe(t,n,r,l,o){return j.makePOSTRequest(`/control/${t}/swipe`,{},{x:n,y:r,endX:l,endY:o})}static typeText(t,n){return j.makePOSTRequest(`/control/${t}/text`,{},{text:n})}static pressKey(t,n){return j.makePOSTRequest(`/control/${t}/keyevent`,{},{keyCode:n})}static getClipboard(t){return j.makeGETRequest(`/control/${t}/clipboard`)}static setClipboard(t,n){return j.makePOSTRequest(`/control/${t}/clipboard`,{},{content:n})}static getScreenshot(t){return j.makeGETRequest(`/control/${t}/screenshot`)}static touchAndHold(t,n,r,l){return j.makePOSTRequest(`/control/${t}/touchAndHold`,{},{x:n,y:r,duration:l})}static lock(t){return j.makePOSTRequest(`/control/${t}/lock`,{},{})}static unlock(t){return j.makePOSTRequest(`/control/${t}/unlock`,{},{})}static installApp(t,n){return j.makePOSTRequest(`/control/${t}/install`,{},{appPath:n})}static startStream(t){return j.makePOSTRequest(`/control/${t}/stream/start`,{},{})}static stopStream(t){return j.makePOSTRequest(`/control/${t}/stream/stop`,{},{},{keepalive:!0})}static uninstallApp(t,n){return j.makePOSTRequest(`/control/${t}/uninstall`,{},{bundleId:n})}static uploadAndInstallApp(t,n){const r=new FormData;return r.append("app",n),fetch(`/xenon/api/control/${t}/upload-install`,{method:"POST",body:r}).then(l=>l.json())}static listApps(t){return j.makeGETRequest(`/control/${t}/apps`)}static getLogs(t){return j.makeGETRequest(`/control/${t}/logs`)}static getApps(){return j.makeGETRequest("/apps")}static uploadApp(t){const n=new FormData;return n.append("app",t),fetch("/xenon/api/apps/upload",{method:"POST",body:n}).then(r=>r.json())}static deleteApp(t){return j.makeDELETERequest(`/apps/${t}`)}static installRepositoryApp(t,n){return j.makePOSTRequest(`/control/${t}/install-repository-app`,{},{appId:n})}static executeShell(t,n){return j.makePOSTRequest(`/control/${t}/shell`,{},{command:n})}static getInspectorSnapshot(t){return j.makeGETRequest(`/control/${t}/inspector/snapshot`)}static getWebhookConfigs(){return j.makeGETRequest("/webhook")}static addWebhookConfig(t,n,r,l){return j.makePOSTRequest("/webhook",{},{url:t,events:n,type:r,payloadTemplate:l})}static deleteWebhookConfig(t){return j.makeDELETERequest(`/webhook/${t}`)}static testWebhook(t,n){return j.makePOSTRequest("/webhook/test",{},{url:t,type:n})}static getGlobalConfig(){return j.makeGETRequest("/config")}static updateGlobalConfig(t){return j.makePOSTRequest("/config",{},t)}static testAIConfig(t){return j.makePOSTRequest("/config/test-ai",{},t)}static resetMetrics(){return j.makePOSTRequest("/config/reset-metrics",{},{})}static getRecentHealingEvents(t=50){return j.makeGETRequest(`/healing/events?limit=${t}&t=${Date.now()}`)}static getHealingSummary(t=30){return j.makeGETRequest(`/healing/summary?windowDays=${t}&t=${Date.now()}`)}static getHealingHotspots(t={}){const{windowDays:n=30,limit:r=20,tier:l,platform:o,status:i="active"}=t;let s=`/healing/hotspots?windowDays=${n}&limit=${r}&status=${i}&t=${Date.now()}`;return l&&(s+=`&tier=${encodeURIComponent(l)}`),o&&(s+=`&platform=${encodeURIComponent(o)}`),j.makeGETRequest(s)}static getMutedSelectors(t={}){const{limit:n=50,offset:r=0}=t;return j.makeGETRequest(`/healing/state/muted?limit=${n}&offset=${r}&t=${Date.now()}`)}static getSelectorState(t,n){return j.makeGETRequest(`/healing/state/${encodeURIComponent(t)}/${encodeURIComponent(n)}?t=${Date.now()}`)}static async postSelectorStateAction(t){const n=await fetch("/xenon/api/healing/selector/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({})),l=new Error(r.error??`Selector state action failed (${n.status})`);throw l.status=n.status,l.currentStatus=r.currentStatus??null,l}return n.json()}static getHealingSelectorDetail(t,n=30){return j.makeGETRequest(`/healing/selector?value=${encodeURIComponent(t)}&windowDays=${n}&t=${Date.now()}`)}static sendHealingDigest(t={}){return j.makePOSTRequest("/healing/digest/send",{},t)}static async exportBuild(t,n,r){const l=await fetch(`/xenon/api/build/${encodeURIComponent(t)}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:n,...r?{sessionIds:r}:{}})});if(!l.ok){const u=await l.text().catch(()=>l.statusText);throw new Error(`Export failed (${l.status}): ${u||l.statusText}`)}const o=l.headers.get("Content-Disposition")||"",i=/filename="?([^";]+)"?/.exec(o),s=i?i[1]:`build-${t}-sessions.${n}`;return{blob:await l.blob(),filename:s}}}function Sm(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"}function _m(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=l=>{(l.metaKey||l.ctrlKey)&&l.key.toLowerCase()==="k"&&!Sm(l.target)&&(l.preventDefault(),t(o=>!o)),l.key==="Escape"&&t(!1)},r=()=>t(!0);return window.addEventListener("keydown",n),window.addEventListener("xenon.open-command-palette",r),()=>{window.removeEventListener("keydown",n),window.removeEventListener("xenon.open-command-palette",r)}},[]),{open:e,setOpen:t}}function Ea(e,t){if(!e)return 0;const n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 1e4;if(r.startsWith(n))return 5e3-(r.length-n.length);let l=0,o=0,i=0;for(let s=0;s<n.length;s++){const a=n[s],u=r.indexOf(a,l);if(u===-1)return 0;u===l?(i+=1,o+=20+i*5):(i=0,o+=10-Math.min(u-l,10)),l=u+1}return Math.max(o,1)}const Sa=[{id:"nav:overview",kind:"nav",label:"Overview",path:"/overview"},{id:"nav:devices",kind:"nav",label:"Devices",path:"/devices"},{id:"nav:builds",kind:"nav",label:"Sessions",path:"/builds"},{id:"nav:apps",kind:"nav",label:"Apps",path:"/apps"},{id:"nav:notifications",kind:"nav",label:"Notifications",path:"/notifications"},{id:"nav:settings",kind:"nav",label:"Settings",path:"/settings"},{id:"nav:ai-settings",kind:"nav",label:"AI Engine",path:"/ai-settings"},{id:"nav:maintenance",kind:"nav",label:"Maintenance",path:"/maintenance"},{id:"nav:teams",kind:"nav",label:"Teams",path:"/teams"},{id:"nav:api-keys",kind:"nav",label:"API Keys",path:"/api-keys"}];class Cm{constructor(){this.devices=[],this.sessions=[],this.teams=[],this.keys=[],this.apps=[]}setDevices(t){this.devices=t.map(n=>({id:`device:${n.udid}`,kind:"device",label:n.name||n.udid,sub:n.udid,path:`/devices/${n.udid}/control`}))}setSessions(t){this.sessions=t.map(n=>({id:`session:${n.id}`,kind:"session",label:n.name||n.id,sub:n.id,path:`/builds?session=${encodeURIComponent(n.id)}`}))}setTeams(t){this.teams=t.map(n=>({id:`team:${n.id}`,kind:"team",label:n.name||n.id,sub:n.id,path:`/teams?team=${encodeURIComponent(n.id)}`}))}setKeys(t){this.keys=t.map(n=>({id:`key:${n.id}`,kind:"key",label:n.name||n.id,sub:n.id,path:`/api-keys?key=${encodeURIComponent(n.id)}`}))}setApps(t){this.apps=t.map(n=>({id:`app:${n.id}`,kind:"app",label:n.name||n.id,sub:n.id,path:`/apps?app=${encodeURIComponent(n.id)}`}))}search(t,n=8){return t.trim()?[...Sa,...this.devices,...this.sessions,...this.teams,...this.keys,...this.apps].map(l=>{const o=Ea(t,l.label),i=l.sub?Ea(t,l.sub):0;return{it:l,score:Math.max(o,i)}}).filter(l=>l.score>0).sort((l,o)=>o.score-l.score).slice(0,n).map(l=>l.it):Sa.slice(0,n)}}const Pm={nav:"Navigation",device:"Devices",session:"Sessions",team:"Teams",key:"API Keys",app:"Apps"},jm=["nav","device","session","team","key","app"],Rm=()=>{const{open:e,setOpen:t}=_m(),[n,r]=y.useState(""),[l,o]=y.useState(0),i=sn(),s=y.useRef(new Cm),a=y.useRef(null);y.useEffect(()=>{if(!e)return;Promise.all([kr.getDevices().catch(()=>[]),kr.getSessions().catch(()=>[]),kr.getApps().catch(()=>[]),kr.listTeams().catch(()=>[])]).then(([x,c,f,d])=>{Array.isArray(x)&&s.current.setDevices(x),Array.isArray(c)&&s.current.setSessions(c),Array.isArray(f)&&s.current.setApps(f),Array.isArray(d)&&s.current.setTeams(d)});const k=setTimeout(()=>{var x;return(x=a.current)==null?void 0:x.focus()},0);return()=>clearTimeout(k)},[e]),y.useEffect(()=>{e||(r(""),o(0))},[e]);const u=y.useMemo(()=>s.current.search(n,8),[n,e]),v=y.useMemo(()=>{const k=new Map;return u.forEach(x=>{const c=k.get(x.kind)||[];c.push(x),k.set(x.kind,c)}),k},[u]),g=y.useCallback(k=>{i(k.path),t(!1)},[i,t]),h=k=>{k.key==="ArrowDown"?(k.preventDefault(),o(x=>Math.min(x+1,Math.max(u.length-1,0)))):k.key==="ArrowUp"?(k.preventDefault(),o(x=>Math.max(x-1,0))):k.key==="Enter"&&(k.preventDefault(),u[l]&&g(u[l]))};if(!e)return null;let S=-1;return p.jsx("div",{className:"cp-overlay",onClick:()=>t(!1),children:p.jsxs("div",{className:"cp",role:"dialog","aria-modal":!0,"aria-label":"Command palette",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"cp-input-row",children:[p.jsx(Lc,{size:14}),p.jsx("input",{ref:a,className:"cp-input",placeholder:"Search devices, sessions, settings…",value:n,onChange:k=>{r(k.target.value),o(0)},onKeyDown:h}),p.jsx("span",{className:"cp-esc",children:"ESC"})]}),p.jsxs("div",{className:"cp-results",children:[u.length===0&&p.jsx("div",{className:"cp-empty",children:"No results."}),jm.filter(k=>v.has(k)).map(k=>p.jsxs("div",{className:"cp-group",children:[p.jsx("div",{className:"cp-group-head",children:Pm[k]}),v.get(k).map(x=>{S+=1;const c=S===l;return p.jsxs("button",{type:"button",className:`cp-item${c?" cp-item-active":""}`,onMouseEnter:()=>{o(S)},onClick:()=>g(x),children:[p.jsx("span",{className:"cp-item-label",children:x.label}),x.sub&&p.jsx("span",{className:"cp-item-sub",children:x.sub})]},x.id)})]},k))]})]})})};function Nm({children:e}){const{loading:t,me:n}=Bi(),r=at();if(t)return p.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-dim)"},children:"Loading…"});if(!n){const l=encodeURIComponent(r.pathname+r.search);return p.jsx(rl,{to:`/login?next=${l}`,replace:!0})}return p.jsx(p.Fragment,{children:e})}const Tm=y.lazy(()=>Q(()=>import("./login-DaJOt8Qz.js"),__vite__mapDeps([67,68]))),Om=y.lazy(()=>Q(()=>import("./forgot-password-BSYQX2oR.js"),__vite__mapDeps([69,68]))),Lm=y.lazy(()=>Q(()=>import("./reset-password-BgpjbCac.js"),__vite__mapDeps([70,68]))),Im=y.lazy(()=>Q(()=>import("./ApiKeyGate-BousCIQZ.js"),[]).then(e=>({default:e.ApiKeyGate})));function Mm(){return p.jsx(wm,{children:p.jsxs("div",{className:"min-h-screen w-full bg-[var(--bg)] text-[var(--text)]",children:[p.jsx(Em,{}),p.jsx(bh,{}),p.jsx("main",{className:"pl-14 pt-14 h-screen overflow-y-auto",children:p.jsx(ym,{})}),p.jsx(Rm,{})]})})}function Dm(){return p.jsx(Xp,{basename:"/xenon",children:p.jsx(Jh,{children:p.jsx(y.Suspense,{fallback:p.jsx("div",{style:{padding:40},children:"Loading…"}),children:p.jsxs(Nc,{children:[p.jsx($,{path:"/login",element:p.jsx(Tm,{})}),p.jsx($,{path:"/forgot-password",element:p.jsx(Om,{})}),p.jsx($,{path:"/reset-password/:token",element:p.jsx(Lm,{})}),p.jsx($,{path:"/api-key-gate",element:p.jsx(Im,{children:p.jsx(rl,{to:"/overview",replace:!0})})}),p.jsx($,{path:"*",element:p.jsx(Nm,{children:p.jsx(Mm,{})})})]})})})})}wc.render(p.jsx(y.StrictMode,{children:p.jsx(Dm,{})}),document.getElementById("root"));export{Um as A,uh as B,mh as C,Bm as D,wh as H,kh as I,Sh as K,Am as L,Oh as M,Qc as R,Uh as S,Wh as T,qh as U,kr as X,at as a,Bi as b,zm as c,Wm as d,Hm as e,Vm as f,B as g,wc as h,$m as i,p as j,Gc as k,Fm as l,qm as m,Kh as n,Lc as o,Bh as p,ph as q,y as r,zh as s,jh as t,sn as u,Oc as v,_a as w,sh as x,fh as y,ya as z};
209
+ */const Qh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Kh=B("x",Qh),Pt="/xenon/api/auth";async function Fm(e,t){const n=await fetch(`${Pt}/login`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Login failed (${n.status})`)}}async function Xh(){await fetch(`${Pt}/logout`,{method:"POST",credentials:"include"})}async function Yh(){const e=await fetch(`${Pt}/me`,{credentials:"include"});if(e.status===401)return null;if(!e.ok)throw new Error(`Failed to fetch /me (${e.status})`);return e.json()}async function Bm(e,t){const n=await fetch(`${Pt}/change-password`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:e,newPassword:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Change password failed (${n.status})`)}}async function Vm(e){const t=await fetch(`${Pt}/forgot-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok&&t.status!==204)throw t.status===429?new Error("Too many attempts — try again later."):new Error(`Request failed (${t.status})`)}async function Wm(e){return(await fetch(`${Pt}/reset-password/check/${encodeURIComponent(e)}`)).ok}async function Hm(e,t){const n=await fetch(`${Pt}/reset-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,newPassword:t})});if(!n.ok&&n.status!==204){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Reset failed (${n.status})`)}}const Ic=y.createContext(null);function Jh({children:e}){const[t,n]=y.useState(!0),[r,l]=y.useState(null);async function o(){try{l(await Yh())}finally{n(!1)}}async function i(){await Xh(),l(null),window.location.href="/xenon/login"}return y.useEffect(()=>{o()},[]),p.jsx(Ic.Provider,{value:{loading:t,me:r,refresh:o,signOut:i},children:e})}function Bi(){const e=y.useContext(Ic);if(!e)throw new Error("useAuth must be used inside AuthProvider");return e}function Zh(){const[e,t]=y.useState(0),[n]=y.useState(()=>Date.now());y.useEffect(()=>{const a=setInterval(()=>t(u=>u+1),5e3);return()=>clearInterval(a)},[]);const r=Math.floor((Date.now()-n)/1e3)+e*0,l=Math.floor(r/60),o=Math.floor(l/60),i=r<10?"Updated just now":r<60?`Updated ${r}s ago`:l<60?`Updated ${l}m ago`:`Updated ${o}h ago`,s=l>=10?"stale":l>=2?"aging":"fresh";return{label:i,staleness:s}}const bh=()=>{const e=sn(),{me:t,signOut:n}=Bi(),{label:r,staleness:l}=Zh(),[o,i]=y.useState(!1),s=y.useRef(null),a=((t==null?void 0:t.name)??"A").split(" ").map(g=>g[0]).slice(0,2).join("").toUpperCase(),u=(t==null?void 0:t.role)==="SUPER_ADMIN"?"Super Admin":(t==null?void 0:t.role)==="ADMIN"?"Admin":"Member";y.useEffect(()=>{const g=h=>{s.current&&!s.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const v=()=>window.dispatchEvent(new CustomEvent("xenon.open-command-palette"));return p.jsx("header",{className:"fixed top-0 left-14 right-0 z-20 h-14 border-b border-[var(--border)] bg-[var(--bg)]/80 backdrop-blur-md",children:p.jsxs("div",{className:"flex items-center h-full px-4 gap-4",children:[p.jsx("button",{type:"button",onClick:()=>e("/overview"),className:"flex items-center gap-3 min-w-0 cursor-pointer","aria-label":"Xenon home",children:p.jsx("div",{className:"flex items-center gap-2",children:p.jsx("img",{src:"/xenon/logo.svg",alt:"Xenon Logo",className:"h-8 w-auto object-contain"})})}),p.jsx("div",{className:"flex-1 max-w-xl mx-auto",children:p.jsxs("button",{type:"button",onClick:v,className:"relative w-full h-9 flex items-center text-left","aria-label":"Open command palette",children:[p.jsx("div",{className:"w-full h-9 pl-9 pr-14 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm text-[var(--text-dim)] hover:border-[var(--border-strong)] hover:text-[var(--text)] transition-colors flex items-center",children:"Search devices, sessions, settings…"}),p.jsx(Lc,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-[var(--text-dim)]"}),p.jsx("kbd",{className:"absolute right-3 top-1/2 -translate-y-1/2 font-mono text-[10px] text-[var(--text-dim)] border border-[var(--border)] rounded px-1.5 py-0.5",children:"⌘K"})]})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`hidden md:inline text-xs font-mono transition-colors ${l==="stale"?"text-[var(--red)]":l==="aging"?"text-[var(--amber)]":"text-[var(--text-dim)]"}`,title:l==="stale"?"Data is stale — reconnection may be needed.":l==="aging"?"Data hasn’t updated in a while.":"Live data.",children:r}),p.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-[var(--green)]/10 border border-[var(--green)]/20",children:[p.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--green)] pulse-dot"}),p.jsx("span",{className:"text-[11px] font-medium text-[var(--green)]",children:"Online"})]}),p.jsxs("div",{className:"relative",ref:s,children:[p.jsxs("button",{type:"button",className:"flex items-center gap-2 h-9 pl-1.5 pr-2.5 rounded-md border border-[var(--border)] hover:border-[var(--border-strong)] hover:bg-[var(--surface)] transition-colors",onClick:()=>i(g=>!g),"aria-haspopup":"true","aria-expanded":o,children:[p.jsx("span",{className:"h-6 w-6 rounded-full bg-[var(--green)]/15 text-[var(--green)] text-[11px] font-semibold flex items-center justify-center",children:a}),p.jsxs("span",{className:"flex flex-col items-start leading-tight",children:[p.jsx("span",{className:"text-xs text-[var(--text)]",children:(t==null?void 0:t.name)??"Account"}),p.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:u})]}),p.jsx(ph,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"})]}),o&&p.jsxs("div",{className:"absolute top-full right-0 mt-2 w-64 rounded-md border border-[var(--border)] bg-[var(--surface)] shadow-lg overflow-hidden",children:[p.jsxs("div",{className:"px-3 py-2",children:[p.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-dim)] mb-1",children:"Workspace"}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)]",children:[p.jsx("span",{className:"text-[var(--text-muted)]",children:"Registry"}),p.jsx("span",{children:"Default"})]}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)] mt-1",children:[p.jsx("span",{className:"text-[var(--text-muted)]",children:"Node"}),p.jsx("span",{children:"Root · Primary"})]})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("div",{className:"px-3 py-2",children:[p.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-dim)] mb-1",children:"System"}),p.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--text)]",children:[p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--green)]"}),"Stable"]}),p.jsxs("span",{className:"font-mono text-[var(--text-muted)]",children:["v","0.3.0"]})]})]}),p.jsx("div",{className:"h-px bg-[var(--border)]"}),p.jsxs("button",{type:"button",onClick:()=>{i(!1),e("/profile")},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--bg)] text-left",children:[p.jsx(qh,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"}),"Profile"]}),p.jsxs("button",{type:"button",onClick:()=>{i(!1),n()},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--red)] hover:bg-[var(--bg)] text-left",children:[p.jsx(Nh,{className:"h-3.5 w-3.5"}),"Logout"]})]})]})]})]})})};class em extends y.Component{constructor(){super(...arguments),this.state={hasError:!1},this.handleReset=()=>{this.setState({hasError:!1}),window.location.reload()}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Uncaught error:",t,n)}render(){return this.state.hasError?this.props.fallback||p.jsxs("div",{className:"error-boundary-container",style:{padding:"4rem 2rem",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:"1.5rem",color:"var(--text)",background:"var(--bg-main)",minHeight:"100vh"},children:[p.jsx("div",{style:{color:"var(--accent-red)",filter:"drop-shadow(0 0 10px rgba(239, 68, 68, 0.3))"},children:p.jsx(Bh,{size:64})}),p.jsx("h2",{style:{fontSize:"2rem",fontWeight:700,margin:0},children:"Component Exception Detected"}),p.jsx("p",{style:{color:"var(--text-muted)",maxWidth:"500px",lineHeight:1.6},children:"An unexpected error occurred while rendering this section. Xenon's isolation engine has contained the fault to prevent a total system crash."}),this.state.error&&p.jsx("pre",{style:{background:"rgba(0,0,0,0.3)",padding:"1rem",borderRadius:"8px",fontSize:"0.8rem",color:"var(--accent-red)",maxWidth:"80%",overflowX:"auto"},children:this.state.error.message}),p.jsxs("button",{onClick:this.handleReset,style:{background:"var(--green)",color:"var(--secondary)",border:"none",padding:"0.75rem 2rem",borderRadius:"8px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",gap:"0.5rem",transition:"all 0.2s"},onMouseOver:t=>t.currentTarget.style.transform="translateY(-2px)",onMouseOut:t=>t.currentTarget.style.transform="translateY(0)",children:[p.jsx(Oc,{size:18}),"Reload Application"]})]}):this.props.children}}const tm=y.lazy(()=>Q(()=>import("./overview-DNeH4FfG.js"),__vite__mapDeps([0,1,2,3,4,5]))),ga=y.lazy(()=>Q(()=>import("./device-explorer-B3PK2XW9.js"),__vite__mapDeps([6,7,8,9,10,11,12,13,14,15,16,5,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,1,31]))),wa=y.lazy(()=>Q(()=>import("./builds-page-wquO6Xb2.js"),__vite__mapDeps([32,33,1,18,4,34,35,16,28,23,3,7]))),nm=y.lazy(()=>Q(()=>import("./session-detail-page-BApz2wZr.js"),__vite__mapDeps([36,33,1,18,10,11,37,23,17,38,39,40,41,42,12,13,28,43]))),rm=y.lazy(()=>Q(()=>import("./runbook-page-DTTw_cb3.js"),__vite__mapDeps([44,37,45]))),lm=y.lazy(()=>Q(()=>import("./apps-CyetRRfI.js"),__vite__mapDeps([46,18,8,9,7,21,17,22,28,27,47]))),om=y.lazy(()=>Q(()=>import("./webhook-settings-y8EAM79b.js"),__vite__mapDeps([48,14,15,7,27,5,34,35,22,4,49,50])).then(e=>({default:e.WebhookSettings}))),im=y.lazy(()=>Q(()=>import("./settings-CuYjTdtb.js"),__vite__mapDeps([51,52,53,7,1,54,35,16,19,21,4,38,50])).then(e=>({default:e.Settings}))),sm=y.lazy(()=>Q(()=>import("./ai-settings-0dEPftlc.js"),__vite__mapDeps([55,52,53,7,26,35,4,50])).then(e=>({default:e.AISettings}))),am=y.lazy(()=>Q(()=>import("./maintenance-settings-CDDl4Q8B.js"),__vite__mapDeps([56,52,53,7,54,27,21,50])).then(e=>({default:e.MaintenanceSettings}))),um=y.lazy(()=>Q(()=>import("./api-keys-Cg1cbSUt.js"),__vite__mapDeps([57,18,41,42,14,15,7,12,13,24,5,27,21,17,50])).then(e=>({default:e.ApiKeys}))),cm=y.lazy(()=>Q(()=>import("./teams-EuX6i7H2.js"),__vite__mapDeps([58,18,41,42,14,15,7,12,13,59,24,5,37,27,50])).then(e=>({default:e.Teams}))),fm=y.lazy(()=>Q(()=>import("./selector-health-page-CZ_AAjtV.js"),__vite__mapDeps([60,22,61,62,35,12,13,21,17,18,1,39,40,7,29,30,2,23,38]))),dm=y.lazy(()=>Q(()=>import("./selector-detail-page-BVPMp3ZK.js"),__vite__mapDeps([63,18,7,61,62,20,35,22,21,17]))),pm=y.lazy(()=>Q(()=>import("./DeviceMosaicView-BEDnJqk5.js"),__vite__mapDeps([64,25]))),hm=y.lazy(()=>Q(()=>import("./profile-page-DKiZOb_Y.js"),__vite__mapDeps([65,7,18,17,27]))),mm=y.lazy(()=>Q(()=>import("./users-CPafGHcL.js"),__vite__mapDeps([66,59,18,7,5,27]))),vm=()=>p.jsxs("div",{className:"flex items-center justify-center gap-2 h-full text-xs text-[var(--text-dim)]",children:[p.jsx(Oc,{className:"animate-spin",size:14}),p.jsx("span",{children:"Hydrating view…"})]}),ym=()=>p.jsx(em,{children:p.jsx(y.Suspense,{fallback:p.jsx(vm,{}),children:p.jsxs(Nc,{children:[p.jsx($,{path:"/",element:p.jsx(rl,{to:"/overview",replace:!0})}),p.jsx($,{path:"/overview",element:p.jsx(tm,{})}),p.jsx($,{path:"/devices",element:p.jsx(ga,{})}),p.jsx($,{path:"/devices/:udid/control/:tab?",element:p.jsx(ga,{})}),p.jsx($,{path:"/apps",element:p.jsx(lm,{})}),p.jsx($,{path:"/builds",element:p.jsx(wa,{})}),p.jsx($,{path:"/builds/:buildId",element:p.jsx(wa,{})}),p.jsx($,{path:"/builds/:buildId/sessions/:sessionId",element:p.jsx(nm,{})}),p.jsx($,{path:"/notifications",element:p.jsx(om,{})}),p.jsx($,{path:"/settings",element:p.jsx(im,{})}),p.jsx($,{path:"/ai-settings",element:p.jsx(sm,{})}),p.jsx($,{path:"/maintenance",element:p.jsx(am,{})}),p.jsx($,{path:"/api-keys",element:p.jsx(um,{})}),p.jsx($,{path:"/teams",element:p.jsx(cm,{})}),p.jsx($,{path:"/users",element:p.jsx(mm,{})}),p.jsx($,{path:"/selector-health",element:p.jsx(fm,{})}),p.jsx($,{path:"/selector-health/detail",element:p.jsx(dm,{})}),p.jsx($,{path:"/devices/live",element:p.jsx(pm,{})}),p.jsx($,{path:"/runbooks/:category",element:p.jsx(rm,{})}),p.jsx($,{path:"/profile",element:p.jsx(hm,{})}),p.jsx($,{path:"*",element:p.jsx(rl,{to:"/overview",replace:!0})})]})})});let Uo=null;function xa(e){Uo=e}class gm{makeGETRequest(t){return fetch(this.formatUrl(t)).then(this.jsonResult)}makePOSTRequest(t,n,r,l={}){return fetch(this.formatUrl(t),{method:"POST",body:JSON.stringify(r||{}),headers:{"Content-Type":"application/json"},...l}).then(this.jsonResult)}makeDELETERequest(t){return fetch(this.formatUrl(t),{method:"DELETE"}).then(this.jsonResult)}formatUrl(t){return`/xenon/api${t}`}async jsonResult(t){if(t.status===403){const n=await t.clone().json().catch(()=>({})),r=n&&(n.error||n.message)||"You do not have permission for this action.";Uo&&Uo(r,"error")}return t.json()}}const j=new gm,Mc=y.createContext(void 0),qm=()=>{const e=y.useContext(Mc);if(!e)throw new Error("useToast must be used within a ToastProvider");return e},wm=({children:e})=>{const[t,n]=y.useState([]),r=y.useCallback(o=>{n(i=>i.filter(s=>s.id!==o))},[]),l=y.useCallback((o,i="info",s=4e3)=>{const a=Math.random().toString(36).substring(2,9);return n(u=>[...u,{id:a,message:o,type:i,duration:s}]),i!=="loading"&&s>0&&setTimeout(()=>{r(a)},s),a},[r]);return y.useEffect(()=>(xa((o,i="info")=>l(o,i)),()=>xa(null)),[l]),p.jsxs(Mc.Provider,{value:{toast:l,removeToast:r},children:[e,p.jsx("div",{className:"toast-container","aria-live":"polite","aria-atomic":"true",role:"status",children:t.map(o=>p.jsxs("div",{className:`toast-item toast-${o.type} animate-slide-in`,children:[p.jsxs("div",{className:"toast-icon",children:[o.type==="success"&&p.jsx(yh,{size:18}),o.type==="error"&&p.jsx(mh,{size:18}),o.type==="info"&&p.jsx(kh,{size:18}),o.type==="loading"&&p.jsx(jh,{size:18,className:"animate-spin"})]}),p.jsx("div",{className:"toast-message",children:o.message}),p.jsx("button",{className:"toast-close",onClick:()=>r(o.id),"aria-label":`Close ${o.type} notification`,children:p.jsx(Kh,{size:14})})]},o.id))})]})},xm=[{id:"overview",label:"Overview",icon:Ch,path:"/overview"},{id:"devices",label:"Devices",icon:Uh,path:"/devices"},{id:"live-devices",label:"Live Devices",icon:Wh,path:"/devices/live"},{id:"apps",label:"Apps",icon:oh,path:"/apps"},{id:"sessions",label:"Sessions",icon:Oh,path:"/builds"},{id:"selector-health",label:"Selector Health",icon:wh,path:"/selector-health"},{id:"notifications",label:"Notifications",icon:sh,path:"/notifications"},{id:"settings",label:"Settings",icon:Dh,path:"/settings",minRole:"ADMIN"},{id:"ai",label:"AI Engine",icon:fh,path:"/ai-settings",minRole:"ADMIN"},{id:"maintenance",label:"Maintenance",icon:zh,path:"/maintenance",minRole:"ADMIN"},{id:"teams",label:"Teams",icon:ya,path:"/teams",minRole:"ADMIN"},{id:"users",label:"Users",icon:ya,path:"/users",minRole:"ADMIN"},{id:"apikeys",label:"API Keys",icon:Sh,path:"/api-keys",minRole:"ADMIN"}],ka={SUPER_ADMIN:3,ADMIN:2,MEMBER:1};function km(e,t){return t?(e?ka[e]??0:0)>=ka[t]:!0}const Em=()=>{const e=sn(),t=at(),{me:n}=Bi(),r=xm.filter(s=>km(n==null?void 0:n.role,s.minRole)),l=t.pathname.replace(/\/$/,"")||"/",o=r.filter(s=>l===s.path||l.startsWith(s.path+"/")).sort((s,a)=>a.path.length-s.path.length)[0],i=s=>(o==null?void 0:o.path)===s;return p.jsxs("aside",{className:"fixed inset-y-0 left-0 z-30 w-14 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col items-center py-3",children:[p.jsx("nav",{className:"flex-1 flex flex-col gap-1 w-full items-center",children:r.map(s=>{const a=s.icon,u=i(s.path);return p.jsxs("button",{type:"button",onClick:()=>e(s.path),className:`group relative w-full flex justify-center py-2.5 mx-1 rounded-md transition-colors ${u?"bg-[var(--surface-2)]":"hover:bg-[var(--surface-2)]/60"}`,"aria-label":s.label,"aria-current":u?"page":void 0,children:[p.jsx("span",{className:`absolute left-0 top-1 bottom-1 w-[3px] rounded-r transition-all ${u?"bg-[var(--green)]":"bg-transparent"}`}),p.jsx(a,{className:`h-[18px] w-[18px] transition-colors ${u?"text-[var(--green)]":"text-[var(--text-dim)] group-hover:text-[var(--text)]"}`,strokeWidth:u?2.25:2}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:s.label})]},s.id)})}),p.jsxs("button",{type:"button",className:"group relative w-full flex justify-center py-2.5 mt-2","aria-label":"API Docs",onClick:()=>window.open(window.location.origin+"/xenon/api-docs","_blank"),children:[p.jsx(uh,{className:"h-[18px] w-[18px] text-[var(--text-dim)] group-hover:text-[var(--text)] transition-colors"}),p.jsx("span",{className:"pointer-events-none absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[var(--surface-2)] border border-[var(--border-strong)] px-2 py-1 text-xs text-[var(--text)] opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-lg",children:"API Docs"})]})]})};class kr{static getDevices(){return j.makeGETRequest(`/device?t=${Date.now()}`)}static getPendingSessionsCount(){return j.makeGETRequest("/queue/length")}static getPendingSessions(){return j.makeGETRequest("/queue")}static getQueueSummary(){return j.makeGETRequest("/queue/summary")}static getQueueStatus(t){return j.makeGETRequest(`/queue/status/${t}`)}static getBuilds(){return j.makeGETRequest("/build")}static getSessions(t={}){let r=`/session?t=${Date.now()}`;return t.buildId&&(r+=`&buildId=${encodeURIComponent(t.buildId)}`),t.query&&(r+=`&query=${encodeURIComponent(t.query)}`),t.status&&(r+=`&status=${encodeURIComponent(t.status)}`),t.platform&&(r+=`&platform=${encodeURIComponent(t.platform)}`),j.makeGETRequest(r)}static getSession(t){return j.makeGETRequest(`/session/${t}`)}static getSessionLogs(t){return j.makeGETRequest(`/session/${t}/session_log`)}static getDeviceLogs(t){return j.makeGETRequest(`/session/${t}/logs/device`)}static getDebugLogs(t){return j.makeGETRequest(`/session/${t}/logs/debug`)}static getProfilingData(t){return j.makeGETRequest(`/session/${t}/profiling`)}static omniScan(t){return j.makeGETRequest(`/session/${t}/xenon/omni-scan`)}static omniScanControl(t){return j.makeGETRequest(`/control/${t}/omni-scan`)}static testAiLocator(t,n,r){return j.makePOSTRequest(`/session/${t}/xenon/test-locator`,{},{strategy:n,selector:r})}static testAiLocatorControl(t,n,r){return j.makePOSTRequest(`/control/${t}/test-locator`,{},{strategy:n,selector:r})}static blockDevice(t,n){return j.makePOSTRequest("/block",{},{udid:t,host:n})}static unblockDevice(t,n){return j.makePOSTRequest("/unblock",{},{udid:t,host:n})}static updateDeviceTags(t,n,r){return j.makePOSTRequest("/device/tags",{},{udid:t,host:n,tags:r})}static async listTeams(){const t=await fetch("/xenon/api/teams",{credentials:"include"});if(!t.ok)throw new Error(`listTeams failed (${t.status})`);return(await t.json()).map(r=>({id:r.id,name:r.name}))}static async setDeviceTeam(t,n){const r=await fetch(`/xenon/api/grid/device/${encodeURIComponent(t)}/team`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:n})});if(!r.ok&&r.status!==204){const l=await r.json().catch(()=>({}));throw new Error(l.error||`setDeviceTeam failed (${r.status})`)}}static getSessionLiveVideoUrl(t){return j.formatUrl(`/session/${t}/live_video`)}static getReservations(){return j.makeGETRequest("/reservation")}static reserveDevice(t,n,r,l,o){return j.makePOSTRequest("/reservation",{},{udid:t,host:n,reservedBy:r,duration:l,reason:o})}static releaseReservation(t,n){return j.makeDELETERequest(`/reservation/${t}/${encodeURIComponent(n)}`)}static extendReservation(t,n,r){return j.makePOSTRequest(`/reservation/${t}/${encodeURIComponent(n)}/extend`,{},{duration:r})}static getAssetUrl(t){return t?`/xenon/assets/${t.replace(/^\//,"")}`:""}static tap(t,n,r){return j.makePOSTRequest(`/control/${t}/tap`,{},{x:n,y:r})}static swipe(t,n,r,l,o){return j.makePOSTRequest(`/control/${t}/swipe`,{},{x:n,y:r,endX:l,endY:o})}static typeText(t,n){return j.makePOSTRequest(`/control/${t}/text`,{},{text:n})}static pressKey(t,n){return j.makePOSTRequest(`/control/${t}/keyevent`,{},{keyCode:n})}static getClipboard(t){return j.makeGETRequest(`/control/${t}/clipboard`)}static setClipboard(t,n){return j.makePOSTRequest(`/control/${t}/clipboard`,{},{content:n})}static getScreenshot(t){return j.makeGETRequest(`/control/${t}/screenshot`)}static touchAndHold(t,n,r,l){return j.makePOSTRequest(`/control/${t}/touchAndHold`,{},{x:n,y:r,duration:l})}static lock(t){return j.makePOSTRequest(`/control/${t}/lock`,{},{})}static unlock(t){return j.makePOSTRequest(`/control/${t}/unlock`,{},{})}static installApp(t,n){return j.makePOSTRequest(`/control/${t}/install`,{},{appPath:n})}static startStream(t){return j.makePOSTRequest(`/control/${t}/stream/start`,{},{})}static stopStream(t){return j.makePOSTRequest(`/control/${t}/stream/stop`,{},{},{keepalive:!0})}static uninstallApp(t,n){return j.makePOSTRequest(`/control/${t}/uninstall`,{},{bundleId:n})}static uploadAndInstallApp(t,n){const r=new FormData;return r.append("app",n),fetch(`/xenon/api/control/${t}/upload-install`,{method:"POST",body:r}).then(l=>l.json())}static listApps(t){return j.makeGETRequest(`/control/${t}/apps`)}static getLogs(t){return j.makeGETRequest(`/control/${t}/logs`)}static getApps(){return j.makeGETRequest("/apps")}static uploadApp(t){const n=new FormData;return n.append("app",t),fetch("/xenon/api/apps/upload",{method:"POST",body:n}).then(r=>r.json())}static deleteApp(t){return j.makeDELETERequest(`/apps/${t}`)}static installRepositoryApp(t,n){return j.makePOSTRequest(`/control/${t}/install-repository-app`,{},{appId:n})}static executeShell(t,n){return j.makePOSTRequest(`/control/${t}/shell`,{},{command:n})}static getInspectorSnapshot(t){return j.makeGETRequest(`/control/${t}/inspector/snapshot`)}static getWebhookConfigs(){return j.makeGETRequest("/webhook")}static addWebhookConfig(t,n,r,l){return j.makePOSTRequest("/webhook",{},{url:t,events:n,type:r,payloadTemplate:l})}static deleteWebhookConfig(t){return j.makeDELETERequest(`/webhook/${t}`)}static testWebhook(t,n){return j.makePOSTRequest("/webhook/test",{},{url:t,type:n})}static getGlobalConfig(){return j.makeGETRequest("/config")}static updateGlobalConfig(t){return j.makePOSTRequest("/config",{},t)}static testAIConfig(t){return j.makePOSTRequest("/config/test-ai",{},t)}static resetMetrics(){return j.makePOSTRequest("/config/reset-metrics",{},{})}static getRecentHealingEvents(t=50){return j.makeGETRequest(`/healing/events?limit=${t}&t=${Date.now()}`)}static getHealingSummary(t=30){return j.makeGETRequest(`/healing/summary?windowDays=${t}&t=${Date.now()}`)}static getHealingHotspots(t={}){const{windowDays:n=30,limit:r=20,tier:l,platform:o,status:i="active"}=t;let s=`/healing/hotspots?windowDays=${n}&limit=${r}&status=${i}&t=${Date.now()}`;return l&&(s+=`&tier=${encodeURIComponent(l)}`),o&&(s+=`&platform=${encodeURIComponent(o)}`),j.makeGETRequest(s)}static getMutedSelectors(t={}){const{limit:n=50,offset:r=0}=t;return j.makeGETRequest(`/healing/state/muted?limit=${n}&offset=${r}&t=${Date.now()}`)}static getSelectorState(t,n){return j.makeGETRequest(`/healing/state/${encodeURIComponent(t)}/${encodeURIComponent(n)}?t=${Date.now()}`)}static async postSelectorStateAction(t){const n=await fetch("/xenon/api/healing/selector/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({})),l=new Error(r.error??`Selector state action failed (${n.status})`);throw l.status=n.status,l.currentStatus=r.currentStatus??null,l}return n.json()}static getHealingSelectorDetail(t,n=30){return j.makeGETRequest(`/healing/selector?value=${encodeURIComponent(t)}&windowDays=${n}&t=${Date.now()}`)}static sendHealingDigest(t={}){return j.makePOSTRequest("/healing/digest/send",{},t)}static async exportBuild(t,n,r){const l=await fetch(`/xenon/api/build/${encodeURIComponent(t)}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({format:n,...r?{sessionIds:r}:{}})});if(!l.ok){const u=await l.text().catch(()=>l.statusText);throw new Error(`Export failed (${l.status}): ${u||l.statusText}`)}const o=l.headers.get("Content-Disposition")||"",i=/filename="?([^";]+)"?/.exec(o),s=i?i[1]:`build-${t}-sessions.${n}`;return{blob:await l.blob(),filename:s}}}function Sm(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"}function _m(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=l=>{(l.metaKey||l.ctrlKey)&&l.key.toLowerCase()==="k"&&!Sm(l.target)&&(l.preventDefault(),t(o=>!o)),l.key==="Escape"&&t(!1)},r=()=>t(!0);return window.addEventListener("keydown",n),window.addEventListener("xenon.open-command-palette",r),()=>{window.removeEventListener("keydown",n),window.removeEventListener("xenon.open-command-palette",r)}},[]),{open:e,setOpen:t}}function Ea(e,t){if(!e)return 0;const n=e.toLowerCase(),r=t.toLowerCase();if(r===n)return 1e4;if(r.startsWith(n))return 5e3-(r.length-n.length);let l=0,o=0,i=0;for(let s=0;s<n.length;s++){const a=n[s],u=r.indexOf(a,l);if(u===-1)return 0;u===l?(i+=1,o+=20+i*5):(i=0,o+=10-Math.min(u-l,10)),l=u+1}return Math.max(o,1)}const Sa=[{id:"nav:overview",kind:"nav",label:"Overview",path:"/overview"},{id:"nav:devices",kind:"nav",label:"Devices",path:"/devices"},{id:"nav:builds",kind:"nav",label:"Sessions",path:"/builds"},{id:"nav:apps",kind:"nav",label:"Apps",path:"/apps"},{id:"nav:notifications",kind:"nav",label:"Notifications",path:"/notifications"},{id:"nav:settings",kind:"nav",label:"Settings",path:"/settings"},{id:"nav:ai-settings",kind:"nav",label:"AI Engine",path:"/ai-settings"},{id:"nav:maintenance",kind:"nav",label:"Maintenance",path:"/maintenance"},{id:"nav:teams",kind:"nav",label:"Teams",path:"/teams"},{id:"nav:api-keys",kind:"nav",label:"API Keys",path:"/api-keys"}];class Cm{constructor(){this.devices=[],this.sessions=[],this.teams=[],this.keys=[],this.apps=[]}setDevices(t){this.devices=t.map(n=>({id:`device:${n.udid}`,kind:"device",label:n.name||n.udid,sub:n.udid,path:`/devices/${n.udid}/control`}))}setSessions(t){this.sessions=t.map(n=>({id:`session:${n.id}`,kind:"session",label:n.name||n.id,sub:n.id,path:`/builds?session=${encodeURIComponent(n.id)}`}))}setTeams(t){this.teams=t.map(n=>({id:`team:${n.id}`,kind:"team",label:n.name||n.id,sub:n.id,path:`/teams?team=${encodeURIComponent(n.id)}`}))}setKeys(t){this.keys=t.map(n=>({id:`key:${n.id}`,kind:"key",label:n.name||n.id,sub:n.id,path:`/api-keys?key=${encodeURIComponent(n.id)}`}))}setApps(t){this.apps=t.map(n=>({id:`app:${n.id}`,kind:"app",label:n.name||n.id,sub:n.id,path:`/apps?app=${encodeURIComponent(n.id)}`}))}search(t,n=8){return t.trim()?[...Sa,...this.devices,...this.sessions,...this.teams,...this.keys,...this.apps].map(l=>{const o=Ea(t,l.label),i=l.sub?Ea(t,l.sub):0;return{it:l,score:Math.max(o,i)}}).filter(l=>l.score>0).sort((l,o)=>o.score-l.score).slice(0,n).map(l=>l.it):Sa.slice(0,n)}}const Pm={nav:"Navigation",device:"Devices",session:"Sessions",team:"Teams",key:"API Keys",app:"Apps"},jm=["nav","device","session","team","key","app"],Rm=()=>{const{open:e,setOpen:t}=_m(),[n,r]=y.useState(""),[l,o]=y.useState(0),i=sn(),s=y.useRef(new Cm),a=y.useRef(null);y.useEffect(()=>{if(!e)return;Promise.all([kr.getDevices().catch(()=>[]),kr.getSessions().catch(()=>[]),kr.getApps().catch(()=>[]),kr.listTeams().catch(()=>[])]).then(([x,c,f,d])=>{Array.isArray(x)&&s.current.setDevices(x),Array.isArray(c)&&s.current.setSessions(c),Array.isArray(f)&&s.current.setApps(f),Array.isArray(d)&&s.current.setTeams(d)});const k=setTimeout(()=>{var x;return(x=a.current)==null?void 0:x.focus()},0);return()=>clearTimeout(k)},[e]),y.useEffect(()=>{e||(r(""),o(0))},[e]);const u=y.useMemo(()=>s.current.search(n,8),[n,e]),v=y.useMemo(()=>{const k=new Map;return u.forEach(x=>{const c=k.get(x.kind)||[];c.push(x),k.set(x.kind,c)}),k},[u]),g=y.useCallback(k=>{i(k.path),t(!1)},[i,t]),h=k=>{k.key==="ArrowDown"?(k.preventDefault(),o(x=>Math.min(x+1,Math.max(u.length-1,0)))):k.key==="ArrowUp"?(k.preventDefault(),o(x=>Math.max(x-1,0))):k.key==="Enter"&&(k.preventDefault(),u[l]&&g(u[l]))};if(!e)return null;let S=-1;return p.jsx("div",{className:"cp-overlay",onClick:()=>t(!1),children:p.jsxs("div",{className:"cp",role:"dialog","aria-modal":!0,"aria-label":"Command palette",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"cp-input-row",children:[p.jsx(Lc,{size:14}),p.jsx("input",{ref:a,className:"cp-input",placeholder:"Search devices, sessions, settings…",value:n,onChange:k=>{r(k.target.value),o(0)},onKeyDown:h}),p.jsx("span",{className:"cp-esc",children:"ESC"})]}),p.jsxs("div",{className:"cp-results",children:[u.length===0&&p.jsx("div",{className:"cp-empty",children:"No results."}),jm.filter(k=>v.has(k)).map(k=>p.jsxs("div",{className:"cp-group",children:[p.jsx("div",{className:"cp-group-head",children:Pm[k]}),v.get(k).map(x=>{S+=1;const c=S===l;return p.jsxs("button",{type:"button",className:`cp-item${c?" cp-item-active":""}`,onMouseEnter:()=>{o(S)},onClick:()=>g(x),children:[p.jsx("span",{className:"cp-item-label",children:x.label}),x.sub&&p.jsx("span",{className:"cp-item-sub",children:x.sub})]},x.id)})]},k))]})]})})};function Nm({children:e}){const{loading:t,me:n}=Bi(),r=at();if(t)return p.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-dim)"},children:"Loading…"});if(!n){const l=encodeURIComponent(r.pathname+r.search);return p.jsx(rl,{to:`/login?next=${l}`,replace:!0})}return p.jsx(p.Fragment,{children:e})}const Tm=y.lazy(()=>Q(()=>import("./login-DCIOMQb8.js"),__vite__mapDeps([67,68]))),Om=y.lazy(()=>Q(()=>import("./forgot-password-DvHMwK0-.js"),__vite__mapDeps([69,68]))),Lm=y.lazy(()=>Q(()=>import("./reset-password-6rl6YA7S.js"),__vite__mapDeps([70,68]))),Im=y.lazy(()=>Q(()=>import("./ApiKeyGate-DX4HKDBA.js"),[]).then(e=>({default:e.ApiKeyGate})));function Mm(){return p.jsx(wm,{children:p.jsxs("div",{className:"min-h-screen w-full bg-[var(--bg)] text-[var(--text)]",children:[p.jsx(Em,{}),p.jsx(bh,{}),p.jsx("main",{className:"pl-14 pt-14 h-screen overflow-y-auto",children:p.jsx(ym,{})}),p.jsx(Rm,{})]})})}function Dm(){return p.jsx(Xp,{basename:"/xenon",children:p.jsx(Jh,{children:p.jsx(y.Suspense,{fallback:p.jsx("div",{style:{padding:40},children:"Loading…"}),children:p.jsxs(Nc,{children:[p.jsx($,{path:"/login",element:p.jsx(Tm,{})}),p.jsx($,{path:"/forgot-password",element:p.jsx(Om,{})}),p.jsx($,{path:"/reset-password/:token",element:p.jsx(Lm,{})}),p.jsx($,{path:"/api-key-gate",element:p.jsx(Im,{children:p.jsx(rl,{to:"/overview",replace:!0})})}),p.jsx($,{path:"*",element:p.jsx(Nm,{children:p.jsx(Mm,{})})})]})})})})}wc.render(p.jsx(y.StrictMode,{children:p.jsx(Dm,{})}),document.getElementById("root"));export{Um as A,uh as B,mh as C,Bm as D,wh as H,kh as I,Sh as K,Am as L,Oh as M,Qc as R,Uh as S,Wh as T,qh as U,kr as X,at as a,Bi as b,zm as c,Wm as d,Hm as e,Vm as f,B as g,wc as h,$m as i,p as j,Gc as k,Fm as l,qm as m,Kh as n,Lc as o,Bh as p,ph as q,y as r,zh as s,jh as t,sn as u,Oc as v,_a as w,sh as x,fh as y,ya as z};
@@ -1,4 +1,4 @@
1
- import{g as a}from"./index-PtnKslHU.js";/**
1
+ import{g as a}from"./index-wbxPcwMM.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.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{u as v,a as p,b as f,r as s,j as e,L as j,l as w}from"./index-PtnKslHU.js";import{A as N}from"./auth-shell-BBGlC6i3.js";function k(){const u=v(),c=p(),{refresh:m}=f(),d=new URLSearchParams(c.search).get("next")||"/overview",[a,x]=s.useState(""),[r,b]=s.useState(""),[o,n]=s.useState(!1),[l,i]=s.useState(null);async function g(t){t.preventDefault(),n(!0),i(null);try{await w(a,r),await m(),u(d,{replace:!0})}catch(h){i(h.message||"Login failed")}finally{n(!1)}}return e.jsx(N,{children:e.jsxs("form",{onSubmit:g,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Welcome back!"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] mb-6",children:"Sign in to your account"}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"Email"}),e.jsx("input",{type:"email",value:a,onChange:t=>x(t.target.value),autoFocus:!0,required:!0,className:"w-full mb-4 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"Password"}),e.jsx("input",{type:"password",value:r,onChange:t=>b(t.target.value),required:!0,className:"w-full mb-2 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),e.jsx("div",{className:"text-right mb-4",children:e.jsx(j,{to:"/forgot-password",className:"text-[11px] text-[var(--text-dim)] hover:text-[var(--text)]",children:"Forgot password?"})}),l&&e.jsx("div",{className:"mt-3 text-xs text-[var(--red)]",children:l}),e.jsx("button",{type:"submit",disabled:o,className:"mt-5 w-full h-10 rounded-md bg-[var(--green)] text-black font-medium text-sm disabled:opacity-50",children:o?"Signing in…":"Sign in"})]})})}export{k as default};
1
+ import{u as v,a as p,b as f,r as s,j as e,L as j,l as w}from"./index-wbxPcwMM.js";import{A as N}from"./auth-shell-BXwxuIPK.js";function k(){const u=v(),c=p(),{refresh:m}=f(),d=new URLSearchParams(c.search).get("next")||"/overview",[a,x]=s.useState(""),[r,b]=s.useState(""),[o,n]=s.useState(!1),[l,i]=s.useState(null);async function g(t){t.preventDefault(),n(!0),i(null);try{await w(a,r),await m(),u(d,{replace:!0})}catch(h){i(h.message||"Login failed")}finally{n(!1)}}return e.jsx(N,{children:e.jsxs("form",{onSubmit:g,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Welcome back!"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] mb-6",children:"Sign in to your account"}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"Email"}),e.jsx("input",{type:"email",value:a,onChange:t=>x(t.target.value),autoFocus:!0,required:!0,className:"w-full mb-4 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"Password"}),e.jsx("input",{type:"password",value:r,onChange:t=>b(t.target.value),required:!0,className:"w-full mb-2 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),e.jsx("div",{className:"text-right mb-4",children:e.jsx(j,{to:"/forgot-password",className:"text-[11px] text-[var(--text-dim)] hover:text-[var(--text)]",children:"Forgot password?"})}),l&&e.jsx("div",{className:"mt-3 text-xs text-[var(--red)]",children:l}),e.jsx("button",{type:"submit",disabled:o,className:"mt-5 w-full h-10 rounded-md bg-[var(--green)] text-black font-medium text-sm disabled:opacity-50",children:o?"Signing in…":"Sign in"})]})})}export{k as default};
@@ -1,4 +1,4 @@
1
- import{g as S,m as N,r as d,X as C,j as e,v as D,s as M,I as A}from"./index-PtnKslHU.js";/* empty css */import{S as o,A as B}from"./SettingCard-Dp7XIdcl.js";import{P as w}from"./page-header-CSvuGbSO.js";import{S as k,C as z}from"./shield-JGzamJo5.js";import{T as E}from"./trash-2-BrTSfFh5.js";import{C as L}from"./check-BZMx8AhR.js";/**
1
+ import{g as S,m as N,r as d,X as C,j as e,v as D,s as M,I as A}from"./index-wbxPcwMM.js";/* empty css */import{S as o,A as B}from"./SettingCard-DVZUpQJR.js";import{P as w}from"./page-header-DZpQDeCw.js";import{S as k,C as z}from"./shield-DVYhrtS6.js";import{T as E}from"./trash-2-8zA1h40t.js";import{C as L}from"./check-CDOZKQih.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as R,r as b,X as S,j as e,u as U,T as X,S as Y}from"./index-PtnKslHU.js";import{u as z}from"./useSocket-BRto9a5m.js";import{F as V}from"./funnel-CptlpFZ9.js";import{T as W,M as K}from"./tablet-DHY88mxw.js";import{A as Q}from"./activity-DCBAvxuo.js";import{P as G}from"./plus-vJJF9g79.js";/**
1
+ import{g as R,r as b,X as S,j as e,u as U,T as X,S as Y}from"./index-wbxPcwMM.js";import{u as z}from"./useSocket-qyqK9PWr.js";import{F as V}from"./funnel-DfsfiM0o.js";import{T as W,M as K}from"./tablet-CxgLRRaU.js";import{A as Q}from"./activity-KiLkzk_U.js";import{P as G}from"./plus-CTjPrkU5.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{j as e}from"./index-PtnKslHU.js";const m=({icon:s,eyebrow:t,title:x,subtitle:a,action:r})=>e.jsx("header",{className:"px-6 pt-6 pb-4 border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[t&&e.jsx("div",{className:"text-[10px] font-mono font-semibold uppercase tracking-widest text-[var(--text-dim)] mb-1.5",children:t}),e.jsxs("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight text-[var(--text)]",children:[s&&e.jsx(s,{className:"h-5 w-5 text-[var(--green)] shrink-0"}),e.jsx("span",{className:"truncate",children:x})]}),a&&e.jsx("p",{className:"mt-1.5 text-sm text-[var(--text-muted)] max-w-3xl",children:a})]}),r&&e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})]})});export{m as P};
1
+ import{j as e}from"./index-wbxPcwMM.js";const m=({icon:s,eyebrow:t,title:x,subtitle:a,action:r})=>e.jsx("header",{className:"px-6 pt-6 pb-4 border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[t&&e.jsx("div",{className:"text-[10px] font-mono font-semibold uppercase tracking-widest text-[var(--text-dim)] mb-1.5",children:t}),e.jsxs("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight text-[var(--text)]",children:[s&&e.jsx(s,{className:"h-5 w-5 text-[var(--green)] shrink-0"}),e.jsx("span",{className:"truncate",children:x})]}),a&&e.jsx("p",{className:"mt-1.5 text-sm text-[var(--text-muted)] max-w-3xl",children:a})]}),r&&e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})]})});export{m as P};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as T,b as k,r as o,j as e,D as S,v as E}from"./index-PtnKslHU.js";import{P as C}from"./page-header-CSvuGbSO.js";import{a as y,f as w}from"./time-B8FIgwPE.js";import{C as A}from"./copy-ve3lNhva.js";import{T as $}from"./trash-2-BrTSfFh5.js";/**
1
+ import{g as T,b as k,r as o,j as e,D as S,v as E}from"./index-wbxPcwMM.js";import{P as C}from"./page-header-DZpQDeCw.js";import{a as y,f as w}from"./time-B8FIgwPE.js";import{C as A}from"./copy-DkXT5Ggc.js";import{T as $}from"./trash-2-8zA1h40t.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{c as f,u as g,r as n,d as p,j as e,L as v,e as w}from"./index-PtnKslHU.js";import{A as o}from"./auth-shell-BBGlC6i3.js";function k(){const{token:i}=f(),m=g(),[s,r]=n.useState("checking"),[a,u]=n.useState(""),[l,x]=n.useState(""),[c,d]=n.useState(null);n.useEffect(()=>{if(!i){r("invalid");return}p(i).then(t=>r(t?"ready":"invalid"))},[i]);async function h(t){if(t.preventDefault(),d(null),a!==l){d("Passwords do not match.");return}if(a.length<8){d("Password must be at least 8 characters.");return}r("submitting");try{await w(i,a),r("done"),setTimeout(()=>m("/login",{replace:!0}),1500)}catch(b){d(b.message||"Reset failed"),r("ready")}}return s==="checking"?e.jsx(o,{children:e.jsx("div",{className:"text-sm text-[var(--text-dim)] text-center",children:"Checking link…"})}):s==="invalid"?e.jsx(o,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"This link is invalid or expired"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] mb-6",children:"Reset links are good for 1 hour and single-use. Request a new one."}),e.jsx(v,{to:"/forgot-password",className:"inline-block h-10 px-4 rounded-md bg-[var(--green)] text-black text-sm font-medium leading-10",children:"Request a new link"})]})}):s==="done"?e.jsx(o,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"Password updated"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"Redirecting to sign in…"})]})}):e.jsx(o,{children:e.jsxs("form",{onSubmit:h,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Reset your password"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] mb-6",children:"Choose a new password to sign in with."}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"New password"}),e.jsx("input",{type:"password",value:a,onChange:t=>u(t.target.value),autoFocus:!0,required:!0,className:"w-full mb-3 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"Confirm new password"}),e.jsx("input",{type:"password",value:l,onChange:t=>x(t.target.value),required:!0,className:"w-full mb-3 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),c&&e.jsx("div",{className:"text-xs text-[var(--red)] mb-3",children:c}),e.jsx("button",{type:"submit",disabled:s==="submitting"||a.length<8,className:"mt-5 w-full h-10 rounded-md bg-[var(--green)] text-black font-medium text-sm disabled:opacity-50",children:s==="submitting"?"Updating…":"Update password"})]})})}export{k as default};
1
+ import{c as f,u as g,r as n,d as p,j as e,L as v,e as w}from"./index-wbxPcwMM.js";import{A as o}from"./auth-shell-BXwxuIPK.js";function k(){const{token:i}=f(),m=g(),[s,r]=n.useState("checking"),[a,u]=n.useState(""),[l,x]=n.useState(""),[c,d]=n.useState(null);n.useEffect(()=>{if(!i){r("invalid");return}p(i).then(t=>r(t?"ready":"invalid"))},[i]);async function h(t){if(t.preventDefault(),d(null),a!==l){d("Passwords do not match.");return}if(a.length<8){d("Password must be at least 8 characters.");return}r("submitting");try{await w(i,a),r("done"),setTimeout(()=>m("/login",{replace:!0}),1500)}catch(b){d(b.message||"Reset failed"),r("ready")}}return s==="checking"?e.jsx(o,{children:e.jsx("div",{className:"text-sm text-[var(--text-dim)] text-center",children:"Checking link…"})}):s==="invalid"?e.jsx(o,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"This link is invalid or expired"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] mb-6",children:"Reset links are good for 1 hour and single-use. Request a new one."}),e.jsx(v,{to:"/forgot-password",className:"inline-block h-10 px-4 rounded-md bg-[var(--green)] text-black text-sm font-medium leading-10",children:"Request a new link"})]})}):s==="done"?e.jsx(o,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"Password updated"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)]",children:"Redirecting to sign in…"})]})}):e.jsx(o,{children:e.jsxs("form",{onSubmit:h,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Reset your password"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] mb-6",children:"Choose a new password to sign in with."}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"New password"}),e.jsx("input",{type:"password",value:a,onChange:t=>u(t.target.value),autoFocus:!0,required:!0,className:"w-full mb-3 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),e.jsx("label",{className:"block text-xs text-[var(--text-dim)] mb-1",children:"Confirm new password"}),e.jsx("input",{type:"password",value:l,onChange:t=>x(t.target.value),required:!0,className:"w-full mb-3 h-10 px-3 rounded-md bg-[var(--surface)] border border-[var(--border)] text-sm focus:border-[var(--green)] outline-none"}),c&&e.jsx("div",{className:"text-xs text-[var(--red)] mb-3",children:c}),e.jsx("button",{type:"submit",disabled:s==="submitting"||a.length<8,className:"mt-5 w-full h-10 rounded-md bg-[var(--green)] text-black font-medium text-sm disabled:opacity-50",children:s==="submitting"?"Updating…":"Update password"})]})})}export{k as default};
@@ -1,4 +1,4 @@
1
- import{w as Me,k as Ie,c as Ir,u as Tr,j as J,B as Or}from"./index-PtnKslHU.js";import{A as vr}from"./arrow-left-GX0vzYtn.js";const qn=["http","https","mailto","tel"];function Lr(e){const n=(e||"").trim(),t=n.charAt(0);if(t==="#"||t==="/")return n;const r=n.indexOf(":");if(r===-1)return n;let i=-1;for(;++i<qn.length;){const l=qn[i];if(r===l.length&&n.slice(0,l.length).toLowerCase()===l)return n}return i=n.indexOf("?"),i!==-1&&r>i||(i=n.indexOf("#"),i!==-1&&r>i)?n:"javascript:void(0)"}/*!
1
+ import{w as Me,k as Ie,c as Ir,u as Tr,j as J,B as Or}from"./index-wbxPcwMM.js";import{A as vr}from"./arrow-left-C1v7ukDM.js";const qn=["http","https","mailto","tel"];function Lr(e){const n=(e||"").trim(),t=n.charAt(0);if(t==="#"||t==="/")return n;const r=n.indexOf(":");if(r===-1)return n;let i=-1;for(;++i<qn.length;){const l=qn[i];if(r===l.length&&n.slice(0,l.length).toLowerCase()===l)return n}return i=n.indexOf("?"),i!==-1&&r>i||(i=n.indexOf("#"),i!==-1&&r>i)?n:"javascript:void(0)"}/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1 +1 @@
1
- import{u as I,m as A,A as F,r,X as v,j as e,H as f,v as w,C as R,p as D}from"./index-PtnKslHU.js";import{f as g}from"./time-B8FIgwPE.js";import{P as S}from"./page-header-CSvuGbSO.js";import{f as H,H as P,V as B,E as L}from"./selector-health-BjMHf106.js";import{C as M,L as E}from"./layers-DRpwoKhI.js";import{C as U}from"./circle-check-CI2xUlDo.js";import{Z as O}from"./zap-JUbOoK3o.js";import{C as K}from"./check-BZMx8AhR.js";import{C as V}from"./copy-ve3lNhva.js";function X(d){const h=Date.parse(d);if(!Number.isFinite(h))return"";const x=Math.max(0,Date.now()-h),l=Math.floor(x/1e3);if(l<60)return`${l}s ago`;const i=Math.floor(l/60);if(i<60)return`${i}m ago`;const o=Math.floor(i/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Q(d){return d===0?"$0":d<.01?"<$0.01":`$${d.toFixed(2)}`}const te=()=>{const d=I(),{toast:h}=A(),[x]=F(),l=x.get("value")??"",i=x.get("strategy")??"",o=parseInt(x.get("windowDays")??"30",10)||30,[t,y]=r.useState(null),[a,p]=r.useState(null),[_,C]=r.useState(!1),[$,T]=r.useState(!1),[N,k]=r.useState(null),b=r.useCallback(async()=>{if(l){C(!0);try{const s=await v.getHealingSelectorDetail(l,o);y(s??null)}catch{y(null)}finally{C(!1),T(!0)}}},[l,o]),j=r.useCallback(async()=>{if(!i||!l){p(null);return}try{const s=await v.getSelectorState(i,l);p((s==null?void 0:s.state)??null)}catch{p(null)}},[i,l]);r.useEffect(()=>{b()},[b]),r.useEffect(()=>{j()},[j]);const m=r.useCallback(async s=>{if(!i||!l)return;const n=(()=>{switch(s){case"mark_fixed":return"Mark this selector as fixed? Move to Pending Verification.";case"mute":return"Mute this selector? It will be hidden from Hotspots, the CI gate, and digests.";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(n))try{await v.postSelectorStateAction({original_strategy:i,original_selector:l,action:s}),h("Done.","success"),j()}catch(c){const u=c!=null&&c.currentStatus?` (currently ${c.currentStatus})`:"";h(`${(c==null?void 0:c.message)??"Action failed"}${u}`,"error")}},[i,l,h,j]),z=(s,n)=>{navigator.clipboard.writeText(s).catch(()=>{}),k(n),setTimeout(()=>k(c=>c===n?null:c),1500)};return l?e.jsxs("div",{className:"selector-health-page",children:[e.jsx(S,{icon:f,eyebrow:"Test Quality / Selector",title:e.jsx("span",{className:"sh-detail-title",children:e.jsx("code",{title:l,children:l})}),subtitle:`All heals for this selector over the last ${o} days.`,action:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"sh-back-btn",onClick:()=>d("/selector-health"),children:[e.jsx(M,{size:12})," Back"]}),e.jsxs("button",{className:"sh-refresh-btn",onClick:b,disabled:_,title:"Refresh",children:[e.jsx(w,{size:12,className:_?"animate-spin":""}),"Refresh"]})]})}),e.jsxs("div",{className:"sh-content",children:[i&&e.jsxs("div",{className:"sh-detail-strategy-line",title:"Tuple identity for this drill-down",children:[e.jsx("span",{className:"sh-strategy-badge",children:H(i)}),e.jsx("code",{children:l})]}),!i&&e.jsxs("div",{className:"sh-detail-banner",children:["Showing every strategy that ever healed this selector value. To scope to a single tuple, append ",e.jsx("code",{children:"?strategy=<name>"})," ","to the URL or open this row from the Active tab on Selector Health."]}),a&&e.jsxs("div",{className:`sh-detail-state sh-detail-state--${a.status}`,children:[e.jsxs("div",{className:"sh-detail-state__head",children:[e.jsxs("span",{className:"sh-detail-state__badge",children:[a.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{size:16,style:{color:"var(--accent, #60a5fa)"}}),e.jsx("span",{children:"Pending verification"})]}),a.status==="resolved"&&e.jsxs(e.Fragment,{children:[e.jsx(U,{size:16,style:{color:"var(--green, #4ade80)"}}),e.jsx("span",{children:"Resolved"})]}),a.status==="muted"&&e.jsxs(e.Fragment,{children:[e.jsx(B,{size:16,style:{color:"var(--text-muted)"}}),e.jsx("span",{children:"Muted"})]}),a.status==="active"&&(a.regression_count>0?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:16,style:{color:"var(--amber, #f59e0b)"}}),e.jsxs("span",{children:["Active — regressed ",a.regression_count,"×"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:16}),e.jsx("span",{children:"Active"})]}))]}),e.jsxs("div",{className:"sh-detail-state__actions",children:[a.status==="active"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn sh-action-btn--primary",onClick:()=>m("mark_fixed"),children:"Mark Fixed"}),e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("mute"),children:"Mute"})]}),a.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("cancel_verification"),children:"Cancel verification"}),e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("mute"),children:"Mute"})]}),a.status==="resolved"&&e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("mute"),children:"Mute"}),a.status==="muted"&&e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("unmute"),children:"Unmute"})]})]}),e.jsxs("div",{className:"sh-detail-state__meta",children:[a.fixed_at&&e.jsxs("span",{children:["Marked fixed: ",g(a.fixed_at)]}),a.resolved_at&&e.jsxs("span",{children:["Resolved: ",g(a.resolved_at)]}),a.muted_at&&e.jsxs("span",{children:["Muted: ",g(a.muted_at)]}),a.status==="pending"&&e.jsxs("span",{children:["Clean builds: ",a.clean_builds_count,"/3"]}),a.regression_count>0&&e.jsxs("span",{children:["Regressions on record: ",a.regression_count]})]})]}),_&&!$?e.jsxs("div",{className:"sh-empty",children:[e.jsx(w,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading detail…"})]}):!t||t.healCount===0?e.jsxs("div",{className:"sh-empty sh-empty--clean",children:[e.jsx(f,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"sh-empty__title",children:"No heals recorded"}),e.jsxs("div",{className:"sh-empty__subtitle",children:["This selector has no healing events in the last ",o," days."]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sh-detail-stats",children:[e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Heals"}),e.jsx("span",{className:"sh-detail-stat__value",children:t.healCount})]}),e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Sessions"}),e.jsx("span",{className:"sh-detail-stat__value",children:t.sessionCount})]}),e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Est. cost"}),e.jsx("span",{className:"sh-detail-stat__value",children:Q(t.estCostUsd)})]}),e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Tiers used"}),e.jsx("span",{className:"sh-detail-stat__value",children:Object.keys(t.byTier).length||"—"})]})]}),e.jsxs("div",{className:"sh-detail-grid",children:[e.jsxs("section",{className:"sh-card",children:[e.jsxs("header",{className:"sh-card__head",children:[e.jsx(E,{size:12}),e.jsx("span",{children:"Suggested rewrites"}),e.jsx("span",{className:"sh-card__hint",children:"every alternate the healer landed on, ranked by frequency"})]}),e.jsxs("ul",{className:"sh-alternates",children:[t.alternates.length===0&&e.jsx("li",{className:"sh-alternates__empty",children:"No healed selectors recorded — only the failure was captured."}),t.alternates.map((s,n)=>{const c=Math.round(s.share*100),u=`alt-${n}`;return e.jsxs("li",{className:"sh-alternate",children:[e.jsxs("div",{className:"sh-alternate__top",children:[e.jsxs("span",{className:"sh-alternate__share",children:[c,"%"]}),e.jsx("code",{className:"sh-alternate__value",title:s.healedSelector,children:s.healedSelector}),e.jsx("button",{type:"button",className:`sh-icon-btn ${N===u?"copied":""}`,onClick:()=>z(s.healedSelector,u),"aria-label":"Copy alternate",title:N===u?"Copied":"Copy",children:N===u?e.jsx(K,{size:11}):e.jsx(V,{size:11})})]}),e.jsxs("div",{className:"sh-alternate__meta",children:[e.jsxs("span",{children:[s.count," heal",s.count===1?"":"s"]}),s.averageConfidence!==null&&e.jsxs("span",{children:["· avg ",Math.round(s.averageConfidence*100),"% confidence"]}),s.tiers.length>0&&e.jsxs("span",{children:["· via ",s.tiers.join(", ")]})]})]},s.healedSelector)})]})]}),e.jsxs("section",{className:"sh-card",children:[e.jsxs("header",{className:"sh-card__head",children:[e.jsx(D,{size:12}),e.jsx("span",{children:"Breakdown"})]}),e.jsxs("div",{className:"sh-breakdown",children:[e.jsxs("div",{className:"sh-breakdown__group",children:[e.jsx("div",{className:"sh-breakdown__label",children:"By tier"}),Object.entries(t.byTier).sort((s,n)=>n[1]-s[1]).map(([s,n])=>e.jsxs("div",{className:"sh-breakdown__row",children:[e.jsx("span",{className:"sh-tier-pill",children:s}),e.jsx("span",{className:"sh-breakdown__count",children:n})]},s)),Object.keys(t.byTier).length===0&&e.jsx("div",{className:"sh-breakdown__empty",children:"none recorded"})]}),e.jsxs("div",{className:"sh-breakdown__group",children:[e.jsx("div",{className:"sh-breakdown__label",children:"By platform"}),Object.entries(t.byPlatform).sort((s,n)=>n[1]-s[1]).map(([s,n])=>e.jsxs("div",{className:"sh-breakdown__row",children:[e.jsx("span",{className:"sh-platform-pill",children:s}),e.jsx("span",{className:"sh-breakdown__count",children:n})]},s))]}),e.jsxs("div",{className:"sh-breakdown__group",children:[e.jsx("div",{className:"sh-breakdown__label",children:"By build"}),t.byBuild.slice(0,8).map(s=>e.jsxs("div",{className:"sh-breakdown__row",children:[e.jsx("span",{className:"sh-build-pill",title:s.buildId,children:s.buildId==="unattached"?"unattached":s.buildId.length>12?s.buildId.slice(0,8)+"…":s.buildId}),e.jsx("span",{className:"sh-breakdown__count",children:s.count})]},s.buildId)),t.byBuild.length===0&&e.jsx("div",{className:"sh-breakdown__empty",children:"none recorded"})]})]})]})]}),e.jsxs("section",{className:"sh-card",children:[e.jsxs("header",{className:"sh-card__head",children:[e.jsx("span",{children:"Timeline"}),e.jsxs("span",{className:"sh-card__hint",children:["most recent ",t.timeline.length," of ",t.healCount," heal",t.healCount===1?"":"s"]})]}),e.jsx("div",{className:"sh-timeline",children:t.timeline.map(s=>e.jsxs("div",{className:"sh-timeline__row",children:[e.jsx("span",{className:"sh-timeline__when",children:X(s.createdAt)}),s.tier&&e.jsx("span",{className:"sh-tier-pill",children:s.tier}),e.jsx("span",{className:"sh-timeline__cmd",children:s.commandName??"—"}),e.jsx("span",{className:"sh-timeline__device",children:s.deviceName??s.deviceUdid??"—"}),e.jsx("code",{className:"sh-timeline__healed",title:s.healedSelector??"",children:s.healedSelector??"—"}),s.confidence!==null&&e.jsxs("span",{className:"sh-timeline__conf",children:[Math.round(s.confidence*100),"%"]}),s.buildId&&s.sessionId&&e.jsx("a",{className:"sh-timeline__link",href:`/xenon/builds/${encodeURIComponent(s.buildId)}/sessions/${encodeURIComponent(s.sessionId)}`,title:"Open session detail",children:e.jsx(L,{size:11})})]},s.id))})]})]})]})]}):e.jsxs("div",{className:"selector-health-page",children:[e.jsx(S,{icon:f,eyebrow:"Test Quality",title:"Selector Detail",subtitle:"No selector specified."}),e.jsx("div",{className:"sh-content",children:e.jsxs("button",{className:"sh-back-btn",onClick:()=>d("/selector-health"),children:[e.jsx(M,{size:12})," Back to Selector Health"]})})]})};export{te as default};
1
+ import{u as I,m as A,A as F,r,X as v,j as e,H as f,v as w,C as R,p as D}from"./index-wbxPcwMM.js";import{f as g}from"./time-B8FIgwPE.js";import{P as S}from"./page-header-DZpQDeCw.js";import{f as H,H as P,V as B,E as L}from"./selector-health-BVJ8fGyw.js";import{C as M,L as E}from"./layers-D-4LYQG3.js";import{C as U}from"./circle-check-DDqpikKW.js";import{Z as O}from"./zap-C-b2-XlO.js";import{C as K}from"./check-CDOZKQih.js";import{C as V}from"./copy-DkXT5Ggc.js";function X(d){const h=Date.parse(d);if(!Number.isFinite(h))return"";const x=Math.max(0,Date.now()-h),l=Math.floor(x/1e3);if(l<60)return`${l}s ago`;const i=Math.floor(l/60);if(i<60)return`${i}m ago`;const o=Math.floor(i/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Q(d){return d===0?"$0":d<.01?"<$0.01":`$${d.toFixed(2)}`}const te=()=>{const d=I(),{toast:h}=A(),[x]=F(),l=x.get("value")??"",i=x.get("strategy")??"",o=parseInt(x.get("windowDays")??"30",10)||30,[t,y]=r.useState(null),[a,p]=r.useState(null),[_,C]=r.useState(!1),[$,T]=r.useState(!1),[N,k]=r.useState(null),b=r.useCallback(async()=>{if(l){C(!0);try{const s=await v.getHealingSelectorDetail(l,o);y(s??null)}catch{y(null)}finally{C(!1),T(!0)}}},[l,o]),j=r.useCallback(async()=>{if(!i||!l){p(null);return}try{const s=await v.getSelectorState(i,l);p((s==null?void 0:s.state)??null)}catch{p(null)}},[i,l]);r.useEffect(()=>{b()},[b]),r.useEffect(()=>{j()},[j]);const m=r.useCallback(async s=>{if(!i||!l)return;const n=(()=>{switch(s){case"mark_fixed":return"Mark this selector as fixed? Move to Pending Verification.";case"mute":return"Mute this selector? It will be hidden from Hotspots, the CI gate, and digests.";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(n))try{await v.postSelectorStateAction({original_strategy:i,original_selector:l,action:s}),h("Done.","success"),j()}catch(c){const u=c!=null&&c.currentStatus?` (currently ${c.currentStatus})`:"";h(`${(c==null?void 0:c.message)??"Action failed"}${u}`,"error")}},[i,l,h,j]),z=(s,n)=>{navigator.clipboard.writeText(s).catch(()=>{}),k(n),setTimeout(()=>k(c=>c===n?null:c),1500)};return l?e.jsxs("div",{className:"selector-health-page",children:[e.jsx(S,{icon:f,eyebrow:"Test Quality / Selector",title:e.jsx("span",{className:"sh-detail-title",children:e.jsx("code",{title:l,children:l})}),subtitle:`All heals for this selector over the last ${o} days.`,action:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"sh-back-btn",onClick:()=>d("/selector-health"),children:[e.jsx(M,{size:12})," Back"]}),e.jsxs("button",{className:"sh-refresh-btn",onClick:b,disabled:_,title:"Refresh",children:[e.jsx(w,{size:12,className:_?"animate-spin":""}),"Refresh"]})]})}),e.jsxs("div",{className:"sh-content",children:[i&&e.jsxs("div",{className:"sh-detail-strategy-line",title:"Tuple identity for this drill-down",children:[e.jsx("span",{className:"sh-strategy-badge",children:H(i)}),e.jsx("code",{children:l})]}),!i&&e.jsxs("div",{className:"sh-detail-banner",children:["Showing every strategy that ever healed this selector value. To scope to a single tuple, append ",e.jsx("code",{children:"?strategy=<name>"})," ","to the URL or open this row from the Active tab on Selector Health."]}),a&&e.jsxs("div",{className:`sh-detail-state sh-detail-state--${a.status}`,children:[e.jsxs("div",{className:"sh-detail-state__head",children:[e.jsxs("span",{className:"sh-detail-state__badge",children:[a.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{size:16,style:{color:"var(--accent, #60a5fa)"}}),e.jsx("span",{children:"Pending verification"})]}),a.status==="resolved"&&e.jsxs(e.Fragment,{children:[e.jsx(U,{size:16,style:{color:"var(--green, #4ade80)"}}),e.jsx("span",{children:"Resolved"})]}),a.status==="muted"&&e.jsxs(e.Fragment,{children:[e.jsx(B,{size:16,style:{color:"var(--text-muted)"}}),e.jsx("span",{children:"Muted"})]}),a.status==="active"&&(a.regression_count>0?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:16,style:{color:"var(--amber, #f59e0b)"}}),e.jsxs("span",{children:["Active — regressed ",a.regression_count,"×"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:16}),e.jsx("span",{children:"Active"})]}))]}),e.jsxs("div",{className:"sh-detail-state__actions",children:[a.status==="active"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn sh-action-btn--primary",onClick:()=>m("mark_fixed"),children:"Mark Fixed"}),e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("mute"),children:"Mute"})]}),a.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("cancel_verification"),children:"Cancel verification"}),e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("mute"),children:"Mute"})]}),a.status==="resolved"&&e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("mute"),children:"Mute"}),a.status==="muted"&&e.jsx("button",{type:"button",className:"sh-action-btn",onClick:()=>m("unmute"),children:"Unmute"})]})]}),e.jsxs("div",{className:"sh-detail-state__meta",children:[a.fixed_at&&e.jsxs("span",{children:["Marked fixed: ",g(a.fixed_at)]}),a.resolved_at&&e.jsxs("span",{children:["Resolved: ",g(a.resolved_at)]}),a.muted_at&&e.jsxs("span",{children:["Muted: ",g(a.muted_at)]}),a.status==="pending"&&e.jsxs("span",{children:["Clean builds: ",a.clean_builds_count,"/3"]}),a.regression_count>0&&e.jsxs("span",{children:["Regressions on record: ",a.regression_count]})]})]}),_&&!$?e.jsxs("div",{className:"sh-empty",children:[e.jsx(w,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading detail…"})]}):!t||t.healCount===0?e.jsxs("div",{className:"sh-empty sh-empty--clean",children:[e.jsx(f,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"sh-empty__title",children:"No heals recorded"}),e.jsxs("div",{className:"sh-empty__subtitle",children:["This selector has no healing events in the last ",o," days."]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sh-detail-stats",children:[e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Heals"}),e.jsx("span",{className:"sh-detail-stat__value",children:t.healCount})]}),e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Sessions"}),e.jsx("span",{className:"sh-detail-stat__value",children:t.sessionCount})]}),e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Est. cost"}),e.jsx("span",{className:"sh-detail-stat__value",children:Q(t.estCostUsd)})]}),e.jsxs("div",{className:"sh-detail-stat",children:[e.jsx("span",{className:"sh-detail-stat__label",children:"Tiers used"}),e.jsx("span",{className:"sh-detail-stat__value",children:Object.keys(t.byTier).length||"—"})]})]}),e.jsxs("div",{className:"sh-detail-grid",children:[e.jsxs("section",{className:"sh-card",children:[e.jsxs("header",{className:"sh-card__head",children:[e.jsx(E,{size:12}),e.jsx("span",{children:"Suggested rewrites"}),e.jsx("span",{className:"sh-card__hint",children:"every alternate the healer landed on, ranked by frequency"})]}),e.jsxs("ul",{className:"sh-alternates",children:[t.alternates.length===0&&e.jsx("li",{className:"sh-alternates__empty",children:"No healed selectors recorded — only the failure was captured."}),t.alternates.map((s,n)=>{const c=Math.round(s.share*100),u=`alt-${n}`;return e.jsxs("li",{className:"sh-alternate",children:[e.jsxs("div",{className:"sh-alternate__top",children:[e.jsxs("span",{className:"sh-alternate__share",children:[c,"%"]}),e.jsx("code",{className:"sh-alternate__value",title:s.healedSelector,children:s.healedSelector}),e.jsx("button",{type:"button",className:`sh-icon-btn ${N===u?"copied":""}`,onClick:()=>z(s.healedSelector,u),"aria-label":"Copy alternate",title:N===u?"Copied":"Copy",children:N===u?e.jsx(K,{size:11}):e.jsx(V,{size:11})})]}),e.jsxs("div",{className:"sh-alternate__meta",children:[e.jsxs("span",{children:[s.count," heal",s.count===1?"":"s"]}),s.averageConfidence!==null&&e.jsxs("span",{children:["· avg ",Math.round(s.averageConfidence*100),"% confidence"]}),s.tiers.length>0&&e.jsxs("span",{children:["· via ",s.tiers.join(", ")]})]})]},s.healedSelector)})]})]}),e.jsxs("section",{className:"sh-card",children:[e.jsxs("header",{className:"sh-card__head",children:[e.jsx(D,{size:12}),e.jsx("span",{children:"Breakdown"})]}),e.jsxs("div",{className:"sh-breakdown",children:[e.jsxs("div",{className:"sh-breakdown__group",children:[e.jsx("div",{className:"sh-breakdown__label",children:"By tier"}),Object.entries(t.byTier).sort((s,n)=>n[1]-s[1]).map(([s,n])=>e.jsxs("div",{className:"sh-breakdown__row",children:[e.jsx("span",{className:"sh-tier-pill",children:s}),e.jsx("span",{className:"sh-breakdown__count",children:n})]},s)),Object.keys(t.byTier).length===0&&e.jsx("div",{className:"sh-breakdown__empty",children:"none recorded"})]}),e.jsxs("div",{className:"sh-breakdown__group",children:[e.jsx("div",{className:"sh-breakdown__label",children:"By platform"}),Object.entries(t.byPlatform).sort((s,n)=>n[1]-s[1]).map(([s,n])=>e.jsxs("div",{className:"sh-breakdown__row",children:[e.jsx("span",{className:"sh-platform-pill",children:s}),e.jsx("span",{className:"sh-breakdown__count",children:n})]},s))]}),e.jsxs("div",{className:"sh-breakdown__group",children:[e.jsx("div",{className:"sh-breakdown__label",children:"By build"}),t.byBuild.slice(0,8).map(s=>e.jsxs("div",{className:"sh-breakdown__row",children:[e.jsx("span",{className:"sh-build-pill",title:s.buildId,children:s.buildId==="unattached"?"unattached":s.buildId.length>12?s.buildId.slice(0,8)+"…":s.buildId}),e.jsx("span",{className:"sh-breakdown__count",children:s.count})]},s.buildId)),t.byBuild.length===0&&e.jsx("div",{className:"sh-breakdown__empty",children:"none recorded"})]})]})]})]}),e.jsxs("section",{className:"sh-card",children:[e.jsxs("header",{className:"sh-card__head",children:[e.jsx("span",{children:"Timeline"}),e.jsxs("span",{className:"sh-card__hint",children:["most recent ",t.timeline.length," of ",t.healCount," heal",t.healCount===1?"":"s"]})]}),e.jsx("div",{className:"sh-timeline",children:t.timeline.map(s=>e.jsxs("div",{className:"sh-timeline__row",children:[e.jsx("span",{className:"sh-timeline__when",children:X(s.createdAt)}),s.tier&&e.jsx("span",{className:"sh-tier-pill",children:s.tier}),e.jsx("span",{className:"sh-timeline__cmd",children:s.commandName??"—"}),e.jsx("span",{className:"sh-timeline__device",children:s.deviceName??s.deviceUdid??"—"}),e.jsx("code",{className:"sh-timeline__healed",title:s.healedSelector??"",children:s.healedSelector??"—"}),s.confidence!==null&&e.jsxs("span",{className:"sh-timeline__conf",children:[Math.round(s.confidence*100),"%"]}),s.buildId&&s.sessionId&&e.jsx("a",{className:"sh-timeline__link",href:`/xenon/builds/${encodeURIComponent(s.buildId)}/sessions/${encodeURIComponent(s.sessionId)}`,title:"Open session detail",children:e.jsx(L,{size:11})})]},s.id))})]})]})]})]}):e.jsxs("div",{className:"selector-health-page",children:[e.jsx(S,{icon:f,eyebrow:"Test Quality",title:"Selector Detail",subtitle:"No selector specified."}),e.jsx("div",{className:"sh-content",children:e.jsxs("button",{className:"sh-back-btn",onClick:()=>d("/selector-health"),children:[e.jsx(M,{size:12})," Back to Selector Health"]})})]})};export{te as default};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as D,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-PtnKslHU.js";import{Z as he}from"./zap-JUbOoK3o.js";import{H as B,V as R,f as w,E as ue}from"./selector-health-BjMHf106.js";import{C as Y}from"./circle-check-CI2xUlDo.js";import{M as me}from"./Modal-MMGhL8eW.js";import{C as pe}from"./check-BZMx8AhR.js";import{C as ge}from"./copy-ve3lNhva.js";import{b as N}from"./time-B8FIgwPE.js";import{u as Z}from"./useSocket-BRto9a5m.js";import{E as ve}from"./EmptyState-CPOfuV3O.js";import{P as xe}from"./page-header-CSvuGbSO.js";import{S as be}from"./SegmentedControl-CZfAicws.js";import{F as G}from"./funnel-CptlpFZ9.js";import{C as fe}from"./chevron-right-WL_bcB02.js";import{A as J}from"./arrow-up-right-DePHHOby.js";/**
1
+ import{g as D,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-wbxPcwMM.js";import{Z as he}from"./zap-C-b2-XlO.js";import{H as B,V as R,f as w,E as ue}from"./selector-health-BVJ8fGyw.js";import{C as Y}from"./circle-check-DDqpikKW.js";import{M as me}from"./Modal-Cuva-zxU.js";import{C as pe}from"./check-CDOZKQih.js";import{C as ge}from"./copy-DkXT5Ggc.js";import{b as N}from"./time-B8FIgwPE.js";import{u as Z}from"./useSocket-qyqK9PWr.js";import{E as ve}from"./EmptyState-X7DYPoPj.js";import{P as xe}from"./page-header-DZpQDeCw.js";import{S as be}from"./SegmentedControl-Bdc4A0UR.js";import{F as G}from"./funnel-DfsfiM0o.js";import{C as fe}from"./chevron-right-CnpP0W_l.js";import{A as J}from"./arrow-up-right-B-YmrLSY.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as W,r as d,X as _,m as D,j as e,L as B,p as Y,c as Q,u as q}from"./index-PtnKslHU.js";import{u as Z,h as ee,a as te,d as re,p as se,o as ae,f as ne,S as ie}from"./status-pill-outline-50aN0wRU.js";import{B as oe,P as j}from"./BugReportButton-Gw4lnGnV.js";import{A as le}from"./arrow-left-GX0vzYtn.js";import{C as $}from"./chevron-right-WL_bcB02.js";import{C as L}from"./copy-ve3lNhva.js";import{A as ce}from"./arrow-up-right-DePHHOby.js";import{E as O}from"./EmptyState-CPOfuV3O.js";import{T as de,a as xe,b as M,c as S,d as me,e as R}from"./Table-DsN_IX6J.js";import{u as ue}from"./useSocket-BRto9a5m.js";import{M as fe}from"./Modal-MMGhL8eW.js";import{D as pe}from"./download-BDZj44ke.js";import"./time-B8FIgwPE.js";/**
1
+ import{g as W,r as d,X as _,m as D,j as e,L as B,p as Y,c as Q,u as q}from"./index-wbxPcwMM.js";import{u as Z,h as ee,a as te,d as re,p as se,o as ae,f as ne,S as ie}from"./status-pill-outline-DjKuXDLG.js";import{B as oe,P as j}from"./BugReportButton-N-NBBb3l.js";import{A as le}from"./arrow-left-C1v7ukDM.js";import{C as $}from"./chevron-right-CnpP0W_l.js";import{C as L}from"./copy-DkXT5Ggc.js";import{A as ce}from"./arrow-up-right-B-YmrLSY.js";import{E as O}from"./EmptyState-X7DYPoPj.js";import{T as de,a as xe,b as M,c as S,d as me,e as R}from"./Table-Casq-_Hh.js";import{u as ue}from"./useSocket-qyqK9PWr.js";import{M as fe}from"./Modal-Cuva-zxU.js";import{D as pe}from"./download-B0tbRUtY.js";import"./time-B8FIgwPE.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-PtnKslHU.js";/* empty css */import{S as x,A as q}from"./SettingCard-Dp7XIdcl.js";import{P as X}from"./page-header-CSvuGbSO.js";import{u as G}from"./useSocket-BRto9a5m.js";import{S as V,C as O}from"./shield-JGzamJo5.js";import{C as _}from"./circle-check-CI2xUlDo.js";import{C as U}from"./clock-BFVLE7wW.js";import{M as K,F as W}from"./mouse-pointer-2-Dpcc76zN.js";import{C as J}from"./check-BZMx8AhR.js";import{A as Q}from"./activity-DCBAvxuo.js";import{A as Y}from"./arrow-up-right-DePHHOby.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 E(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),[y,b]=c.useState([]),[A,H]=c.useState(!1),{on:k}=G();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):[];b(d)}).catch(()=>{}).finally(()=>{a||H(!0)}),()=>{a=!0}},[]),c.useEffect(()=>{const a=k("healing_event",i=>{const d=i;!d||!d.id||b(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:V,title:"Settings",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 * * * * (hourly, at minute 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(K,{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 6-tier strategy: etalon recovery, native retry, 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(W,{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})]})]}),y.length>0?e.jsx("ul",{className:"healing-events__list",children:y.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:E(a),children:E(a)})]})]},a.id))}):e.jsx("div",{className:"healing-events__empty",children:A?"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};
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-wbxPcwMM.js";/* empty css */import{S as x,A as q}from"./SettingCard-DVZUpQJR.js";import{P as X}from"./page-header-DZpQDeCw.js";import{u as G}from"./useSocket-qyqK9PWr.js";import{S as V,C as O}from"./shield-DVYhrtS6.js";import{C as _}from"./circle-check-DDqpikKW.js";import{C as U}from"./clock-CfNmWqai.js";import{M as K,F as W}from"./mouse-pointer-2-DoCqhosb.js";import{C as J}from"./check-CDOZKQih.js";import{A as Q}from"./activity-KiLkzk_U.js";import{A as Y}from"./arrow-up-right-B-YmrLSY.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 E(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),[y,b]=c.useState([]),[A,H]=c.useState(!1),{on:k}=G();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):[];b(d)}).catch(()=>{}).finally(()=>{a||H(!0)}),()=>{a=!0}},[]),c.useEffect(()=>{const a=k("healing_event",i=>{const d=i;!d||!d.id||b(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:V,title:"Settings",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 * * * * (hourly, at minute 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(K,{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 6-tier strategy: etalon recovery, native retry, 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(W,{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})]})]}),y.length>0?e.jsx("ul",{className:"healing-events__list",children:y.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:E(a),children:E(a)})]})]},a.id))}):e.jsx("div",{className:"healing-events__empty",children:A?"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};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.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{r as n,X as v,j as x}from"./index-PtnKslHU.js";import{u as y}from"./useSocket-BRto9a5m.js";import{f as E}from"./time-B8FIgwPE.js";const _=3e3;function L(){const[e,t]=n.useState([]),[r,o]=n.useState([]),[i,u]=n.useState(null),[d,p]=n.useState(""),[b,S]=n.useState(!0),[h,m]=n.useState(null),c=n.useRef(!0),{on:l}=y(),a=n.useCallback(async()=>{try{const[s,f]=await Promise.all([v.getBuilds(),i?v.getSessions({buildId:i,query:d}):Promise.resolve([])]);if(!c.current)return;t(Array.isArray(s)?s:[]),o(Array.isArray(f)?f:[]),m(null)}catch(s){if(!c.current)return;m(s instanceof Error?s.message:String(s))}finally{c.current&&S(!1)}},[i,d]);return n.useEffect(()=>{c.current=!0,a();const s=setInterval(a,_);return()=>{c.current=!1,clearInterval(s)}},[a]),n.useEffect(()=>{const s=()=>a(),f=[l("session_started",s),l("session_stopped",s),l("device_added",s),l("device_removed",s)];return()=>{for(const g of f)g()}},[l,a]),{builds:e,selectedBuildId:i,sessions:r,loading:b,error:h,selectBuild:u,searchQuery:d,setSearchQuery:p,refresh:a}}function T(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 k(e){var r;const t=(r=e.device_name)==null?void 0:r.trim();return t&&t.length>0?t:"Unknown Device"}function w(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 B(e){return e.device_version?`v${e.device_version}`:""}function F(e){return E(e)}function N(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 C(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3,r=Math.floor(t/3600),o=Math.floor(t%3600/60),u=(t-r*3600-o*60).toFixed(1);return r>0?`${r}h ${o}m ${u}s`:o>0?`${o}m ${u}s`:`${u}s`}function M(e,t=10,r=4){return e?e.length<=t+r+1?e:`${e.slice(0,t)}…${e.slice(-r)}`:""}const $={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)]"},R=({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 ${$[t]}`,children:e});export{R as S,N as a,T as b,k as d,F as f,C as h,B as o,w as p,M as s,L as u};
1
+ import{r as n,X as v,j as x}from"./index-wbxPcwMM.js";import{u as y}from"./useSocket-qyqK9PWr.js";import{f as E}from"./time-B8FIgwPE.js";const _=3e3;function L(){const[e,t]=n.useState([]),[r,o]=n.useState([]),[i,u]=n.useState(null),[d,p]=n.useState(""),[b,S]=n.useState(!0),[h,m]=n.useState(null),c=n.useRef(!0),{on:l}=y(),a=n.useCallback(async()=>{try{const[s,f]=await Promise.all([v.getBuilds(),i?v.getSessions({buildId:i,query:d}):Promise.resolve([])]);if(!c.current)return;t(Array.isArray(s)?s:[]),o(Array.isArray(f)?f:[]),m(null)}catch(s){if(!c.current)return;m(s instanceof Error?s.message:String(s))}finally{c.current&&S(!1)}},[i,d]);return n.useEffect(()=>{c.current=!0,a();const s=setInterval(a,_);return()=>{c.current=!1,clearInterval(s)}},[a]),n.useEffect(()=>{const s=()=>a(),f=[l("session_started",s),l("session_stopped",s),l("device_added",s),l("device_removed",s)];return()=>{for(const g of f)g()}},[l,a]),{builds:e,selectedBuildId:i,sessions:r,loading:b,error:h,selectBuild:u,searchQuery:d,setSearchQuery:p,refresh:a}}function T(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 k(e){var r;const t=(r=e.device_name)==null?void 0:r.trim();return t&&t.length>0?t:"Unknown Device"}function w(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 B(e){return e.device_version?`v${e.device_version}`:""}function F(e){return E(e)}function N(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 C(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3,r=Math.floor(t/3600),o=Math.floor(t%3600/60),u=(t-r*3600-o*60).toFixed(1);return r>0?`${r}h ${o}m ${u}s`:o>0?`${o}m ${u}s`:`${u}s`}function M(e,t=10,r=4){return e?e.length<=t+r+1?e:`${e.slice(0,t)}…${e.slice(-r)}`:""}const $={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)]"},R=({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 ${$[t]}`,children:e});export{R as S,N as a,T as b,k as d,F as f,C as h,B as o,w as p,M as s,L as u};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./index-PtnKslHU.js";/**
1
+ import{g as e}from"./index-wbxPcwMM.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 D,r as n,j as e,v as z,z as f,S as B}from"./index-PtnKslHU.js";/* empty css */import{a as $}from"./time-B8FIgwPE.js";import{T as E,a as M,b as T,c as u,d as R,e as j}from"./Table-DsN_IX6J.js";import{F as Y}from"./FieldGroup-C5UkCHbe.js";import{P as U}from"./page-header-CSvuGbSO.js";import{M as K}from"./Modal-MMGhL8eW.js";import{l as Q}from"./users-cwrwUhwo.js";import{S as V}from"./shield-alert-DzE36jcb.js";import{P as N}from"./plus-vJJF9g79.js";import{A as W}from"./arrow-left-GX0vzYtn.js";import{T as F}from"./trash-2-BrTSfFh5.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 xe=()=>{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:V,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(ee,{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(Z,{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 ",$(a.createdAt)]})]},a.id))})]}),x&&e.jsx(X,{onClose:()=>d(!1),onCreated:()=>{d(!1),v()}})]})},X=({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(K,{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(Y,{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:w,autoFocus:!0})})})})},Z=({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(F,{size:14}),l?"Deleting…":"Delete"]})},ee=({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,G]=await Promise.all([p(`/xenon/api/teams/${i.id}/members`),Q(),p("/xenon/api/device")]);m(s),h(g);const I=G;d(I.filter(A=>A.teamId===i.id)),S(I.filter(A=>!A.teamId))}catch(s){t(`Failed to load team detail: ${s.message}`,"error")}finally{C(!1)}};n.useEffect(()=>{b()},[i.id]);const L=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")}},O=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")}},H=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")}},J=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")}},q=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(W,{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:{...w,flex:1},children:[e.jsx("option",{value:"",children:"Select a user to add…"}),q.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:L,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:$(s.addedAt)}),e.jsx(j,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>O(s.userId),style:{color:"var(--status-error-fg)"},"aria-label":"Remove member",title:"Remove member",children:e.jsx(F,{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:{...w,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:H,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:()=>J(s.udid),children:"Return to shared pool"})})]},s.udid))})]})]})]})]})]})},w={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{xe as Teams};
1
+ import{m as D,r as n,j as e,v as z,z as f,S as B}from"./index-wbxPcwMM.js";/* empty css */import{a as $}from"./time-B8FIgwPE.js";import{T as E,a as M,b as T,c as u,d as R,e as j}from"./Table-Casq-_Hh.js";import{F as Y}from"./FieldGroup-a9gzUh4W.js";import{P as U}from"./page-header-DZpQDeCw.js";import{M as K}from"./Modal-Cuva-zxU.js";import{l as Q}from"./users-cwrwUhwo.js";import{S as V}from"./shield-alert-BhxlmXys.js";import{P as N}from"./plus-CTjPrkU5.js";import{A as W}from"./arrow-left-C1v7ukDM.js";import{T as F}from"./trash-2-8zA1h40t.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 xe=()=>{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:V,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(ee,{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(Z,{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 ",$(a.createdAt)]})]},a.id))})]}),x&&e.jsx(X,{onClose:()=>d(!1),onCreated:()=>{d(!1),v()}})]})},X=({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(K,{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(Y,{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:w,autoFocus:!0})})})})},Z=({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(F,{size:14}),l?"Deleting…":"Delete"]})},ee=({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,G]=await Promise.all([p(`/xenon/api/teams/${i.id}/members`),Q(),p("/xenon/api/device")]);m(s),h(g);const I=G;d(I.filter(A=>A.teamId===i.id)),S(I.filter(A=>!A.teamId))}catch(s){t(`Failed to load team detail: ${s.message}`,"error")}finally{C(!1)}};n.useEffect(()=>{b()},[i.id]);const L=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")}},O=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")}},H=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")}},J=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")}},q=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(W,{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:{...w,flex:1},children:[e.jsx("option",{value:"",children:"Select a user to add…"}),q.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:L,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:$(s.addedAt)}),e.jsx(j,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>O(s.userId),style:{color:"var(--status-error-fg)"},"aria-label":"Remove member",title:"Remove member",children:e.jsx(F,{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:{...w,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:H,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:()=>J(s.udid),children:"Return to shared pool"})})]},s.udid))})]})]})]})]})]})},w={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{xe as Teams};