@xenon-device-management/xenon 1.7.7 → 1.7.9

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 (66) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{ApiKeyGate-BVaB1Eg_.js → ApiKeyGate-DstjGHCV.js} +1 -1
  3. package/lib/public/assets/{BugReportButton-CioDV7QP.js → BugReportButton-CCFNeE8T.js} +1 -1
  4. package/lib/public/assets/DeviceMosaicView-CeSU4Cin.js +2 -0
  5. package/lib/public/assets/{EmptyState-UcJej2vi.js → EmptyState-BLKITXvX.js} +1 -1
  6. package/lib/public/assets/{FieldGroup-CYlyr34Q.js → FieldGroup-DnJ8AU1V.js} +1 -1
  7. package/lib/public/assets/{Modal-CjmzIR4Y.js → Modal-QVER5CZo.js} +1 -1
  8. package/lib/public/assets/{SegmentedControl-wRDvkYAQ.js → SegmentedControl-C2vcRRnn.js} +1 -1
  9. package/lib/public/assets/{SettingCard-BzjYlAYS.js → SettingCard-BCRyZfOg.js} +1 -1
  10. package/lib/public/assets/{Table-ta1UYEeC.js → Table-CEvMaA5P.js} +1 -1
  11. package/lib/public/assets/{activity-jltyhcrF.js → activity-C9XYmP_g.js} +1 -1
  12. package/lib/public/assets/{ai-settings-Dfjxb1SZ.js → ai-settings-CUkrWRb4.js} +1 -1
  13. package/lib/public/assets/{api-keys-cFOese97.js → api-keys-DOEqEyCC.js} +1 -1
  14. package/lib/public/assets/{apps-sHtZU8T_.js → apps-kS8notsd.js} +1 -1
  15. package/lib/public/assets/{arrow-left-DGZzN6Sl.js → arrow-left-USNjWr3g.js} +1 -1
  16. package/lib/public/assets/{arrow-up-right-DtZUe0YH.js → arrow-up-right-CA-0ObXb.js} +1 -1
  17. package/lib/public/assets/{auth-shell-D0eF5eyS.js → auth-shell-0GDuDM6t.js} +1 -1
  18. package/lib/public/assets/builds-page-B3hcVeUY.js +6 -0
  19. package/lib/public/assets/{button-3RkAu6xE.js → button-30pnTauc.js} +1 -1
  20. package/lib/public/assets/{check-D6DDcFwM.js → check-CVbtgHOC.js} +1 -1
  21. package/lib/public/assets/{chevron-right-BtA7DR8A.js → chevron-right-BpHMOuL1.js} +1 -1
  22. package/lib/public/assets/{circle-check-Bjgvpq5F.js → circle-check-BR3SeBx6.js} +1 -1
  23. package/lib/public/assets/{circle-x-_TOawobA.js → circle-x-BISG5iH-.js} +1 -1
  24. package/lib/public/assets/{clock-pm4LDp97.js → clock-BiZmZWEe.js} +1 -1
  25. package/lib/public/assets/{copy-x-UuUQkc.js → copy-E317aAW3.js} +1 -1
  26. package/lib/public/assets/{device-explorer-BDih8ZO9.js → device-explorer-DTj4kvcs.js} +8 -8
  27. package/lib/public/assets/{download-CuDjBGgs.js → download-Blklg-SX.js} +1 -1
  28. package/lib/public/assets/{forgot-password-lgHuL3gW.js → forgot-password-Bwo7pGp7.js} +1 -1
  29. package/lib/public/assets/{funnel-DQuWVevA.js → funnel-C8pl8r9F.js} +1 -1
  30. package/lib/public/assets/{index--TKsSVZp.js → index-Doq8HO3X.js} +14 -14
  31. package/lib/public/assets/index-TkL430dq.css +1 -0
  32. package/lib/public/assets/{layers-CdE4q4fN.js → layers-C2U3k-wh.js} +1 -1
  33. package/lib/public/assets/{lock-D2Vg6I6G.js → lock-pCxyVW83.js} +1 -1
  34. package/lib/public/assets/{login-C2dtnYcH.js → login-Cn6qENaF.js} +1 -1
  35. package/lib/public/assets/{maintenance-settings-Ck0suBTt.js → maintenance-settings-DybzeKfb.js} +1 -1
  36. package/lib/public/assets/{mouse-pointer-2-JuM7rDhC.js → mouse-pointer-2-cmVLOY6H.js} +1 -1
  37. package/lib/public/assets/overview-Dqw_olJm.js +11 -0
  38. package/lib/public/assets/{page-header-D5tpZwkI.js → page-header-Qk9pGEaH.js} +1 -1
  39. package/lib/public/assets/{plus-tcA3_CAo.js → plus-DkzZBN8d.js} +1 -1
  40. package/lib/public/assets/{profile-page-BuuLTEtS.js → profile-page-D_BlUsba.js} +1 -1
  41. package/lib/public/assets/{reset-password-ERq0WAyA.js → reset-password-vxmC3PEa.js} +1 -1
  42. package/lib/public/assets/{runbook-page-BubL06xm.js → runbook-page-rzVHVBte.js} +1 -1
  43. package/lib/public/assets/{selector-detail-page-DgL7bNdy.js → selector-detail-page-DUPHHW7E.js} +1 -1
  44. package/lib/public/assets/selector-health-C4Sv_nTk.css +1 -0
  45. package/lib/public/assets/{selector-health-B-V7vomq.js → selector-health-CS_wYWYA.js} +1 -1
  46. package/lib/public/assets/{selector-health-page-DWy7bTdU.js → selector-health-page-CQT_ghIj.js} +1 -1
  47. package/lib/public/assets/{session-detail-page-COgS5oAy.js → session-detail-page-Md2BJeDW.js} +1 -1
  48. package/lib/public/assets/{settings-D0fQ4JNR.js → settings-DcRs-Ksu.js} +1 -1
  49. package/lib/public/assets/{shield-DINNxWHp.js → shield-DKOl26Qj.js} +1 -1
  50. package/lib/public/assets/{shield-alert-DDDbE5ER.js → shield-alert-B6RlIJqv.js} +1 -1
  51. package/lib/public/assets/status-pill-outline-Df9QaRNJ.js +1 -0
  52. package/lib/public/assets/{tablet-DoE7LIzI.js → tablet-1xXXhpqC.js} +1 -1
  53. package/lib/public/assets/{teams-DpW-IUPC.js → teams-DnBnZECm.js} +1 -1
  54. package/lib/public/assets/{trash-2-Dvr08Dpq.js → trash-2-D-ONhY9W.js} +1 -1
  55. package/lib/public/assets/{useSocket-COssbQIj.js → useSocket-D9iZtppJ.js} +1 -1
  56. package/lib/public/assets/{users-DKmLh2WK.js → users-BFrjP_42.js} +1 -1
  57. package/lib/public/assets/{webhook-settings-nwtLvp2Q.js → webhook-settings-DgJKt5Wf.js} +1 -1
  58. package/lib/public/assets/{zap-CM2cWetx.js → zap-C8F21kM1.js} +1 -1
  59. package/lib/public/index.html +2 -2
  60. package/package.json +1 -1
  61. package/lib/public/assets/DeviceMosaicView-BtRxZTXc.js +0 -2
  62. package/lib/public/assets/builds-page-DxDwaq_t.js +0 -6
  63. package/lib/public/assets/index-BW3kENYH.css +0 -1
  64. package/lib/public/assets/overview-BBzmQBEl.js +0 -11
  65. package/lib/public/assets/selector-health-BwHGcem9.css +0 -1
  66. package/lib/public/assets/status-pill-outline-CFz5xaoF.js +0 -1
@@ -1,4 +1,4 @@
1
- import{g as B,j as t,r as m,h as On,R as Pn,i as zn,k as Re,C as $s,U as Fn,X as P,m as en,n as Bn,u as ys,b as Hn,o as ls,p as ds,q as tn,s as Ts,c as sn,t as It,S as Ms,v as Ls}from"./index--TKsSVZp.js";import{P as Wn}from"./page-header-D5tpZwkI.js";import{T as us,B as lt,P as Un,U as Vn}from"./button-3RkAu6xE.js";import{P as dt,B as qn}from"./BugReportButton-CioDV7QP.js";import{P as Rt,u as Wt,a as kt,b as nn,c as vs,d as Xn,D as Kn,e as Is,f as Yn,g as ut,h as Gn,M as rn}from"./Modal-CjmzIR4Y.js";import{F as Ft}from"./FieldGroup-CYlyr34Q.js";import{C as an}from"./clock-pm4LDp97.js";import{P as Zn}from"./plus-tcA3_CAo.js";import{A as Jn}from"./activity-jltyhcrF.js";import{C as Ct}from"./copy-x-UuUQkc.js";import{f as Qn}from"./time-B8FIgwPE.js";import{M as ei,F as ti}from"./mouse-pointer-2-JuM7rDhC.js";import{L as si,C as es}from"./layers-CdE4q4fN.js";import{C as Bt}from"./check-D6DDcFwM.js";import{Z as on}from"./zap-CM2cWetx.js";import{C as cn}from"./chevron-right-BtA7DR8A.js";import{S as ts}from"./shield-alert-DDDbE5ER.js";import{A as jt,I as ss}from"./keycodes-bIEJfQzr.js";import{L as ni}from"./lock-D2Vg6I6G.js";import{T as _t}from"./trash-2-Dvr08Dpq.js";import{D as ii}from"./download-CuDjBGgs.js";import{S as ri}from"./SegmentedControl-wRDvkYAQ.js";import{u as ai}from"./useSocket-COssbQIj.js";/**
1
+ import{g as B,j as t,r as m,h as On,R as Pn,i as zn,k as Re,C as Ts,U as Fn,X as P,m as en,n as Bn,u as vs,b as Hn,o as ds,p as us,q as tn,s as Ms,c as sn,t as It,S as Ls,v as es}from"./index-Doq8HO3X.js";import{P as Wn}from"./page-header-Qk9pGEaH.js";import{T as ms,B as lt,P as Un,U as Vn}from"./button-30pnTauc.js";import{P as dt,B as qn}from"./BugReportButton-CCFNeE8T.js";import{P as Rt,u as Wt,a as kt,b as nn,c as bs,d as Xn,D as Kn,e as Is,f as Yn,g as ut,h as Gn,M as rn}from"./Modal-QVER5CZo.js";import{F as Ft}from"./FieldGroup-DnJ8AU1V.js";import{C as an}from"./clock-BiZmZWEe.js";import{P as Zn}from"./plus-DkzZBN8d.js";import{A as Jn}from"./activity-C9XYmP_g.js";import{C as Ct}from"./copy-E317aAW3.js";import{f as Qn}from"./time-B8FIgwPE.js";import{M as ei,F as ti}from"./mouse-pointer-2-cmVLOY6H.js";import{L as si,C as ts}from"./layers-C2U3k-wh.js";import{C as Bt}from"./check-CVbtgHOC.js";import{Z as on}from"./zap-C8F21kM1.js";import{C as cn}from"./chevron-right-BpHMOuL1.js";import{S as ss}from"./shield-alert-B6RlIJqv.js";import{A as jt,I as ns}from"./keycodes-bIEJfQzr.js";import{L as ni}from"./lock-pCxyVW83.js";import{T as _t}from"./trash-2-D-ONhY9W.js";import{D as ii}from"./download-Blklg-SX.js";import{S as ri}from"./SegmentedControl-C2vcRRnn.js";import{u as ai}from"./useSocket-D9iZtppJ.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -113,7 +113,7 @@ import{g as B,j as t,r as m,h as On,R as Pn,i as zn,k as Re,C as $s,U as Fn,X as
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const Ki=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ms=B("sparkles",Ki);/**
116
+ */const Ki=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],hs=B("sparkles",Ki);/**
117
117
  * @license lucide-react v0.555.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
@@ -128,7 +128,7 @@ import{g as B,j as t,r as m,h as On,R as Pn,i as zn,k as Re,C as $s,U as Fn,X as
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const Qi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ns=B("target",Qi);/**
131
+ */const Qi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],is=B("target",Qi);/**
132
132
  * @license lucide-react v0.555.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
@@ -153,7 +153,7 @@ import{g as B,j as t,r as m,h as On,R as Pn,i as zn,k as Re,C as $s,U as Fn,X as
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const cr=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],lr=B("wifi",cr);function dr(e){if(typeof e!="number")throw new TypeError("Expected a number");const s=e>0?Math.floor:Math.ceil;return{days:s(e/864e5),hours:s(e/36e5)%24,minutes:s(e/6e4)%60,seconds:s(e/1e3)%60,milliseconds:s(e)%1e3,microseconds:s(e*1e3)%1e3,nanoseconds:s(e*1e6)%1e3}}const ur=(e,s)=>s===1?e:`${e}s`,mr=1e-7;function Os(e,s={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],r=(i,l)=>{const d=Math.floor(i*10**l+mr);return(Math.round(d)/10**l).toFixed(l)},a=(i,l,d,u)=>{if((n.length===0||!s.colonNotation)&&i===0&&!(s.colonNotation&&d==="m"))return;u=(u||i||"0").toString();let c,h;if(s.colonNotation){c=n.length>0?":":"",h="";const x=u.includes(".")?u.split(".")[0].length:u.length,g=n.length>0?2:1;u="0".repeat(Math.max(0,g-x))+u}else c="",h=s.verbose?" "+ur(l,i):d;n.push(c+u+h)},o=dr(e);if(a(Math.trunc(o.days/365),"year","y"),a(o.days%365,"day","d"),a(o.hours,"hour","h"),a(o.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&e<1e3)if(a(o.seconds,"second","s"),s.formatSubMilliseconds)a(o.milliseconds,"millisecond","ms"),a(o.microseconds,"microsecond","µs"),a(o.nanoseconds,"nanosecond","ns");else{const i=o.milliseconds+o.microseconds/1e3+o.nanoseconds/1e6,l=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,d=i>=1?Math.round(i):Math.ceil(i),u=l?i.toFixed(l):d;a(Number.parseFloat(u),"millisecond","ms",u)}else{const i=e/1e3%60,l=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,d=r(i,l),u=s.keepDecimalsOnWholeSeconds?d:d.replace(/\.0+$/,"");a(Number.parseFloat(u),"second","s",u)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const i=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(i)}return s.colonNotation?n.join(""):n.join(" ")}const hr=({kind:e,size:s=6,className:n})=>t.jsx("span",{className:`status-dot status-dot-${e}${n?" "+n:""}`,style:{width:s,height:s},"aria-hidden":!0}),fr=({kind:e,showDot:s,children:n})=>t.jsxs("span",{className:`status-code status-code-${e}`,children:[s&&t.jsx(hr,{kind:e}),t.jsx("span",{className:"status-code-label",children:String(n).toUpperCase()})]}),Ps=({label:e,value:s,mono:n,valueClassName:r})=>t.jsxs("div",{className:"kv-row",children:[t.jsx("span",{className:"kv-label",children:e}),t.jsx("span",{className:`kv-value${n?" kv-value-mono":""}${r?" "+r:""}`,children:s})]}),pr=["top","right","bottom","left"],We=Math.min,he=Math.max,Ut=Math.round,Ot=Math.floor,De=e=>({x:e,y:e}),gr={left:"right",right:"left",bottom:"top",top:"bottom"};function hs(e,s,n){return he(e,We(s,n))}function _e(e,s){return typeof e=="function"?e(s):e}function Oe(e){return e.split("-")[0]}function pt(e){return e.split("-")[1]}function bs(e){return e==="x"?"y":"x"}function ws(e){return e==="y"?"height":"width"}function Ee(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function js(e){return bs(Ee(e))}function xr(e,s,n){n===void 0&&(n=!1);const r=pt(e),a=js(e),o=ws(a);let i=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(i=Vt(i)),[i,Vt(i)]}function yr(e){const s=Vt(e);return[fs(e),s,fs(s)]}function fs(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const zs=["left","right"],Fs=["right","left"],vr=["top","bottom"],br=["bottom","top"];function wr(e,s,n){switch(e){case"top":case"bottom":return n?s?Fs:zs:s?zs:Fs;case"left":case"right":return s?vr:br;default:return[]}}function jr(e,s,n,r){const a=pt(e);let o=wr(Oe(e),n==="start",r);return a&&(o=o.map(i=>i+"-"+a),s&&(o=o.concat(o.map(fs)))),o}function Vt(e){const s=Oe(e);return gr[s]+e.slice(s.length)}function Nr(e){return{top:0,right:0,bottom:0,left:0,...e}}function ln(e){return typeof e!="number"?Nr(e):{top:e,right:e,bottom:e,left:e}}function qt(e){const{x:s,y:n,width:r,height:a}=e;return{width:r,height:a,top:n,left:s,right:s+r,bottom:n+a,x:s,y:n}}function Bs(e,s,n){let{reference:r,floating:a}=e;const o=Ee(s),i=js(s),l=ws(i),d=Oe(s),u=o==="y",c=r.x+r.width/2-a.width/2,h=r.y+r.height/2-a.height/2,x=r[l]/2-a[l]/2;let g;switch(d){case"top":g={x:c,y:r.y-a.height};break;case"bottom":g={x:c,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-a.width,y:h};break;default:g={x:r.x,y:r.y}}switch(pt(s)){case"start":g[i]-=x*(n&&u?-1:1);break;case"end":g[i]+=x*(n&&u?-1:1);break}return g}async function Cr(e,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:o,rects:i,elements:l,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:h="floating",altBoundary:x=!1,padding:g=0}=_e(s,e),b=ln(g),p=l[x?h==="floating"?"reference":"floating":h],S=qt(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(p)))==null||n?p:p.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:c,strategy:d})),j=h==="floating"?{x:r,y:a,width:i.floating.width,height:i.floating.height}:i.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),v=await(o.isElement==null?void 0:o.isElement(w))?await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1}:{x:1,y:1},E=qt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:j,offsetParent:w,strategy:d}):j);return{top:(S.top-E.top+b.top)/v.y,bottom:(E.bottom-S.bottom+b.bottom)/v.y,left:(S.left-E.left+b.left)/v.x,right:(E.right-S.right+b.right)/v.x}}const Sr=50,kr=async(e,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:o=[],platform:i}=n,l=i.detectOverflow?i:{...i,detectOverflow:Cr},d=await(i.isRTL==null?void 0:i.isRTL(s));let u=await i.getElementRects({reference:e,floating:s,strategy:a}),{x:c,y:h}=Bs(u,r,d),x=r,g=0;const b={};for(let y=0;y<o.length;y++){const p=o[y];if(!p)continue;const{name:S,fn:j}=p,{x:w,y:v,data:E,reset:A}=await j({x:c,y:h,initialPlacement:r,placement:x,strategy:a,middlewareData:b,rects:u,platform:l,elements:{reference:e,floating:s}});c=w??c,h=v??h,b[S]={...b[S],...E},A&&g<Sr&&(g++,typeof A=="object"&&(A.placement&&(x=A.placement),A.rects&&(u=A.rects===!0?await i.getElementRects({reference:e,floating:s,strategy:a}):A.rects),{x:c,y:h}=Bs(u,x,d)),y=-1)}return{x:c,y:h,placement:x,strategy:a,middlewareData:b}},Ar=e=>({name:"arrow",options:e,async fn(s){const{x:n,y:r,placement:a,rects:o,platform:i,elements:l,middlewareData:d}=s,{element:u,padding:c=0}=_e(e,s)||{};if(u==null)return{};const h=ln(c),x={x:n,y:r},g=js(a),b=ws(g),y=await i.getDimensions(u),p=g==="y",S=p?"top":"left",j=p?"bottom":"right",w=p?"clientHeight":"clientWidth",v=o.reference[b]+o.reference[g]-x[g]-o.floating[b],E=x[g]-o.reference[g],A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let T=A?A[w]:0;(!T||!await(i.isElement==null?void 0:i.isElement(A)))&&(T=l.floating[w]||o.floating[b]);const M=v/2-E/2,V=T/2-y[b]/2-1,I=We(h[S],V),Y=We(h[j],V),q=I,K=T-y[b]-Y,N=T/2-y[b]/2+M,ne=hs(q,N,K),O=!d.arrow&&pt(a)!=null&&N!==ne&&o.reference[b]/2-(N<q?I:Y)-y[b]/2<0,J=O?N<q?N-q:N-K:0;return{[g]:x[g]+J,data:{[g]:ne,centerOffset:N-ne-J,...O&&{alignmentOffset:J}},reset:O}}}),Rr=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var n,r;const{placement:a,middlewareData:o,rects:i,initialPlacement:l,platform:d,elements:u}=s,{mainAxis:c=!0,crossAxis:h=!0,fallbackPlacements:x,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:y=!0,...p}=_e(e,s);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const S=Oe(a),j=Ee(l),w=Oe(l)===l,v=await(d.isRTL==null?void 0:d.isRTL(u.floating)),E=x||(w||!y?[Vt(l)]:yr(l)),A=b!=="none";!x&&A&&E.push(...jr(l,y,b,v));const T=[l,...E],M=await d.detectOverflow(s,p),V=[];let I=((r=o.flip)==null?void 0:r.overflows)||[];if(c&&V.push(M[S]),h){const N=xr(a,i,v);V.push(M[N[0]],M[N[1]])}if(I=[...I,{placement:a,overflows:V}],!V.every(N=>N<=0)){var Y,q;const N=(((Y=o.flip)==null?void 0:Y.index)||0)+1,ne=T[N];if(ne&&(!(h==="alignment"?j!==Ee(ne):!1)||I.every(_=>Ee(_.placement)===j?_.overflows[0]>0:!0)))return{data:{index:N,overflows:I},reset:{placement:ne}};let O=(q=I.filter(J=>J.overflows[0]<=0).sort((J,_)=>J.overflows[1]-_.overflows[1])[0])==null?void 0:q.placement;if(!O)switch(g){case"bestFit":{var K;const J=(K=I.filter(_=>{if(A){const Q=Ee(_.placement);return Q===j||Q==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(Q=>Q>0).reduce((Q,re)=>Q+re,0)]).sort((_,Q)=>_[1]-Q[1])[0])==null?void 0:K[0];J&&(O=J);break}case"initialPlacement":O=l;break}if(a!==O)return{reset:{placement:O}}}return{}}}};function Hs(e,s){return{top:e.top-s.height,right:e.right-s.width,bottom:e.bottom-s.height,left:e.left-s.width}}function Ws(e){return pr.some(s=>e[s]>=0)}const Er=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...o}=_e(e,s);switch(a){case"referenceHidden":{const i=await r.detectOverflow(s,{...o,elementContext:"reference"}),l=Hs(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ws(l)}}}case"escaped":{const i=await r.detectOverflow(s,{...o,altBoundary:!0}),l=Hs(i,n.floating);return{data:{escapedOffsets:l,escaped:Ws(l)}}}default:return{}}}}},dn=new Set(["left","top"]);async function Dr(e,s){const{placement:n,platform:r,elements:a}=e,o=await(r.isRTL==null?void 0:r.isRTL(a.floating)),i=Oe(n),l=pt(n),d=Ee(n)==="y",u=dn.has(i)?-1:1,c=o&&d?-1:1,h=_e(s,e);let{mainAxis:x,crossAxis:g,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof b=="number"&&(g=l==="end"?b*-1:b),d?{x:g*c,y:x*u}:{x:x*u,y:g*c}}const $r=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var n,r;const{x:a,y:o,placement:i,middlewareData:l}=s,d=await Dr(s,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:i}}}}},Tr=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:n,y:r,placement:a,platform:o}=s,{mainAxis:i=!0,crossAxis:l=!1,limiter:d={fn:S=>{let{x:j,y:w}=S;return{x:j,y:w}}},...u}=_e(e,s),c={x:n,y:r},h=await o.detectOverflow(s,u),x=Ee(Oe(a)),g=bs(x);let b=c[g],y=c[x];if(i){const S=g==="y"?"top":"left",j=g==="y"?"bottom":"right",w=b+h[S],v=b-h[j];b=hs(w,b,v)}if(l){const S=x==="y"?"top":"left",j=x==="y"?"bottom":"right",w=y+h[S],v=y-h[j];y=hs(w,y,v)}const p=d.fn({...s,[g]:b,[x]:y});return{...p,data:{x:p.x-n,y:p.y-r,enabled:{[g]:i,[x]:l}}}}}},Mr=function(e){return e===void 0&&(e={}),{options:e,fn(s){const{x:n,y:r,placement:a,rects:o,middlewareData:i}=s,{offset:l=0,mainAxis:d=!0,crossAxis:u=!0}=_e(e,s),c={x:n,y:r},h=Ee(a),x=bs(h);let g=c[x],b=c[h];const y=_e(l,s),p=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(d){const w=x==="y"?"height":"width",v=o.reference[x]-o.floating[w]+p.mainAxis,E=o.reference[x]+o.reference[w]-p.mainAxis;g<v?g=v:g>E&&(g=E)}if(u){var S,j;const w=x==="y"?"width":"height",v=dn.has(Oe(a)),E=o.reference[h]-o.floating[w]+(v&&((S=i.offset)==null?void 0:S[h])||0)+(v?0:p.crossAxis),A=o.reference[h]+o.reference[w]+(v?0:((j=i.offset)==null?void 0:j[h])||0)-(v?p.crossAxis:0);b<E?b=E:b>A&&(b=A)}return{[x]:g,[h]:b}}}},Lr=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(s){var n,r;const{placement:a,rects:o,platform:i,elements:l}=s,{apply:d=()=>{},...u}=_e(e,s),c=await i.detectOverflow(s,u),h=Oe(a),x=pt(a),g=Ee(a)==="y",{width:b,height:y}=o.floating;let p,S;h==="top"||h==="bottom"?(p=h,S=x===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(S=h,p=x==="end"?"top":"bottom");const j=y-c.top-c.bottom,w=b-c.left-c.right,v=We(y-c[p],j),E=We(b-c[S],w),A=!s.middlewareData.shift;let T=v,M=E;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(M=w),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(T=j),A&&!x){const I=he(c.left,0),Y=he(c.right,0),q=he(c.top,0),K=he(c.bottom,0);g?M=b-2*(I!==0||Y!==0?I+Y:he(c.left,c.right)):T=y-2*(q!==0||K!==0?q+K:he(c.top,c.bottom))}await d({...s,availableWidth:M,availableHeight:T});const V=await i.getDimensions(l.floating);return b!==V.width||y!==V.height?{reset:{rects:!0}}:{}}}};function Yt(){return typeof window<"u"}function gt(e){return un(e)?(e.nodeName||"").toLowerCase():"#document"}function fe(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function $e(e){var s;return(s=(un(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function un(e){return Yt()?e instanceof Node||e instanceof fe(e).Node:!1}function we(e){return Yt()?e instanceof Element||e instanceof fe(e).Element:!1}function ze(e){return Yt()?e instanceof HTMLElement||e instanceof fe(e).HTMLElement:!1}function Us(e){return!Yt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fe(e).ShadowRoot}function Et(e){const{overflow:s,overflowX:n,overflowY:r,display:a}=je(e);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function Ir(e){return/^(table|td|th)$/.test(gt(e))}function Gt(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const _r=/transform|translate|scale|rotate|perspective|filter/,Or=/paint|layout|strict|content/,et=e=>!!e&&e!=="none";let is;function Ns(e){const s=we(e)?je(e):e;return et(s.transform)||et(s.translate)||et(s.scale)||et(s.rotate)||et(s.perspective)||!Cs()&&(et(s.backdropFilter)||et(s.filter))||_r.test(s.willChange||"")||Or.test(s.contain||"")}function Pr(e){let s=Ue(e);for(;ze(s)&&!ht(s);){if(Ns(s))return s;if(Gt(s))return null;s=Ue(s)}return null}function Cs(){return is==null&&(is=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),is}function ht(e){return/^(html|body|#document)$/.test(gt(e))}function je(e){return fe(e).getComputedStyle(e)}function Zt(e){return we(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ue(e){if(gt(e)==="html")return e;const s=e.assignedSlot||e.parentNode||Us(e)&&e.host||$e(e);return Us(s)?s.host:s}function mn(e){const s=Ue(e);return ht(s)?e.ownerDocument?e.ownerDocument.body:e.body:ze(s)&&Et(s)?s:mn(s)}function At(e,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=mn(e),o=a===((r=e.ownerDocument)==null?void 0:r.body),i=fe(a);if(o){const l=ps(i);return s.concat(i,i.visualViewport||[],Et(a)?a:[],l&&n?At(l):[])}else return s.concat(a,At(a,[],n))}function ps(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hn(e){const s=je(e);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=ze(e),o=a?e.offsetWidth:n,i=a?e.offsetHeight:r,l=Ut(n)!==o||Ut(r)!==i;return l&&(n=o,r=i),{width:n,height:r,$:l}}function Ss(e){return we(e)?e:e.contextElement}function mt(e){const s=Ss(e);if(!ze(s))return De(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:o}=hn(s);let i=(o?Ut(n.width):n.width)/r,l=(o?Ut(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const zr=De(0);function fn(e){const s=fe(e);return!Cs()||!s.visualViewport?zr:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Fr(e,s,n){return s===void 0&&(s=!1),!n||s&&n!==fe(e)?!1:s}function tt(e,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=Ss(e);let i=De(1);s&&(r?we(r)&&(i=mt(r)):i=mt(e));const l=Fr(o,n,r)?fn(o):De(0);let d=(a.left+l.x)/i.x,u=(a.top+l.y)/i.y,c=a.width/i.x,h=a.height/i.y;if(o){const x=fe(o),g=r&&we(r)?fe(r):r;let b=x,y=ps(b);for(;y&&r&&g!==b;){const p=mt(y),S=y.getBoundingClientRect(),j=je(y),w=S.left+(y.clientLeft+parseFloat(j.paddingLeft))*p.x,v=S.top+(y.clientTop+parseFloat(j.paddingTop))*p.y;d*=p.x,u*=p.y,c*=p.x,h*=p.y,d+=w,u+=v,b=fe(y),y=ps(b)}}return qt({width:c,height:h,x:d,y:u})}function Jt(e,s){const n=Zt(e).scrollLeft;return s?s.left+n:tt($e(e)).left+n}function pn(e,s){const n=e.getBoundingClientRect(),r=n.left+s.scrollLeft-Jt(e,n),a=n.top+s.scrollTop;return{x:r,y:a}}function Br(e){let{elements:s,rect:n,offsetParent:r,strategy:a}=e;const o=a==="fixed",i=$e(r),l=s?Gt(s.floating):!1;if(r===i||l&&o)return n;let d={scrollLeft:0,scrollTop:0},u=De(1);const c=De(0),h=ze(r);if((h||!h&&!o)&&((gt(r)!=="body"||Et(i))&&(d=Zt(r)),h)){const g=tt(r);u=mt(r),c.x=g.x+r.clientLeft,c.y=g.y+r.clientTop}const x=i&&!h&&!o?pn(i,d):De(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-d.scrollLeft*u.x+c.x+x.x,y:n.y*u.y-d.scrollTop*u.y+c.y+x.y}}function Hr(e){return Array.from(e.getClientRects())}function Wr(e){const s=$e(e),n=Zt(e),r=e.ownerDocument.body,a=he(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),o=he(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Jt(e);const l=-n.scrollTop;return je(r).direction==="rtl"&&(i+=he(s.clientWidth,r.clientWidth)-a),{width:a,height:o,x:i,y:l}}const Vs=25;function Ur(e,s){const n=fe(e),r=$e(e),a=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,l=0,d=0;if(a){o=a.width,i=a.height;const c=Cs();(!c||c&&s==="fixed")&&(l=a.offsetLeft,d=a.offsetTop)}const u=Jt(r);if(u<=0){const c=r.ownerDocument,h=c.body,x=getComputedStyle(h),g=c.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,b=Math.abs(r.clientWidth-h.clientWidth-g);b<=Vs&&(o-=b)}else u<=Vs&&(o+=u);return{width:o,height:i,x:l,y:d}}function Vr(e,s){const n=tt(e,!0,s==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=ze(e)?mt(e):De(1),i=e.clientWidth*o.x,l=e.clientHeight*o.y,d=a*o.x,u=r*o.y;return{width:i,height:l,x:d,y:u}}function qs(e,s,n){let r;if(s==="viewport")r=Ur(e,n);else if(s==="document")r=Wr($e(e));else if(we(s))r=Vr(s,n);else{const a=fn(e);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return qt(r)}function gn(e,s){const n=Ue(e);return n===s||!we(n)||ht(n)?!1:je(n).position==="fixed"||gn(n,s)}function qr(e,s){const n=s.get(e);if(n)return n;let r=At(e,[],!1).filter(l=>we(l)&&gt(l)!=="body"),a=null;const o=je(e).position==="fixed";let i=o?Ue(e):e;for(;we(i)&&!ht(i);){const l=je(i),d=Ns(i);!d&&l.position==="fixed"&&(a=null),(o?!d&&!a:!d&&l.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Et(i)&&!d&&gn(e,i))?r=r.filter(c=>c!==i):a=l,i=Ue(i)}return s.set(e,r),r}function Xr(e){let{element:s,boundary:n,rootBoundary:r,strategy:a}=e;const i=[...n==="clippingAncestors"?Gt(s)?[]:qr(s,this._c):[].concat(n),r],l=qs(s,i[0],a);let d=l.top,u=l.right,c=l.bottom,h=l.left;for(let x=1;x<i.length;x++){const g=qs(s,i[x],a);d=he(g.top,d),u=We(g.right,u),c=We(g.bottom,c),h=he(g.left,h)}return{width:u-h,height:c-d,x:h,y:d}}function Kr(e){const{width:s,height:n}=hn(e);return{width:s,height:n}}function Yr(e,s,n){const r=ze(s),a=$e(s),o=n==="fixed",i=tt(e,!0,o,s);let l={scrollLeft:0,scrollTop:0};const d=De(0);function u(){d.x=Jt(a)}if(r||!r&&!o)if((gt(s)!=="body"||Et(a))&&(l=Zt(s)),r){const g=tt(s,!0,o,s);d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}else a&&u();o&&!r&&a&&u();const c=a&&!r&&!o?pn(a,l):De(0),h=i.left+l.scrollLeft-d.x-c.x,x=i.top+l.scrollTop-d.y-c.y;return{x:h,y:x,width:i.width,height:i.height}}function rs(e){return je(e).position==="static"}function Xs(e,s){if(!ze(e)||je(e).position==="fixed")return null;if(s)return s(e);let n=e.offsetParent;return $e(e)===n&&(n=n.ownerDocument.body),n}function xn(e,s){const n=fe(e);if(Gt(e))return n;if(!ze(e)){let a=Ue(e);for(;a&&!ht(a);){if(we(a)&&!rs(a))return a;a=Ue(a)}return n}let r=Xs(e,s);for(;r&&Ir(r)&&rs(r);)r=Xs(r,s);return r&&ht(r)&&rs(r)&&!Ns(r)?n:r||Pr(e)||n}const Gr=async function(e){const s=this.getOffsetParent||xn,n=this.getDimensions,r=await n(e.floating);return{reference:Yr(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zr(e){return je(e).direction==="rtl"}const Jr={convertOffsetParentRelativeRectToViewportRelativeRect:Br,getDocumentElement:$e,getClippingRect:Xr,getOffsetParent:xn,getElementRects:Gr,getClientRects:Hr,getDimensions:Kr,getScale:mt,isElement:we,isRTL:Zr};function yn(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function Qr(e,s){let n=null,r;const a=$e(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),o();const u=e.getBoundingClientRect(),{left:c,top:h,width:x,height:g}=u;if(l||s(),!x||!g)return;const b=Ot(h),y=Ot(a.clientWidth-(c+x)),p=Ot(a.clientHeight-(h+g)),S=Ot(c),w={rootMargin:-b+"px "+-y+"px "+-p+"px "+-S+"px",threshold:he(0,We(1,d))||1};let v=!0;function E(A){const T=A[0].intersectionRatio;if(T!==d){if(!v)return i();T?i(!1,T):r=setTimeout(()=>{i(!1,1e-7)},1e3)}T===1&&!yn(u,e.getBoundingClientRect())&&i(),v=!1}try{n=new IntersectionObserver(E,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(E,w)}n.observe(e)}return i(!0),o}function ea(e,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,u=Ss(e),c=a||o?[...u?At(u):[],...s?At(s):[]]:[];c.forEach(S=>{a&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});const h=u&&l?Qr(u,n):null;let x=-1,g=null;i&&(g=new ResizeObserver(S=>{let[j]=S;j&&j.target===u&&g&&s&&(g.unobserve(s),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(s)})),n()}),u&&!d&&g.observe(u),s&&g.observe(s));let b,y=d?tt(e):null;d&&p();function p(){const S=tt(e);y&&!yn(y,S)&&n(),y=S,b=requestAnimationFrame(p)}return n(),()=>{var S;c.forEach(j=>{a&&j.removeEventListener("scroll",n),o&&j.removeEventListener("resize",n)}),h==null||h(),(S=g)==null||S.disconnect(),g=null,d&&cancelAnimationFrame(b)}}const ta=$r,sa=Tr,na=Rr,ia=Lr,ra=Er,Ks=Ar,aa=Mr,oa=(e,s,n)=>{const r=new Map,a={platform:Jr,...n},o={...a.platform,_c:r};return kr(e,s,{...a,platform:o})};var ca=typeof document<"u",la=function(){},Ht=ca?m.useLayoutEffect:la;function Xt(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let n,r,a;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==s.length)return!1;for(r=n;r--!==0;)if(!Xt(e[r],s[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(s).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(s,a[r]))return!1;for(r=n;r--!==0;){const o=a[r];if(!(o==="_owner"&&e.$$typeof)&&!Xt(e[o],s[o]))return!1}return!0}return e!==e&&s!==s}function vn(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ys(e,s){const n=vn(e);return Math.round(s*n)/n}function as(e){const s=m.useRef(e);return Ht(()=>{s.current=e}),s}function da(e){e===void 0&&(e={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:o,floating:i}={},transform:l=!0,whileElementsMounted:d,open:u}=e,[c,h]=m.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[x,g]=m.useState(r);Xt(x,r)||g(r);const[b,y]=m.useState(null),[p,S]=m.useState(null),j=m.useCallback(_=>{_!==A.current&&(A.current=_,y(_))},[]),w=m.useCallback(_=>{_!==T.current&&(T.current=_,S(_))},[]),v=o||b,E=i||p,A=m.useRef(null),T=m.useRef(null),M=m.useRef(c),V=d!=null,I=as(d),Y=as(a),q=as(u),K=m.useCallback(()=>{if(!A.current||!T.current)return;const _={placement:s,strategy:n,middleware:x};Y.current&&(_.platform=Y.current),oa(A.current,T.current,_).then(Q=>{const re={...Q,isPositioned:q.current!==!1};N.current&&!Xt(M.current,re)&&(M.current=re,On.flushSync(()=>{h(re)}))})},[x,s,n,Y,q]);Ht(()=>{u===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,h(_=>({..._,isPositioned:!1})))},[u]);const N=m.useRef(!1);Ht(()=>(N.current=!0,()=>{N.current=!1}),[]),Ht(()=>{if(v&&(A.current=v),E&&(T.current=E),v&&E){if(I.current)return I.current(v,E,K);K()}},[v,E,K,I,V]);const ne=m.useMemo(()=>({reference:A,floating:T,setReference:j,setFloating:w}),[j,w]),O=m.useMemo(()=>({reference:v,floating:E}),[v,E]),J=m.useMemo(()=>{const _={position:n,left:0,top:0};if(!O.floating)return _;const Q=Ys(O.floating,c.x),re=Ys(O.floating,c.y);return l?{..._,transform:"translate("+Q+"px, "+re+"px)",...vn(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Q,top:re}},[n,l,O.floating,c.x,c.y]);return m.useMemo(()=>({...c,update:K,refs:ne,elements:O,floatingStyles:J}),[c,K,ne,O,J])}const ua=e=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:a}=typeof e=="function"?e(n):e;return r&&s(r)?r.current!=null?Ks({element:r.current,padding:a}).fn(n):{}:r?Ks({element:r,padding:a}).fn(n):{}}}},ma=(e,s)=>{const n=ta(e);return{name:n.name,fn:n.fn,options:[e,s]}},ha=(e,s)=>{const n=sa(e);return{name:n.name,fn:n.fn,options:[e,s]}},fa=(e,s)=>({fn:aa(e).fn,options:[e,s]}),pa=(e,s)=>{const n=na(e);return{name:n.name,fn:n.fn,options:[e,s]}},ga=(e,s)=>{const n=ia(e);return{name:n.name,fn:n.fn,options:[e,s]}},xa=(e,s)=>{const n=ra(e);return{name:n.name,fn:n.fn,options:[e,s]}},ya=(e,s)=>{const n=ua(e);return{name:n.name,fn:n.fn,options:[e,s]}};var va="Arrow",bn=m.forwardRef((e,s)=>{const{children:n,width:r=10,height:a=5,...o}=e;return t.jsx(Rt.svg,{...o,ref:s,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});bn.displayName=va;var ba=bn;function wa(e){const[s,n]=m.useState(void 0);return Wt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let i,l;if("borderBoxSize"in o){const d=o.borderBoxSize,u=Array.isArray(d)?d[0]:d;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),s}var ks="Popper",[wn]=vs(ks),[ja,jn]=wn(ks),Nn=e=>{const{__scopePopper:s,children:n}=e,[r,a]=m.useState(null);return t.jsx(ja,{scope:s,anchor:r,onAnchorChange:a,children:n})};Nn.displayName=ks;var Cn="PopperAnchor",Sn=m.forwardRef((e,s)=>{const{__scopePopper:n,virtualRef:r,...a}=e,o=jn(Cn,n),i=m.useRef(null),l=kt(s,i),d=m.useRef(null);return m.useEffect(()=>{const u=d.current;d.current=(r==null?void 0:r.current)||i.current,u!==d.current&&o.onAnchorChange(d.current)}),r?null:t.jsx(Rt.div,{...a,ref:l})});Sn.displayName=Cn;var As="PopperContent",[Na,Ca]=wn(As),kn=m.forwardRef((e,s)=>{var nt,pe,it,Fe,Me,Be;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:o="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:g="optimized",onPlaced:b,...y}=e,p=jn(As,n),[S,j]=m.useState(null),w=kt(s,me=>j(me)),[v,E]=m.useState(null),A=wa(v),T=(A==null?void 0:A.width)??0,M=(A==null?void 0:A.height)??0,V=r+(o!=="center"?"-"+o:""),I=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},Y=Array.isArray(u)?u:[u],q=Y.length>0,K={padding:I,boundary:Y.filter(Aa),altBoundary:q},{refs:N,floatingStyles:ne,placement:O,isPositioned:J,middlewareData:_}=da({strategy:"fixed",placement:V,whileElementsMounted:(...me)=>ea(...me,{animationFrame:g==="always"}),elements:{reference:p.anchor},middleware:[ma({mainAxis:a+M,alignmentAxis:i}),d&&ha({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?fa():void 0,...K}),d&&pa({...K}),ga({...K,apply:({elements:me,rects:Le,availableWidth:rt,availableHeight:He})=>{const{width:Ve,height:qe}=Le.reference,Ce=me.floating.style;Ce.setProperty("--radix-popper-available-width",`${rt}px`),Ce.setProperty("--radix-popper-available-height",`${He}px`),Ce.setProperty("--radix-popper-anchor-width",`${Ve}px`),Ce.setProperty("--radix-popper-anchor-height",`${qe}px`)}}),v&&ya({element:v,padding:l}),Ra({arrowWidth:T,arrowHeight:M}),x&&xa({strategy:"referenceHidden",...K})]}),[Q,re]=Rn(O),Ne=nn(b);Wt(()=>{J&&(Ne==null||Ne())},[J,Ne]);const ye=(nt=_.arrow)==null?void 0:nt.x,st=(pe=_.arrow)==null?void 0:pe.y,ve=((it=_.arrow)==null?void 0:it.centerOffset)!==0,[Te,de]=m.useState();return Wt(()=>{S&&de(window.getComputedStyle(S).zIndex)},[S]),t.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...ne,transform:J?ne.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Te,"--radix-popper-transform-origin":[(Fe=_.transformOrigin)==null?void 0:Fe.x,(Me=_.transformOrigin)==null?void 0:Me.y].join(" "),...((Be=_.hide)==null?void 0:Be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Na,{scope:n,placedSide:Q,onArrowChange:E,arrowX:ye,arrowY:st,shouldHideArrow:ve,children:t.jsx(Rt.div,{"data-side":Q,"data-align":re,...y,ref:w,style:{...y.style,animation:J?void 0:"none"}})})})});kn.displayName=As;var An="PopperArrow",Sa={top:"bottom",right:"left",bottom:"top",left:"right"},ka=m.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,o=Ca(An,r),i=Sa[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(ba,{...a,ref:n,style:{...a.style,display:"block"}})})});ka.displayName=An;function Aa(e){return e!==null}var Ra=e=>({name:"transformOrigin",options:e,fn(s){var p,S,j;const{placement:n,rects:r,middlewareData:a}=s,i=((p=a.arrow)==null?void 0:p.centerOffset)!==0,l=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[u,c]=Rn(n),h={start:"0%",center:"50%",end:"100%"}[c],x=(((S=a.arrow)==null?void 0:S.x)??0)+l/2,g=(((j=a.arrow)==null?void 0:j.y)??0)+d/2;let b="",y="";return u==="bottom"?(b=i?h:`${x}px`,y=`${-d}px`):u==="top"?(b=i?h:`${x}px`,y=`${r.floating.height+d}px`):u==="right"?(b=`${-d}px`,y=i?h:`${g}px`):u==="left"&&(b=`${r.floating.width+d}px`,y=i?h:`${g}px`),{data:{x:b,y}}}});function Rn(e){const[s,n="center"]=e.split("-");return[s,n]}var Ea=Nn,Da=Sn,$a=kn,Ta=Symbol.for("react.lazy"),Kt=Pn[" use ".trim().toString()];function Ma(e){return typeof e=="object"&&e!==null&&"then"in e}function En(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ta&&"_payload"in e&&Ma(e._payload)}function La(e){const s=Ia(e),n=m.forwardRef((r,a)=>{let{children:o,...i}=r;En(o)&&typeof Kt=="function"&&(o=Kt(o._payload));const l=m.Children.toArray(o),d=l.find(Oa);if(d){const u=d.props.children,c=l.map(h=>h===d?m.Children.count(u)>1?m.Children.only(null):m.isValidElement(u)?u.props.children:null:h);return t.jsx(s,{...i,ref:a,children:m.isValidElement(u)?m.cloneElement(u,void 0,c):null})}return t.jsx(s,{...i,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function Ia(e){const s=m.forwardRef((n,r)=>{let{children:a,...o}=n;if(En(a)&&typeof Kt=="function"&&(a=Kt(a._payload)),m.isValidElement(a)){const i=za(a),l=Pa(o,a.props);return a.type!==m.Fragment&&(l.ref=r?Xn(r,i):i),m.cloneElement(a,l)}return m.Children.count(a)>1?m.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var _a=Symbol("radix.slottable");function Oa(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_a}function Pa(e,s){const n={...s};for(const r in s){const a=e[r],o=s[r];/^on[A-Z]/.test(r)?a&&o?n[r]=(...l)=>{const d=o(...l);return a(...l),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...o}:r==="className"&&(n[r]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function za(e){var r,a;let s=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?e.ref:(s=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Fa=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ba=Fa.reduce((e,s)=>{const n=La(`Primitive.${s}`),r=m.forwardRef((a,o)=>{const{asChild:i,...l}=a,d=i?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...l,ref:o})});return r.displayName=`Primitive.${s}`,{...e,[s]:r}},{}),Ha="Portal",Dn=m.forwardRef((e,s)=>{var l;const{container:n,...r}=e,[a,o]=m.useState(!1);Wt(()=>o(!0),[]);const i=n||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?zn.createPortal(t.jsx(Ba.div,{...r,ref:s}),i):null});Dn.displayName=Ha;const Wa=({open:e,onClose:s,anchorRef:n,placement:r="bottom-end",children:a})=>{const o=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const u=c=>{var h,x;e&&((h=o.current)!=null&&h.contains(c.target)||(x=n.current)!=null&&x.contains(c.target)||s())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[e,s,n]),!e)return null;const i=r.startsWith("top")?"top":"bottom",l=r.endsWith("end")?"end":"start",d=r.startsWith("top")?8:4;return t.jsxs(Ea,{children:[t.jsx(Da,{virtualRef:n}),t.jsx(Dn,{children:t.jsx(Kn,{onEscapeKeyDown:u=>{u.preventDefault(),s()},onPointerDownOutside:u=>{var c;if((c=n.current)!=null&&c.contains(u.target)){u.preventDefault();return}s()},children:t.jsx($a,{ref:o,side:i,align:l,sideOffset:d,className:`popover popover-${r}`,role:"dialog",children:a})})})]})};function Ua(e){const s=e+"CollectionProvider",[n,r]=vs(s),[a,o]=n(s,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:p,children:S}=y,j=Re.useRef(null),w=Re.useRef(new Map).current;return t.jsx(a,{scope:p,itemMap:w,collectionRef:j,children:S})};i.displayName=s;const l=e+"CollectionSlot",d=Is(l),u=Re.forwardRef((y,p)=>{const{scope:S,children:j}=y,w=o(l,S),v=kt(p,w.collectionRef);return t.jsx(d,{ref:v,children:j})});u.displayName=l;const c=e+"CollectionItemSlot",h="data-radix-collection-item",x=Is(c),g=Re.forwardRef((y,p)=>{const{scope:S,children:j,...w}=y,v=Re.useRef(null),E=kt(p,v),A=o(c,S);return Re.useEffect(()=>(A.itemMap.set(v,{ref:v,...w}),()=>void A.itemMap.delete(v))),t.jsx(x,{[h]:"",ref:E,children:j})});g.displayName=c;function b(y){const p=o(e+"CollectionConsumer",y);return Re.useCallback(()=>{const j=p.collectionRef.current;if(!j)return[];const w=Array.from(j.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((A,T)=>w.indexOf(A.ref.current)-w.indexOf(T.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},b,r]}var Va=m.createContext(void 0);function qa(e){const s=m.useContext(Va);return e||s||"ltr"}var os="rovingFocusGroup.onEntryFocus",Xa={bubbles:!1,cancelable:!0},Dt="RovingFocusGroup",[gs,$n,Ka]=Ua(Dt),[Ya]=vs(Dt,[Ka]),[Ga,Za]=Ya(Dt),Tn=m.forwardRef((e,s)=>t.jsx(gs.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(gs.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ja,{...e,ref:s})})}));Tn.displayName=Dt;var Ja=m.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:o,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...h}=e,x=m.useRef(null),g=kt(s,x),b=qa(o),[y,p]=Gn({prop:i,defaultProp:l??null,onChange:d,caller:Dt}),[S,j]=m.useState(!1),w=nn(u),v=$n(n),E=m.useRef(!1),[A,T]=m.useState(0);return m.useEffect(()=>{const M=x.current;if(M)return M.addEventListener(os,w),()=>M.removeEventListener(os,w)},[w]),t.jsx(Ga,{scope:n,orientation:r,dir:b,loop:a,currentTabStopId:y,onItemFocus:m.useCallback(M=>p(M),[p]),onItemShiftTab:m.useCallback(()=>j(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(M=>M+1),[]),onFocusableItemRemove:m.useCallback(()=>T(M=>M-1),[]),children:t.jsx(Rt.div,{tabIndex:S||A===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:ut(e.onMouseDown,()=>{E.current=!0}),onFocus:ut(e.onFocus,M=>{const V=!E.current;if(M.target===M.currentTarget&&V&&!S){const I=new CustomEvent(os,Xa);if(M.currentTarget.dispatchEvent(I),!I.defaultPrevented){const Y=v().filter(O=>O.focusable),q=Y.find(O=>O.active),K=Y.find(O=>O.id===y),ne=[q,K,...Y].filter(Boolean).map(O=>O.ref.current);In(ne,c)}}E.current=!1}),onBlur:ut(e.onBlur,()=>j(!1))})})}),Mn="RovingFocusGroupItem",Ln=m.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:o,children:i,...l}=e,d=Yn(),u=o||d,c=Za(Mn,n),h=c.currentTabStopId===u,x=$n(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:y}=c;return m.useEffect(()=>{if(r)return g(),()=>b()},[r,g,b]),t.jsx(gs.ItemSlot,{scope:n,id:u,focusable:r,active:a,children:t.jsx(Rt.span,{tabIndex:h?0:-1,"data-orientation":c.orientation,...l,ref:s,onMouseDown:ut(e.onMouseDown,p=>{r?c.onItemFocus(u):p.preventDefault()}),onFocus:ut(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:ut(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){c.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const S=to(p,c.orientation,c.dir);if(S!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let w=x().filter(v=>v.focusable).map(v=>v.ref.current);if(S==="last")w.reverse();else if(S==="prev"||S==="next"){S==="prev"&&w.reverse();const v=w.indexOf(p.currentTarget);w=c.loop?so(w,v+1):w.slice(v+1)}setTimeout(()=>In(w))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:y!=null}):i})})});Ln.displayName=Mn;var Qa={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eo(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function to(e,s,n){const r=eo(e.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Qa[r]}function In(e,s=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function so(e,s){return e.map((n,r)=>e[(s+r)%e.length])}var no=Tn,io=Ln;const Pt=({icon:e,children:s,onClick:n,danger:r,disabled:a})=>t.jsx(io,{asChild:!0,focusable:!a,active:!1,children:t.jsxs("button",{type:"button",role:"menuitem",className:`menu-item${r?" menu-item-danger":""}`,onClick:n,disabled:a,children:[e&&t.jsx("span",{className:"menu-item-icon",children:e}),t.jsx("span",{className:"menu-item-label",children:s})]})}),ro=()=>t.jsx("div",{className:"menu-divider",role:"separator"}),ao=({children:e})=>t.jsx(no,{asChild:!0,orientation:"vertical",loop:!0,children:t.jsx("div",{className:"menu",role:"menu",children:e})}),oo=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],co=({device:e,onClose:s,onReserved:n})=>{const[r,a]=m.useState(""),[o,i]=m.useState("1h"),[l,d]=m.useState(""),[u,c]=m.useState(!1),[h,x]=m.useState(null),[g,b]=m.useState(null),y=async()=>{if(!r.trim()){x("Please enter your name/ID");return}c(!0),x(null),b(null);try{const p=await P.reserveDevice(e.udid,e.host,r,o,l);p.success?(n(),s()):b(p.error||"Failed to reserve device")}catch(p){b(p.message||"An unexpected error occurred")}finally{c(!1)}};return t.jsx(rn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(gi,{size:16,className:"title-icon"}),"Reserve Device"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,disabled:u,children:"Cancel"}),t.jsx("button",{className:"btn-reserve",onClick:y,disabled:u||!r.trim(),children:u?"Reserving...":"Confirm Reservation"})]}),children:t.jsxs("div",{className:"reservation-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsxs("p",{children:["Reserve ",t.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),t.jsx(Ft,{label:t.jsxs(t.Fragment,{children:[t.jsx(Fn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reserved By"]}),htmlFor:"reservation-reserved-by",error:h?t.jsxs(t.Fragment,{children:[t.jsx($s,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),h]}):void 0,children:t.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:r,onChange:p=>{a(p.target.value),h&&x(null)},disabled:u})}),t.jsx(Ft,{label:t.jsxs(t.Fragment,{children:[t.jsx(an,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Duration"]}),children:t.jsx("div",{className:"duration-selector",children:oo.map(p=>t.jsx("div",{className:`duration-option ${o===p.value?"active":""}`,onClick:()=>i(p.value),children:p.label},p.value))})}),t.jsx(Ft,{label:t.jsxs(t.Fragment,{children:[t.jsx(Fi,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reason (Optional)"]}),htmlFor:"reservation-reason",error:g?t.jsxs(t.Fragment,{children:[t.jsx($s,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),g]}):void 0,children:t.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:l,onChange:p=>d(p.target.value),disabled:u})})]})})},lo=({device:e,onClose:s,onUpdated:n})=>{const{toast:r}=en(),[a,o]=m.useState(e.tags||[]),[i,l]=m.useState(""),[d,u]=m.useState(!1),c=m.useRef(null);m.useEffect(()=>{c.current&&c.current.focus()},[]);const h=()=>{const y=i.trim();y&&!a.includes(y)&&(o([...a,y]),l(""))},x=y=>{o(a.filter(p=>p!==y))},g=y=>{y.key==="Enter"&&h()},b=async()=>{u(!0);try{await P.updateDeviceTags(e.udid,e.host,a),n(),s()}catch(y){console.error("Failed to update tags",y),r("Error saving tags. Please try again.","error")}finally{u(!1)}};return t.jsx(rn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(Ji,{size:16,className:"title-icon"}),"Manage Device Tags"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),t.jsx("button",{className:"btn-save",onClick:b,disabled:d,children:d?"Saving...":"Apply Changes"})]}),children:t.jsxs("div",{className:"tag-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsx(Ft,{label:"Add New Tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:t.jsxs("div",{className:"input-with-button",children:[t.jsx("input",{ref:c,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:i,onChange:y=>l(y.target.value),onKeyDown:g}),t.jsx("button",{className:"add-inline-btn",onClick:h,disabled:!i.trim(),children:t.jsx(Zn,{size:16})})]})}),t.jsxs("div",{className:"tags-display-section",children:[t.jsx("label",{children:"Current Tags"}),t.jsx("div",{className:"tags-list",children:a.length>0?a.map(y=>t.jsxs("div",{className:"tag-pill-editable",children:[y,t.jsx("button",{className:"remove-tag",onClick:()=>x(y),children:t.jsx(Bn,{size:12})})]},y)):t.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})};function uo(e){return e>=50?"ready":e>=20?"reserved":"error"}function mo(e){return e>=50?t.jsx(mi,{size:10}):e>=20?t.jsx(ci,{size:10}):t.jsx(di,{size:10})}function ho(e){return e==="Normal"?"ready":e==="Critical"?"error":"reserved"}const fo=({device:e})=>{const s=typeof e.batteryLevel=="number",n=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!s&&!n?t.jsx("div",{className:"dc2-health",children:t.jsxs(dt,{tone:"neutral",title:"Device does not report battery or thermal data",children:[t.jsx(Jn,{size:10}),"No telemetry"]})}):t.jsxs("div",{className:"dc2-health",children:[s&&t.jsxs(dt,{tone:uo(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[mo(e.batteryLevel),e.batteryLevel,"%"]}),n&&t.jsxs(dt,{tone:ho(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[t.jsx(tr,{size:10}),e.thermalStatus]})]})},po=({udid:e,currentTeamId:s,teams:n,canEdit:r,onChanged:a})=>{const[o,i]=m.useState(!1),[l,d]=m.useState(!1),u=s?n.get(s)??`Team ${s.slice(0,6)}`:"Unassigned";async function c(h){d(!0);try{await P.setDeviceTeam(e,h),a(),i(!1)}catch(x){alert((x==null?void 0:x.message)||"Failed to update team")}finally{d(!1)}}return r?o?t.jsxs("select",{autoFocus:!0,disabled:l,defaultValue:s??"",onBlur:()=>i(!1),onChange:h=>c(h.target.value||null),className:"dc2-team-select",children:[t.jsx("option",{value:"",children:"(Unassigned)"}),Array.from(n.entries()).map(([h,x])=>t.jsx("option",{value:h,children:x},h))]}):t.jsx("button",{type:"button",onClick:()=>i(!0),className:"dc2-team-pill",title:"Click to change team",children:u}):s?t.jsx(dt,{tone:"accent",title:`Team: ${u}`,children:u}):null};function go(e){return e.offline?"offline":e.userBlocked?"error":e.busy?"busy":e.reservedUntil&&Date.now()<e.reservedUntil?"reserved":"ready"}function xo(e,s=10,n=4){return!e||e.length<=s+n+1?e:`${e.slice(0,s)}…${e.slice(-n)}`}function yo(e){if(!e)return"—";try{const s=new URL(e.includes("://")?e:`http://${e}`);return s.port?`${s.hostname}:${s.port}`:s.hostname}catch{return e}}const vo=({device:e,reloadDevices:s,navigate:n,teams:r})=>{var v,E,A;const[a,o]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),c=m.useRef(null),{me:h}=Hn(),x=(h==null?void 0:h.role)==="ADMIN"||(h==null?void 0:h.role)==="SUPER_ADMIN",g=go(e),b=g==="reserved",y=!!(e.busy&&e.session_id&&!String(e.session_id).startsWith("manual_")),p=()=>{var T;return(T=navigator.clipboard)==null?void 0:T.writeText(e.udid)},S=async()=>{await P.releaseReservation(e.udid,e.host),s()},j=async()=>{await P.blockDevice(e.udid,e.host),s()},w=async()=>{await P.unblockDevice(e.udid,e.host),s()};return t.jsxs("div",{className:`dc2 dc2-${g}`,children:[t.jsx("div",{className:"dc2-stripe"}),t.jsxs("div",{className:"dc2-header",children:[t.jsxs("span",{className:"dc2-platform",children:[e.platform.toUpperCase()," · ",e.sdk]}),t.jsx(fr,{kind:g,showDot:!0,children:g})]}),t.jsx("div",{className:"dc2-name",title:e.name,children:e.name}),t.jsx("div",{className:"dc2-udid",title:e.udid,children:xo(e.udid)}),t.jsx(fo,{device:e}),(e.teamId||x||e.tags&&e.tags.length>0)&&t.jsxs("div",{className:"dc2-tags",children:[(e.teamId||x)&&t.jsx(po,{udid:e.udid,currentTeamId:e.teamId??null,teams:r??new Map,canEdit:x,onChanged:s}),(v=e.tags)==null?void 0:v.slice(0,3).map(T=>t.jsx(dt,{tone:"neutral",title:T,children:T},T)),(((E=e.tags)==null?void 0:E.length)||0)>3&&t.jsxs(dt,{tone:"neutral",children:["+",(((A=e.tags)==null?void 0:A.length)||0)-3]})]}),t.jsxs("div",{className:"dc2-metrics",children:[b?t.jsxs("div",{className:"dc2-banner dc2-banner-reserved",children:[t.jsx(an,{size:12}),t.jsxs("span",{children:["RES · ",e.reservedBy||"anon",e.reservedUntil?` (${Os(e.reservedUntil-Date.now(),{compact:!0})})`:""]})]}):e.session_id?t.jsxs("div",{className:"dc2-banner dc2-banner-session",children:[t.jsx(us,{size:12}),t.jsxs("span",{children:["SID · ",String(e.session_id).slice(0,10)]})]}):t.jsx(Ps,{label:"Time in use",value:e.totalUtilizationTimeMilliSec?Os(e.totalUtilizationTimeMilliSec,{compact:!0}):"—"}),t.jsx(Ps,{label:"Host",value:yo(e.ip||e.host),mono:!0})]}),t.jsxs("div",{className:"dc2-actions",children:[t.jsx(lt,{variant:"primary",size:"sm",disabled:y,onClick:()=>{y||n(`/devices/${e.udid}/control`)},title:y?"Locked: Appium session running":"Take control",className:"dc2-primary",children:"Control"}),b?t.jsx(lt,{variant:"secondary",size:"sm",onClick:S,children:"Release"}):!e.userBlocked&&!e.busy?t.jsx(lt,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:"Reserve"}):null,t.jsx("button",{ref:c,type:"button",className:"dc2-more",onClick:()=>u(T=>!T),"aria-label":"More actions",children:t.jsx(Ri,{size:14})}),t.jsx(Wa,{open:d,onClose:()=>u(!1),anchorRef:c,children:t.jsxs(ao,{children:[t.jsx(Pt,{onClick:()=>{u(!1),l(!0)},children:"Manage tags…"}),e.userBlocked?t.jsx(Pt,{onClick:()=>{u(!1),w()},children:"Exit maintenance"}):t.jsx(Pt,{onClick:()=>{u(!1),j()},children:"Enter maintenance"}),t.jsx(ro,{}),t.jsx(Pt,{icon:t.jsx(Ct,{size:12}),onClick:()=>{u(!1),p()},children:"Copy UDID"})]})})]}),a&&t.jsx(co,{device:e,onClose:()=>o(!1),onReserved:()=>s()}),i&&t.jsx(lo,{device:e,onClose:()=>l(!1),onUpdated:()=>s()})]})};function bo(e){const s=ys();return t.jsx(vo,{device:e.device,reloadDevices:e.reloadDevices,navigate:s,teams:e.teams})}class wo extends Re.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){P.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return t.jsx("div",{className:"device-explorer-card-container",children:Re.Children.toArray(this.props.devices.map(s=>t.jsx(bo,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}var zt,jo=new Uint8Array(16);function No(){if(!zt&&(zt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!zt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return zt(jo)}const Co=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function So(e){return typeof e=="string"&&Co.test(e)}var oe=[];for(var cs=0;cs<256;++cs)oe.push((cs+256).toString(16).substr(1));function ko(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(oe[e[s+0]]+oe[e[s+1]]+oe[e[s+2]]+oe[e[s+3]]+"-"+oe[e[s+4]]+oe[e[s+5]]+"-"+oe[e[s+6]]+oe[e[s+7]]+"-"+oe[e[s+8]]+oe[e[s+9]]+"-"+oe[e[s+10]]+oe[e[s+11]]+oe[e[s+12]]+oe[e[s+13]]+oe[e[s+14]]+oe[e[s+15]]).toLowerCase();if(!So(n))throw TypeError("Stringified UUID is invalid");return n}function Ao(e,s,n){e=e||{};var r=e.random||(e.rng||No)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,ko(r)}const Ro=({onCommand:e,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:r})=>{const[a,o]=m.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[i,l]=m.useState(""),[d,u]=m.useState([]),[c,h]=m.useState(-1),[x,g]=m.useState(!1),b=m.useRef(null),y=m.useRef(null);m.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[a]);const p=j=>{const w=j.trim();if((w.startsWith("{")||w.startsWith("["))&&(w.endsWith("}")||w.endsWith("]")))try{const v=JSON.parse(w);return JSON.stringify(v,null,2)}catch{}return j},S=async j=>{if(j.key==="Enter"&&!x){const w=i.trim();if(!w)return;if(l(""),o(v=>[...v,{type:"command",content:`${s} ${w}`,timestamp:Date.now()}]),u(v=>[...v,w]),h(-1),g(!0),w==="clear"){o([]),g(!1);return}if(w==="help"){let v="";r==="android"?v=`
156
+ */const cr=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],lr=B("wifi",cr);function dr(e){if(typeof e!="number")throw new TypeError("Expected a number");const s=e>0?Math.floor:Math.ceil;return{days:s(e/864e5),hours:s(e/36e5)%24,minutes:s(e/6e4)%60,seconds:s(e/1e3)%60,milliseconds:s(e)%1e3,microseconds:s(e*1e3)%1e3,nanoseconds:s(e*1e6)%1e3}}const ur=(e,s)=>s===1?e:`${e}s`,mr=1e-7;function Os(e,s={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],r=(i,l)=>{const d=Math.floor(i*10**l+mr);return(Math.round(d)/10**l).toFixed(l)},a=(i,l,d,u)=>{if((n.length===0||!s.colonNotation)&&i===0&&!(s.colonNotation&&d==="m"))return;u=(u||i||"0").toString();let c,h;if(s.colonNotation){c=n.length>0?":":"",h="";const x=u.includes(".")?u.split(".")[0].length:u.length,g=n.length>0?2:1;u="0".repeat(Math.max(0,g-x))+u}else c="",h=s.verbose?" "+ur(l,i):d;n.push(c+u+h)},o=dr(e);if(a(Math.trunc(o.days/365),"year","y"),a(o.days%365,"day","d"),a(o.hours,"hour","h"),a(o.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&e<1e3)if(a(o.seconds,"second","s"),s.formatSubMilliseconds)a(o.milliseconds,"millisecond","ms"),a(o.microseconds,"microsecond","µs"),a(o.nanoseconds,"nanosecond","ns");else{const i=o.milliseconds+o.microseconds/1e3+o.nanoseconds/1e6,l=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,d=i>=1?Math.round(i):Math.ceil(i),u=l?i.toFixed(l):d;a(Number.parseFloat(u),"millisecond","ms",u)}else{const i=e/1e3%60,l=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,d=r(i,l),u=s.keepDecimalsOnWholeSeconds?d:d.replace(/\.0+$/,"");a(Number.parseFloat(u),"second","s",u)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const i=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(i)}return s.colonNotation?n.join(""):n.join(" ")}const hr=({kind:e,size:s=6,className:n})=>t.jsx("span",{className:`status-dot status-dot-${e}${n?" "+n:""}`,style:{width:s,height:s},"aria-hidden":!0}),fr=({kind:e,showDot:s,children:n})=>t.jsxs("span",{className:`status-code status-code-${e}`,children:[s&&t.jsx(hr,{kind:e}),t.jsx("span",{className:"status-code-label",children:String(n).toUpperCase()})]}),Ps=({label:e,value:s,mono:n,valueClassName:r})=>t.jsxs("div",{className:"kv-row",children:[t.jsx("span",{className:"kv-label",children:e}),t.jsx("span",{className:`kv-value${n?" kv-value-mono":""}${r?" "+r:""}`,children:s})]}),pr=["top","right","bottom","left"],We=Math.min,he=Math.max,Ut=Math.round,Ot=Math.floor,De=e=>({x:e,y:e}),gr={left:"right",right:"left",bottom:"top",top:"bottom"};function fs(e,s,n){return he(e,We(s,n))}function _e(e,s){return typeof e=="function"?e(s):e}function Oe(e){return e.split("-")[0]}function pt(e){return e.split("-")[1]}function ws(e){return e==="x"?"y":"x"}function js(e){return e==="y"?"height":"width"}function Ee(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function Ns(e){return ws(Ee(e))}function xr(e,s,n){n===void 0&&(n=!1);const r=pt(e),a=Ns(e),o=js(a);let i=a==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(i=Vt(i)),[i,Vt(i)]}function yr(e){const s=Vt(e);return[ps(e),s,ps(s)]}function ps(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const zs=["left","right"],Fs=["right","left"],vr=["top","bottom"],br=["bottom","top"];function wr(e,s,n){switch(e){case"top":case"bottom":return n?s?Fs:zs:s?zs:Fs;case"left":case"right":return s?vr:br;default:return[]}}function jr(e,s,n,r){const a=pt(e);let o=wr(Oe(e),n==="start",r);return a&&(o=o.map(i=>i+"-"+a),s&&(o=o.concat(o.map(ps)))),o}function Vt(e){const s=Oe(e);return gr[s]+e.slice(s.length)}function Nr(e){return{top:0,right:0,bottom:0,left:0,...e}}function ln(e){return typeof e!="number"?Nr(e):{top:e,right:e,bottom:e,left:e}}function qt(e){const{x:s,y:n,width:r,height:a}=e;return{width:r,height:a,top:n,left:s,right:s+r,bottom:n+a,x:s,y:n}}function Bs(e,s,n){let{reference:r,floating:a}=e;const o=Ee(s),i=Ns(s),l=js(i),d=Oe(s),u=o==="y",c=r.x+r.width/2-a.width/2,h=r.y+r.height/2-a.height/2,x=r[l]/2-a[l]/2;let g;switch(d){case"top":g={x:c,y:r.y-a.height};break;case"bottom":g={x:c,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-a.width,y:h};break;default:g={x:r.x,y:r.y}}switch(pt(s)){case"start":g[i]-=x*(n&&u?-1:1);break;case"end":g[i]+=x*(n&&u?-1:1);break}return g}async function Cr(e,s){var n;s===void 0&&(s={});const{x:r,y:a,platform:o,rects:i,elements:l,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:h="floating",altBoundary:x=!1,padding:g=0}=_e(s,e),b=ln(g),p=l[x?h==="floating"?"reference":"floating":h],S=qt(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(p)))==null||n?p:p.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:c,strategy:d})),j=h==="floating"?{x:r,y:a,width:i.floating.width,height:i.floating.height}:i.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),v=await(o.isElement==null?void 0:o.isElement(w))?await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1}:{x:1,y:1},E=qt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:j,offsetParent:w,strategy:d}):j);return{top:(S.top-E.top+b.top)/v.y,bottom:(E.bottom-S.bottom+b.bottom)/v.y,left:(S.left-E.left+b.left)/v.x,right:(E.right-S.right+b.right)/v.x}}const Sr=50,kr=async(e,s,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:o=[],platform:i}=n,l=i.detectOverflow?i:{...i,detectOverflow:Cr},d=await(i.isRTL==null?void 0:i.isRTL(s));let u=await i.getElementRects({reference:e,floating:s,strategy:a}),{x:c,y:h}=Bs(u,r,d),x=r,g=0;const b={};for(let y=0;y<o.length;y++){const p=o[y];if(!p)continue;const{name:S,fn:j}=p,{x:w,y:v,data:E,reset:A}=await j({x:c,y:h,initialPlacement:r,placement:x,strategy:a,middlewareData:b,rects:u,platform:l,elements:{reference:e,floating:s}});c=w??c,h=v??h,b[S]={...b[S],...E},A&&g<Sr&&(g++,typeof A=="object"&&(A.placement&&(x=A.placement),A.rects&&(u=A.rects===!0?await i.getElementRects({reference:e,floating:s,strategy:a}):A.rects),{x:c,y:h}=Bs(u,x,d)),y=-1)}return{x:c,y:h,placement:x,strategy:a,middlewareData:b}},Ar=e=>({name:"arrow",options:e,async fn(s){const{x:n,y:r,placement:a,rects:o,platform:i,elements:l,middlewareData:d}=s,{element:u,padding:c=0}=_e(e,s)||{};if(u==null)return{};const h=ln(c),x={x:n,y:r},g=Ns(a),b=js(g),y=await i.getDimensions(u),p=g==="y",S=p?"top":"left",j=p?"bottom":"right",w=p?"clientHeight":"clientWidth",v=o.reference[b]+o.reference[g]-x[g]-o.floating[b],E=x[g]-o.reference[g],A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let T=A?A[w]:0;(!T||!await(i.isElement==null?void 0:i.isElement(A)))&&(T=l.floating[w]||o.floating[b]);const M=v/2-E/2,V=T/2-y[b]/2-1,I=We(h[S],V),Y=We(h[j],V),q=I,K=T-y[b]-Y,N=T/2-y[b]/2+M,ne=fs(q,N,K),O=!d.arrow&&pt(a)!=null&&N!==ne&&o.reference[b]/2-(N<q?I:Y)-y[b]/2<0,J=O?N<q?N-q:N-K:0;return{[g]:x[g]+J,data:{[g]:ne,centerOffset:N-ne-J,...O&&{alignmentOffset:J}},reset:O}}}),Rr=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var n,r;const{placement:a,middlewareData:o,rects:i,initialPlacement:l,platform:d,elements:u}=s,{mainAxis:c=!0,crossAxis:h=!0,fallbackPlacements:x,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:y=!0,...p}=_e(e,s);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const S=Oe(a),j=Ee(l),w=Oe(l)===l,v=await(d.isRTL==null?void 0:d.isRTL(u.floating)),E=x||(w||!y?[Vt(l)]:yr(l)),A=b!=="none";!x&&A&&E.push(...jr(l,y,b,v));const T=[l,...E],M=await d.detectOverflow(s,p),V=[];let I=((r=o.flip)==null?void 0:r.overflows)||[];if(c&&V.push(M[S]),h){const N=xr(a,i,v);V.push(M[N[0]],M[N[1]])}if(I=[...I,{placement:a,overflows:V}],!V.every(N=>N<=0)){var Y,q;const N=(((Y=o.flip)==null?void 0:Y.index)||0)+1,ne=T[N];if(ne&&(!(h==="alignment"?j!==Ee(ne):!1)||I.every(_=>Ee(_.placement)===j?_.overflows[0]>0:!0)))return{data:{index:N,overflows:I},reset:{placement:ne}};let O=(q=I.filter(J=>J.overflows[0]<=0).sort((J,_)=>J.overflows[1]-_.overflows[1])[0])==null?void 0:q.placement;if(!O)switch(g){case"bestFit":{var K;const J=(K=I.filter(_=>{if(A){const Q=Ee(_.placement);return Q===j||Q==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(Q=>Q>0).reduce((Q,re)=>Q+re,0)]).sort((_,Q)=>_[1]-Q[1])[0])==null?void 0:K[0];J&&(O=J);break}case"initialPlacement":O=l;break}if(a!==O)return{reset:{placement:O}}}return{}}}};function Hs(e,s){return{top:e.top-s.height,right:e.right-s.width,bottom:e.bottom-s.height,left:e.left-s.width}}function Ws(e){return pr.some(s=>e[s]>=0)}const Er=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(s){const{rects:n,platform:r}=s,{strategy:a="referenceHidden",...o}=_e(e,s);switch(a){case"referenceHidden":{const i=await r.detectOverflow(s,{...o,elementContext:"reference"}),l=Hs(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ws(l)}}}case"escaped":{const i=await r.detectOverflow(s,{...o,altBoundary:!0}),l=Hs(i,n.floating);return{data:{escapedOffsets:l,escaped:Ws(l)}}}default:return{}}}}},dn=new Set(["left","top"]);async function Dr(e,s){const{placement:n,platform:r,elements:a}=e,o=await(r.isRTL==null?void 0:r.isRTL(a.floating)),i=Oe(n),l=pt(n),d=Ee(n)==="y",u=dn.has(i)?-1:1,c=o&&d?-1:1,h=_e(s,e);let{mainAxis:x,crossAxis:g,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof b=="number"&&(g=l==="end"?b*-1:b),d?{x:g*c,y:x*u}:{x:x*u,y:g*c}}const $r=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var n,r;const{x:a,y:o,placement:i,middlewareData:l}=s,d=await Dr(s,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:i}}}}},Tr=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:n,y:r,placement:a,platform:o}=s,{mainAxis:i=!0,crossAxis:l=!1,limiter:d={fn:S=>{let{x:j,y:w}=S;return{x:j,y:w}}},...u}=_e(e,s),c={x:n,y:r},h=await o.detectOverflow(s,u),x=Ee(Oe(a)),g=ws(x);let b=c[g],y=c[x];if(i){const S=g==="y"?"top":"left",j=g==="y"?"bottom":"right",w=b+h[S],v=b-h[j];b=fs(w,b,v)}if(l){const S=x==="y"?"top":"left",j=x==="y"?"bottom":"right",w=y+h[S],v=y-h[j];y=fs(w,y,v)}const p=d.fn({...s,[g]:b,[x]:y});return{...p,data:{x:p.x-n,y:p.y-r,enabled:{[g]:i,[x]:l}}}}}},Mr=function(e){return e===void 0&&(e={}),{options:e,fn(s){const{x:n,y:r,placement:a,rects:o,middlewareData:i}=s,{offset:l=0,mainAxis:d=!0,crossAxis:u=!0}=_e(e,s),c={x:n,y:r},h=Ee(a),x=ws(h);let g=c[x],b=c[h];const y=_e(l,s),p=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(d){const w=x==="y"?"height":"width",v=o.reference[x]-o.floating[w]+p.mainAxis,E=o.reference[x]+o.reference[w]-p.mainAxis;g<v?g=v:g>E&&(g=E)}if(u){var S,j;const w=x==="y"?"width":"height",v=dn.has(Oe(a)),E=o.reference[h]-o.floating[w]+(v&&((S=i.offset)==null?void 0:S[h])||0)+(v?0:p.crossAxis),A=o.reference[h]+o.reference[w]+(v?0:((j=i.offset)==null?void 0:j[h])||0)-(v?p.crossAxis:0);b<E?b=E:b>A&&(b=A)}return{[x]:g,[h]:b}}}},Lr=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(s){var n,r;const{placement:a,rects:o,platform:i,elements:l}=s,{apply:d=()=>{},...u}=_e(e,s),c=await i.detectOverflow(s,u),h=Oe(a),x=pt(a),g=Ee(a)==="y",{width:b,height:y}=o.floating;let p,S;h==="top"||h==="bottom"?(p=h,S=x===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(S=h,p=x==="end"?"top":"bottom");const j=y-c.top-c.bottom,w=b-c.left-c.right,v=We(y-c[p],j),E=We(b-c[S],w),A=!s.middlewareData.shift;let T=v,M=E;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(M=w),(r=s.middlewareData.shift)!=null&&r.enabled.y&&(T=j),A&&!x){const I=he(c.left,0),Y=he(c.right,0),q=he(c.top,0),K=he(c.bottom,0);g?M=b-2*(I!==0||Y!==0?I+Y:he(c.left,c.right)):T=y-2*(q!==0||K!==0?q+K:he(c.top,c.bottom))}await d({...s,availableWidth:M,availableHeight:T});const V=await i.getDimensions(l.floating);return b!==V.width||y!==V.height?{reset:{rects:!0}}:{}}}};function Yt(){return typeof window<"u"}function gt(e){return un(e)?(e.nodeName||"").toLowerCase():"#document"}function fe(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function $e(e){var s;return(s=(un(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function un(e){return Yt()?e instanceof Node||e instanceof fe(e).Node:!1}function we(e){return Yt()?e instanceof Element||e instanceof fe(e).Element:!1}function ze(e){return Yt()?e instanceof HTMLElement||e instanceof fe(e).HTMLElement:!1}function Us(e){return!Yt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fe(e).ShadowRoot}function Et(e){const{overflow:s,overflowX:n,overflowY:r,display:a}=je(e);return/auto|scroll|overlay|hidden|clip/.test(s+r+n)&&a!=="inline"&&a!=="contents"}function Ir(e){return/^(table|td|th)$/.test(gt(e))}function Gt(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const _r=/transform|translate|scale|rotate|perspective|filter/,Or=/paint|layout|strict|content/,et=e=>!!e&&e!=="none";let rs;function Cs(e){const s=we(e)?je(e):e;return et(s.transform)||et(s.translate)||et(s.scale)||et(s.rotate)||et(s.perspective)||!Ss()&&(et(s.backdropFilter)||et(s.filter))||_r.test(s.willChange||"")||Or.test(s.contain||"")}function Pr(e){let s=Ue(e);for(;ze(s)&&!ht(s);){if(Cs(s))return s;if(Gt(s))return null;s=Ue(s)}return null}function Ss(){return rs==null&&(rs=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),rs}function ht(e){return/^(html|body|#document)$/.test(gt(e))}function je(e){return fe(e).getComputedStyle(e)}function Zt(e){return we(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ue(e){if(gt(e)==="html")return e;const s=e.assignedSlot||e.parentNode||Us(e)&&e.host||$e(e);return Us(s)?s.host:s}function mn(e){const s=Ue(e);return ht(s)?e.ownerDocument?e.ownerDocument.body:e.body:ze(s)&&Et(s)?s:mn(s)}function At(e,s,n){var r;s===void 0&&(s=[]),n===void 0&&(n=!0);const a=mn(e),o=a===((r=e.ownerDocument)==null?void 0:r.body),i=fe(a);if(o){const l=gs(i);return s.concat(i,i.visualViewport||[],Et(a)?a:[],l&&n?At(l):[])}else return s.concat(a,At(a,[],n))}function gs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hn(e){const s=je(e);let n=parseFloat(s.width)||0,r=parseFloat(s.height)||0;const a=ze(e),o=a?e.offsetWidth:n,i=a?e.offsetHeight:r,l=Ut(n)!==o||Ut(r)!==i;return l&&(n=o,r=i),{width:n,height:r,$:l}}function ks(e){return we(e)?e:e.contextElement}function mt(e){const s=ks(e);if(!ze(s))return De(1);const n=s.getBoundingClientRect(),{width:r,height:a,$:o}=hn(s);let i=(o?Ut(n.width):n.width)/r,l=(o?Ut(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const zr=De(0);function fn(e){const s=fe(e);return!Ss()||!s.visualViewport?zr:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Fr(e,s,n){return s===void 0&&(s=!1),!n||s&&n!==fe(e)?!1:s}function tt(e,s,n,r){s===void 0&&(s=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=ks(e);let i=De(1);s&&(r?we(r)&&(i=mt(r)):i=mt(e));const l=Fr(o,n,r)?fn(o):De(0);let d=(a.left+l.x)/i.x,u=(a.top+l.y)/i.y,c=a.width/i.x,h=a.height/i.y;if(o){const x=fe(o),g=r&&we(r)?fe(r):r;let b=x,y=gs(b);for(;y&&r&&g!==b;){const p=mt(y),S=y.getBoundingClientRect(),j=je(y),w=S.left+(y.clientLeft+parseFloat(j.paddingLeft))*p.x,v=S.top+(y.clientTop+parseFloat(j.paddingTop))*p.y;d*=p.x,u*=p.y,c*=p.x,h*=p.y,d+=w,u+=v,b=fe(y),y=gs(b)}}return qt({width:c,height:h,x:d,y:u})}function Jt(e,s){const n=Zt(e).scrollLeft;return s?s.left+n:tt($e(e)).left+n}function pn(e,s){const n=e.getBoundingClientRect(),r=n.left+s.scrollLeft-Jt(e,n),a=n.top+s.scrollTop;return{x:r,y:a}}function Br(e){let{elements:s,rect:n,offsetParent:r,strategy:a}=e;const o=a==="fixed",i=$e(r),l=s?Gt(s.floating):!1;if(r===i||l&&o)return n;let d={scrollLeft:0,scrollTop:0},u=De(1);const c=De(0),h=ze(r);if((h||!h&&!o)&&((gt(r)!=="body"||Et(i))&&(d=Zt(r)),h)){const g=tt(r);u=mt(r),c.x=g.x+r.clientLeft,c.y=g.y+r.clientTop}const x=i&&!h&&!o?pn(i,d):De(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-d.scrollLeft*u.x+c.x+x.x,y:n.y*u.y-d.scrollTop*u.y+c.y+x.y}}function Hr(e){return Array.from(e.getClientRects())}function Wr(e){const s=$e(e),n=Zt(e),r=e.ownerDocument.body,a=he(s.scrollWidth,s.clientWidth,r.scrollWidth,r.clientWidth),o=he(s.scrollHeight,s.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Jt(e);const l=-n.scrollTop;return je(r).direction==="rtl"&&(i+=he(s.clientWidth,r.clientWidth)-a),{width:a,height:o,x:i,y:l}}const Vs=25;function Ur(e,s){const n=fe(e),r=$e(e),a=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,l=0,d=0;if(a){o=a.width,i=a.height;const c=Ss();(!c||c&&s==="fixed")&&(l=a.offsetLeft,d=a.offsetTop)}const u=Jt(r);if(u<=0){const c=r.ownerDocument,h=c.body,x=getComputedStyle(h),g=c.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,b=Math.abs(r.clientWidth-h.clientWidth-g);b<=Vs&&(o-=b)}else u<=Vs&&(o+=u);return{width:o,height:i,x:l,y:d}}function Vr(e,s){const n=tt(e,!0,s==="fixed"),r=n.top+e.clientTop,a=n.left+e.clientLeft,o=ze(e)?mt(e):De(1),i=e.clientWidth*o.x,l=e.clientHeight*o.y,d=a*o.x,u=r*o.y;return{width:i,height:l,x:d,y:u}}function qs(e,s,n){let r;if(s==="viewport")r=Ur(e,n);else if(s==="document")r=Wr($e(e));else if(we(s))r=Vr(s,n);else{const a=fn(e);r={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return qt(r)}function gn(e,s){const n=Ue(e);return n===s||!we(n)||ht(n)?!1:je(n).position==="fixed"||gn(n,s)}function qr(e,s){const n=s.get(e);if(n)return n;let r=At(e,[],!1).filter(l=>we(l)&&gt(l)!=="body"),a=null;const o=je(e).position==="fixed";let i=o?Ue(e):e;for(;we(i)&&!ht(i);){const l=je(i),d=Cs(i);!d&&l.position==="fixed"&&(a=null),(o?!d&&!a:!d&&l.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Et(i)&&!d&&gn(e,i))?r=r.filter(c=>c!==i):a=l,i=Ue(i)}return s.set(e,r),r}function Xr(e){let{element:s,boundary:n,rootBoundary:r,strategy:a}=e;const i=[...n==="clippingAncestors"?Gt(s)?[]:qr(s,this._c):[].concat(n),r],l=qs(s,i[0],a);let d=l.top,u=l.right,c=l.bottom,h=l.left;for(let x=1;x<i.length;x++){const g=qs(s,i[x],a);d=he(g.top,d),u=We(g.right,u),c=We(g.bottom,c),h=he(g.left,h)}return{width:u-h,height:c-d,x:h,y:d}}function Kr(e){const{width:s,height:n}=hn(e);return{width:s,height:n}}function Yr(e,s,n){const r=ze(s),a=$e(s),o=n==="fixed",i=tt(e,!0,o,s);let l={scrollLeft:0,scrollTop:0};const d=De(0);function u(){d.x=Jt(a)}if(r||!r&&!o)if((gt(s)!=="body"||Et(a))&&(l=Zt(s)),r){const g=tt(s,!0,o,s);d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}else a&&u();o&&!r&&a&&u();const c=a&&!r&&!o?pn(a,l):De(0),h=i.left+l.scrollLeft-d.x-c.x,x=i.top+l.scrollTop-d.y-c.y;return{x:h,y:x,width:i.width,height:i.height}}function as(e){return je(e).position==="static"}function Xs(e,s){if(!ze(e)||je(e).position==="fixed")return null;if(s)return s(e);let n=e.offsetParent;return $e(e)===n&&(n=n.ownerDocument.body),n}function xn(e,s){const n=fe(e);if(Gt(e))return n;if(!ze(e)){let a=Ue(e);for(;a&&!ht(a);){if(we(a)&&!as(a))return a;a=Ue(a)}return n}let r=Xs(e,s);for(;r&&Ir(r)&&as(r);)r=Xs(r,s);return r&&ht(r)&&as(r)&&!Cs(r)?n:r||Pr(e)||n}const Gr=async function(e){const s=this.getOffsetParent||xn,n=this.getDimensions,r=await n(e.floating);return{reference:Yr(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zr(e){return je(e).direction==="rtl"}const Jr={convertOffsetParentRelativeRectToViewportRelativeRect:Br,getDocumentElement:$e,getClippingRect:Xr,getOffsetParent:xn,getElementRects:Gr,getClientRects:Hr,getDimensions:Kr,getScale:mt,isElement:we,isRTL:Zr};function yn(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function Qr(e,s){let n=null,r;const a=$e(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),o();const u=e.getBoundingClientRect(),{left:c,top:h,width:x,height:g}=u;if(l||s(),!x||!g)return;const b=Ot(h),y=Ot(a.clientWidth-(c+x)),p=Ot(a.clientHeight-(h+g)),S=Ot(c),w={rootMargin:-b+"px "+-y+"px "+-p+"px "+-S+"px",threshold:he(0,We(1,d))||1};let v=!0;function E(A){const T=A[0].intersectionRatio;if(T!==d){if(!v)return i();T?i(!1,T):r=setTimeout(()=>{i(!1,1e-7)},1e3)}T===1&&!yn(u,e.getBoundingClientRect())&&i(),v=!1}try{n=new IntersectionObserver(E,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(E,w)}n.observe(e)}return i(!0),o}function ea(e,s,n,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,u=ks(e),c=a||o?[...u?At(u):[],...s?At(s):[]]:[];c.forEach(S=>{a&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});const h=u&&l?Qr(u,n):null;let x=-1,g=null;i&&(g=new ResizeObserver(S=>{let[j]=S;j&&j.target===u&&g&&s&&(g.unobserve(s),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(s)})),n()}),u&&!d&&g.observe(u),s&&g.observe(s));let b,y=d?tt(e):null;d&&p();function p(){const S=tt(e);y&&!yn(y,S)&&n(),y=S,b=requestAnimationFrame(p)}return n(),()=>{var S;c.forEach(j=>{a&&j.removeEventListener("scroll",n),o&&j.removeEventListener("resize",n)}),h==null||h(),(S=g)==null||S.disconnect(),g=null,d&&cancelAnimationFrame(b)}}const ta=$r,sa=Tr,na=Rr,ia=Lr,ra=Er,Ks=Ar,aa=Mr,oa=(e,s,n)=>{const r=new Map,a={platform:Jr,...n},o={...a.platform,_c:r};return kr(e,s,{...a,platform:o})};var ca=typeof document<"u",la=function(){},Ht=ca?m.useLayoutEffect:la;function Xt(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let n,r,a;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==s.length)return!1;for(r=n;r--!==0;)if(!Xt(e[r],s[r]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(s).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(s,a[r]))return!1;for(r=n;r--!==0;){const o=a[r];if(!(o==="_owner"&&e.$$typeof)&&!Xt(e[o],s[o]))return!1}return!0}return e!==e&&s!==s}function vn(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ys(e,s){const n=vn(e);return Math.round(s*n)/n}function os(e){const s=m.useRef(e);return Ht(()=>{s.current=e}),s}function da(e){e===void 0&&(e={});const{placement:s="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:o,floating:i}={},transform:l=!0,whileElementsMounted:d,open:u}=e,[c,h]=m.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[x,g]=m.useState(r);Xt(x,r)||g(r);const[b,y]=m.useState(null),[p,S]=m.useState(null),j=m.useCallback(_=>{_!==A.current&&(A.current=_,y(_))},[]),w=m.useCallback(_=>{_!==T.current&&(T.current=_,S(_))},[]),v=o||b,E=i||p,A=m.useRef(null),T=m.useRef(null),M=m.useRef(c),V=d!=null,I=os(d),Y=os(a),q=os(u),K=m.useCallback(()=>{if(!A.current||!T.current)return;const _={placement:s,strategy:n,middleware:x};Y.current&&(_.platform=Y.current),oa(A.current,T.current,_).then(Q=>{const re={...Q,isPositioned:q.current!==!1};N.current&&!Xt(M.current,re)&&(M.current=re,On.flushSync(()=>{h(re)}))})},[x,s,n,Y,q]);Ht(()=>{u===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,h(_=>({..._,isPositioned:!1})))},[u]);const N=m.useRef(!1);Ht(()=>(N.current=!0,()=>{N.current=!1}),[]),Ht(()=>{if(v&&(A.current=v),E&&(T.current=E),v&&E){if(I.current)return I.current(v,E,K);K()}},[v,E,K,I,V]);const ne=m.useMemo(()=>({reference:A,floating:T,setReference:j,setFloating:w}),[j,w]),O=m.useMemo(()=>({reference:v,floating:E}),[v,E]),J=m.useMemo(()=>{const _={position:n,left:0,top:0};if(!O.floating)return _;const Q=Ys(O.floating,c.x),re=Ys(O.floating,c.y);return l?{..._,transform:"translate("+Q+"px, "+re+"px)",...vn(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Q,top:re}},[n,l,O.floating,c.x,c.y]);return m.useMemo(()=>({...c,update:K,refs:ne,elements:O,floatingStyles:J}),[c,K,ne,O,J])}const ua=e=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:a}=typeof e=="function"?e(n):e;return r&&s(r)?r.current!=null?Ks({element:r.current,padding:a}).fn(n):{}:r?Ks({element:r,padding:a}).fn(n):{}}}},ma=(e,s)=>{const n=ta(e);return{name:n.name,fn:n.fn,options:[e,s]}},ha=(e,s)=>{const n=sa(e);return{name:n.name,fn:n.fn,options:[e,s]}},fa=(e,s)=>({fn:aa(e).fn,options:[e,s]}),pa=(e,s)=>{const n=na(e);return{name:n.name,fn:n.fn,options:[e,s]}},ga=(e,s)=>{const n=ia(e);return{name:n.name,fn:n.fn,options:[e,s]}},xa=(e,s)=>{const n=ra(e);return{name:n.name,fn:n.fn,options:[e,s]}},ya=(e,s)=>{const n=ua(e);return{name:n.name,fn:n.fn,options:[e,s]}};var va="Arrow",bn=m.forwardRef((e,s)=>{const{children:n,width:r=10,height:a=5,...o}=e;return t.jsx(Rt.svg,{...o,ref:s,width:r,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});bn.displayName=va;var ba=bn;function wa(e){const[s,n]=m.useState(void 0);return Wt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let i,l;if("borderBoxSize"in o){const d=o.borderBoxSize,u=Array.isArray(d)?d[0]:d;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),s}var As="Popper",[wn]=bs(As),[ja,jn]=wn(As),Nn=e=>{const{__scopePopper:s,children:n}=e,[r,a]=m.useState(null);return t.jsx(ja,{scope:s,anchor:r,onAnchorChange:a,children:n})};Nn.displayName=As;var Cn="PopperAnchor",Sn=m.forwardRef((e,s)=>{const{__scopePopper:n,virtualRef:r,...a}=e,o=jn(Cn,n),i=m.useRef(null),l=kt(s,i),d=m.useRef(null);return m.useEffect(()=>{const u=d.current;d.current=(r==null?void 0:r.current)||i.current,u!==d.current&&o.onAnchorChange(d.current)}),r?null:t.jsx(Rt.div,{...a,ref:l})});Sn.displayName=Cn;var Rs="PopperContent",[Na,Ca]=wn(Rs),kn=m.forwardRef((e,s)=>{var nt,pe,it,Fe,Me,Be;const{__scopePopper:n,side:r="bottom",sideOffset:a=0,align:o="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:g="optimized",onPlaced:b,...y}=e,p=jn(Rs,n),[S,j]=m.useState(null),w=kt(s,me=>j(me)),[v,E]=m.useState(null),A=wa(v),T=(A==null?void 0:A.width)??0,M=(A==null?void 0:A.height)??0,V=r+(o!=="center"?"-"+o:""),I=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},Y=Array.isArray(u)?u:[u],q=Y.length>0,K={padding:I,boundary:Y.filter(Aa),altBoundary:q},{refs:N,floatingStyles:ne,placement:O,isPositioned:J,middlewareData:_}=da({strategy:"fixed",placement:V,whileElementsMounted:(...me)=>ea(...me,{animationFrame:g==="always"}),elements:{reference:p.anchor},middleware:[ma({mainAxis:a+M,alignmentAxis:i}),d&&ha({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?fa():void 0,...K}),d&&pa({...K}),ga({...K,apply:({elements:me,rects:Le,availableWidth:rt,availableHeight:He})=>{const{width:Ve,height:qe}=Le.reference,Ce=me.floating.style;Ce.setProperty("--radix-popper-available-width",`${rt}px`),Ce.setProperty("--radix-popper-available-height",`${He}px`),Ce.setProperty("--radix-popper-anchor-width",`${Ve}px`),Ce.setProperty("--radix-popper-anchor-height",`${qe}px`)}}),v&&ya({element:v,padding:l}),Ra({arrowWidth:T,arrowHeight:M}),x&&xa({strategy:"referenceHidden",...K})]}),[Q,re]=Rn(O),Ne=nn(b);Wt(()=>{J&&(Ne==null||Ne())},[J,Ne]);const ye=(nt=_.arrow)==null?void 0:nt.x,st=(pe=_.arrow)==null?void 0:pe.y,ve=((it=_.arrow)==null?void 0:it.centerOffset)!==0,[Te,de]=m.useState();return Wt(()=>{S&&de(window.getComputedStyle(S).zIndex)},[S]),t.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...ne,transform:J?ne.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Te,"--radix-popper-transform-origin":[(Fe=_.transformOrigin)==null?void 0:Fe.x,(Me=_.transformOrigin)==null?void 0:Me.y].join(" "),...((Be=_.hide)==null?void 0:Be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Na,{scope:n,placedSide:Q,onArrowChange:E,arrowX:ye,arrowY:st,shouldHideArrow:ve,children:t.jsx(Rt.div,{"data-side":Q,"data-align":re,...y,ref:w,style:{...y.style,animation:J?void 0:"none"}})})})});kn.displayName=Rs;var An="PopperArrow",Sa={top:"bottom",right:"left",bottom:"top",left:"right"},ka=m.forwardRef(function(s,n){const{__scopePopper:r,...a}=s,o=Ca(An,r),i=Sa[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(ba,{...a,ref:n,style:{...a.style,display:"block"}})})});ka.displayName=An;function Aa(e){return e!==null}var Ra=e=>({name:"transformOrigin",options:e,fn(s){var p,S,j;const{placement:n,rects:r,middlewareData:a}=s,i=((p=a.arrow)==null?void 0:p.centerOffset)!==0,l=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[u,c]=Rn(n),h={start:"0%",center:"50%",end:"100%"}[c],x=(((S=a.arrow)==null?void 0:S.x)??0)+l/2,g=(((j=a.arrow)==null?void 0:j.y)??0)+d/2;let b="",y="";return u==="bottom"?(b=i?h:`${x}px`,y=`${-d}px`):u==="top"?(b=i?h:`${x}px`,y=`${r.floating.height+d}px`):u==="right"?(b=`${-d}px`,y=i?h:`${g}px`):u==="left"&&(b=`${r.floating.width+d}px`,y=i?h:`${g}px`),{data:{x:b,y}}}});function Rn(e){const[s,n="center"]=e.split("-");return[s,n]}var Ea=Nn,Da=Sn,$a=kn,Ta=Symbol.for("react.lazy"),Kt=Pn[" use ".trim().toString()];function Ma(e){return typeof e=="object"&&e!==null&&"then"in e}function En(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ta&&"_payload"in e&&Ma(e._payload)}function La(e){const s=Ia(e),n=m.forwardRef((r,a)=>{let{children:o,...i}=r;En(o)&&typeof Kt=="function"&&(o=Kt(o._payload));const l=m.Children.toArray(o),d=l.find(Oa);if(d){const u=d.props.children,c=l.map(h=>h===d?m.Children.count(u)>1?m.Children.only(null):m.isValidElement(u)?u.props.children:null:h);return t.jsx(s,{...i,ref:a,children:m.isValidElement(u)?m.cloneElement(u,void 0,c):null})}return t.jsx(s,{...i,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function Ia(e){const s=m.forwardRef((n,r)=>{let{children:a,...o}=n;if(En(a)&&typeof Kt=="function"&&(a=Kt(a._payload)),m.isValidElement(a)){const i=za(a),l=Pa(o,a.props);return a.type!==m.Fragment&&(l.ref=r?Xn(r,i):i),m.cloneElement(a,l)}return m.Children.count(a)>1?m.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var _a=Symbol("radix.slottable");function Oa(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_a}function Pa(e,s){const n={...s};for(const r in s){const a=e[r],o=s[r];/^on[A-Z]/.test(r)?a&&o?n[r]=(...l)=>{const d=o(...l);return a(...l),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...o}:r==="className"&&(n[r]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function za(e){var r,a;let s=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?e.ref:(s=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Fa=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ba=Fa.reduce((e,s)=>{const n=La(`Primitive.${s}`),r=m.forwardRef((a,o)=>{const{asChild:i,...l}=a,d=i?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...l,ref:o})});return r.displayName=`Primitive.${s}`,{...e,[s]:r}},{}),Ha="Portal",Dn=m.forwardRef((e,s)=>{var l;const{container:n,...r}=e,[a,o]=m.useState(!1);Wt(()=>o(!0),[]);const i=n||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?zn.createPortal(t.jsx(Ba.div,{...r,ref:s}),i):null});Dn.displayName=Ha;const Wa=({open:e,onClose:s,anchorRef:n,placement:r="bottom-end",children:a})=>{const o=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const u=c=>{var h,x;e&&((h=o.current)!=null&&h.contains(c.target)||(x=n.current)!=null&&x.contains(c.target)||s())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[e,s,n]),!e)return null;const i=r.startsWith("top")?"top":"bottom",l=r.endsWith("end")?"end":"start",d=r.startsWith("top")?8:4;return t.jsxs(Ea,{children:[t.jsx(Da,{virtualRef:n}),t.jsx(Dn,{children:t.jsx(Kn,{onEscapeKeyDown:u=>{u.preventDefault(),s()},onPointerDownOutside:u=>{var c;if((c=n.current)!=null&&c.contains(u.target)){u.preventDefault();return}s()},children:t.jsx($a,{ref:o,side:i,align:l,sideOffset:d,className:`popover popover-${r}`,role:"dialog",children:a})})})]})};function Ua(e){const s=e+"CollectionProvider",[n,r]=bs(s),[a,o]=n(s,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:p,children:S}=y,j=Re.useRef(null),w=Re.useRef(new Map).current;return t.jsx(a,{scope:p,itemMap:w,collectionRef:j,children:S})};i.displayName=s;const l=e+"CollectionSlot",d=Is(l),u=Re.forwardRef((y,p)=>{const{scope:S,children:j}=y,w=o(l,S),v=kt(p,w.collectionRef);return t.jsx(d,{ref:v,children:j})});u.displayName=l;const c=e+"CollectionItemSlot",h="data-radix-collection-item",x=Is(c),g=Re.forwardRef((y,p)=>{const{scope:S,children:j,...w}=y,v=Re.useRef(null),E=kt(p,v),A=o(c,S);return Re.useEffect(()=>(A.itemMap.set(v,{ref:v,...w}),()=>void A.itemMap.delete(v))),t.jsx(x,{[h]:"",ref:E,children:j})});g.displayName=c;function b(y){const p=o(e+"CollectionConsumer",y);return Re.useCallback(()=>{const j=p.collectionRef.current;if(!j)return[];const w=Array.from(j.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((A,T)=>w.indexOf(A.ref.current)-w.indexOf(T.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},b,r]}var Va=m.createContext(void 0);function qa(e){const s=m.useContext(Va);return e||s||"ltr"}var cs="rovingFocusGroup.onEntryFocus",Xa={bubbles:!1,cancelable:!0},Dt="RovingFocusGroup",[xs,$n,Ka]=Ua(Dt),[Ya]=bs(Dt,[Ka]),[Ga,Za]=Ya(Dt),Tn=m.forwardRef((e,s)=>t.jsx(xs.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(xs.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ja,{...e,ref:s})})}));Tn.displayName=Dt;var Ja=m.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:o,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...h}=e,x=m.useRef(null),g=kt(s,x),b=qa(o),[y,p]=Gn({prop:i,defaultProp:l??null,onChange:d,caller:Dt}),[S,j]=m.useState(!1),w=nn(u),v=$n(n),E=m.useRef(!1),[A,T]=m.useState(0);return m.useEffect(()=>{const M=x.current;if(M)return M.addEventListener(cs,w),()=>M.removeEventListener(cs,w)},[w]),t.jsx(Ga,{scope:n,orientation:r,dir:b,loop:a,currentTabStopId:y,onItemFocus:m.useCallback(M=>p(M),[p]),onItemShiftTab:m.useCallback(()=>j(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(M=>M+1),[]),onFocusableItemRemove:m.useCallback(()=>T(M=>M-1),[]),children:t.jsx(Rt.div,{tabIndex:S||A===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:ut(e.onMouseDown,()=>{E.current=!0}),onFocus:ut(e.onFocus,M=>{const V=!E.current;if(M.target===M.currentTarget&&V&&!S){const I=new CustomEvent(cs,Xa);if(M.currentTarget.dispatchEvent(I),!I.defaultPrevented){const Y=v().filter(O=>O.focusable),q=Y.find(O=>O.active),K=Y.find(O=>O.id===y),ne=[q,K,...Y].filter(Boolean).map(O=>O.ref.current);In(ne,c)}}E.current=!1}),onBlur:ut(e.onBlur,()=>j(!1))})})}),Mn="RovingFocusGroupItem",Ln=m.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:o,children:i,...l}=e,d=Yn(),u=o||d,c=Za(Mn,n),h=c.currentTabStopId===u,x=$n(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:y}=c;return m.useEffect(()=>{if(r)return g(),()=>b()},[r,g,b]),t.jsx(xs.ItemSlot,{scope:n,id:u,focusable:r,active:a,children:t.jsx(Rt.span,{tabIndex:h?0:-1,"data-orientation":c.orientation,...l,ref:s,onMouseDown:ut(e.onMouseDown,p=>{r?c.onItemFocus(u):p.preventDefault()}),onFocus:ut(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:ut(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){c.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const S=to(p,c.orientation,c.dir);if(S!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let w=x().filter(v=>v.focusable).map(v=>v.ref.current);if(S==="last")w.reverse();else if(S==="prev"||S==="next"){S==="prev"&&w.reverse();const v=w.indexOf(p.currentTarget);w=c.loop?so(w,v+1):w.slice(v+1)}setTimeout(()=>In(w))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:y!=null}):i})})});Ln.displayName=Mn;var Qa={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eo(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function to(e,s,n){const r=eo(e.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Qa[r]}function In(e,s=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:s}),document.activeElement!==n))return}function so(e,s){return e.map((n,r)=>e[(s+r)%e.length])}var no=Tn,io=Ln;const Pt=({icon:e,children:s,onClick:n,danger:r,disabled:a})=>t.jsx(io,{asChild:!0,focusable:!a,active:!1,children:t.jsxs("button",{type:"button",role:"menuitem",className:`menu-item${r?" menu-item-danger":""}`,onClick:n,disabled:a,children:[e&&t.jsx("span",{className:"menu-item-icon",children:e}),t.jsx("span",{className:"menu-item-label",children:s})]})}),ro=()=>t.jsx("div",{className:"menu-divider",role:"separator"}),ao=({children:e})=>t.jsx(no,{asChild:!0,orientation:"vertical",loop:!0,children:t.jsx("div",{className:"menu",role:"menu",children:e})}),oo=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],co=({device:e,onClose:s,onReserved:n})=>{const[r,a]=m.useState(""),[o,i]=m.useState("1h"),[l,d]=m.useState(""),[u,c]=m.useState(!1),[h,x]=m.useState(null),[g,b]=m.useState(null),y=async()=>{if(!r.trim()){x("Please enter your name/ID");return}c(!0),x(null),b(null);try{const p=await P.reserveDevice(e.udid,e.host,r,o,l);p.success?(n(),s()):b(p.error||"Failed to reserve device")}catch(p){b(p.message||"An unexpected error occurred")}finally{c(!1)}};return t.jsx(rn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(gi,{size:16,className:"title-icon"}),"Reserve Device"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,disabled:u,children:"Cancel"}),t.jsx("button",{className:"btn-reserve",onClick:y,disabled:u||!r.trim(),children:u?"Reserving...":"Confirm Reservation"})]}),children:t.jsxs("div",{className:"reservation-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsxs("p",{children:["Reserve ",t.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),t.jsx(Ft,{label:t.jsxs(t.Fragment,{children:[t.jsx(Fn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reserved By"]}),htmlFor:"reservation-reserved-by",error:h?t.jsxs(t.Fragment,{children:[t.jsx(Ts,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),h]}):void 0,children:t.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:r,onChange:p=>{a(p.target.value),h&&x(null)},disabled:u})}),t.jsx(Ft,{label:t.jsxs(t.Fragment,{children:[t.jsx(an,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Duration"]}),children:t.jsx("div",{className:"duration-selector",children:oo.map(p=>t.jsx("div",{className:`duration-option ${o===p.value?"active":""}`,onClick:()=>i(p.value),children:p.label},p.value))})}),t.jsx(Ft,{label:t.jsxs(t.Fragment,{children:[t.jsx(Fi,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reason (Optional)"]}),htmlFor:"reservation-reason",error:g?t.jsxs(t.Fragment,{children:[t.jsx(Ts,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),g]}):void 0,children:t.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:l,onChange:p=>d(p.target.value),disabled:u})})]})})},lo=({device:e,onClose:s,onUpdated:n})=>{const{toast:r}=en(),[a,o]=m.useState(e.tags||[]),[i,l]=m.useState(""),[d,u]=m.useState(!1),c=m.useRef(null);m.useEffect(()=>{c.current&&c.current.focus()},[]);const h=()=>{const y=i.trim();y&&!a.includes(y)&&(o([...a,y]),l(""))},x=y=>{o(a.filter(p=>p!==y))},g=y=>{y.key==="Enter"&&h()},b=async()=>{u(!0);try{await P.updateDeviceTags(e.udid,e.host,a),n(),s()}catch(y){console.error("Failed to update tags",y),r("Error saving tags. Please try again.","error")}finally{u(!1)}};return t.jsx(rn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(Ji,{size:16,className:"title-icon"}),"Manage Device Tags"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),t.jsx("button",{className:"btn-save",onClick:b,disabled:d,children:d?"Saving...":"Apply Changes"})]}),children:t.jsxs("div",{className:"tag-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsx(Ft,{label:"Add New Tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:t.jsxs("div",{className:"input-with-button",children:[t.jsx("input",{ref:c,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:i,onChange:y=>l(y.target.value),onKeyDown:g}),t.jsx("button",{className:"add-inline-btn",onClick:h,disabled:!i.trim(),children:t.jsx(Zn,{size:16})})]})}),t.jsxs("div",{className:"tags-display-section",children:[t.jsx("label",{children:"Current Tags"}),t.jsx("div",{className:"tags-list",children:a.length>0?a.map(y=>t.jsxs("div",{className:"tag-pill-editable",children:[y,t.jsx("button",{className:"remove-tag",onClick:()=>x(y),children:t.jsx(Bn,{size:12})})]},y)):t.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})};function uo(e){return e>=50?"ready":e>=20?"reserved":"error"}function mo(e){return e>=50?t.jsx(mi,{size:10}):e>=20?t.jsx(ci,{size:10}):t.jsx(di,{size:10})}function ho(e){return e==="Normal"?"ready":e==="Critical"?"error":"reserved"}const fo=({device:e})=>{const s=typeof e.batteryLevel=="number",n=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!s&&!n?t.jsx("div",{className:"dc2-health",children:t.jsxs(dt,{tone:"neutral",title:"Device does not report battery or thermal data",children:[t.jsx(Jn,{size:10}),"No telemetry"]})}):t.jsxs("div",{className:"dc2-health",children:[s&&t.jsxs(dt,{tone:uo(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[mo(e.batteryLevel),e.batteryLevel,"%"]}),n&&t.jsxs(dt,{tone:ho(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[t.jsx(tr,{size:10}),e.thermalStatus]})]})},po=({udid:e,currentTeamId:s,teams:n,canEdit:r,onChanged:a})=>{const[o,i]=m.useState(!1),[l,d]=m.useState(!1),u=s?n.get(s)??`Team ${s.slice(0,6)}`:"Unassigned";async function c(h){d(!0);try{await P.setDeviceTeam(e,h),a(),i(!1)}catch(x){alert((x==null?void 0:x.message)||"Failed to update team")}finally{d(!1)}}return r?o?t.jsxs("select",{autoFocus:!0,disabled:l,defaultValue:s??"",onBlur:()=>i(!1),onChange:h=>c(h.target.value||null),className:"dc2-team-select",children:[t.jsx("option",{value:"",children:"(Unassigned)"}),Array.from(n.entries()).map(([h,x])=>t.jsx("option",{value:h,children:x},h))]}):t.jsx("button",{type:"button",onClick:()=>i(!0),className:"dc2-team-pill",title:"Click to change team",children:u}):s?t.jsx(dt,{tone:"accent",title:`Team: ${u}`,children:u}):null};function go(e){return e.offline?"offline":e.userBlocked?"error":e.busy?"busy":e.reservedUntil&&Date.now()<e.reservedUntil?"reserved":"ready"}function xo(e,s=10,n=4){return!e||e.length<=s+n+1?e:`${e.slice(0,s)}…${e.slice(-n)}`}function yo(e){if(!e)return"—";try{const s=new URL(e.includes("://")?e:`http://${e}`);return s.port?`${s.hostname}:${s.port}`:s.hostname}catch{return e}}const vo=({device:e,reloadDevices:s,navigate:n,teams:r})=>{var v,E,A;const[a,o]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),c=m.useRef(null),{me:h}=Hn(),x=(h==null?void 0:h.role)==="ADMIN"||(h==null?void 0:h.role)==="SUPER_ADMIN",g=go(e),b=g==="reserved",y=!!(e.busy&&e.session_id&&!String(e.session_id).startsWith("manual_")),p=()=>{var T;return(T=navigator.clipboard)==null?void 0:T.writeText(e.udid)},S=async()=>{await P.releaseReservation(e.udid,e.host),s()},j=async()=>{await P.blockDevice(e.udid,e.host),s()},w=async()=>{await P.unblockDevice(e.udid,e.host),s()};return t.jsxs("div",{className:`dc2 dc2-${g}`,children:[t.jsx("div",{className:"dc2-stripe"}),t.jsxs("div",{className:"dc2-header",children:[t.jsxs("span",{className:"dc2-platform",children:[e.platform.toUpperCase()," · ",e.sdk]}),t.jsx(fr,{kind:g,showDot:!0,children:g})]}),t.jsx("div",{className:"dc2-name",title:e.name,children:e.name}),t.jsx("div",{className:"dc2-udid",title:e.udid,children:xo(e.udid)}),t.jsx(fo,{device:e}),(e.teamId||x||e.tags&&e.tags.length>0)&&t.jsxs("div",{className:"dc2-tags",children:[(e.teamId||x)&&t.jsx(po,{udid:e.udid,currentTeamId:e.teamId??null,teams:r??new Map,canEdit:x,onChanged:s}),(v=e.tags)==null?void 0:v.slice(0,3).map(T=>t.jsx(dt,{tone:"neutral",title:T,children:T},T)),(((E=e.tags)==null?void 0:E.length)||0)>3&&t.jsxs(dt,{tone:"neutral",children:["+",(((A=e.tags)==null?void 0:A.length)||0)-3]})]}),t.jsxs("div",{className:"dc2-metrics",children:[b?t.jsxs("div",{className:"dc2-banner dc2-banner-reserved",children:[t.jsx(an,{size:12}),t.jsxs("span",{children:["RES · ",e.reservedBy||"anon",e.reservedUntil?` (${Os(e.reservedUntil-Date.now(),{compact:!0})})`:""]})]}):e.session_id?t.jsxs("div",{className:"dc2-banner dc2-banner-session",children:[t.jsx(ms,{size:12}),t.jsxs("span",{children:["SID · ",String(e.session_id).slice(0,10)]})]}):t.jsx(Ps,{label:"Time in use",value:e.totalUtilizationTimeMilliSec?Os(e.totalUtilizationTimeMilliSec,{compact:!0}):"—"}),t.jsx(Ps,{label:"Host",value:yo(e.ip||e.host),mono:!0})]}),t.jsxs("div",{className:"dc2-actions",children:[t.jsx(lt,{variant:"primary",size:"sm",disabled:y,onClick:()=>{y||n(`/devices/${e.udid}/control`)},title:y?"Locked: Appium session running":"Take control",className:"dc2-primary",children:"Control"}),b?t.jsx(lt,{variant:"secondary",size:"sm",onClick:S,children:"Release"}):!e.userBlocked&&!e.busy?t.jsx(lt,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:"Reserve"}):null,t.jsx("button",{ref:c,type:"button",className:"dc2-more",onClick:()=>u(T=>!T),"aria-label":"More actions",children:t.jsx(Ri,{size:14})}),t.jsx(Wa,{open:d,onClose:()=>u(!1),anchorRef:c,children:t.jsxs(ao,{children:[t.jsx(Pt,{onClick:()=>{u(!1),l(!0)},children:"Manage tags…"}),e.userBlocked?t.jsx(Pt,{onClick:()=>{u(!1),w()},children:"Exit maintenance"}):t.jsx(Pt,{onClick:()=>{u(!1),j()},children:"Enter maintenance"}),t.jsx(ro,{}),t.jsx(Pt,{icon:t.jsx(Ct,{size:12}),onClick:()=>{u(!1),p()},children:"Copy UDID"})]})})]}),a&&t.jsx(co,{device:e,onClose:()=>o(!1),onReserved:()=>s()}),i&&t.jsx(lo,{device:e,onClose:()=>l(!1),onUpdated:()=>s()})]})};function bo(e){const s=vs();return t.jsx(vo,{device:e.device,reloadDevices:e.reloadDevices,navigate:s,teams:e.teams})}class wo extends Re.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){P.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return t.jsx("div",{className:"device-explorer-card-container",children:Re.Children.toArray(this.props.devices.map(s=>t.jsx(bo,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}var zt,jo=new Uint8Array(16);function No(){if(!zt&&(zt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!zt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return zt(jo)}const Co=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function So(e){return typeof e=="string"&&Co.test(e)}var oe=[];for(var ls=0;ls<256;++ls)oe.push((ls+256).toString(16).substr(1));function ko(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(oe[e[s+0]]+oe[e[s+1]]+oe[e[s+2]]+oe[e[s+3]]+"-"+oe[e[s+4]]+oe[e[s+5]]+"-"+oe[e[s+6]]+oe[e[s+7]]+"-"+oe[e[s+8]]+oe[e[s+9]]+"-"+oe[e[s+10]]+oe[e[s+11]]+oe[e[s+12]]+oe[e[s+13]]+oe[e[s+14]]+oe[e[s+15]]).toLowerCase();if(!So(n))throw TypeError("Stringified UUID is invalid");return n}function Ao(e,s,n){e=e||{};var r=e.random||(e.rng||No)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,ko(r)}const Ro=({onCommand:e,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:r})=>{const[a,o]=m.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[i,l]=m.useState(""),[d,u]=m.useState([]),[c,h]=m.useState(-1),[x,g]=m.useState(!1),b=m.useRef(null),y=m.useRef(null);m.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[a]);const p=j=>{const w=j.trim();if((w.startsWith("{")||w.startsWith("["))&&(w.endsWith("}")||w.endsWith("]")))try{const v=JSON.parse(w);return JSON.stringify(v,null,2)}catch{}return j},S=async j=>{if(j.key==="Enter"&&!x){const w=i.trim();if(!w)return;if(l(""),o(v=>[...v,{type:"command",content:`${s} ${w}`,timestamp:Date.now()}]),u(v=>[...v,w]),h(-1),g(!0),w==="clear"){o([]),g(!1);return}if(w==="help"){let v="";r==="android"?v=`
157
157
  Android Allowed Commands:
158
158
  • System Info: getprop, ip addr, date, uptime, cat /proc/meminfo, cat /proc/cpuinfo
159
159
  • Process Mgmt: ps, top
@@ -168,7 +168,7 @@ iOS Allowed Commands:
168
168
  listapps, get_app_container, list, getenv
169
169
  • Simulator System:
170
170
  ls, ps, top, date, uptime, whoami
171
- `),o(E=>[...E,{type:"output",content:v.trim(),timestamp:Date.now()}]),g(!1);return}try{const v=await e(w),E=p(v||"(No output)");o(A=>[...A,{type:"output",content:E,timestamp:Date.now()}])}catch(v){o(E=>[...E,{type:"error",content:v.message||"Unknown error",timestamp:Date.now()}])}finally{g(!1),setTimeout(()=>{var v;return(v=y.current)==null?void 0:v.focus()},10)}}else if(j.key==="ArrowUp"){if(j.preventDefault(),d.length>0){const w=c===-1?d.length-1:Math.max(0,c-1);h(w),l(d[w])}}else if(j.key==="ArrowDown"&&(j.preventDefault(),c!==-1)){const w=c+1;w>=d.length?(h(-1),l("")):(h(w),l(d[w]))}};return t.jsxs("div",{className:"terminal-container",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"terminal-header",children:[t.jsxs("div",{className:"terminal-controls",children:[t.jsx("div",{className:"dot red"}),t.jsx("div",{className:"dot yellow"}),t.jsx("div",{className:"dot green"})]}),t.jsxs("div",{className:"terminal-title",children:[r.toUpperCase()," INTERNAL SHELL"]}),t.jsx("div",{className:"terminal-actions",children:t.jsx("button",{className:"terminal-action-btn",onClick:()=>o([]),title:"Clear Terminal",children:"CLEAR"})})]}),t.jsxs("div",{className:"terminal-history",ref:b,onClick:()=>{var j;return(j=y.current)==null?void 0:j.focus()},children:[a.map((j,w)=>t.jsx("div",{className:`terminal-line ${j.type}`,children:j.content},w)),x&&t.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),t.jsxs("div",{className:"terminal-input-area",children:[t.jsx("span",{className:"terminal-prompt",children:s}),t.jsx("input",{ref:y,className:"terminal-input",value:i,onChange:j=>l(j.target.value),onKeyDown:S,disabled:x,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Pe(e,s){var n;s(e),(n=e.children)==null||n.forEach(r=>Pe(r,s))}function Ie(e,...s){var n;for(const r of s){const a=(n=e.attributes)==null?void 0:n[r];if(a!=null&&a!=="")return String(a)}}function ft(e){var s;return((s=e.type)==null?void 0:s.split(".").pop())||e.type||""}function Eo(e,s){const n=[];return Pe(e,r=>{Ie(r,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(r)}),n}function Do(e,s){const n=[];return Pe(e,r=>{Ie(r,"resource-id","resourceId","identifier")===s&&n.push(r)}),n}function xs(e,s){const n=[];return Pe(e,r=>{(r.type===s||ft(r)===s)&&n.push(r)}),n}function $o(e,s){const n=[];return Pe(e,r=>{Ie(r,"name")===s&&n.push(r)}),n}function To(e){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function Mo(e,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const r=[];for(const o of n){const i=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(o);if(!i)return null;r.push({type:i[1],index:parseInt(i[2],10)})}if(r[0].type!==e.type&&r[0].type!==ft(e)||r[0].index!==1)return null;let a=e;for(let o=1;o<r.length&&a;o++){const{type:i,index:l}=r[o];let d=0,u;for(const c of a.children||[])if((c.type===i||ft(c)===i)&&(d+=1,d===l)){u=c;break}a=u}return a?[a]:[]}function Lo(e,s){const n=Mo(e,s);if(n!==null)return{kind:"matched",nodes:n};const r=To(s);if(r){const a=[];return Pe(e,o=>{if(r.tag&&o.type!==r.tag&&ft(o)!==r.tag)return;Ie(o,r.attrKey)===r.attrValue&&a.push(o)}),{kind:"matched",nodes:a}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Io(e,s){const n=s.trim(),r=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(r){const[,i,l,d]=r,u=[];return Pe(e,c=>{if(c.type!==i&&ft(c)!==i)return;Ie(c,l)===d&&u.push(c)}),{kind:"matched",nodes:u}}const a=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(a){const[,i,l]=a,d=parseInt(l,10),u=[];return Pe(e,c=>{(c.type===i||ft(c)===i)&&u.push(c)}),{kind:"matched",nodes:u[d-1]?[u[d-1]]:[]}}const o=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return o?xs(e,o[1]).length>0?{kind:"matched",nodes:xs(e,o[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function _o(e,s){const r=s.trim().split(/\s+AND\s+/i).map(i=>i.trim()),a=[];for(const i of r){const l=/^(\w+)\s*==\s*"([^"]*)"$/.exec(i);if(!l)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};a.push({key:l[1],value:l[2]})}const o=[];return Pe(e,i=>{for(const l of a){let d;if(l.key==="type"?d=i.type:l.key==="label"?d=Ie(i,"label")??i.label:l.key==="name"?d=Ie(i,"name")??i.name:l.key==="value"?d=Ie(i,"value")??i.value:d=Ie(i,l.key),d!==l.value)return}o.push(i)}),{kind:"matched",nodes:o}}function Oo(e,s,n){const r=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(r){case"accessibility id":return{kind:"matched",nodes:Eo(e,n)};case"id":return{kind:"matched",nodes:Do(e,n)};case"class name":return{kind:"matched",nodes:xs(e,n)};case"name":return{kind:"matched",nodes:$o(e,n)};case"xpath":return Lo(e,n);case"-ios class chain":return Io(e,n);case"-ios predicate string":return _o(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Gs(e,s){const n=e.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(s)&&!s.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(s)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(s.startsWith("/hierarchy")||s.startsWith("/")&&!s.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(s))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const r=(s.match(/\//g)||[]).length;return r>7?{level:"fragile",reason:`${r}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:s.includes("@content-desc")||s.includes("@resource-id")||s.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?s.includes("resourceId")||s.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:s.includes("textContains")||s.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function Zs(e,s,n,r){var j,w,v,E,A,T,M;const{strategy:a,value:o}=r,i=(e.text||e.name||((j=e.type)==null?void 0:j.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",l=i.charAt(0).toLowerCase()+i.slice(1),d=((w=e.type)==null?void 0:w.toLowerCase().includes("edit"))||((v=e.type)==null?void 0:v.toLowerCase().includes("input"))||((E=e.type)==null?void 0:E.toLowerCase().includes("field"))||((A=e.type)==null?void 0:A.toLowerCase().includes("textfield")),u=((T=e.attributes)==null?void 0:T.scrollable)==="true"||((M=e.attributes)==null?void 0:M.scrollable)===!0,c=a.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
171
+ `),o(E=>[...E,{type:"output",content:v.trim(),timestamp:Date.now()}]),g(!1);return}try{const v=await e(w),E=p(v||"(No output)");o(A=>[...A,{type:"output",content:E,timestamp:Date.now()}])}catch(v){o(E=>[...E,{type:"error",content:v.message||"Unknown error",timestamp:Date.now()}])}finally{g(!1),setTimeout(()=>{var v;return(v=y.current)==null?void 0:v.focus()},10)}}else if(j.key==="ArrowUp"){if(j.preventDefault(),d.length>0){const w=c===-1?d.length-1:Math.max(0,c-1);h(w),l(d[w])}}else if(j.key==="ArrowDown"&&(j.preventDefault(),c!==-1)){const w=c+1;w>=d.length?(h(-1),l("")):(h(w),l(d[w]))}};return t.jsxs("div",{className:"terminal-container",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"terminal-header",children:[t.jsxs("div",{className:"terminal-controls",children:[t.jsx("div",{className:"dot red"}),t.jsx("div",{className:"dot yellow"}),t.jsx("div",{className:"dot green"})]}),t.jsxs("div",{className:"terminal-title",children:[r.toUpperCase()," INTERNAL SHELL"]}),t.jsx("div",{className:"terminal-actions",children:t.jsx("button",{className:"terminal-action-btn",onClick:()=>o([]),title:"Clear Terminal",children:"CLEAR"})})]}),t.jsxs("div",{className:"terminal-history",ref:b,onClick:()=>{var j;return(j=y.current)==null?void 0:j.focus()},children:[a.map((j,w)=>t.jsx("div",{className:`terminal-line ${j.type}`,children:j.content},w)),x&&t.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),t.jsxs("div",{className:"terminal-input-area",children:[t.jsx("span",{className:"terminal-prompt",children:s}),t.jsx("input",{ref:y,className:"terminal-input",value:i,onChange:j=>l(j.target.value),onKeyDown:S,disabled:x,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Pe(e,s){var n;s(e),(n=e.children)==null||n.forEach(r=>Pe(r,s))}function Ie(e,...s){var n;for(const r of s){const a=(n=e.attributes)==null?void 0:n[r];if(a!=null&&a!=="")return String(a)}}function ft(e){var s;return((s=e.type)==null?void 0:s.split(".").pop())||e.type||""}function Eo(e,s){const n=[];return Pe(e,r=>{Ie(r,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(r)}),n}function Do(e,s){const n=[];return Pe(e,r=>{Ie(r,"resource-id","resourceId","identifier")===s&&n.push(r)}),n}function ys(e,s){const n=[];return Pe(e,r=>{(r.type===s||ft(r)===s)&&n.push(r)}),n}function $o(e,s){const n=[];return Pe(e,r=>{Ie(r,"name")===s&&n.push(r)}),n}function To(e){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function Mo(e,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const r=[];for(const o of n){const i=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(o);if(!i)return null;r.push({type:i[1],index:parseInt(i[2],10)})}if(r[0].type!==e.type&&r[0].type!==ft(e)||r[0].index!==1)return null;let a=e;for(let o=1;o<r.length&&a;o++){const{type:i,index:l}=r[o];let d=0,u;for(const c of a.children||[])if((c.type===i||ft(c)===i)&&(d+=1,d===l)){u=c;break}a=u}return a?[a]:[]}function Lo(e,s){const n=Mo(e,s);if(n!==null)return{kind:"matched",nodes:n};const r=To(s);if(r){const a=[];return Pe(e,o=>{if(r.tag&&o.type!==r.tag&&ft(o)!==r.tag)return;Ie(o,r.attrKey)===r.attrValue&&a.push(o)}),{kind:"matched",nodes:a}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Io(e,s){const n=s.trim(),r=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(r){const[,i,l,d]=r,u=[];return Pe(e,c=>{if(c.type!==i&&ft(c)!==i)return;Ie(c,l)===d&&u.push(c)}),{kind:"matched",nodes:u}}const a=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(a){const[,i,l]=a,d=parseInt(l,10),u=[];return Pe(e,c=>{(c.type===i||ft(c)===i)&&u.push(c)}),{kind:"matched",nodes:u[d-1]?[u[d-1]]:[]}}const o=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return o?ys(e,o[1]).length>0?{kind:"matched",nodes:ys(e,o[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function _o(e,s){const r=s.trim().split(/\s+AND\s+/i).map(i=>i.trim()),a=[];for(const i of r){const l=/^(\w+)\s*==\s*"([^"]*)"$/.exec(i);if(!l)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};a.push({key:l[1],value:l[2]})}const o=[];return Pe(e,i=>{for(const l of a){let d;if(l.key==="type"?d=i.type:l.key==="label"?d=Ie(i,"label")??i.label:l.key==="name"?d=Ie(i,"name")??i.name:l.key==="value"?d=Ie(i,"value")??i.value:d=Ie(i,l.key),d!==l.value)return}o.push(i)}),{kind:"matched",nodes:o}}function Oo(e,s,n){const r=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(r){case"accessibility id":return{kind:"matched",nodes:Eo(e,n)};case"id":return{kind:"matched",nodes:Do(e,n)};case"class name":return{kind:"matched",nodes:ys(e,n)};case"name":return{kind:"matched",nodes:$o(e,n)};case"xpath":return Lo(e,n);case"-ios class chain":return Io(e,n);case"-ios predicate string":return _o(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Gs(e,s){const n=e.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(s)&&!s.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(s)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(s.startsWith("/hierarchy")||s.startsWith("/")&&!s.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(s))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const r=(s.match(/\//g)||[]).length;return r>7?{level:"fragile",reason:`${r}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:s.includes("@content-desc")||s.includes("@resource-id")||s.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?s.includes("resourceId")||s.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:s.includes("textContains")||s.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function Zs(e,s,n,r){var j,w,v,E,A,T,M;const{strategy:a,value:o}=r,i=(e.text||e.name||((j=e.type)==null?void 0:j.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",l=i.charAt(0).toLowerCase()+i.slice(1),d=((w=e.type)==null?void 0:w.toLowerCase().includes("edit"))||((v=e.type)==null?void 0:v.toLowerCase().includes("input"))||((E=e.type)==null?void 0:E.toLowerCase().includes("field"))||((A=e.type)==null?void 0:A.toLowerCase().includes("textfield")),u=((T=e.attributes)==null?void 0:T.scrollable)==="true"||((M=e.attributes)==null?void 0:M.scrollable)===!0,c=a.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
172
172
  `:a.toLowerCase().startsWith("-android")&&s!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
173
173
  `:"",h={"accessibility id":`~${o}`,id:s==="ios"?`-ios predicate string:label == "${o}"`:`android=new UiSelector().resourceId("${o}")`,xpath:`${o}`,"-ios predicate string":`-ios predicate string:${o}`,"-ios class chain":`-ios class chain:${o}`,"-android uiautomator":`android=${o}`},x={"accessibility id":`AppiumBy.accessibilityId("${o}")`,id:`AppiumBy.id("${o}")`,xpath:`AppiumBy.xpath("${o}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${o}")`,"-ios class chain":`AppiumBy.iOSClassChain("${o}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${o}")`,"class name":`AppiumBy.className("${o}")`},g={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${o}"`,id:`AppiumBy.ID, "${o}"`,xpath:`AppiumBy.XPATH, "${o}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${o}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${o}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${o}'`,"class name":`AppiumBy.CLASS_NAME, "${o}"`},b=x[a.toLowerCase()],y=g[a.toLowerCase()],p=h[a.toLowerCase()];return n==="java"?b?`${c}// Appium Java Client 9.x + Selenium 4 + TestNG
174
174
  import io.appium.java_client.AppiumBy;
@@ -204,7 +204,7 @@ const element = await driver.$('${p}');
204
204
  await element.waitForExist({ timeout: 5000 });
205
205
  ${d?`await driver.$('target').clearValue();
206
206
  await element.addValue("your text here");`:"await element.click();"}
207
- // Assert with expect(element).toBeDisplayed()`:`// Strategy "${a}" not supported in WebdriverIO mobile`}function Js(e){var g,b,y,p,S,j,w,v,E,A,T;const s=(e.type||"").toLowerCase(),n=((g=e.attributes)==null?void 0:g.clickable)==="true"||((b=e.attributes)==null?void 0:b.clickable)===!0,r=((y=e.attributes)==null?void 0:y.enabled)!=="false"&&((p=e.attributes)==null?void 0:p.enabled)!==!1,a=((S=e.attributes)==null?void 0:S.scrollable)==="true"||((j=e.attributes)==null?void 0:j.scrollable)===!0,o=e.text||e.label||e.value||"",i=((w=e.children)==null?void 0:w.length)||0;let l="Element",d="📦";s.includes("button")||s.includes("btn")||n&&i===0?(l="Button",d="🔘"):s.includes("edit")||s.includes("input")||s.includes("field")?(l="Text Input",d="✏️"):s.includes("image")||s.includes("img")||s.includes("imageview")?(l="Image",d="🖼️"):s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?(l="Scrollable List",d="📜"):s.includes("text")||s.includes("label")?(l="Text Label",d="📝"):s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?(l="Toggle / Checkbox",d="☑️"):s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?(l="Navigation Bar",d="🧭"):i>0&&(l=`Container (${i} children)`,d="🗂️");const u=((v=e.suggestedLocators)==null?void 0:v.find(M=>M.strategy==="accessibility id"||M.strategy==="id"))||((E=e.suggestedLocators)==null?void 0:E[0]),c=r?((A=e.rect)==null?void 0:A.width)===0||((T=e.rect)==null?void 0:T.height)===0?"⚠️ Zero-size element — may not be interactable":void 0:"⚠️ Element is disabled",h=o?` with text "${o.slice(0,30)}"`:"",x=`This is a ${l.toLowerCase()}${h}. ${n?"It can be tapped/clicked.":a?"It supports scrolling.":"It is a visual container."}${i>0?` Contains ${i} child element${i>1?"s":""}.`:""}`;return{role:l,description:x,interactable:n||r,bestLocator:u,warning:c,emoji:d}}function Qs(e,s){if(!s)return!0;const n=s.toLowerCase().trim(),r={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},a=(e.type||"").toLowerCase(),o=(e.text||e.label||e.value||"").toLowerCase(),i=(e.name||"").toLowerCase(),l=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[d,u]of Object.entries(r))if(n.includes(d)&&u.some(c=>a.includes(c)))return!0;return a.includes(n)||o.includes(n)||i.includes(n)||l.includes(n)}const Po=({sessionId:e,udid:s,streamUrl:n,embedded:r=!1})=>{var Se,ke,ot,Ye,vt,Mt,bt,Ge,wt;const[a,o]=m.useState(!0),[i,l]=m.useState(null),[d,u]=m.useState(null),[c,h]=m.useState(null),[x,g]=m.useState(null),[b,y]=m.useState(new Set(["/"])),[p,S]=m.useState(""),[j,w]=m.useState(null),[v,E]=m.useState("info"),[A,T]=m.useState("java"),[M,V]=m.useState(null),[I,Y]=m.useState({width:0,height:0}),[q,K]=m.useState({width:0,height:0}),[N,ne]=m.useState(!1),[O,J]=m.useState("inspect"),[_,Q]=m.useState({}),[re,Ne]=m.useState(null),ye=m.useRef(null),st=m.useRef(null),ve=m.useRef(null),Te=m.useRef(null),de=m.useCallback(()=>{var Z,ue,xe;if(!ye.current)return;const f=ye.current.getBoundingClientRect(),k=f.width,D=f.height,$=(Z=i==null?void 0:i.hierarchy)==null?void 0:Z.rect;let z=((ue=i==null?void 0:i.metadata)==null?void 0:ue.screenWidth)||I.width||1,H=((xe=i==null?void 0:i.metadata)==null?void 0:xe.screenHeight)||I.height||1;$&&$.width>0&&$.height>0&&(z=$.width,H=$.height);const W=z/H;let G,U;k/D>W?(U=D,G=U*W):(G=k,U=G/W),K({width:G,height:U})},[i,I]);m.useEffect(()=>(de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)),[de]),m.useEffect(()=>{s&&pe()},[s]),m.useEffect(()=>{var f;if((f=c==null?void 0:c.suggestedLocators)!=null&&f.length){const k=c.suggestedLocators.find(D=>D.strategy==="accessibility id"||D.strategy==="id")||c.suggestedLocators[0];V(k)}else V(null);Q({}),Ne(null)},[c]);const nt=m.useCallback((f,k)=>{if(!(i!=null&&i.hierarchy))return;const D=Oo(i.hierarchy,f,k);Q($=>({...$,[f]:D})),Ne(f)},[i]),pe=async()=>{if(s){o(!0),u(null);try{const f=await P.getInspectorSnapshot(s);l(f);const k=new Set(["/"]),D=($,z)=>{var H;z<2&&(k.add($.xpath),(H=$.children)==null||H.forEach(W=>D(W,z+1)))};f.hierarchy&&D(f.hierarchy,0),y(k)}catch(f){u(f.message||"Failed to capture snapshot")}finally{o(!1)}}},it=f=>{const{naturalWidth:k,naturalHeight:D}=f.currentTarget;Y({width:k,height:D})},Fe=()=>ne(!0),Me=f=>{ne(!1);const{naturalWidth:k,naturalHeight:D}=f.currentTarget;k>0&&D>0&&Y({width:k,height:D})},Be=n&&!N,me=f=>{if(O!=="interact"||!s)return;const k=f.currentTarget.getBoundingClientRect();Te.current={x:f.clientX-k.left,y:f.clientY-k.top,time:Date.now()}},Le=async f=>{var ae,Ze,Je;if(O!=="interact"||!s||!Te.current)return;const k=Te.current,D=f.currentTarget.getBoundingClientRect(),$=f.clientX-D.left,z=f.clientY-D.top,H=Date.now()-k.time,W=q.width,G=q.height,U=(ae=i==null?void 0:i.hierarchy)==null?void 0:ae.rect;let Z=((Ze=i==null?void 0:i.metadata)==null?void 0:Ze.screenWidth)||I.width,ue=((Je=i==null?void 0:i.metadata)==null?void 0:Je.screenHeight)||I.height;if(U&&U.width>0&&U.height>0&&(Z=U.width,ue=U.height),!Z||!ue||W===0||G===0)return;const xe=(Qe,C)=>({x:Math.round(Qe/W*Z),y:Math.round(C/G*ue),px:Qe/W,py:C/G}),ie=xe(k.x,k.y),Ae=xe($,z),be=Math.sqrt(Math.pow($-k.x,2)+Math.pow(z-k.y,2));if(!(ie.px<0||ie.px>1||ie.py<0||ie.py>1)){try{H<500&&be<10?await P.tap(s,ie.x,ie.y):H>=500&&be<10?await P.touchAndHold(s,ie.x,ie.y,H):be>=10&&await P.swipe(s,ie.x,ie.y,Ae.x,Ae.y)}catch(Qe){console.error("Interaction failed:",Qe)}Te.current=null}},rt=f=>{const k=new Set(b);k.has(f)?k.delete(f):k.add(f),y(k)},He=()=>{const f=new Set,k=D=>{var $;f.add(D.xpath),($=D.children)==null||$.forEach(k)};i!=null&&i.hierarchy&&k(i.hierarchy),y(f)},Ve=()=>y(new Set(["/"])),qe=(f,k)=>{navigator.clipboard.writeText(f),w(k),setTimeout(()=>w(null),2e3)},Ce=f=>{var D;let k=1;return(D=f.children)==null||D.forEach($=>k+=Ce($)),k},$t=f=>{if(!f)return[];const k={},D=$=>{var W;const z=Js($),H=z.role.replace(/\s*\(.*?\)\s*/,"");k[H]||(k[H]={emoji:z.emoji,count:0}),k[H].count+=1,(W=$.children)==null||W.forEach(D)};return D(f),Object.entries(k).map(([$,z])=>({role:$,emoji:z.emoji,count:z.count})).sort(($,z)=>z.count-$.count)},Qt=f=>f.xpath.split("/").filter(Boolean).slice(-3),Xe=(f,k=0)=>{var xe,ie,Ae,be;if(!f)return null;const D=b.has(f.xpath),$=((xe=f.children)==null?void 0:xe.length)>0,z=(c==null?void 0:c.xpath)===f.xpath,H=(x==null?void 0:x.xpath)===f.xpath,W=((ie=f.type)==null?void 0:ie.split(".").pop())||"Element",G=f.label||((Ae=f.attributes)==null?void 0:Ae["content-desc"])||((be=f.attributes)==null?void 0:be["resource-id"])||f.name,U=typeof G=="string"&&G&&G!==W&&G!==f.type?G:null,Z=U||W,ue=!p||Qs(f,p);if(!ue&&!$)return null;if(p&&!ue){const ae=Ze=>{var Je;return Qs(Ze,p)?!0:((Je=Ze.children)==null?void 0:Je.some(ae))||!1};if(!ae(f))return null}return t.jsxs("div",{className:"tree-node",children:[t.jsxs("div",{className:`tree-item ${z?"selected":""} ${H&&!z?"hovered":""}`,onClick:()=>{h(f),E("info")},onMouseEnter:()=>g(f),onMouseLeave:()=>g(null),children:[t.jsx("div",{className:"tree-item-indent",style:{width:`${k*14}px`}}),$?t.jsx("button",{onClick:ae=>{ae.stopPropagation(),rt(f.xpath)},className:"tree-toggle",children:D?t.jsx(tn,{size:11}):t.jsx(cn,{size:11})}):t.jsx("span",{className:"tree-toggle-spacer"}),t.jsx(fi,{size:11,className:"tree-icon"}),t.jsx("span",{className:"tree-label",title:`${W}${U?` — ${U}`:""}`,children:Z}),U&&t.jsx("span",{className:"tree-type-tag",title:W,children:W}),f.text&&t.jsxs("span",{className:"tree-text-preview",children:['"',f.text.slice(0,20),'"']}),$&&t.jsx("span",{className:"tree-badge",children:f.children.length})]}),D&&$&&t.jsx("div",{className:"tree-children",children:f.children.map(ae=>Xe(ae,k+1))})]},f.xpath)},ge=f=>{var W,G,U;if(!I.width)return[];const k=[],D=(W=i==null?void 0:i.hierarchy)==null?void 0:W.rect;let $=((G=i==null?void 0:i.metadata)==null?void 0:G.screenWidth)||I.width,z=((U=i==null?void 0:i.metadata)==null?void 0:U.screenHeight)||I.height;D&&D.width>0&&D.height>0&&($=D.width,z=D.height);const H=(Z,ue)=>{var ie,Ae,be;const xe=!Z.children||Z.children.length===0;((ie=Z.rect)==null?void 0:ie.width)>0&&((Ae=Z.rect)==null?void 0:Ae.height)>0&&xe&&k.push(t.jsx("div",{className:"omni-hit-area",style:{left:`${Z.rect.x/$*100}%`,top:`${Z.rect.y/z*100}%`,width:`${Z.rect.width/$*100}%`,height:`${Z.rect.height/z*100}%`,zIndex:ue},onClick:ae=>{ae.stopPropagation(),h(Z),E("info")},onMouseEnter:()=>g(Z),onMouseLeave:()=>g(null)},Z.xpath)),(be=Z.children)==null||be.forEach(ae=>H(ae,ue+1))};return i!=null&&i.hierarchy&&H(i.hierarchy,1),k},at=()=>{var H,W,G;if(!re||!I.width)return[];const f=_[re];if(!f||f.kind!=="matched"||f.nodes.length===0)return[];const k=(H=i==null?void 0:i.hierarchy)==null?void 0:H.rect;let D=((W=i==null?void 0:i.metadata)==null?void 0:W.screenWidth)||I.width,$=((G=i==null?void 0:i.metadata)==null?void 0:G.screenHeight)||I.height;k&&k.width>0&&k.height>0&&(D=k.width,$=k.height);const z=f.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return f.nodes.filter(U=>U.rect&&U.rect.width>0&&U.rect.height>0).map((U,Z)=>t.jsx("div",{className:z,style:{left:`${U.rect.x/D*100}%`,top:`${U.rect.y/$*100}%`,width:`${U.rect.width/D*100}%`,height:`${U.rect.height/$*100}%`}},`match-${re}-${Z}`))},Ke=(f,k)=>{var H,W,G;if(!(f!=null&&f.rect)||!I.width)return null;const D=(H=i==null?void 0:i.hierarchy)==null?void 0:H.rect;let $=((W=i==null?void 0:i.metadata)==null?void 0:W.screenWidth)||I.width,z=((G=i==null?void 0:i.metadata)==null?void 0:G.screenHeight)||I.height;return D&&D.width>0&&D.height>0&&($=D.width,z=D.height),t.jsx("div",{className:`omni-frame-${k}`,style:{left:`${f.rect.x/$*100}%`,top:`${f.rect.y/z*100}%`,width:`${f.rect.width/$*100}%`,height:`${f.rect.height/z*100}%`}})},xt=i!=null&&i.hierarchy?Ce(i.hierarchy):0,ce=c?Js(c):null,Tt={stable:{icon:t.jsx(Ts,{size:10}),cls:"stable"},moderate:{icon:t.jsx(ds,{size:10}),cls:"moderate"},fragile:{icon:t.jsx(ts,{size:10}),cls:"fragile"},"very-fragile":{icon:t.jsx(ts,{size:10}),cls:"very-fragile"}},yt=r&&(i!=null&&i.hierarchy)?$t(i.hierarchy):[];return t.jsx("div",{className:`omni-inspector-container ${r?"omni-embedded":""}`,children:t.jsxs("div",{className:"omni-main-content",children:[!r&&t.jsxs("div",{className:"omni-screenshot-panel",children:[t.jsxs("div",{className:"omni-screenshot-header",children:[t.jsxs("div",{className:"omni-header-left",children:[t.jsx("span",{className:"omni-screenshot-title",children:"Device Preview"}),t.jsxs("div",{className:"omni-mode-toggle",children:[t.jsxs("button",{className:`omni-mode-btn ${O==="inspect"?"active":""}`,onClick:()=>J("inspect"),title:"Inspection Mode (Highlight Elements)",children:[t.jsx(ei,{size:12}),t.jsx("span",{children:"Inspect"})]}),t.jsxs("button",{className:`omni-mode-btn ${O==="interact"?"active":""}`,onClick:()=>J("interact"),title:"Interaction Mode (Direct Control)",children:[t.jsx(nr,{size:12}),t.jsx("span",{children:"Interact"})]})]})]}),t.jsxs("button",{className:"omni-refresh-btn",onClick:pe,disabled:a,children:[t.jsx(St,{size:12,className:a?"animate-spin":""}),a?"Capturing...":"Refresh"]})]}),t.jsxs("div",{className:"omni-screenshot-container",ref:ye,children:[a&&!Be&&t.jsxs("div",{className:"omni-loading-overlay",children:[t.jsx("div",{className:"omni-spinner"}),t.jsx("span",{children:"Capturing screen..."})]}),!i&&!a&&!Be&&t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(ns,{size:40}),t.jsx("span",{children:"Click Refresh to capture"})]}),Be&&t.jsxs("div",{className:`omni-screenshot-wrapper ${O==="interact"?"interactable":""}`,onMouseDown:me,onMouseUp:Le,children:[t.jsx("img",{ref:ve,src:n,onLoad:Me,onError:Fe,className:"omni-screenshot-img",style:O==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),(i==null?void 0:i.hierarchy)&&O==="inspect"&&t.jsxs("div",{className:"omni-overlay",children:[ge(i.hierarchy),at(),Ke(x,"hover"),Ke(c,"select")]})]}),!Be&&(i==null?void 0:i.screenshot)&&t.jsxs("div",{className:`omni-screenshot-wrapper ${O==="interact"?"interactable":""}`,onMouseDown:me,onMouseUp:Le,children:[t.jsx("img",{ref:st,src:`data:image/png;base64,${i.screenshot}`,onLoad:it,className:"omni-screenshot-img",style:O==="interact"?{pointerEvents:"none"}:{},draggable:!1}),O==="inspect"&&t.jsxs("div",{className:"omni-overlay",children:[ge(i.hierarchy),at(),Ke(x,"hover"),Ke(c,"select")]})]})]})]}),t.jsxs("div",{className:"omni-tree-panel",children:[t.jsxs("div",{className:"omni-tree-header",children:[t.jsxs("div",{className:"omni-tree-title",children:[t.jsx(si,{size:14}),t.jsx("span",{children:"Source"}),xt>0&&t.jsxs("span",{className:"omni-count-badge",children:[xt," elements"]})]}),t.jsxs("div",{className:"omni-tree-actions",children:[t.jsx("button",{onClick:He,className:"omni-action-btn",title:"Expand All",children:t.jsx(Di,{size:12})}),t.jsx("button",{onClick:Ve,className:"omni-action-btn",title:"Collapse All",children:t.jsx(Ui,{size:12})}),r&&t.jsx("button",{onClick:pe,className:"omni-action-btn",title:a?"Capturing…":"Refresh snapshot",disabled:a,children:t.jsx(St,{size:12,className:a?"animate-spin":""})})]})]}),t.jsxs("div",{className:"omni-tree-search",children:[t.jsx(ls,{size:14}),t.jsx("input",{type:"text",placeholder:"Search elements... (try 'login button' or 'text field')",value:p,onChange:f=>S(f.target.value),"aria-label":"Search elements"}),p&&t.jsx("button",{onClick:()=>S(""),className:"omni-clear-btn",children:"×"})]}),p&&t.jsxs("div",{className:"omni-search-hint",children:[t.jsx(ms,{size:10}),' Smart search active — try "button", "input", "image"']}),t.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?Xe(i.hierarchy):t.jsx("div",{className:"omni-empty-state small",children:t.jsx("span",{children:"No hierarchy loaded"})})})]}),t.jsxs("div",{className:"omni-details-panel",children:[t.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[t.jsxs("button",{className:`omni-details-tab ${v==="info"?"active":""}`,onClick:()=>E("info"),role:"tab","aria-selected":v==="info",children:[t.jsx(Pi,{size:12})," ",t.jsx("span",{children:"Info"})]}),t.jsxs("button",{className:`omni-details-tab ${v==="insight"?"active":""}`,onClick:()=>E("insight"),disabled:!c,title:"AI Element Analysis",role:"tab","aria-selected":v==="insight",children:[t.jsx(Li,{size:12})," ",t.jsx("span",{children:"AI Insight"})]}),t.jsxs("button",{className:`omni-details-tab ${v==="code"?"active":""}`,onClick:()=>E("code"),disabled:!c,title:"Generate Test Code",role:"tab","aria-selected":v==="code",children:[t.jsx(_s,{size:12})," ",t.jsx("span",{children:"Code Gen"})]})]}),t.jsx("div",{className:"omni-details-content",children:c?t.jsxs(t.Fragment,{children:[v==="info"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Element Info"}),t.jsxs("div",{className:"omni-info-table",children:[t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Type"}),t.jsx("span",{className:"omni-info-value mono",children:c.type})]}),c.text&&t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Text"}),t.jsx("span",{className:"omni-info-value",children:c.text})]}),t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Path"}),t.jsx("span",{className:"omni-info-value mono small",children:Qt(c).join(" › ")})]})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Layout"}),t.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(f=>t.jsxs("div",{className:"omni-layout-item",children:[t.jsx("span",{className:"omni-layout-label",children:f.toUpperCase()}),t.jsx("span",{className:"omni-layout-value",children:c.rect[f]})]},f))})]}),t.jsxs("div",{className:"omni-section",children:[t.jsxs("div",{className:"omni-section-header",children:["Locators",t.jsx("span",{className:"omni-section-badge",children:"Stability Scored"})]}),t.jsx("div",{className:"omni-locators-list",children:(ot=c.suggestedLocators)==null?void 0:ot.map(f=>{const k=Gs(f.strategy,f.value),D=Tt[k.level],$=_[f.strategy];let z=null;return $&&($.kind==="unsupported"?z=t.jsxs("span",{className:"omni-match-badge unsupported",title:$.reason||"Cannot evaluate without a real driver",children:[t.jsx(wi,{size:10})," preview unavailable"]}):$.nodes.length===0?z=t.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[t.jsx(ts,{size:10})," 0 matches"]}):$.nodes.length===1?z=t.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[t.jsx(Ts,{size:10})," unique"]}):z=t.jsxs("span",{className:"omni-match-badge multi",title:`${$.nodes.length} elements match — selector is not unique`,children:[t.jsx(ds,{size:10})," ",$.nodes.length," matches"]})),t.jsxs("div",{className:`omni-locator-row ${(M==null?void 0:M.strategy)===f.strategy?"selected-for-code":""}`,onClick:()=>V(f),title:"Click to use in Code Generator",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsxs("div",{className:"omni-locator-top",children:[t.jsx("span",{className:"omni-locator-strategy",children:f.strategy}),t.jsxs("span",{className:`omni-stability-badge ${D.cls}`,title:k.reason,children:[D.icon,k.level]}),z]}),t.jsx("code",{className:"omni-locator-value",children:f.value}),t.jsx("span",{className:"omni-stability-reason",children:k.reason})]}),t.jsxs("div",{className:"omni-locator-actions",children:[t.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),nt(f.strategy,f.value)},className:`omni-test-btn ${re===f.strategy?"active":""}`,title:"Test this locator against the current snapshot",children:t.jsx(ki,{size:12})}),t.jsx("button",{onClick:H=>{H.stopPropagation(),qe(f.value,f.strategy)},className:`omni-copy-btn ${j===f.strategy?"copied":""}`,children:j===f.strategy?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]})]},f.strategy)})})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Attributes"}),t.jsx("div",{className:"omni-attributes-table",children:Object.entries(c.attributes||{}).filter(([f,k])=>k!=null&&k!=="").map(([f,k])=>t.jsxs("div",{className:"omni-attr-row",children:[t.jsx("span",{className:"omni-attr-key",children:f}),t.jsx("span",{className:"omni-attr-value",children:String(k)})]},f))})]})]}),v==="insight"&&ce&&t.jsxs("div",{className:"omni-insight-panel",children:[t.jsxs("div",{className:"omni-insight-role",children:[t.jsx("span",{className:"omni-insight-emoji",children:ce.emoji}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-insight-role-name",children:ce.role}),t.jsx("div",{className:"omni-insight-interactable",children:ce.interactable?t.jsxs("span",{className:"omni-badge-green",children:[t.jsx(on,{size:10})," Interactable"]}):t.jsx("span",{className:"omni-badge-gray",children:"Visual Only"})})]})]}),ce.warning&&t.jsx("div",{className:"omni-insight-warning",children:ce.warning}),t.jsxs("div",{className:"omni-insight-description",children:[t.jsx(ms,{size:12,className:"omni-insight-icon"}),t.jsx("p",{children:ce.description})]}),ce.bestLocator&&t.jsxs("div",{className:"omni-insight-best-locator",children:[t.jsx("div",{className:"omni-section-header",children:"Recommended Locator"}),t.jsxs("div",{className:"omni-locator-row",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsx("span",{className:"omni-locator-strategy",children:ce.bestLocator.strategy}),t.jsx("code",{className:"omni-locator-value",children:ce.bestLocator.value})]}),t.jsx("button",{onClick:()=>qe(ce.bestLocator.value,"best"),className:`omni-copy-btn ${j==="best"?"copied":""}`,children:j==="best"?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]})]}),t.jsxs("div",{className:"omni-insight-attributes",children:[t.jsx("div",{className:"omni-section-header",children:"Quick Facts"}),t.jsx("div",{className:"omni-quick-facts",children:[{label:"Clickable",value:(Ye=c.attributes)==null?void 0:Ye.clickable},{label:"Enabled",value:(vt=c.attributes)==null?void 0:vt.enabled},{label:"Scrollable",value:(Mt=c.attributes)==null?void 0:Mt.scrollable},{label:"Focusable",value:(bt=c.attributes)==null?void 0:bt.focusable},{label:"Children",value:((Ge=c.children)==null?void 0:Ge.length)||0}].map(({label:f,value:k})=>t.jsxs("div",{className:"omni-quick-fact-row",children:[t.jsx("span",{className:"omni-quick-fact-label",children:f}),t.jsx("span",{className:`omni-quick-fact-value ${k==="true"||k===!0?"true":""}`,children:String(k??"—")})]},f))})]})]}),v==="code"&&t.jsxs("div",{className:"omni-codegen-panel",children:[t.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(f=>t.jsx("button",{className:`omni-fw-btn ${A===f?"active":""}`,onClick:()=>T(f),children:f==="java"?"☕ Java":f==="python"?"🐍 Python":f==="javascript"?"🟨 JS":"🔷 WD.io"},f))}),M?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-codegen-locator-selector",children:[t.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),t.jsx("select",{value:M.strategy,onChange:f=>{var D;const k=(D=c.suggestedLocators)==null?void 0:D.find($=>$.strategy===f.target.value);k&&V(k)},className:"omni-fw-select",children:(wt=c.suggestedLocators)==null?void 0:wt.map(f=>t.jsxs("option",{value:f.strategy,children:[f.strategy," — ",Gs(f.strategy,f.value).level]},f.strategy))})]}),t.jsxs("div",{className:"omni-codegen-output",children:[t.jsxs("div",{className:"omni-codegen-header",children:[t.jsx("span",{className:"omni-codegen-lang",children:A==="java"?"Java / TestNG":A==="python"?"Python / unittest":A==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),t.jsx("button",{className:"omni-copy-btn",onClick:()=>qe(Zs(c,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",A,M),"code"),children:j==="code"?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]}),t.jsx("pre",{className:"omni-codegen-pre",children:t.jsx("code",{children:Zs(c,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",A,M)})})]})]}):t.jsxs("div",{className:"omni-empty-state small",children:[t.jsx(_s,{size:24}),t.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?t.jsxs("div",{className:"omni-summary-panel",children:[t.jsxs("div",{className:"omni-summary-hero",children:[t.jsx(ns,{size:28}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-summary-title",children:"No element selected"}),t.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Snapshot Stats"}),t.jsxs("div",{className:"omni-summary-stats",children:[t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),t.jsx("span",{className:"omni-summary-stat__value",children:xt})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),t.jsx("span",{className:"omni-summary-stat__value",children:((Se=i.metadata)==null?void 0:Se.screenWidth)??I.width??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),t.jsx("span",{className:"omni-summary-stat__value",children:((ke=i.metadata)==null?void 0:ke.screenHeight)??I.height??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),t.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),yt.length>0&&t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"By Role"}),t.jsx("div",{className:"omni-summary-roles",children:yt.slice(0,8).map(f=>t.jsxs("div",{className:"omni-summary-role",children:[t.jsx("span",{className:"omni-summary-role__emoji",children:f.emoji}),t.jsx("span",{className:"omni-summary-role__name",children:f.role}),t.jsx("span",{className:"omni-summary-role__count",children:f.count})]},f.role))})]})]}):t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(ns,{size:32}),t.jsx("span",{children:a?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})})};function zo({device:e,onClose:s}){var Qe;const{toast:n,removeToast:r}=en(),a=ys(),{tab:o}=sn(),i=m.useRef(null),l=m.useRef(null),[d,u]=m.useState({width:0,height:0}),[c,h]=m.useState(o||"actions"),[x,g]=m.useState(""),[b,y]=m.useState(""),[p,S]=m.useState(""),[j,w]=m.useState(!0),[v,E]=m.useState([]),[A,T]=m.useState(null),[M,V]=m.useState(!1),[I,Y]=m.useState(!1),[q,K]=m.useState(0),[N,ne]=m.useState(e),[O,J]=m.useState([]),[_,Q]=m.useState(!1),[re,Ne]=m.useState(!1),[ye,st]=m.useState(null),[ve,Te]=m.useState([]),[de,nt]=m.useState(!0),[pe,it]=m.useState(""),[Fe,Me]=m.useState(!1),[Be,me]=m.useState(0),[Le,rt]=m.useState(!1),[He,Ve]=m.useState(!1),qe=10,[Ce,$t]=m.useState(!1),Qt=()=>{navigator.clipboard.writeText(N.udid).catch(()=>{}),$t(!0),setTimeout(()=>$t(!1),1500)},Xe=m.useRef(""),ge=m.useRef(null),[at,Ke]=m.useState(!1);m.useEffect(()=>{c&&(!o||o!==c)&&a(`/devices/${e.udid}/control/${c}`,{replace:!0})},[c,o,e.udid,a]),m.useEffect(()=>{let C;if(c==="logs"){Me(!1),me(0);const R=async()=>{try{const L=await P.getLogs(N.udid);if(me(F=>F+1),L&&L.logs&&L.logs.trim().length>0){Me(!0);const F=L.logs.replace(/\\u[0-9a-fA-F]{4}/g,X=>JSON.parse(`"${X}"`)).replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"").split(`
208
- `).filter(X=>X.trim().length>0);F.length>0&&Te(X=>[...X,...F].slice(-1e3))}else me(F=>(F>=3&&Me(!0),F))}catch(L){console.error("Failed to fetch logs:",L),me(F=>(F>=3&&Me(!0),F))}};R(),C=setInterval(R,3e3)}return()=>clearInterval(C)},[c,N.udid]);const xt=()=>{if(ve.length===0)return t.jsx("div",{className:"log-empty-state",children:Fe?t.jsxs(t.Fragment,{children:[t.jsx(us,{size:28,style:{color:"var(--text-muted)",marginBottom:12,opacity:.4}}),t.jsx("p",{className:"log-empty-title",children:"No log output yet"}),t.jsx("p",{className:"log-empty-subtitle",children:"The log stream is active but the device is quiet. Interact with the device to generate logs."})]}):t.jsxs(t.Fragment,{children:[t.jsx(It,{size:28,className:"animate-spin",style:{color:"var(--green)",marginBottom:12}}),t.jsx("p",{className:"log-empty-title",children:"Connecting to device syslog..."}),t.jsxs("p",{className:"log-empty-subtitle",children:["Initializing persistent log stream for ",N.name]})]})});const C=ve.filter(R=>!pe||R.toLowerCase().includes(pe.toLowerCase()));return C.length===0&&pe?t.jsxs("div",{className:"log-empty-state",children:[t.jsx(ls,{size:28,style:{color:"var(--text-muted)",marginBottom:12,opacity:.4}}),t.jsxs("p",{className:"log-empty-title",children:['No matches for "',pe,'"']}),t.jsxs("p",{className:"log-empty-subtitle",children:[ve.length," lines in buffer. Try a different search term."]})]}):C.map((R,L)=>{let F="log-debug";const X=R.toLowerCase();return X.includes("error")||X.includes("fail")?F="log-error":X.includes("warning")||X.includes("warn")?F="log-warn":(X.includes("notice")||X.includes("info"))&&(F="log-notice"),t.jsxs("div",{className:`log-line ${F}`,children:[t.jsx("span",{className:"log-index",children:L+1}),t.jsx("span",{className:"log-content",children:R})]},`${L}-${R.substring(0,10)}`)})};m.useEffect(()=>{c==="logs"&&de&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[ve,c,de]),m.useEffect(()=>((async()=>{try{Y(!0),await P.startStream(N.udid);const L=(await P.getDevices()).find(F=>F.udid===N.udid);L&&ne(L)}catch(R){console.error("Auto-start stream failed:",R)}finally{Y(!1)}})(),()=>{P.stopStream(N.udid).catch(()=>{})}),[e.udid]);const ce=m.useCallback(async()=>{try{Q(!0);const C=await P.listApps(N.udid);Array.isArray(C)&&J(C)}catch(C){console.error("Failed to load apps:",C)}finally{Q(!1)}},[N.udid]);m.useEffect(()=>{c==="actions"&&ce()},[c,ce]);const Tt=parseInt(N.screenWidth||"1080",10),yt=parseInt(N.screenHeight||"1920",10),Se=Math.min(Tt,yt),ke=Math.max(Tt,yt),ot=Se/ke,Ye=m.useCallback(()=>{const C=!j,R=C?window.innerHeight*.55:window.innerHeight*.7,L=620,X=window.innerWidth>900;let ee;C?ee=X?Math.min(window.innerWidth*.8,window.innerWidth-L):window.innerWidth*.8:ee=window.innerWidth*.45;const le=j?ot:1/ot;let te,se;j?(te=R,se=te*le,se>ee&&(se=ee,te=se/le)):(se=ee,te=se/le,te>R&&(te=R,se=te*le)),u({width:se,height:te})},[ot,j]);m.useEffect(()=>(Ye(),window.addEventListener("resize",Ye),()=>window.removeEventListener("resize",Ye)),[Ye]),m.useEffect(()=>{const C=async()=>{if(Xe.current.length>0){const L=Xe.current;Xe.current="";try{await P.typeText(N.udid,L)}catch(F){console.error("Keyboard buffering flush failed:",F)}}},R=L=>{const F=document.activeElement;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable)||!at&&c!=="terminal")return;const ee=L.key;ee==="Enter"?(ge.current&&clearTimeout(ge.current),C(),P.pressKey(N.udid,N.platform==="android"?66:"enter")):ee==="Backspace"?(ge.current&&clearTimeout(ge.current),C(),P.pressKey(N.udid,N.platform==="android"?67:"backspace")):ee.length===1&&(Xe.current+=ee,ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{C()},50))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),ge.current&&clearTimeout(ge.current)}},[N.udid,N.platform,at,c]);const[vt,Mt]=m.useState(Date.now()),bt=()=>{const C=q>0?`r=${q}&`:"";return N.session_id&&!String(N.session_id).startsWith("manual_")?`/xenon/api/session/${N.session_id}/live_video?${C}t=${vt}`:`/xenon/api/control/${N.udid}/stream?${C}t=${vt}`};m.useEffect(()=>{q>0&&Mt(Date.now())},[q]),m.useEffect(()=>{if(Le||He)return;const C=setTimeout(()=>Ve(!0),3e4);return()=>clearTimeout(C)},[Le,He,q]);const Ge=m.useRef(null),wt=C=>{const R=C.currentTarget.getBoundingClientRect();return{x:C.clientX-R.left,y:C.clientY-R.top}},f=C=>{const R=wt(C);Ge.current={x:R.x,y:R.y,time:Date.now()}},k=async C=>{var Ds;if(!Ge.current)return;const R=Ge.current,L=wt(C),F=Date.now()-R.time,X=(Ds=i.current)==null?void 0:Ds.getBoundingClientRect(),ee=(X==null?void 0:X.width)||d.width,le=(X==null?void 0:X.height)||d.height;let te,se,ct,Lt;j?(te=R.x/ee*Se,se=R.y/le*ke,ct=L.x/ee*Se,Lt=L.y/le*ke):(te=R.x/ee*ke,se=R.y/le*Se,ct=L.x/ee*ke,Lt=L.y/le*Se);const Rs=Math.abs(ct-te),Es=Math.abs(Lt-se);try{F<500&&Rs<10&&Es<10?await P.tap(N.udid,Math.round(te),Math.round(se)):F>=500&&Rs<10&&Es<10?await P.touchAndHold(N.udid,Math.round(te),Math.round(se),F):await P.swipe(N.udid,Math.round(te),Math.round(se),Math.round(ct),Math.round(Lt))}catch(_n){console.error("Action failed:",_n)}Ge.current=null},D=()=>P.pressKey(N.udid,N.platform==="android"?jt.HOME:ss.HOME),$=()=>P.pressKey(N.udid,jt.BACK),z=()=>P.pressKey(N.udid,jt.APP_SWITCH),H=()=>P.pressKey(N.udid,N.platform==="android"?jt.VOLUME_UP:ss.VOLUME_UP),W=()=>P.pressKey(N.udid,N.platform==="android"?jt.VOLUME_DOWN:ss.VOLUME_DOWN),G=()=>P.lock(N.udid),U=()=>P.unlock(N.udid),Z=async()=>{x.trim()&&(await P.typeText(N.udid,x),g(""))},ue=async()=>{try{y("Fetching...");const C=await P.getClipboard(N.udid);C&&C.content!==void 0?y(C.content||"(Clipboard is empty)"):y("No content received")}catch{y("Error: Check Appium Settings app")}},xe=async()=>{V(!0);try{const C=await P.getScreenshot(N.udid);if(C!=null&&C.screenshot){const R={id:Ao(),base64:C.screenshot,timestamp:Date.now()};E(L=>[R,...L]),T(0)}}catch(C){console.error("Failed to take screenshot:",C)}finally{V(!1)}},ie=C=>{E(R=>{const L=R.filter(F=>F.id!==C);return L.length===0?T(null):A!==null&&A>=L.length&&T(0),L})},Ae=()=>{E([]),T(null),n("Cleared all captured evidence.","success")},be=C=>{const R=document.createElement("a");R.href=`data:image/png;base64,${C}`,R.download=`screenshot-${N.udid}-${Date.now()}.png`,R.click()},ae=async C=>{const R=Se/2,L=ke/2,F=Se*.4,X=ke*.4;let ee,le,te,se;switch(C){case"left":ee=R+F,le=L,te=R-F,se=L;break;case"right":ee=R-F,le=L,te=R+F,se=L;break;case"up":ee=R,le=L+X,te=R,se=L-X;break;case"down":ee=R,le=L-X,te=R,se=L+X;break}try{await P.swipe(N.udid,Math.round(ee),Math.round(le),Math.round(te),Math.round(se))}catch(ct){console.error(`Quick swipe ${C} failed:`,ct)}},Ze=async()=>{if(p.trim()){const C=n(`Uninstalling ${p}...`,"loading",0);try{Q(!0),await P.uninstallApp(N.udid,p),S(""),n(`Request sent for ${p}`,"success"),setTimeout(ce,3e3)}catch{n("Uninstall failed. Check logs.","error")}finally{Q(!1),r(C)}}},Je=async()=>{if(!ye)return;let C;try{Ne(!0),C=n(`Installing app to ${N.udid}...`,"loading",0);const R=await P.uploadAndInstallApp(N.udid,ye);R.success?(n(R.message||"App installed successfully","success"),st(null),setTimeout(ce,5e3)):n("Installation failed: "+(R.error||"Unknown error"),"error")}catch(R){n("Installation failed: "+R.message,"error")}finally{C&&r(C),Ne(!1)}};return t.jsxs("div",{className:"device-control-view",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"control-view-top-bar",children:[t.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[t.jsx(es,{size:18})," DEVICES"]}),t.jsxs("div",{className:"device-info-mini",children:[t.jsx("span",{className:`device-pill platform-pill ${N.platform}`,children:N.platform==="ios"?"Apple":"Android"}),t.jsxs("span",{className:"device-pill version-pill",children:["v",N.sdk]}),N.reservedUntil&&Date.now()<N.reservedUntil&&t.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${N.reservedBy}${N.reservationReason?`: ${N.reservationReason}`:""}`,children:["RESERVED BY ",((Qe=N.reservedBy)==null?void 0:Qe.toUpperCase())||"ANONYMOUS"]}),t.jsx("h2",{className:"device-name-text",children:N.name}),t.jsxs("span",{className:"udid-chip",title:N.udid,children:[t.jsx("span",{className:"udid-chip__value",children:N.udid}),t.jsx("button",{type:"button",className:"udid-chip__copy",onClick:Qt,"aria-label":"Copy UDID",title:Ce?"Copied!":"Copy UDID",children:Ce?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]})]})]}),t.jsxs("div",{className:`control-view-main ${j?"":"is-landscape"} ${c==="omni"?"omni-mode":""}`,children:[t.jsxs("div",{className:"device-preview-column",children:[t.jsx("div",{className:"device-screen-wrapper",children:t.jsxs("div",{ref:i,className:`device-stream-canvas ${j?"":"landscape"} ${at?"focused":""}`,style:{width:d.width,height:d.height,background:"#000"},tabIndex:0,onFocus:()=>Ke(!0),onBlur:()=>Ke(!1),onMouseDown:f,onMouseUp:k,children:[He?t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(ds,{size:40,color:"var(--red, #f87171)"}),t.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),t.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{Ve(!1),K(0)},children:"Retry"})]}):(I||!Le)&&t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(St,{size:40,className:"animate-spin",color:"var(--green)"}),t.jsx("p",{style:{marginTop:16},children:I?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!He&&t.jsx("img",{src:bt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>rt(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),rt(!1),q>=qe){Ve(!0);return}setTimeout(()=>K(C=>C+1),2e3)}})]})}),t.jsxs("aside",{className:"device-footer-actions",children:[t.jsxs("button",{className:`footer-action-btn ${j?"active":""}`,onClick:()=>w(!0),children:[t.jsx(St,{size:14,style:{transform:j?"none":"rotate(-90deg)"}})," ","PORTRAIT"]}),t.jsxs("button",{className:`footer-action-btn ${j?"":"active"}`,onClick:()=>w(!1),children:[t.jsx(St,{size:14,style:{transform:"rotate(90deg)"}})," LANDSCAPE"]}),t.jsx("div",{className:"footer-divider"}),t.jsxs("button",{className:"footer-action-btn",onClick:D,children:[t.jsx(Ti,{size:20})," HOME"]}),N.platform==="android"&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"footer-action-btn",onClick:$,title:"Back",children:[t.jsx(es,{size:20})," BACK"]}),t.jsxs("button",{className:"footer-action-btn",onClick:z,title:"App Switcher",children:[t.jsx(Gi,{size:20})," APPS"]})]}),t.jsx("div",{className:"footer-divider"}),t.jsxs("button",{className:"footer-action-btn",onClick:H,title:"Volume Up",children:[t.jsx(or,{size:20})," VOL+"]}),t.jsxs("button",{className:"footer-action-btn",onClick:W,title:"Volume Down",children:[t.jsx(rr,{size:20})," VOL−"]}),t.jsx("button",{className:"footer-action-btn",onClick:G,title:"Lock Device","aria-label":"Lock device",children:t.jsx(ni,{size:20})}),t.jsx("button",{className:"footer-action-btn",onClick:U,title:"Unlock Device","aria-label":"Unlock device",children:t.jsx(_i,{size:20})})]})]}),t.jsxs("div",{className:"device-interactions-column",children:[t.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[t.jsxs("button",{className:`tab-btn ${c==="actions"?"active":""}`,onClick:()=>h("actions"),role:"tab","aria-selected":c==="actions",children:[t.jsx(on,{size:13}),t.jsx("span",{children:"Actions"})]}),t.jsxs("button",{className:`tab-btn ${c==="screenshot"?"active":""}`,onClick:()=>h("screenshot"),role:"tab","aria-selected":c==="screenshot",children:[t.jsx(Nt,{size:13}),t.jsx("span",{children:"Screenshot"})]}),t.jsxs("button",{className:`tab-btn ${c==="logs"?"active":""}`,onClick:()=>h("logs"),role:"tab","aria-selected":c==="logs",children:[t.jsx(Xi,{size:13}),t.jsx("span",{children:"Debug Logs"})]}),t.jsxs("button",{className:`tab-btn ${c==="terminal"?"active":""}`,onClick:()=>h("terminal"),role:"tab","aria-selected":c==="terminal",children:[t.jsx(us,{size:13}),t.jsx("span",{children:"Shell"})]}),t.jsxs("button",{className:`tab-btn ${c==="omni"?"active":""}`,onClick:()=>h("omni"),role:"tab","aria-selected":c==="omni",children:[t.jsx(ms,{size:13}),t.jsx("span",{children:"Omni-Vision"})]})]}),t.jsx("div",{className:`interactions-scroll-area ${c==="terminal"?"terminal-mode":""} ${c==="screenshot"||c==="logs"?"screenshot-mode":""}`,children:t.jsxs("div",{className:"tab-content",children:[c==="omni"&&t.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:t.jsx(Po,{sessionId:N.session_id?String(N.session_id):null,udid:N.udid,streamUrl:bt(),embedded:!0})}),c==="actions"&&t.jsxs("div",{className:"actions-grid",children:[t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(ti,{size:18,color:"var(--green)"})," Smart Input"]}),t.jsx("p",{className:"action-card-hint",children:"Relay keystrokes to the focused element on the device."}),t.jsx("input",{type:"text",className:"type-input-field compact",placeholder:"Type and press Enter to send…",value:x,onChange:C=>g(C.target.value),onKeyDown:C=>C.key==="Enter"&&Z()})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Un,{size:18,color:"var(--green)"})," App Management"]}),t.jsxs("div",{className:"app-mgmt-content",children:[t.jsxs("div",{className:"install-section",children:[t.jsx("p",{className:"compact-label",children:"Install Package (.apk, .ipa, .app)"}),t.jsxs("div",{className:"upload-box-row",children:[t.jsxs("label",{className:"file-upload-launcher",children:[t.jsx(Vn,{size:14}),t.jsx("span",{children:ye?ye.name:"Select File"}),t.jsx("input",{type:"file",accept:".apk,.ipa,.app",onChange:C=>{var R;return st(((R=C.target.files)==null?void 0:R[0])||null)},hidden:!0})]}),t.jsx("button",{className:"btn-premium btn-sm",disabled:!ye||re,onClick:Je,children:re?t.jsx(It,{className:"animate-spin",size:14}):"INSTALL"})]})]}),t.jsx("div",{className:"divider-v"}),t.jsxs("div",{className:"uninstall-section",children:[t.jsx("p",{className:"compact-label",children:"Quick Uninstall"}),t.jsxs("div",{className:"uninstall-controls-row",children:[t.jsxs("div",{className:"select-wrapper",children:[t.jsxs("select",{className:"app-select-dropdown compact",value:p,onChange:C=>S(C.target.value),disabled:_,children:[t.jsx("option",{value:"",children:_?"Loading apps...":"-- Select App to Remove --"}),O.map(C=>t.jsx("option",{value:C,children:C},C))]}),_&&t.jsx(It,{className:"animate-spin select-loader",size:12})]}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:Ze,disabled:!p||_,children:[t.jsx(_t,{size:14})," UNINSTALL"]})]}),t.jsxs("div",{className:"manual-input-box",children:[t.jsx("p",{className:"hint-text",children:"Or enter manually:"}),t.jsx("input",{type:"text",className:"type-input-field tiny",placeholder:"com.example.app",value:p,onChange:C=>S(C.target.value)})]})]})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Ni,{size:18,color:"var(--green)"})," Clipboard"]}),t.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[t.jsx("button",{className:"btn-premium btn-sm",style:{width:"140px",flexShrink:0},onClick:ue,children:"FETCH VALUE"}),t.jsx("div",{className:"clipboard-display compact",style:{marginTop:0,flex:1},children:b})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Hi,{size:18,color:"var(--green)"})," Directional Gestures"]}),t.jsxs("div",{className:"gestures-grid-container",children:[t.jsxs("div",{className:"gestures-dpad",children:[t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("up"),children:t.jsx(vi,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("left"),children:t.jsx(es,{size:24})}),t.jsx("div",{className:"dpad-center"}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("right"),children:t.jsx(cn,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("down"),children:t.jsx(tn,{size:24})}),t.jsx("div",{})]}),t.jsx("p",{className:"compact-label",style:{opacity:.5},children:"Quick swipe in a direction"})]})]})]}),c==="screenshot"&&t.jsxs("div",{className:"action-card screenshot-card",children:[t.jsxs("header",{className:"action-card-header",children:[t.jsxs("div",{className:"title-group",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Nt,{size:20,color:"var(--green)"})," Captured Evidence"]}),t.jsx("p",{className:"hint-text",children:"Relay screenshots from device to host."})]}),v.length>0&&t.jsx("button",{className:"btn-text-only",onClick:Ae,children:"CLEAR ALL"})]}),t.jsxs("div",{className:"screenshot-workspace",children:[t.jsxs("div",{className:"screenshot-gallery-sidebar",children:[t.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:xe,disabled:M,children:[M?t.jsx(It,{className:"animate-spin",size:16}):t.jsx(Nt,{size:16}),t.jsx("span",{children:M?"CAPTURING...":"NEW CAPTURE"})]}),t.jsxs("div",{className:"screenshot-thumbnails-list",children:[v.length===0&&!M&&t.jsxs("div",{className:"empty-gallery-state",children:[t.jsx(Nt,{size:20,className:"empty-gallery-icon"}),t.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),t.jsxs("p",{className:"empty-gallery-hint",children:["Click ",t.jsx("strong",{children:"New Capture"})," above to grab a screenshot."]})]}),v.map((C,R)=>t.jsxs("div",{className:`screenshot-thumb-item ${A===R?"active":""}`,onClick:()=>T(R),children:[t.jsx("img",{src:`data:image/png;base64,${C.base64}`,alt:"Thumb"}),t.jsx("span",{className:"thumb-time",children:new Date(C.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),t.jsx("button",{className:"thumb-delete-btn",onClick:L=>{L.stopPropagation(),ie(C.id)},children:t.jsx(_t,{size:12})})]},C.id))]})]}),t.jsx("div",{className:"screenshot-main-preview",children:A!==null&&v[A]?t.jsxs("div",{className:"preview-container",children:[t.jsx("div",{className:"preview-image-wrapper",children:t.jsx("img",{src:`data:image/png;base64,${v[A].base64}`,alt:"Selected Evidence"})}),t.jsxs("footer",{className:"preview-footer",children:[t.jsxs("div",{className:"preview-meta",children:[t.jsx("span",{className:"meta-label",children:"ID:"}),t.jsx("span",{className:"meta-value",children:v[A].id.substring(0,8)}),t.jsx("span",{className:"meta-divider",children:"|"}),t.jsx("span",{className:"meta-value",children:Qn(v[A].timestamp)})]}),t.jsxs("div",{className:"preview-actions",children:[t.jsx("button",{className:"btn-premium btn-sm",onClick:()=>be(v[A].base64),children:"DOWNLOAD PNG"}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>ie(v[A].id),children:[t.jsx(_t,{size:14})," DELETE"]})]})]})]}):t.jsxs("div",{className:"preview-empty-placeholder",children:[t.jsx(Nt,{size:48,style:{opacity:.1,marginBottom:16}}),t.jsx("p",{children:"Capture a screenshot to begin analysis"})]})})]})]}),c==="logs"&&t.jsxs("div",{className:"action-card screenshot-card",style:{padding:0,gap:0},children:[t.jsxs("div",{className:"log-toolbar",children:[t.jsxs("div",{className:"log-filter-group",children:[t.jsxs("div",{className:"log-stat-pill",children:[t.jsx("span",{className:`log-live-dot ${Fe?"active":""}`}),Fe?"LIVE":"CONNECTING"]}),t.jsxs("div",{className:"log-stat-pill",style:{opacity:.6},children:[ve.length," LINES"]}),t.jsxs("div",{className:"log-search-box",children:[t.jsx(ls,{size:14,className:"search-icon-inline"}),t.jsx("input",{type:"text",className:"type-input-field tiny",placeholder:"Filter trace...",value:pe,onChange:C=>it(C.target.value),"aria-label":"Filter debug logs"})]})]}),t.jsxs("div",{className:"log-actions-group",children:[t.jsxs("button",{className:`btn-secondary btn-sm ${de?"active":""}`,onClick:()=>nt(!de),title:de?"Freeze Logs":"Follow Logs",children:[t.jsx(lr,{size:14,className:de?"animate-pulse":""}),de?"FREEZE":"FOLLOW"]}),t.jsxs("button",{className:"btn-premium btn-sm",onClick:()=>{const C=new Blob([ve.join(`
207
+ // Assert with expect(element).toBeDisplayed()`:`// Strategy "${a}" not supported in WebdriverIO mobile`}function Js(e){var g,b,y,p,S,j,w,v,E,A,T;const s=(e.type||"").toLowerCase(),n=((g=e.attributes)==null?void 0:g.clickable)==="true"||((b=e.attributes)==null?void 0:b.clickable)===!0,r=((y=e.attributes)==null?void 0:y.enabled)!=="false"&&((p=e.attributes)==null?void 0:p.enabled)!==!1,a=((S=e.attributes)==null?void 0:S.scrollable)==="true"||((j=e.attributes)==null?void 0:j.scrollable)===!0,o=e.text||e.label||e.value||"",i=((w=e.children)==null?void 0:w.length)||0;let l="Element",d="📦";s.includes("button")||s.includes("btn")||n&&i===0?(l="Button",d="🔘"):s.includes("edit")||s.includes("input")||s.includes("field")?(l="Text Input",d="✏️"):s.includes("image")||s.includes("img")||s.includes("imageview")?(l="Image",d="🖼️"):s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?(l="Scrollable List",d="📜"):s.includes("text")||s.includes("label")?(l="Text Label",d="📝"):s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?(l="Toggle / Checkbox",d="☑️"):s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?(l="Navigation Bar",d="🧭"):i>0&&(l=`Container (${i} children)`,d="🗂️");const u=((v=e.suggestedLocators)==null?void 0:v.find(M=>M.strategy==="accessibility id"||M.strategy==="id"))||((E=e.suggestedLocators)==null?void 0:E[0]),c=r?((A=e.rect)==null?void 0:A.width)===0||((T=e.rect)==null?void 0:T.height)===0?"⚠️ Zero-size element — may not be interactable":void 0:"⚠️ Element is disabled",h=o?` with text "${o.slice(0,30)}"`:"",x=`This is a ${l.toLowerCase()}${h}. ${n?"It can be tapped/clicked.":a?"It supports scrolling.":"It is a visual container."}${i>0?` Contains ${i} child element${i>1?"s":""}.`:""}`;return{role:l,description:x,interactable:n||r,bestLocator:u,warning:c,emoji:d}}function Qs(e,s){if(!s)return!0;const n=s.toLowerCase().trim(),r={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},a=(e.type||"").toLowerCase(),o=(e.text||e.label||e.value||"").toLowerCase(),i=(e.name||"").toLowerCase(),l=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[d,u]of Object.entries(r))if(n.includes(d)&&u.some(c=>a.includes(c)))return!0;return a.includes(n)||o.includes(n)||i.includes(n)||l.includes(n)}const Po=({sessionId:e,udid:s,streamUrl:n,embedded:r=!1})=>{var Se,ke,ot,Ye,vt,Mt,bt,Ge,wt;const[a,o]=m.useState(!0),[i,l]=m.useState(null),[d,u]=m.useState(null),[c,h]=m.useState(null),[x,g]=m.useState(null),[b,y]=m.useState(new Set(["/"])),[p,S]=m.useState(""),[j,w]=m.useState(null),[v,E]=m.useState("info"),[A,T]=m.useState("java"),[M,V]=m.useState(null),[I,Y]=m.useState({width:0,height:0}),[q,K]=m.useState({width:0,height:0}),[N,ne]=m.useState(!1),[O,J]=m.useState("inspect"),[_,Q]=m.useState({}),[re,Ne]=m.useState(null),ye=m.useRef(null),st=m.useRef(null),ve=m.useRef(null),Te=m.useRef(null),de=m.useCallback(()=>{var Z,ue,xe;if(!ye.current)return;const f=ye.current.getBoundingClientRect(),k=f.width,D=f.height,$=(Z=i==null?void 0:i.hierarchy)==null?void 0:Z.rect;let z=((ue=i==null?void 0:i.metadata)==null?void 0:ue.screenWidth)||I.width||1,H=((xe=i==null?void 0:i.metadata)==null?void 0:xe.screenHeight)||I.height||1;$&&$.width>0&&$.height>0&&(z=$.width,H=$.height);const W=z/H;let G,U;k/D>W?(U=D,G=U*W):(G=k,U=G/W),K({width:G,height:U})},[i,I]);m.useEffect(()=>(de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)),[de]),m.useEffect(()=>{s&&pe()},[s]),m.useEffect(()=>{var f;if((f=c==null?void 0:c.suggestedLocators)!=null&&f.length){const k=c.suggestedLocators.find(D=>D.strategy==="accessibility id"||D.strategy==="id")||c.suggestedLocators[0];V(k)}else V(null);Q({}),Ne(null)},[c]);const nt=m.useCallback((f,k)=>{if(!(i!=null&&i.hierarchy))return;const D=Oo(i.hierarchy,f,k);Q($=>({...$,[f]:D})),Ne(f)},[i]),pe=async()=>{if(s){o(!0),u(null);try{const f=await P.getInspectorSnapshot(s);l(f);const k=new Set(["/"]),D=($,z)=>{var H;z<2&&(k.add($.xpath),(H=$.children)==null||H.forEach(W=>D(W,z+1)))};f.hierarchy&&D(f.hierarchy,0),y(k)}catch(f){u(f.message||"Failed to capture snapshot")}finally{o(!1)}}},it=f=>{const{naturalWidth:k,naturalHeight:D}=f.currentTarget;Y({width:k,height:D})},Fe=()=>ne(!0),Me=f=>{ne(!1);const{naturalWidth:k,naturalHeight:D}=f.currentTarget;k>0&&D>0&&Y({width:k,height:D})},Be=n&&!N,me=f=>{if(O!=="interact"||!s)return;const k=f.currentTarget.getBoundingClientRect();Te.current={x:f.clientX-k.left,y:f.clientY-k.top,time:Date.now()}},Le=async f=>{var ae,Ze,Je;if(O!=="interact"||!s||!Te.current)return;const k=Te.current,D=f.currentTarget.getBoundingClientRect(),$=f.clientX-D.left,z=f.clientY-D.top,H=Date.now()-k.time,W=q.width,G=q.height,U=(ae=i==null?void 0:i.hierarchy)==null?void 0:ae.rect;let Z=((Ze=i==null?void 0:i.metadata)==null?void 0:Ze.screenWidth)||I.width,ue=((Je=i==null?void 0:i.metadata)==null?void 0:Je.screenHeight)||I.height;if(U&&U.width>0&&U.height>0&&(Z=U.width,ue=U.height),!Z||!ue||W===0||G===0)return;const xe=(Qe,C)=>({x:Math.round(Qe/W*Z),y:Math.round(C/G*ue),px:Qe/W,py:C/G}),ie=xe(k.x,k.y),Ae=xe($,z),be=Math.sqrt(Math.pow($-k.x,2)+Math.pow(z-k.y,2));if(!(ie.px<0||ie.px>1||ie.py<0||ie.py>1)){try{H<500&&be<10?await P.tap(s,ie.x,ie.y):H>=500&&be<10?await P.touchAndHold(s,ie.x,ie.y,H):be>=10&&await P.swipe(s,ie.x,ie.y,Ae.x,Ae.y)}catch(Qe){console.error("Interaction failed:",Qe)}Te.current=null}},rt=f=>{const k=new Set(b);k.has(f)?k.delete(f):k.add(f),y(k)},He=()=>{const f=new Set,k=D=>{var $;f.add(D.xpath),($=D.children)==null||$.forEach(k)};i!=null&&i.hierarchy&&k(i.hierarchy),y(f)},Ve=()=>y(new Set(["/"])),qe=(f,k)=>{navigator.clipboard.writeText(f),w(k),setTimeout(()=>w(null),2e3)},Ce=f=>{var D;let k=1;return(D=f.children)==null||D.forEach($=>k+=Ce($)),k},$t=f=>{if(!f)return[];const k={},D=$=>{var W;const z=Js($),H=z.role.replace(/\s*\(.*?\)\s*/,"");k[H]||(k[H]={emoji:z.emoji,count:0}),k[H].count+=1,(W=$.children)==null||W.forEach(D)};return D(f),Object.entries(k).map(([$,z])=>({role:$,emoji:z.emoji,count:z.count})).sort(($,z)=>z.count-$.count)},Qt=f=>f.xpath.split("/").filter(Boolean).slice(-3),Xe=(f,k=0)=>{var xe,ie,Ae,be;if(!f)return null;const D=b.has(f.xpath),$=((xe=f.children)==null?void 0:xe.length)>0,z=(c==null?void 0:c.xpath)===f.xpath,H=(x==null?void 0:x.xpath)===f.xpath,W=((ie=f.type)==null?void 0:ie.split(".").pop())||"Element",G=f.label||((Ae=f.attributes)==null?void 0:Ae["content-desc"])||((be=f.attributes)==null?void 0:be["resource-id"])||f.name,U=typeof G=="string"&&G&&G!==W&&G!==f.type?G:null,Z=U||W,ue=!p||Qs(f,p);if(!ue&&!$)return null;if(p&&!ue){const ae=Ze=>{var Je;return Qs(Ze,p)?!0:((Je=Ze.children)==null?void 0:Je.some(ae))||!1};if(!ae(f))return null}return t.jsxs("div",{className:"tree-node",children:[t.jsxs("div",{className:`tree-item ${z?"selected":""} ${H&&!z?"hovered":""}`,onClick:()=>{h(f),E("info")},onMouseEnter:()=>g(f),onMouseLeave:()=>g(null),children:[t.jsx("div",{className:"tree-item-indent",style:{width:`${k*14}px`}}),$?t.jsx("button",{onClick:ae=>{ae.stopPropagation(),rt(f.xpath)},className:"tree-toggle",children:D?t.jsx(tn,{size:11}):t.jsx(cn,{size:11})}):t.jsx("span",{className:"tree-toggle-spacer"}),t.jsx(fi,{size:11,className:"tree-icon"}),t.jsx("span",{className:"tree-label",title:`${W}${U?` — ${U}`:""}`,children:Z}),U&&t.jsx("span",{className:"tree-type-tag",title:W,children:W}),f.text&&t.jsxs("span",{className:"tree-text-preview",children:['"',f.text.slice(0,20),'"']}),$&&t.jsx("span",{className:"tree-badge",children:f.children.length})]}),D&&$&&t.jsx("div",{className:"tree-children",children:f.children.map(ae=>Xe(ae,k+1))})]},f.xpath)},ge=f=>{var W,G,U;if(!I.width)return[];const k=[],D=(W=i==null?void 0:i.hierarchy)==null?void 0:W.rect;let $=((G=i==null?void 0:i.metadata)==null?void 0:G.screenWidth)||I.width,z=((U=i==null?void 0:i.metadata)==null?void 0:U.screenHeight)||I.height;D&&D.width>0&&D.height>0&&($=D.width,z=D.height);const H=(Z,ue)=>{var ie,Ae,be;const xe=!Z.children||Z.children.length===0;((ie=Z.rect)==null?void 0:ie.width)>0&&((Ae=Z.rect)==null?void 0:Ae.height)>0&&xe&&k.push(t.jsx("div",{className:"omni-hit-area",style:{left:`${Z.rect.x/$*100}%`,top:`${Z.rect.y/z*100}%`,width:`${Z.rect.width/$*100}%`,height:`${Z.rect.height/z*100}%`,zIndex:ue},onClick:ae=>{ae.stopPropagation(),h(Z),E("info")},onMouseEnter:()=>g(Z),onMouseLeave:()=>g(null)},Z.xpath)),(be=Z.children)==null||be.forEach(ae=>H(ae,ue+1))};return i!=null&&i.hierarchy&&H(i.hierarchy,1),k},at=()=>{var H,W,G;if(!re||!I.width)return[];const f=_[re];if(!f||f.kind!=="matched"||f.nodes.length===0)return[];const k=(H=i==null?void 0:i.hierarchy)==null?void 0:H.rect;let D=((W=i==null?void 0:i.metadata)==null?void 0:W.screenWidth)||I.width,$=((G=i==null?void 0:i.metadata)==null?void 0:G.screenHeight)||I.height;k&&k.width>0&&k.height>0&&(D=k.width,$=k.height);const z=f.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return f.nodes.filter(U=>U.rect&&U.rect.width>0&&U.rect.height>0).map((U,Z)=>t.jsx("div",{className:z,style:{left:`${U.rect.x/D*100}%`,top:`${U.rect.y/$*100}%`,width:`${U.rect.width/D*100}%`,height:`${U.rect.height/$*100}%`}},`match-${re}-${Z}`))},Ke=(f,k)=>{var H,W,G;if(!(f!=null&&f.rect)||!I.width)return null;const D=(H=i==null?void 0:i.hierarchy)==null?void 0:H.rect;let $=((W=i==null?void 0:i.metadata)==null?void 0:W.screenWidth)||I.width,z=((G=i==null?void 0:i.metadata)==null?void 0:G.screenHeight)||I.height;return D&&D.width>0&&D.height>0&&($=D.width,z=D.height),t.jsx("div",{className:`omni-frame-${k}`,style:{left:`${f.rect.x/$*100}%`,top:`${f.rect.y/z*100}%`,width:`${f.rect.width/$*100}%`,height:`${f.rect.height/z*100}%`}})},xt=i!=null&&i.hierarchy?Ce(i.hierarchy):0,ce=c?Js(c):null,Tt={stable:{icon:t.jsx(Ms,{size:10}),cls:"stable"},moderate:{icon:t.jsx(us,{size:10}),cls:"moderate"},fragile:{icon:t.jsx(ss,{size:10}),cls:"fragile"},"very-fragile":{icon:t.jsx(ss,{size:10}),cls:"very-fragile"}},yt=r&&(i!=null&&i.hierarchy)?$t(i.hierarchy):[];return t.jsx("div",{className:`omni-inspector-container ${r?"omni-embedded":""}`,children:t.jsxs("div",{className:"omni-main-content",children:[!r&&t.jsxs("div",{className:"omni-screenshot-panel",children:[t.jsxs("div",{className:"omni-screenshot-header",children:[t.jsxs("div",{className:"omni-header-left",children:[t.jsx("span",{className:"omni-screenshot-title",children:"Device Preview"}),t.jsxs("div",{className:"omni-mode-toggle",children:[t.jsxs("button",{className:`omni-mode-btn ${O==="inspect"?"active":""}`,onClick:()=>J("inspect"),title:"Inspection Mode (Highlight Elements)",children:[t.jsx(ei,{size:12}),t.jsx("span",{children:"Inspect"})]}),t.jsxs("button",{className:`omni-mode-btn ${O==="interact"?"active":""}`,onClick:()=>J("interact"),title:"Interaction Mode (Direct Control)",children:[t.jsx(nr,{size:12}),t.jsx("span",{children:"Interact"})]})]})]}),t.jsxs("button",{className:"omni-refresh-btn",onClick:pe,disabled:a,children:[t.jsx(St,{size:12,className:a?"animate-spin":""}),a?"Capturing...":"Refresh"]})]}),t.jsxs("div",{className:"omni-screenshot-container",ref:ye,children:[a&&!Be&&t.jsxs("div",{className:"omni-loading-overlay",children:[t.jsx("div",{className:"omni-spinner"}),t.jsx("span",{children:"Capturing screen..."})]}),!i&&!a&&!Be&&t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(is,{size:40}),t.jsx("span",{children:"Click Refresh to capture"})]}),Be&&t.jsxs("div",{className:`omni-screenshot-wrapper ${O==="interact"?"interactable":""}`,onMouseDown:me,onMouseUp:Le,children:[t.jsx("img",{ref:ve,src:n,onLoad:Me,onError:Fe,className:"omni-screenshot-img",style:O==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),(i==null?void 0:i.hierarchy)&&O==="inspect"&&t.jsxs("div",{className:"omni-overlay",children:[ge(i.hierarchy),at(),Ke(x,"hover"),Ke(c,"select")]})]}),!Be&&(i==null?void 0:i.screenshot)&&t.jsxs("div",{className:`omni-screenshot-wrapper ${O==="interact"?"interactable":""}`,onMouseDown:me,onMouseUp:Le,children:[t.jsx("img",{ref:st,src:`data:image/png;base64,${i.screenshot}`,onLoad:it,className:"omni-screenshot-img",style:O==="interact"?{pointerEvents:"none"}:{},draggable:!1}),O==="inspect"&&t.jsxs("div",{className:"omni-overlay",children:[ge(i.hierarchy),at(),Ke(x,"hover"),Ke(c,"select")]})]})]})]}),t.jsxs("div",{className:"omni-tree-panel",children:[t.jsxs("div",{className:"omni-tree-header",children:[t.jsxs("div",{className:"omni-tree-title",children:[t.jsx(si,{size:14}),t.jsx("span",{children:"Source"}),xt>0&&t.jsxs("span",{className:"omni-count-badge",children:[xt," elements"]})]}),t.jsxs("div",{className:"omni-tree-actions",children:[t.jsx("button",{onClick:He,className:"omni-action-btn",title:"Expand All",children:t.jsx(Di,{size:12})}),t.jsx("button",{onClick:Ve,className:"omni-action-btn",title:"Collapse All",children:t.jsx(Ui,{size:12})}),r&&t.jsx("button",{onClick:pe,className:"omni-action-btn",title:a?"Capturing…":"Refresh snapshot",disabled:a,children:t.jsx(St,{size:12,className:a?"animate-spin":""})})]})]}),t.jsxs("div",{className:"omni-tree-search",children:[t.jsx(ds,{size:14}),t.jsx("input",{type:"text",placeholder:"Search elements... (try 'login button' or 'text field')",value:p,onChange:f=>S(f.target.value),"aria-label":"Search elements"}),p&&t.jsx("button",{onClick:()=>S(""),className:"omni-clear-btn",children:"×"})]}),p&&t.jsxs("div",{className:"omni-search-hint",children:[t.jsx(hs,{size:10}),' Smart search active — try "button", "input", "image"']}),t.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?Xe(i.hierarchy):t.jsx("div",{className:"omni-empty-state small",children:t.jsx("span",{children:"No hierarchy loaded"})})})]}),t.jsxs("div",{className:"omni-details-panel",children:[t.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[t.jsxs("button",{className:`omni-details-tab ${v==="info"?"active":""}`,onClick:()=>E("info"),role:"tab","aria-selected":v==="info",children:[t.jsx(Pi,{size:12})," ",t.jsx("span",{children:"Info"})]}),t.jsxs("button",{className:`omni-details-tab ${v==="insight"?"active":""}`,onClick:()=>E("insight"),disabled:!c,title:"AI Element Analysis",role:"tab","aria-selected":v==="insight",children:[t.jsx(Li,{size:12})," ",t.jsx("span",{children:"AI Insight"})]}),t.jsxs("button",{className:`omni-details-tab ${v==="code"?"active":""}`,onClick:()=>E("code"),disabled:!c,title:"Generate Test Code",role:"tab","aria-selected":v==="code",children:[t.jsx(_s,{size:12})," ",t.jsx("span",{children:"Code Gen"})]})]}),t.jsx("div",{className:"omni-details-content",children:c?t.jsxs(t.Fragment,{children:[v==="info"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Element Info"}),t.jsxs("div",{className:"omni-info-table",children:[t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Type"}),t.jsx("span",{className:"omni-info-value mono",children:c.type})]}),c.text&&t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Text"}),t.jsx("span",{className:"omni-info-value",children:c.text})]}),t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Path"}),t.jsx("span",{className:"omni-info-value mono small",children:Qt(c).join(" › ")})]})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Layout"}),t.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(f=>t.jsxs("div",{className:"omni-layout-item",children:[t.jsx("span",{className:"omni-layout-label",children:f.toUpperCase()}),t.jsx("span",{className:"omni-layout-value",children:c.rect[f]})]},f))})]}),t.jsxs("div",{className:"omni-section",children:[t.jsxs("div",{className:"omni-section-header",children:["Locators",t.jsx("span",{className:"omni-section-badge",children:"Stability Scored"})]}),t.jsx("div",{className:"omni-locators-list",children:(ot=c.suggestedLocators)==null?void 0:ot.map(f=>{const k=Gs(f.strategy,f.value),D=Tt[k.level],$=_[f.strategy];let z=null;return $&&($.kind==="unsupported"?z=t.jsxs("span",{className:"omni-match-badge unsupported",title:$.reason||"Cannot evaluate without a real driver",children:[t.jsx(wi,{size:10})," preview unavailable"]}):$.nodes.length===0?z=t.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[t.jsx(ss,{size:10})," 0 matches"]}):$.nodes.length===1?z=t.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[t.jsx(Ms,{size:10})," unique"]}):z=t.jsxs("span",{className:"omni-match-badge multi",title:`${$.nodes.length} elements match — selector is not unique`,children:[t.jsx(us,{size:10})," ",$.nodes.length," matches"]})),t.jsxs("div",{className:`omni-locator-row ${(M==null?void 0:M.strategy)===f.strategy?"selected-for-code":""}`,onClick:()=>V(f),title:"Click to use in Code Generator",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsxs("div",{className:"omni-locator-top",children:[t.jsx("span",{className:"omni-locator-strategy",children:f.strategy}),t.jsxs("span",{className:`omni-stability-badge ${D.cls}`,title:k.reason,children:[D.icon,k.level]}),z]}),t.jsx("code",{className:"omni-locator-value",children:f.value}),t.jsx("span",{className:"omni-stability-reason",children:k.reason})]}),t.jsxs("div",{className:"omni-locator-actions",children:[t.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),nt(f.strategy,f.value)},className:`omni-test-btn ${re===f.strategy?"active":""}`,title:"Test this locator against the current snapshot",children:t.jsx(ki,{size:12})}),t.jsx("button",{onClick:H=>{H.stopPropagation(),qe(f.value,f.strategy)},className:`omni-copy-btn ${j===f.strategy?"copied":""}`,children:j===f.strategy?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]})]},f.strategy)})})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Attributes"}),t.jsx("div",{className:"omni-attributes-table",children:Object.entries(c.attributes||{}).filter(([f,k])=>k!=null&&k!=="").map(([f,k])=>t.jsxs("div",{className:"omni-attr-row",children:[t.jsx("span",{className:"omni-attr-key",children:f}),t.jsx("span",{className:"omni-attr-value",children:String(k)})]},f))})]})]}),v==="insight"&&ce&&t.jsxs("div",{className:"omni-insight-panel",children:[t.jsxs("div",{className:"omni-insight-role",children:[t.jsx("span",{className:"omni-insight-emoji",children:ce.emoji}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-insight-role-name",children:ce.role}),t.jsx("div",{className:"omni-insight-interactable",children:ce.interactable?t.jsxs("span",{className:"omni-badge-green",children:[t.jsx(on,{size:10})," Interactable"]}):t.jsx("span",{className:"omni-badge-gray",children:"Visual Only"})})]})]}),ce.warning&&t.jsx("div",{className:"omni-insight-warning",children:ce.warning}),t.jsxs("div",{className:"omni-insight-description",children:[t.jsx(hs,{size:12,className:"omni-insight-icon"}),t.jsx("p",{children:ce.description})]}),ce.bestLocator&&t.jsxs("div",{className:"omni-insight-best-locator",children:[t.jsx("div",{className:"omni-section-header",children:"Recommended Locator"}),t.jsxs("div",{className:"omni-locator-row",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsx("span",{className:"omni-locator-strategy",children:ce.bestLocator.strategy}),t.jsx("code",{className:"omni-locator-value",children:ce.bestLocator.value})]}),t.jsx("button",{onClick:()=>qe(ce.bestLocator.value,"best"),className:`omni-copy-btn ${j==="best"?"copied":""}`,children:j==="best"?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]})]}),t.jsxs("div",{className:"omni-insight-attributes",children:[t.jsx("div",{className:"omni-section-header",children:"Quick Facts"}),t.jsx("div",{className:"omni-quick-facts",children:[{label:"Clickable",value:(Ye=c.attributes)==null?void 0:Ye.clickable},{label:"Enabled",value:(vt=c.attributes)==null?void 0:vt.enabled},{label:"Scrollable",value:(Mt=c.attributes)==null?void 0:Mt.scrollable},{label:"Focusable",value:(bt=c.attributes)==null?void 0:bt.focusable},{label:"Children",value:((Ge=c.children)==null?void 0:Ge.length)||0}].map(({label:f,value:k})=>t.jsxs("div",{className:"omni-quick-fact-row",children:[t.jsx("span",{className:"omni-quick-fact-label",children:f}),t.jsx("span",{className:`omni-quick-fact-value ${k==="true"||k===!0?"true":""}`,children:String(k??"—")})]},f))})]})]}),v==="code"&&t.jsxs("div",{className:"omni-codegen-panel",children:[t.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(f=>t.jsx("button",{className:`omni-fw-btn ${A===f?"active":""}`,onClick:()=>T(f),children:f==="java"?"☕ Java":f==="python"?"🐍 Python":f==="javascript"?"🟨 JS":"🔷 WD.io"},f))}),M?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-codegen-locator-selector",children:[t.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),t.jsx("select",{value:M.strategy,onChange:f=>{var D;const k=(D=c.suggestedLocators)==null?void 0:D.find($=>$.strategy===f.target.value);k&&V(k)},className:"omni-fw-select",children:(wt=c.suggestedLocators)==null?void 0:wt.map(f=>t.jsxs("option",{value:f.strategy,children:[f.strategy," — ",Gs(f.strategy,f.value).level]},f.strategy))})]}),t.jsxs("div",{className:"omni-codegen-output",children:[t.jsxs("div",{className:"omni-codegen-header",children:[t.jsx("span",{className:"omni-codegen-lang",children:A==="java"?"Java / TestNG":A==="python"?"Python / unittest":A==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),t.jsx("button",{className:"omni-copy-btn",onClick:()=>qe(Zs(c,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",A,M),"code"),children:j==="code"?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]}),t.jsx("pre",{className:"omni-codegen-pre",children:t.jsx("code",{children:Zs(c,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",A,M)})})]})]}):t.jsxs("div",{className:"omni-empty-state small",children:[t.jsx(_s,{size:24}),t.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?t.jsxs("div",{className:"omni-summary-panel",children:[t.jsxs("div",{className:"omni-summary-hero",children:[t.jsx(is,{size:28}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-summary-title",children:"No element selected"}),t.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Snapshot Stats"}),t.jsxs("div",{className:"omni-summary-stats",children:[t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),t.jsx("span",{className:"omni-summary-stat__value",children:xt})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),t.jsx("span",{className:"omni-summary-stat__value",children:((Se=i.metadata)==null?void 0:Se.screenWidth)??I.width??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),t.jsx("span",{className:"omni-summary-stat__value",children:((ke=i.metadata)==null?void 0:ke.screenHeight)??I.height??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),t.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),yt.length>0&&t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"By Role"}),t.jsx("div",{className:"omni-summary-roles",children:yt.slice(0,8).map(f=>t.jsxs("div",{className:"omni-summary-role",children:[t.jsx("span",{className:"omni-summary-role__emoji",children:f.emoji}),t.jsx("span",{className:"omni-summary-role__name",children:f.role}),t.jsx("span",{className:"omni-summary-role__count",children:f.count})]},f.role))})]})]}):t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(is,{size:32}),t.jsx("span",{children:a?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})})};function zo({device:e,onClose:s}){var Qe;const{toast:n,removeToast:r}=en(),a=vs(),{tab:o}=sn(),i=m.useRef(null),l=m.useRef(null),[d,u]=m.useState({width:0,height:0}),[c,h]=m.useState(o||"actions"),[x,g]=m.useState(""),[b,y]=m.useState(""),[p,S]=m.useState(""),[j,w]=m.useState(!0),[v,E]=m.useState([]),[A,T]=m.useState(null),[M,V]=m.useState(!1),[I,Y]=m.useState(!1),[q,K]=m.useState(0),[N,ne]=m.useState(e),[O,J]=m.useState([]),[_,Q]=m.useState(!1),[re,Ne]=m.useState(!1),[ye,st]=m.useState(null),[ve,Te]=m.useState([]),[de,nt]=m.useState(!0),[pe,it]=m.useState(""),[Fe,Me]=m.useState(!1),[Be,me]=m.useState(0),[Le,rt]=m.useState(!1),[He,Ve]=m.useState(!1),qe=10,[Ce,$t]=m.useState(!1),Qt=()=>{navigator.clipboard.writeText(N.udid).catch(()=>{}),$t(!0),setTimeout(()=>$t(!1),1500)},Xe=m.useRef(""),ge=m.useRef(null),[at,Ke]=m.useState(!1);m.useEffect(()=>{c&&(!o||o!==c)&&a(`/devices/${e.udid}/control/${c}`,{replace:!0})},[c,o,e.udid,a]),m.useEffect(()=>{let C;if(c==="logs"){Me(!1),me(0);const R=async()=>{try{const L=await P.getLogs(N.udid);if(me(F=>F+1),L&&L.logs&&L.logs.trim().length>0){Me(!0);const F=L.logs.replace(/\\u[0-9a-fA-F]{4}/g,X=>JSON.parse(`"${X}"`)).replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"").split(`
208
+ `).filter(X=>X.trim().length>0);F.length>0&&Te(X=>[...X,...F].slice(-1e3))}else me(F=>(F>=3&&Me(!0),F))}catch(L){console.error("Failed to fetch logs:",L),me(F=>(F>=3&&Me(!0),F))}};R(),C=setInterval(R,3e3)}return()=>clearInterval(C)},[c,N.udid]);const xt=()=>{if(ve.length===0)return t.jsx("div",{className:"log-empty-state",children:Fe?t.jsxs(t.Fragment,{children:[t.jsx(ms,{size:28,style:{color:"var(--text-muted)",marginBottom:12,opacity:.4}}),t.jsx("p",{className:"log-empty-title",children:"No log output yet"}),t.jsx("p",{className:"log-empty-subtitle",children:"The log stream is active but the device is quiet. Interact with the device to generate logs."})]}):t.jsxs(t.Fragment,{children:[t.jsx(It,{size:28,className:"animate-spin",style:{color:"var(--green)",marginBottom:12}}),t.jsx("p",{className:"log-empty-title",children:"Connecting to device syslog..."}),t.jsxs("p",{className:"log-empty-subtitle",children:["Initializing persistent log stream for ",N.name]})]})});const C=ve.filter(R=>!pe||R.toLowerCase().includes(pe.toLowerCase()));return C.length===0&&pe?t.jsxs("div",{className:"log-empty-state",children:[t.jsx(ds,{size:28,style:{color:"var(--text-muted)",marginBottom:12,opacity:.4}}),t.jsxs("p",{className:"log-empty-title",children:['No matches for "',pe,'"']}),t.jsxs("p",{className:"log-empty-subtitle",children:[ve.length," lines in buffer. Try a different search term."]})]}):C.map((R,L)=>{let F="log-debug";const X=R.toLowerCase();return X.includes("error")||X.includes("fail")?F="log-error":X.includes("warning")||X.includes("warn")?F="log-warn":(X.includes("notice")||X.includes("info"))&&(F="log-notice"),t.jsxs("div",{className:`log-line ${F}`,children:[t.jsx("span",{className:"log-index",children:L+1}),t.jsx("span",{className:"log-content",children:R})]},`${L}-${R.substring(0,10)}`)})};m.useEffect(()=>{c==="logs"&&de&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[ve,c,de]),m.useEffect(()=>((async()=>{try{Y(!0),await P.startStream(N.udid);const L=(await P.getDevices()).find(F=>F.udid===N.udid);L&&ne(L)}catch(R){console.error("Auto-start stream failed:",R)}finally{Y(!1)}})(),()=>{P.stopStream(N.udid).catch(()=>{})}),[e.udid]);const ce=m.useCallback(async()=>{try{Q(!0);const C=await P.listApps(N.udid);Array.isArray(C)&&J(C)}catch(C){console.error("Failed to load apps:",C)}finally{Q(!1)}},[N.udid]);m.useEffect(()=>{c==="actions"&&ce()},[c,ce]);const Tt=parseInt(N.screenWidth||"1080",10),yt=parseInt(N.screenHeight||"1920",10),Se=Math.min(Tt,yt),ke=Math.max(Tt,yt),ot=Se/ke,Ye=m.useCallback(()=>{const C=!j,R=C?window.innerHeight*.55:window.innerHeight*.7,L=620,X=window.innerWidth>900;let ee;C?ee=X?Math.min(window.innerWidth*.8,window.innerWidth-L):window.innerWidth*.8:ee=window.innerWidth*.45;const le=j?ot:1/ot;let te,se;j?(te=R,se=te*le,se>ee&&(se=ee,te=se/le)):(se=ee,te=se/le,te>R&&(te=R,se=te*le)),u({width:se,height:te})},[ot,j]);m.useEffect(()=>(Ye(),window.addEventListener("resize",Ye),()=>window.removeEventListener("resize",Ye)),[Ye]),m.useEffect(()=>{const C=async()=>{if(Xe.current.length>0){const L=Xe.current;Xe.current="";try{await P.typeText(N.udid,L)}catch(F){console.error("Keyboard buffering flush failed:",F)}}},R=L=>{const F=document.activeElement;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable)||!at&&c!=="terminal")return;const ee=L.key;ee==="Enter"?(ge.current&&clearTimeout(ge.current),C(),P.pressKey(N.udid,N.platform==="android"?66:"enter")):ee==="Backspace"?(ge.current&&clearTimeout(ge.current),C(),P.pressKey(N.udid,N.platform==="android"?67:"backspace")):ee.length===1&&(Xe.current+=ee,ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{C()},50))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),ge.current&&clearTimeout(ge.current)}},[N.udid,N.platform,at,c]);const[vt,Mt]=m.useState(Date.now()),bt=()=>{const C=q>0?`r=${q}&`:"";return N.session_id&&!String(N.session_id).startsWith("manual_")?`/xenon/api/session/${N.session_id}/live_video?${C}t=${vt}`:`/xenon/api/control/${N.udid}/stream?${C}t=${vt}`};m.useEffect(()=>{q>0&&Mt(Date.now())},[q]),m.useEffect(()=>{if(Le||He)return;const C=setTimeout(()=>Ve(!0),3e4);return()=>clearTimeout(C)},[Le,He,q]);const Ge=m.useRef(null),wt=C=>{const R=C.currentTarget.getBoundingClientRect();return{x:C.clientX-R.left,y:C.clientY-R.top}},f=C=>{const R=wt(C);Ge.current={x:R.x,y:R.y,time:Date.now()}},k=async C=>{var $s;if(!Ge.current)return;const R=Ge.current,L=wt(C),F=Date.now()-R.time,X=($s=i.current)==null?void 0:$s.getBoundingClientRect(),ee=(X==null?void 0:X.width)||d.width,le=(X==null?void 0:X.height)||d.height;let te,se,ct,Lt;j?(te=R.x/ee*Se,se=R.y/le*ke,ct=L.x/ee*Se,Lt=L.y/le*ke):(te=R.x/ee*ke,se=R.y/le*Se,ct=L.x/ee*ke,Lt=L.y/le*Se);const Es=Math.abs(ct-te),Ds=Math.abs(Lt-se);try{F<500&&Es<10&&Ds<10?await P.tap(N.udid,Math.round(te),Math.round(se)):F>=500&&Es<10&&Ds<10?await P.touchAndHold(N.udid,Math.round(te),Math.round(se),F):await P.swipe(N.udid,Math.round(te),Math.round(se),Math.round(ct),Math.round(Lt))}catch(_n){console.error("Action failed:",_n)}Ge.current=null},D=()=>P.pressKey(N.udid,N.platform==="android"?jt.HOME:ns.HOME),$=()=>P.pressKey(N.udid,jt.BACK),z=()=>P.pressKey(N.udid,jt.APP_SWITCH),H=()=>P.pressKey(N.udid,N.platform==="android"?jt.VOLUME_UP:ns.VOLUME_UP),W=()=>P.pressKey(N.udid,N.platform==="android"?jt.VOLUME_DOWN:ns.VOLUME_DOWN),G=()=>P.lock(N.udid),U=()=>P.unlock(N.udid),Z=async()=>{x.trim()&&(await P.typeText(N.udid,x),g(""))},ue=async()=>{try{y("Fetching...");const C=await P.getClipboard(N.udid);C&&C.content!==void 0?y(C.content||"(Clipboard is empty)"):y("No content received")}catch{y("Error: Check Appium Settings app")}},xe=async()=>{V(!0);try{const C=await P.getScreenshot(N.udid);if(C!=null&&C.screenshot){const R={id:Ao(),base64:C.screenshot,timestamp:Date.now()};E(L=>[R,...L]),T(0)}}catch(C){console.error("Failed to take screenshot:",C)}finally{V(!1)}},ie=C=>{E(R=>{const L=R.filter(F=>F.id!==C);return L.length===0?T(null):A!==null&&A>=L.length&&T(0),L})},Ae=()=>{E([]),T(null),n("Cleared all captured evidence.","success")},be=C=>{const R=document.createElement("a");R.href=`data:image/png;base64,${C}`,R.download=`screenshot-${N.udid}-${Date.now()}.png`,R.click()},ae=async C=>{const R=Se/2,L=ke/2,F=Se*.4,X=ke*.4;let ee,le,te,se;switch(C){case"left":ee=R+F,le=L,te=R-F,se=L;break;case"right":ee=R-F,le=L,te=R+F,se=L;break;case"up":ee=R,le=L+X,te=R,se=L-X;break;case"down":ee=R,le=L-X,te=R,se=L+X;break}try{await P.swipe(N.udid,Math.round(ee),Math.round(le),Math.round(te),Math.round(se))}catch(ct){console.error(`Quick swipe ${C} failed:`,ct)}},Ze=async()=>{if(p.trim()){const C=n(`Uninstalling ${p}...`,"loading",0);try{Q(!0),await P.uninstallApp(N.udid,p),S(""),n(`Request sent for ${p}`,"success"),setTimeout(ce,3e3)}catch{n("Uninstall failed. Check logs.","error")}finally{Q(!1),r(C)}}},Je=async()=>{if(!ye)return;let C;try{Ne(!0),C=n(`Installing app to ${N.udid}...`,"loading",0);const R=await P.uploadAndInstallApp(N.udid,ye);R.success?(n(R.message||"App installed successfully","success"),st(null),setTimeout(ce,5e3)):n("Installation failed: "+(R.error||"Unknown error"),"error")}catch(R){n("Installation failed: "+R.message,"error")}finally{C&&r(C),Ne(!1)}};return t.jsxs("div",{className:"device-control-view",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"control-view-top-bar",children:[t.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[t.jsx(ts,{size:18})," DEVICES"]}),t.jsxs("div",{className:"device-info-mini",children:[t.jsx("span",{className:`device-pill platform-pill ${N.platform}`,children:N.platform==="ios"?"Apple":"Android"}),t.jsxs("span",{className:"device-pill version-pill",children:["v",N.sdk]}),N.reservedUntil&&Date.now()<N.reservedUntil&&t.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${N.reservedBy}${N.reservationReason?`: ${N.reservationReason}`:""}`,children:["RESERVED BY ",((Qe=N.reservedBy)==null?void 0:Qe.toUpperCase())||"ANONYMOUS"]}),t.jsx("h2",{className:"device-name-text",children:N.name}),t.jsxs("span",{className:"udid-chip",title:N.udid,children:[t.jsx("span",{className:"udid-chip__value",children:N.udid}),t.jsx("button",{type:"button",className:"udid-chip__copy",onClick:Qt,"aria-label":"Copy UDID",title:Ce?"Copied!":"Copy UDID",children:Ce?t.jsx(Bt,{size:12}):t.jsx(Ct,{size:12})})]})]})]}),t.jsxs("div",{className:`control-view-main ${j?"":"is-landscape"} ${c==="omni"?"omni-mode":""}`,children:[t.jsxs("div",{className:"device-preview-column",children:[t.jsx("div",{className:"device-screen-wrapper",children:t.jsxs("div",{ref:i,className:`device-stream-canvas ${j?"":"landscape"} ${at?"focused":""}`,style:{width:d.width,height:d.height,background:"#000"},tabIndex:0,onFocus:()=>Ke(!0),onBlur:()=>Ke(!1),onMouseDown:f,onMouseUp:k,children:[He?t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(us,{size:40,color:"var(--red, #f87171)"}),t.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),t.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{Ve(!1),K(0)},children:"Retry"})]}):(I||!Le)&&t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(St,{size:40,className:"animate-spin",color:"var(--green)"}),t.jsx("p",{style:{marginTop:16},children:I?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!He&&t.jsx("img",{src:bt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>rt(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),rt(!1),q>=qe){Ve(!0);return}setTimeout(()=>K(C=>C+1),2e3)}})]})}),t.jsxs("aside",{className:"device-footer-actions",children:[t.jsxs("button",{className:`footer-action-btn ${j?"active":""}`,onClick:()=>w(!0),children:[t.jsx(St,{size:14,style:{transform:j?"none":"rotate(-90deg)"}})," ","PORTRAIT"]}),t.jsxs("button",{className:`footer-action-btn ${j?"":"active"}`,onClick:()=>w(!1),children:[t.jsx(St,{size:14,style:{transform:"rotate(90deg)"}})," LANDSCAPE"]}),t.jsx("div",{className:"footer-divider"}),t.jsxs("button",{className:"footer-action-btn",onClick:D,children:[t.jsx(Ti,{size:20})," HOME"]}),N.platform==="android"&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"footer-action-btn",onClick:$,title:"Back",children:[t.jsx(ts,{size:20})," BACK"]}),t.jsxs("button",{className:"footer-action-btn",onClick:z,title:"App Switcher",children:[t.jsx(Gi,{size:20})," APPS"]})]}),t.jsx("div",{className:"footer-divider"}),t.jsxs("button",{className:"footer-action-btn",onClick:H,title:"Volume Up",children:[t.jsx(or,{size:20})," VOL+"]}),t.jsxs("button",{className:"footer-action-btn",onClick:W,title:"Volume Down",children:[t.jsx(rr,{size:20})," VOL−"]}),t.jsx("button",{className:"footer-action-btn",onClick:G,title:"Lock Device","aria-label":"Lock device",children:t.jsx(ni,{size:20})}),t.jsx("button",{className:"footer-action-btn",onClick:U,title:"Unlock Device","aria-label":"Unlock device",children:t.jsx(_i,{size:20})})]})]}),t.jsxs("div",{className:"device-interactions-column",children:[t.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[t.jsxs("button",{className:`tab-btn ${c==="actions"?"active":""}`,onClick:()=>h("actions"),role:"tab","aria-selected":c==="actions",children:[t.jsx(on,{size:13}),t.jsx("span",{children:"Actions"})]}),t.jsxs("button",{className:`tab-btn ${c==="screenshot"?"active":""}`,onClick:()=>h("screenshot"),role:"tab","aria-selected":c==="screenshot",children:[t.jsx(Nt,{size:13}),t.jsx("span",{children:"Screenshot"})]}),t.jsxs("button",{className:`tab-btn ${c==="logs"?"active":""}`,onClick:()=>h("logs"),role:"tab","aria-selected":c==="logs",children:[t.jsx(Xi,{size:13}),t.jsx("span",{children:"Debug Logs"})]}),t.jsxs("button",{className:`tab-btn ${c==="terminal"?"active":""}`,onClick:()=>h("terminal"),role:"tab","aria-selected":c==="terminal",children:[t.jsx(ms,{size:13}),t.jsx("span",{children:"Shell"})]}),t.jsxs("button",{className:`tab-btn ${c==="omni"?"active":""}`,onClick:()=>h("omni"),role:"tab","aria-selected":c==="omni",children:[t.jsx(hs,{size:13}),t.jsx("span",{children:"Omni-Vision"})]})]}),t.jsx("div",{className:`interactions-scroll-area ${c==="terminal"?"terminal-mode":""} ${c==="screenshot"||c==="logs"?"screenshot-mode":""}`,children:t.jsxs("div",{className:"tab-content",children:[c==="omni"&&t.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:t.jsx(Po,{sessionId:N.session_id?String(N.session_id):null,udid:N.udid,streamUrl:bt(),embedded:!0})}),c==="actions"&&t.jsxs("div",{className:"actions-grid",children:[t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(ti,{size:18,color:"var(--green)"})," Smart Input"]}),t.jsx("p",{className:"action-card-hint",children:"Relay keystrokes to the focused element on the device."}),t.jsx("input",{type:"text",className:"type-input-field compact",placeholder:"Type and press Enter to send…",value:x,onChange:C=>g(C.target.value),onKeyDown:C=>C.key==="Enter"&&Z()})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Un,{size:18,color:"var(--green)"})," App Management"]}),t.jsxs("div",{className:"app-mgmt-content",children:[t.jsxs("div",{className:"install-section",children:[t.jsx("p",{className:"compact-label",children:"Install Package (.apk, .ipa, .app)"}),t.jsxs("div",{className:"upload-box-row",children:[t.jsxs("label",{className:"file-upload-launcher",children:[t.jsx(Vn,{size:14}),t.jsx("span",{children:ye?ye.name:"Select File"}),t.jsx("input",{type:"file",accept:".apk,.ipa,.app",onChange:C=>{var R;return st(((R=C.target.files)==null?void 0:R[0])||null)},hidden:!0})]}),t.jsx("button",{className:"btn-premium btn-sm",disabled:!ye||re,onClick:Je,children:re?t.jsx(It,{className:"animate-spin",size:14}):"INSTALL"})]})]}),t.jsx("div",{className:"divider-v"}),t.jsxs("div",{className:"uninstall-section",children:[t.jsx("p",{className:"compact-label",children:"Quick Uninstall"}),t.jsxs("div",{className:"uninstall-controls-row",children:[t.jsxs("div",{className:"select-wrapper",children:[t.jsxs("select",{className:"app-select-dropdown compact",value:p,onChange:C=>S(C.target.value),disabled:_,children:[t.jsx("option",{value:"",children:_?"Loading apps...":"-- Select App to Remove --"}),O.map(C=>t.jsx("option",{value:C,children:C},C))]}),_&&t.jsx(It,{className:"animate-spin select-loader",size:12})]}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:Ze,disabled:!p||_,children:[t.jsx(_t,{size:14})," UNINSTALL"]})]}),t.jsxs("div",{className:"manual-input-box",children:[t.jsx("p",{className:"hint-text",children:"Or enter manually:"}),t.jsx("input",{type:"text",className:"type-input-field tiny",placeholder:"com.example.app",value:p,onChange:C=>S(C.target.value)})]})]})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Ni,{size:18,color:"var(--green)"})," Clipboard"]}),t.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[t.jsx("button",{className:"btn-premium btn-sm",style:{width:"140px",flexShrink:0},onClick:ue,children:"FETCH VALUE"}),t.jsx("div",{className:"clipboard-display compact",style:{marginTop:0,flex:1},children:b})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Hi,{size:18,color:"var(--green)"})," Directional Gestures"]}),t.jsxs("div",{className:"gestures-grid-container",children:[t.jsxs("div",{className:"gestures-dpad",children:[t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("up"),children:t.jsx(vi,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("left"),children:t.jsx(ts,{size:24})}),t.jsx("div",{className:"dpad-center"}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("right"),children:t.jsx(cn,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>ae("down"),children:t.jsx(tn,{size:24})}),t.jsx("div",{})]}),t.jsx("p",{className:"compact-label",style:{opacity:.5},children:"Quick swipe in a direction"})]})]})]}),c==="screenshot"&&t.jsxs("div",{className:"action-card screenshot-card",children:[t.jsxs("header",{className:"action-card-header",children:[t.jsxs("div",{className:"title-group",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Nt,{size:20,color:"var(--green)"})," Captured Evidence"]}),t.jsx("p",{className:"hint-text",children:"Relay screenshots from device to host."})]}),v.length>0&&t.jsx("button",{className:"btn-text-only",onClick:Ae,children:"CLEAR ALL"})]}),t.jsxs("div",{className:"screenshot-workspace",children:[t.jsxs("div",{className:"screenshot-gallery-sidebar",children:[t.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:xe,disabled:M,children:[M?t.jsx(It,{className:"animate-spin",size:16}):t.jsx(Nt,{size:16}),t.jsx("span",{children:M?"CAPTURING...":"NEW CAPTURE"})]}),t.jsxs("div",{className:"screenshot-thumbnails-list",children:[v.length===0&&!M&&t.jsxs("div",{className:"empty-gallery-state",children:[t.jsx(Nt,{size:20,className:"empty-gallery-icon"}),t.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),t.jsxs("p",{className:"empty-gallery-hint",children:["Click ",t.jsx("strong",{children:"New Capture"})," above to grab a screenshot."]})]}),v.map((C,R)=>t.jsxs("div",{className:`screenshot-thumb-item ${A===R?"active":""}`,onClick:()=>T(R),children:[t.jsx("img",{src:`data:image/png;base64,${C.base64}`,alt:"Thumb"}),t.jsx("span",{className:"thumb-time",children:new Date(C.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),t.jsx("button",{className:"thumb-delete-btn",onClick:L=>{L.stopPropagation(),ie(C.id)},children:t.jsx(_t,{size:12})})]},C.id))]})]}),t.jsx("div",{className:"screenshot-main-preview",children:A!==null&&v[A]?t.jsxs("div",{className:"preview-container",children:[t.jsx("div",{className:"preview-image-wrapper",children:t.jsx("img",{src:`data:image/png;base64,${v[A].base64}`,alt:"Selected Evidence"})}),t.jsxs("footer",{className:"preview-footer",children:[t.jsxs("div",{className:"preview-meta",children:[t.jsx("span",{className:"meta-label",children:"ID:"}),t.jsx("span",{className:"meta-value",children:v[A].id.substring(0,8)}),t.jsx("span",{className:"meta-divider",children:"|"}),t.jsx("span",{className:"meta-value",children:Qn(v[A].timestamp)})]}),t.jsxs("div",{className:"preview-actions",children:[t.jsx("button",{className:"btn-premium btn-sm",onClick:()=>be(v[A].base64),children:"DOWNLOAD PNG"}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>ie(v[A].id),children:[t.jsx(_t,{size:14})," DELETE"]})]})]})]}):t.jsxs("div",{className:"preview-empty-placeholder",children:[t.jsx(Nt,{size:48,style:{opacity:.1,marginBottom:16}}),t.jsx("p",{children:"Capture a screenshot to begin analysis"})]})})]})]}),c==="logs"&&t.jsxs("div",{className:"action-card screenshot-card",style:{padding:0,gap:0},children:[t.jsxs("div",{className:"log-toolbar",children:[t.jsxs("div",{className:"log-filter-group",children:[t.jsxs("div",{className:"log-stat-pill",children:[t.jsx("span",{className:`log-live-dot ${Fe?"active":""}`}),Fe?"LIVE":"CONNECTING"]}),t.jsxs("div",{className:"log-stat-pill",style:{opacity:.6},children:[ve.length," LINES"]}),t.jsxs("div",{className:"log-search-box",children:[t.jsx(ds,{size:14,className:"search-icon-inline"}),t.jsx("input",{type:"text",className:"type-input-field tiny",placeholder:"Filter trace...",value:pe,onChange:C=>it(C.target.value),"aria-label":"Filter debug logs"})]})]}),t.jsxs("div",{className:"log-actions-group",children:[t.jsxs("button",{className:`btn-secondary btn-sm ${de?"active":""}`,onClick:()=>nt(!de),title:de?"Freeze Logs":"Follow Logs",children:[t.jsx(lr,{size:14,className:de?"animate-pulse":""}),de?"FREEZE":"FOLLOW"]}),t.jsxs("button",{className:"btn-premium btn-sm",onClick:()=>{const C=new Blob([ve.join(`
209
209
  `)],{type:"text/plain"}),R=URL.createObjectURL(C),L=document.createElement("a");L.href=R,L.download=`logs-${N.udid}-${Date.now()}.txt`,L.click(),URL.revokeObjectURL(R)},disabled:ve.length===0,children:[t.jsx(ii,{size:14}),"EXPORT"]}),t.jsxs("button",{className:"btn-secondary btn-sm",onClick:()=>Te([]),title:"Clear Logs",children:[t.jsx(_t,{size:14}),"CLEAR"]})]})]}),t.jsx("div",{className:"log-display-area",ref:l,style:{flex:1},children:xt()})]}),c==="terminal"&&t.jsx("div",{className:"action-card full-height",children:t.jsx(Ro,{platform:(N.platform||"").toLowerCase(),prompt:`${(N.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${N.name} (${N.udid}).
210
- Internal Shell Environment.`,onCommand:async C=>{const R=await P.executeShell(N.udid,C);if(R.error)throw new Error(R.error);return R.output}})})]})})]})]}),N.session_id&&!String(N.session_id).startsWith("manual_")&&t.jsx(qn,{sessionId:String(N.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}class Fo extends Re.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,statusFilter:"all",search:""}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n)}componentWillUnmount(){this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(s=>s())}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await P.getDevices(),n=this.getBusyDevicesCount(s),r=await P.getPendingSessionsCount(),a=await P.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:r,queueSummary:a})}catch(s){console.log(s)}}getFiltered(){const s=Date.now(),n=a=>!!(a.reservedUntil&&s<a.reservedUntil),r=this.state.search.trim().toLowerCase();return this.state.devices.filter(a=>{if(r&&!`${a.name} ${a.udid}`.toLowerCase().includes(r))return!1;switch(this.state.statusFilter){case"all":return!0;case"offline":return a.offline;case"busy":return a.busy&&!a.offline;case"reserved":return n(a)&&!a.busy&&!a.offline;case"ready":return!a.offline&&!a.busy&&!n(a)&&!a.userBlocked;default:return!0}})}statusCount(s){const n=Date.now(),r=a=>!!(a.reservedUntil&&n<a.reservedUntil);switch(s){case"all":return this.state.devices.length;case"offline":return this.state.devices.filter(a=>a.offline).length;case"busy":return this.state.devices.filter(a=>a.busy&&!a.offline).length;case"reserved":return this.state.devices.filter(a=>r(a)&&!a.busy&&!a.offline).length;case"ready":return this.state.devices.filter(a=>!a.offline&&!a.busy&&!r(a)&&!a.userBlocked).length}}render(){const s=this.getFiltered(),{udid:n}=this.props.params,r=n?this.state.devices.find(a=>a.udid===n):null;return t.jsxs("div",{className:"device-explorer-container",children:[t.jsxs("div",{className:"de2-sticky-group",children:[t.jsx(Wn,{icon:Ms,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),t.jsxs("div",{className:"de2-toolbar",children:[t.jsx(ri,{size:"sm",value:this.state.statusFilter,onChange:a=>this.setState({statusFilter:a}),segments:[{value:"all",label:"All",count:this.statusCount("all")},{value:"ready",label:"Ready",count:this.statusCount("ready")},{value:"busy",label:"Busy",count:this.statusCount("busy")},{value:"reserved",label:"Reserved",count:this.statusCount("reserved")},{value:"offline",label:"Offline",count:this.statusCount("offline")}]}),t.jsx("input",{type:"text",className:"de2-search",placeholder:"Search by name or UDID…",value:this.state.search,onChange:a=>this.setState({search:a.target.value})}),t.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>this.fetchDevices(),children:[t.jsx(Ls,{size:12})," Refresh"]})]})]}),s.length>0?t.jsx(wo,{devices:s,reloadDevices:()=>this.fetchDevices()}):t.jsxs("div",{className:"device-explorer-empty stagger-1",children:[t.jsx("div",{className:"device-explorer-empty-icon",children:t.jsx(Ms,{size:32})}),this.state.devices.length===0?t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"Global Device Registry Empty"}),t.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),t.jsxs(lt,{variant:"primary",onClick:()=>this.fetchDevices(),children:[t.jsx(Ls,{size:14}),"Manual Sync"]})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"No Devices Found"}),t.jsx("p",{children:"Deployment configuration mismatch. Adjust your platform or state filters to find the appropriate testing target."}),t.jsx(lt,{variant:"secondary",onClick:()=>this.setState({statusFilter:"all",search:""}),children:"Reset filters"})]})]}),r&&t.jsx("div",{className:"device-control-modal-overlay",children:t.jsx("div",{className:"device-control-modal",children:t.jsx(zo,{device:r,onClose:()=>this.props.navigate("/devices")})})})]})}}function dc(){const e=sn(),s=ys(),{on:n}=ai();return t.jsx(Fo,{params:e,navigate:s,onSocketEvent:n})}export{Fo as DeviceExplorer,dc as default};
210
+ Internal Shell Environment.`,onCommand:async C=>{const R=await P.executeShell(N.udid,C);if(R.error)throw new Error(R.error);return R.output}})})]})})]})]}),N.session_id&&!String(N.session_id).startsWith("manual_")&&t.jsx(qn,{sessionId:String(N.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}class Fo extends Re.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,statusFilter:"all",search:"",loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n)}componentWillUnmount(){this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(s=>s())}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await P.getDevices(),n=this.getBusyDevicesCount(s),r=await P.getPendingSessionsCount(),a=await P.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:r,queueSummary:a,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}getFiltered(){const s=Date.now(),n=a=>!!(a.reservedUntil&&s<a.reservedUntil),r=this.state.search.trim().toLowerCase();return this.state.devices.filter(a=>{if(r&&!`${a.name} ${a.udid}`.toLowerCase().includes(r))return!1;switch(this.state.statusFilter){case"all":return!0;case"offline":return a.offline;case"busy":return a.busy&&!a.offline;case"reserved":return n(a)&&!a.busy&&!a.offline;case"ready":return!a.offline&&!a.busy&&!n(a)&&!a.userBlocked;default:return!0}})}statusCount(s){const n=Date.now(),r=a=>!!(a.reservedUntil&&n<a.reservedUntil);switch(s){case"all":return this.state.devices.length;case"offline":return this.state.devices.filter(a=>a.offline).length;case"busy":return this.state.devices.filter(a=>a.busy&&!a.offline).length;case"reserved":return this.state.devices.filter(a=>r(a)&&!a.busy&&!a.offline).length;case"ready":return this.state.devices.filter(a=>!a.offline&&!a.busy&&!r(a)&&!a.userBlocked).length}}render(){const s=this.getFiltered(),{udid:n}=this.props.params,r=n?this.state.devices.find(a=>a.udid===n):null;return t.jsxs("div",{className:"device-explorer-container",children:[t.jsxs("div",{className:"de2-sticky-group",children:[t.jsx(Wn,{icon:Ls,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),t.jsxs("div",{className:"de2-toolbar",children:[t.jsx(ri,{size:"sm",value:this.state.statusFilter,onChange:a=>this.setState({statusFilter:a}),segments:[{value:"all",label:"All",count:this.statusCount("all")},{value:"ready",label:"Ready",count:this.statusCount("ready")},{value:"busy",label:"Busy",count:this.statusCount("busy")},{value:"reserved",label:"Reserved",count:this.statusCount("reserved")},{value:"offline",label:"Offline",count:this.statusCount("offline")}]}),t.jsx("input",{type:"text",className:"de2-search",placeholder:"Search by name or UDID…",value:this.state.search,onChange:a=>this.setState({search:a.target.value})}),t.jsxs(lt,{variant:"secondary",size:"sm",onClick:()=>this.fetchDevices(),children:[t.jsx(es,{size:12})," Refresh"]})]})]}),s.length>0?t.jsx(wo,{devices:s,reloadDevices:()=>this.fetchDevices()}):t.jsxs("div",{className:"device-explorer-empty stagger-1",children:[t.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?t.jsx(Ls,{size:32}):t.jsx(es,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"Global Device Registry Empty"}),t.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),t.jsxs(lt,{variant:"primary",onClick:()=>this.fetchDevices(),children:[t.jsx(es,{size:14}),"Manual Sync"]})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"No Devices Found"}),t.jsx("p",{children:"Deployment configuration mismatch. Adjust your platform or state filters to find the appropriate testing target."}),t.jsx(lt,{variant:"secondary",onClick:()=>this.setState({statusFilter:"all",search:""}),children:"Reset filters"})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"Loading devices…"}),t.jsx("p",{children:"Syncing the global device registry."})]})]}),r&&t.jsx("div",{className:"device-control-modal-overlay",children:t.jsx("div",{className:"device-control-modal",children:t.jsx(zo,{device:r,onClose:()=>this.props.navigate("/devices")})})})]})}}function dc(){const e=sn(),s=vs(),{on:n}=ai();return t.jsx(Fo,{params:e,navigate:s,onSocketEvent:n})}export{Fo as DeviceExplorer,dc as default};