@xenon-device-management/xenon 2.17.0 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json +2 -3
- package/lib/public/assets/{AnnotationOverlay-CjmMCS0S.js → AnnotationOverlay-CB8njQvS.js} +1 -1
- package/lib/public/assets/{ApiKeyGate-B4Ob0v3C.js → ApiKeyGate-B-804QBS.js} +1 -1
- package/lib/public/assets/DeviceMosaicView-BsDvfjR1.js +2 -0
- package/lib/public/assets/{EmptyState-DcEG-oAi.js → EmptyState-WzLw1cEV.js} +1 -1
- package/lib/public/assets/{FieldGroup-CtnCDshE.js → FieldGroup-CaQNXgcE.js} +1 -1
- package/lib/public/assets/{FilterMenu-BK0dE9cc.js → FilterMenu-C9gAiypL.js} +1 -1
- package/lib/public/assets/{Menu-eKsmLpKS.js → Menu-CfTti3rw.js} +1 -1
- package/lib/public/assets/{Modal-DPwop3Lz.js → Modal-BcZUFhDm.js} +1 -1
- package/lib/public/assets/{RecordingPage-CfgSkZkB.js → RecordingPage-B_pbl3UE.js} +1 -1
- package/lib/public/assets/{RecordingsPage-Bzl9pTUY.js → RecordingsPage-BkVhplE3.js} +1 -1
- package/lib/public/assets/{SegmentedControl-B_TZTrPm.js → SegmentedControl-CDLMLNl5.js} +1 -1
- package/lib/public/assets/{SettingCard-DlmvZJPM.js → SettingCard-Lyw5CB1F.js} +1 -1
- package/lib/public/assets/{Table-BigPWKXi.js → Table-CK414bOU.js} +1 -1
- package/lib/public/assets/{activity-CvuZdQYu.js → activity-pEyAdE-M.js} +1 -1
- package/lib/public/assets/{ai-settings-lI2UJ2n7.js → ai-settings-CIhS7MMq.js} +1 -1
- package/lib/public/assets/{api-keys-CPgf9XJM.js → api-keys-D2J44Ebv.js} +1 -1
- package/lib/public/assets/{apps-DIzOvtUp.js → apps-CCV3RZY8.js} +1 -1
- package/lib/public/assets/{arrow-left-DiP5ywBT.js → arrow-left-DaEUmERk.js} +1 -1
- package/lib/public/assets/{arrow-right-DtW_8hm5.js → arrow-right-CnRXHXit.js} +1 -1
- package/lib/public/assets/{arrow-up-right-C89FbNU0.js → arrow-up-right-BGCS7zhi.js} +1 -1
- package/lib/public/assets/{auth-shell-B7sUDb--.js → auth-shell-CpW1zsxD.js} +2 -2
- package/lib/public/assets/{builds-page-BBhvrMfA.js → builds-page-B-xdzjMx.js} +1 -1
- package/lib/public/assets/{button-DugsdUw1.js → button-B5QkOVa4.js} +1 -1
- package/lib/public/assets/{calendar-grKd08ZH.js → calendar-gX_1EKue.js} +1 -1
- package/lib/public/assets/{check-ORjyNfnX.js → check-MIM4THvH.js} +1 -1
- package/lib/public/assets/{chevron-right-Ei2FxUXq.js → chevron-right-BZIp3-9t.js} +1 -1
- package/lib/public/assets/{circle-check-Day0HjW4.js → circle-check-Crt-G_uy.js} +1 -1
- package/lib/public/assets/{circle-x-CHxSRLHp.js → circle-x-C8GvvXVt.js} +1 -1
- package/lib/public/assets/{clock-BDHewWTx.js → clock-MFKV4qGa.js} +1 -1
- package/lib/public/assets/{copy-CTwT4I3D.js → copy-BU-Z7mBK.js} +1 -1
- package/lib/public/assets/device-explorer-D-78Twa0.js +282 -0
- package/lib/public/assets/{download-D3bjz_vr.js → download-DIoLCCYv.js} +1 -1
- package/lib/public/assets/{forgot-password-BNBLi023.js → forgot-password-vNYlPnia.js} +1 -1
- package/lib/public/assets/{h264Stream-C51Au2i_.js → h264Stream-BLcSplMU.js} +1 -1
- package/lib/public/assets/{index-Dk5J6HB1.js → index-BpqyclNY.js} +2 -2
- package/lib/public/assets/{index-DncSz5LG.js → index-Hl1OL-k_.js} +1 -1
- package/lib/public/assets/{index-Z7_BY3pJ.js → index-QbukVVrl.js} +1 -1
- package/lib/public/assets/{input-bTXM4l09.js → input-DHH3fHer.js} +1 -1
- package/lib/public/assets/{line-chart-B3YmVYyr.js → line-chart-PdViEphw.js} +1 -1
- package/lib/public/assets/{list-checks-BClKEj1-.js → list-checks-DI_heIg9.js} +1 -1
- package/lib/public/assets/{lock-CZsenX3D.js → lock-DVP_dL6J.js} +1 -1
- package/lib/public/assets/{login-B6A6tOp9.js → login-B8vtTDcr.js} +1 -1
- package/lib/public/assets/{maintenance-settings-CmCJGy7O.js → maintenance-settings-BMa5EfgI.js} +1 -1
- package/lib/public/assets/{monitor-BdTNEglU.js → monitor-CtzX_RkD.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-BM8CaLtt.js → mouse-pointer-2-BA09sdS9.js} +1 -1
- package/lib/public/assets/{network-BS6vUc1x.js → network-B_F9Nox-.js} +1 -1
- package/lib/public/assets/{overview-Yfk_Y7g3.js → overview-kWCYMHMV.js} +1 -1
- package/lib/public/assets/{page-header-DhXCwpml.js → page-header-CAbH1O1a.js} +1 -1
- package/lib/public/assets/{play-D08gP1td.js → play-sg95hLqA.js} +1 -1
- package/lib/public/assets/{plus-BKboorfa.js → plus-BT9mk2gj.js} +1 -1
- package/lib/public/assets/{profile-page-Cd9NodrA.js → profile-page-DZOz5Ypc.js} +1 -1
- package/lib/public/assets/{reset-password-acLDyyDW.js → reset-password-CqeImlEO.js} +1 -1
- package/lib/public/assets/{runbook-page-CWLkC1Fd.js → runbook-page-U_8TSysj.js} +1 -1
- package/lib/public/assets/{select-DZoRKNti.js → select-Cx4JDzsR.js} +1 -1
- package/lib/public/assets/{selector-detail-redirect-DS4qrt84.js → selector-detail-redirect-DiMRe7DW.js} +1 -1
- package/lib/public/assets/{selector-health-page-TpmN61G3.js → selector-health-page-CKR5URll.js} +1 -1
- package/lib/public/assets/{session-detail-page-C0wYaXqy.js → session-detail-page-DuIVzTW_.js} +1 -1
- package/lib/public/assets/{settings-CxPGEY2j.js → settings-B5fuvgTP.js} +1 -1
- package/lib/public/assets/{stat-tile-DUpyYgl-.js → stat-tile-CtHX1dkh.js} +1 -1
- package/lib/public/assets/{tablet-SA02BJNQ.js → tablet-DCGD0GQt.js} +1 -1
- package/lib/public/assets/{teams-jamD0Kxr.js → teams-MzlELlw9.js} +1 -1
- package/lib/public/assets/{trash-2-DO8fv6w4.js → trash-2-BIRm2KVs.js} +1 -1
- package/lib/public/assets/{upload-CaiGCStb.js → upload-C-lgyswH.js} +1 -1
- package/lib/public/assets/{use-builds-data-jS-fcvVf.js → use-builds-data-IOydXA8d.js} +1 -1
- package/lib/public/assets/{use-password-reset-mode-BzoenegM.js → use-password-reset-mode-CIVXG7Me.js} +1 -1
- package/lib/public/assets/{users-Bnw7Vs_B.js → users-hwK5XGIy.js} +1 -1
- package/lib/public/assets/{users-DHvDrriG.js → users-ivNCjeus.js} +1 -1
- package/lib/public/assets/{video-off-FEvy0w5U.js → video-off-DvcIEsdZ.js} +1 -1
- package/lib/public/assets/{webhook-settings-CBVB5lxi.js → webhook-settings-DukgCe1u.js} +1 -1
- package/lib/public/assets/{zap-BMrTJO6M.js → zap-BE9gacFj.js} +1 -1
- package/lib/public/index.html +1 -1
- package/lib/src/app/openapi/control.yaml +69 -4
- package/lib/src/app/routers/control.js +24 -5
- package/lib/src/device-managers/ios/IOSStreamService.js +147 -18
- package/lib/src/device-utils.js +50 -22
- package/lib/src/gateway/internalCall.js +33 -5
- package/lib/src/gateway/sessionGateway.js +9 -4
- package/lib/src/helpers/index.js +9 -6
- package/lib/src/interceptors/CommandInterceptor.js +10 -0
- package/lib/src/services/ServerManager.js +25 -4
- package/lib/src/services/UserService.js +8 -3
- package/lib/src/sessions/appiumUmbrella.js +11 -0
- package/lib/src/sessions/sessionMemory.js +11 -2
- package/lib/test/unit/UserService.test.js +8 -0
- package/lib/test/unit/boot-device-sync.spec.js +195 -0
- package/lib/test/unit/hub-node-gateway-appium-server.spec.js +21 -0
- package/lib/test/unit/install-scripts.spec.js +98 -0
- package/lib/test/unit/internal-call.spec.js +99 -0
- package/lib/test/unit/internal-calls-session-record.spec.js +312 -0
- package/lib/test/unit/ios-simulator-preview.spec.js +315 -0
- package/lib/test/unit/is-xenon-running.spec.js +10 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/lib/public/assets/DeviceMosaicView-DTVOB_NO.js +0 -2
- package/lib/public/assets/device-explorer-DlhrKJ-g.js +0 -282
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import{c as J,j as t,r as l,C as pn,U as ur,X,t as Ue,v as Bs,b as hr,u as Bt,a as ds,T as mr,q as Es,R as vt,w as fr,x as vn,y as Ge,z as Hs,I as Qn,S as Xt,f as gt,A as Jt,B as pr,i as ea,D as vr,E as yr,F as xr,G as gr,H as jr,p as br}from"./index-BpqyclNY.js";import{P as wr}from"./page-header-CAbH1O1a.js";import{P as Qt,u as kr,e as Nr,d as Cr,S as Sr,B as $r}from"./index-Hl1OL-k_.js";import{A as Tr}from"./activity-pEyAdE-M.js";import{h as Rr,M as ta,S as sa,C as Er,a as Lt,i as Ar,b as yn,W as Dr,H as Mr,p as zr,c as Lr,A as Dt,I as gs}from"./h264Stream-BLcSplMU.js";import{p as us}from"./labels-C21SA4JG.js";import{B as F}from"./button-B5QkOVa4.js";import{S as na}from"./select-Cx4JDzsR.js";import{P as ns,M as Vs,a as ke,b as aa}from"./Menu-CfTti3rw.js";import{M as hs}from"./Modal-BcZUFhDm.js";import{F as es}from"./FieldGroup-CaQNXgcE.js";import{C as Ir}from"./clock-MFKV4qGa.js";import{P as _r}from"./plus-BT9mk2gj.js";import{C as Pe}from"./copy-BU-Z7mBK.js";import{T as Or}from"./tablet-DCGD0GQt.js";import{S as Fr,a as xn}from"./SegmentedControl-CDLMLNl5.js";import{T as Pr,a as Ur,b as ra,c as as,d as Br,e as ft}from"./Table-CK414bOU.js";import{L as ia,a as Hr}from"./list-checks-DI_heIg9.js";import{C as Vr}from"./chevron-right-BZIp3-9t.js";import{M as gn}from"./mouse-pointer-2-BA09sdS9.js";import{Z as oa}from"./zap-BE9gacFj.js";import{C as Ot}from"./check-MIM4THvH.js";import{C as ca}from"./circle-check-Crt-G_uy.js";import{C as la}from"./circle-x-C8GvvXVt.js";import{E as Wr}from"./EmptyState-WzLw1cEV.js";import{I as jn}from"./input-DHH3fHer.js";import{P as qr,a as Kr}from"./play-sg95hLqA.js";import{D as da}from"./download-DIoLCCYv.js";import{U as Xr,T as Yr}from"./upload-C-lgyswH.js";import{A as Gr}from"./arrow-left-DaEUmERk.js";import{A as Zr}from"./arrow-right-CnRXHXit.js";import{p as Jr,A as Qr}from"./AnnotationOverlay-CB8njQvS.js";import{T as ei}from"./trash-2-BIRm2KVs.js";import{L as ti}from"./lock-DVP_dL6J.js";import{F as bn}from"./FilterMenu-C9gAiypL.js";import"./utils-CDN07tui.js";import"./index-QbukVVrl.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const si=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ws=J("arrow-down",si);/**
|
|
7
|
+
* @license lucide-react v0.555.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ni=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],qs=J("arrow-up",ni);/**
|
|
12
|
+
* @license lucide-react v0.555.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ai=[["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],ri=J("battery-low",ai);/**
|
|
17
|
+
* @license lucide-react v0.555.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const ii=[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 6h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2",key:"1m83kb"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"h8lgfh"}]],oi=J("battery-warning",ii);/**
|
|
22
|
+
* @license lucide-react v0.555.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const ci=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],li=J("battery",ci);/**
|
|
27
|
+
* @license lucide-react v0.555.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const di=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],ui=J("box",di);/**
|
|
32
|
+
* @license lucide-react v0.555.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const hi=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],mi=J("calendar-plus",hi);/**
|
|
37
|
+
* @license lucide-react v0.555.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const fi=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],pi=J("chevrons-down-up",fi);/**
|
|
42
|
+
* @license lucide-react v0.555.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const vi=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],yi=J("chevrons-up-down",vi);/**
|
|
47
|
+
* @license lucide-react v0.555.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const xi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ua=J("circle-question-mark",xi);/**
|
|
52
|
+
* @license lucide-react v0.555.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const gi=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],wn=J("code-xml",gi);/**
|
|
57
|
+
* @license lucide-react v0.555.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const ji=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],bi=J("columns-2",ji);/**
|
|
62
|
+
* @license lucide-react v0.555.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const wi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],ki=J("crosshair",wi);/**
|
|
67
|
+
* @license lucide-react v0.555.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Ni=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ha=J("ellipsis",Ni);/**
|
|
72
|
+
* @license lucide-react v0.555.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Ci=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]],Si=J("folder-down",Ci);/**
|
|
77
|
+
* @license lucide-react v0.555.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const $i=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],Ti=J("hand",$i);/**
|
|
82
|
+
* @license lucide-react v0.555.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const Ri=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ei=J("image",Ri);/**
|
|
87
|
+
* @license lucide-react v0.555.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const Ai=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Di=J("keyboard",Ai);/**
|
|
92
|
+
* @license lucide-react v0.555.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const Mi=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],zi=J("library",Mi);/**
|
|
97
|
+
* @license lucide-react v0.555.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const Li=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Ii=J("lock-open",Li);/**
|
|
102
|
+
* @license lucide-react v0.555.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const _i=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Oi=J("map-pin",_i);/**
|
|
107
|
+
* @license lucide-react v0.555.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const Fi=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Pi=J("maximize-2",Fi);/**
|
|
112
|
+
* @license lucide-react v0.555.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const Ui=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Bi=J("message-square",Ui);/**
|
|
117
|
+
* @license lucide-react v0.555.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const Hi=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Vi=J("minimize-2",Hi);/**
|
|
122
|
+
* @license lucide-react v0.555.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const Wi=[["path",{d:"M18 5h4",key:"1lhgn2"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],qi=J("moon-star",Wi);/**
|
|
127
|
+
* @license lucide-react v0.555.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const Ki=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Xi=J("mouse-pointer-click",Ki);/**
|
|
132
|
+
* @license lucide-react v0.555.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const Yi=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Gi=J("package",Yi);/**
|
|
137
|
+
* @license lucide-react v0.555.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const Zi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],Ji=J("panel-top",Zi);/**
|
|
142
|
+
* @license lucide-react v0.555.0 - ISC
|
|
143
|
+
*
|
|
144
|
+
* This source code is licensed under the ISC license.
|
|
145
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
+
*/const Qi=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ma=J("pen-line",Qi);/**
|
|
147
|
+
* @license lucide-react v0.555.0 - ISC
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the ISC license.
|
|
150
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
+
*/const eo=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],to=J("rectangle-horizontal",eo);/**
|
|
152
|
+
* @license lucide-react v0.555.0 - ISC
|
|
153
|
+
*
|
|
154
|
+
* This source code is licensed under the ISC license.
|
|
155
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
+
*/const so=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],no=J("rectangle-vertical",so);/**
|
|
157
|
+
* @license lucide-react v0.555.0 - ISC
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the ISC license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/const ao=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],It=J("rotate-cw",ao);/**
|
|
162
|
+
* @license lucide-react v0.555.0 - ISC
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the ISC license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/const ro=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],fa=J("scroll-text",ro);/**
|
|
167
|
+
* @license lucide-react v0.555.0 - ISC
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the ISC license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/const io=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],St=J("shield-alert",io);/**
|
|
172
|
+
* @license lucide-react v0.555.0 - ISC
|
|
173
|
+
*
|
|
174
|
+
* This source code is licensed under the ISC license.
|
|
175
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
+
*/const oo=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],co=J("tag",oo);/**
|
|
177
|
+
* @license lucide-react v0.555.0 - ISC
|
|
178
|
+
*
|
|
179
|
+
* This source code is licensed under the ISC license.
|
|
180
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
+
*/const lo=[["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"}]],js=J("target",lo);/**
|
|
182
|
+
* @license lucide-react v0.555.0 - ISC
|
|
183
|
+
*
|
|
184
|
+
* This source code is licensed under the ISC license.
|
|
185
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
+
*/const uo=[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]],ho=J("text-cursor-input",uo);/**
|
|
187
|
+
* @license lucide-react v0.555.0 - ISC
|
|
188
|
+
*
|
|
189
|
+
* This source code is licensed under the ISC license.
|
|
190
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
+
*/const mo=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],fo=J("thermometer",mo);/**
|
|
192
|
+
* @license lucide-react v0.555.0 - ISC
|
|
193
|
+
*
|
|
194
|
+
* This source code is licensed under the ISC license.
|
|
195
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
+
*/const po=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],vo=J("toggle-left",po);/**
|
|
197
|
+
* @license lucide-react v0.555.0 - ISC
|
|
198
|
+
*
|
|
199
|
+
* This source code is licensed under the ISC license.
|
|
200
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
+
*/const yo=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]],kn=J("touchpad",yo);/**
|
|
202
|
+
* @license lucide-react v0.555.0 - ISC
|
|
203
|
+
*
|
|
204
|
+
* This source code is licensed under the ISC license.
|
|
205
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
+
*/const xo=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],go=J("type",xo);/**
|
|
207
|
+
* @license lucide-react v0.555.0 - ISC
|
|
208
|
+
*
|
|
209
|
+
* This source code is licensed under the ISC license.
|
|
210
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
+
*/const jo=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],bo=J("volume-1",jo);/**
|
|
212
|
+
* @license lucide-react v0.555.0 - ISC
|
|
213
|
+
*
|
|
214
|
+
* This source code is licensed under the ISC license.
|
|
215
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
+
*/const wo=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],ko=J("volume-2",wo);function No(e){return e>=50?"ready":e>=20?"warning":"error"}function Co(e){return e>=50?t.jsx(li,{size:10}):e>=20?t.jsx(ri,{size:10}):t.jsx(oi,{size:10})}function So(e){return e==="Normal"?"ready":e==="Critical"?"error":"warning"}const $o=({device:e})=>{if(e.deviceType==="emulator"||e.deviceType==="simulator"||e.offline)return null;const n=typeof e.batteryLevel=="number",a=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!n&&!a?t.jsx("div",{className:"dc2-health",children:t.jsxs(Qt,{tone:"neutral",title:"Device does not report battery or thermal data",children:[t.jsx(Tr,{size:10}),"No telemetry"]})}):t.jsxs("div",{className:"dc2-health",children:[n&&t.jsxs(Qt,{tone:No(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[Co(e.batteryLevel),e.batteryLevel,"%"]}),a&&t.jsxs(Qt,{tone:So(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[t.jsx(fo,{size:10}),e.thermalStatus]})]})};function To(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 Ro=(e,s)=>s===1?e:`${e}s`,Eo=1e-7;function pa(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=[],a=(c,h)=>{const d=Math.floor(c*10**h+Eo);return(Math.round(d)/10**h).toFixed(h)},r=(c,h,d,o)=>{if((n.length===0||!s.colonNotation)&&c===0&&!(s.colonNotation&&d==="m"))return;o=(o||c||"0").toString();let u,p;if(s.colonNotation){u=n.length>0?":":"",p="";const y=o.includes(".")?o.split(".")[0].length:o.length,f=n.length>0?2:1;o="0".repeat(Math.max(0,f-y))+o}else u="",p=s.verbose?" "+Ro(h,c):d;n.push(u+o+p)},i=To(e);if(r(Math.trunc(i.days/365),"year","y"),r(i.days%365,"day","d"),r(i.hours,"hour","h"),r(i.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&e<1e3)if(r(i.seconds,"second","s"),s.formatSubMilliseconds)r(i.milliseconds,"millisecond","ms"),r(i.microseconds,"microsecond","µs"),r(i.nanoseconds,"nanosecond","ns");else{const c=i.milliseconds+i.microseconds/1e3+i.nanoseconds/1e6,h=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,d=c>=1?Math.round(c):Math.ceil(c),o=h?c.toFixed(h):d;r(Number.parseFloat(o),"millisecond","ms",o)}else{const c=e/1e3%60,h=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,d=a(c,h),o=s.keepDecimalsOnWholeSeconds?d:d.replace(/\.0+$/,"");r(Number.parseFloat(o),"second","s",o)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const c=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(c)}return s.colonNotation?n.join(""):n.join(" ")}const bs=6e4;function Ao(e){return!Number.isFinite(e)||e<=0?"expiring":e<bs?"under 1m":pa(Math.floor(e/bs)*bs,{unitCount:2})}const As=["ready","busy","reserved","maintenance","offline"],va={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function Ft(e,s){return e.offline?"offline":e.userBlocked?"maintenance":e.busy?"busy":e.reservedUntil&&s<e.reservedUntil?"reserved":"ready"}function ya(e,s){const n=Rr(e);if(!e.busy||!n)return null;const a=String(n);return a.startsWith("manual_")?s!=null&&s.userId&&a===`manual_${s.userId}_${e.udid}`?"self":"other":"session"}const Nn=e=>(e==null?void 0:e.role)==="ADMIN"||(e==null?void 0:e.role)==="SUPER_ADMIN";function Do(e,s,n){switch(ya(e,s)){case"session":return e.sessionStartTime&&e.sessionStartTime>0&&n>e.sessionStartTime?`Test session · ${pa(n-e.sessionStartTime,{compact:!0})}`:"Test session running";case"self":return"Live control by you";case"other":return"Live control by another user"}if(e.reservedUntil&&n<e.reservedUntil){const r=!!e.reservedBy&&(e.reservedBy===(s==null?void 0:s.email)||e.reservedBy===(s==null?void 0:s.name))?"you":e.reservedBy||"another user";return`${Ao(e.reservedUntil-n)} left · by ${r}`}return null}function Mo(e,s){if(e.offline)return{enabled:!1,reason:"Device is offline"};if(e.userBlocked&&!Nn(s))return{enabled:!1,reason:"In maintenance"};const n=ya(e,s);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!Nn(s)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function ot(e){var s;return((s=e.marketingName)==null?void 0:s.trim())||e.name}function xa(e){const s=[us(e.platform),e.sdk].filter(Boolean).join(" ");if(e.deviceType==="emulator")return`Emulator · ${s}`;if(e.deviceType==="simulator")return`Simulator · ${s}`;const a=[e.manufacturer?e.manufacturer.charAt(0).toUpperCase()+e.manufacturer.slice(1):"",e.model].filter(Boolean).join(" ");return a?`${a} · ${s}`:s}function zo(e){return e.formFactor==="tablet"||e.formFactor==="tv"?e.formFactor:"phone"}function Tt(e,s){return e.teamId?(s==null?void 0:s.get(e.teamId))??e.teamName??`Team ${e.teamId.slice(0,6)}`:null}const Lo=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],Io=({device:e,onClose:s,onReserved:n})=>{const[a,r]=l.useState(""),[i,c]=l.useState("1h"),[h,d]=l.useState(""),[o,u]=l.useState(!1),[p,y]=l.useState(null),[f,g]=l.useState(null),k=async()=>{if(!a.trim()){y("Please enter your name/ID");return}u(!0),y(null),g(null);try{const b=await X.reserveDevice(e.udid,e.host,a,i,h);b.success?(n(),s()):g(b.error||"Failed to reserve device")}catch(b){g(b.message||"An unexpected error occurred")}finally{u(!1)}};return t.jsx(hs,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(mi,{size:16,className:"title-icon"}),"Reserve device"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,disabled:o,children:"Cancel"}),t.jsx("button",{className:"btn-reserve",onClick:k,disabled:o||!a.trim(),children:o?"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(es,{label:t.jsxs(t.Fragment,{children:[t.jsx(ur,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:p?t.jsxs(t.Fragment,{children:[t.jsx(pn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),p]}):void 0,children:t.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:a,onChange:b=>{r(b.target.value),p&&y(null)},disabled:o})}),t.jsx(es,{label:t.jsxs(t.Fragment,{children:[t.jsx(Ir,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:t.jsx("div",{className:"duration-selector",children:Lo.map(b=>t.jsx("div",{className:`duration-option ${i===b.value?"active":""}`,onClick:()=>c(b.value),children:b.label},b.value))})}),t.jsx(es,{label:t.jsxs(t.Fragment,{children:[t.jsx(Bi,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?t.jsxs(t.Fragment,{children:[t.jsx(pn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:t.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:h,onChange:b=>d(b.target.value),disabled:o})})]})})},_o=({device:e,onClose:s,onUpdated:n})=>{const{toast:a}=Ue(),[r,i]=l.useState(e.tags||[]),[c,h]=l.useState(""),[d,o]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{u.current&&u.current.focus()},[]);const p=()=>{const k=c.trim();k&&!r.includes(k)&&(i([...r,k]),h(""))},y=k=>{i(r.filter(b=>b!==k))},f=k=>{k.key==="Enter"&&p()},g=async()=>{o(!0);try{await X.updateDeviceTags(e.udid,e.host,r),n(),s()}catch(k){console.error("Failed to update tags",k),a("Error saving tags. Please try again.","error")}finally{o(!1)}};return t.jsx(hs,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(co,{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:g,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(es,{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:u,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:c,onChange:k=>h(k.target.value),onKeyDown:f}),t.jsx("button",{className:"add-inline-btn",onClick:p,disabled:!c.trim(),children:t.jsx(_r,{size:16})})]})}),t.jsxs("div",{className:"tags-display-section",children:[t.jsx("label",{children:"Current Tags"}),t.jsx("div",{className:"tags-list",children:r.length>0?r.map(k=>t.jsxs("div",{className:"tag-pill-editable",children:[k,t.jsx("button",{className:"remove-tag",onClick:()=>y(k),children:t.jsx(Bs,{size:12})})]},k)):t.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},Oo="/wd/hub";function Fo(e){return e==="android"?"UiAutomator2":"XCUITest"}function Po(e){return e==="android"?"Android":e==="tvos"?"tvOS":"iOS"}function Uo(e,s=Oo){if(!e)return"—";try{const n=new URL(e.includes("://")?e:`http://${e}`),a=s.startsWith("/")?s:`/${s}`,r=n.pathname.replace(/\/$/,"");return r===a||r.endsWith(a)?`${n.protocol}//${n.host}${r}`:`${n.protocol}//${n.host}${a}`}catch{return e}}function Bo(e){const s={platformName:Po(e.platform),"appium:automationName":Fo(e.platform),"appium:udid":e.udid};return e.sdk&&e.sdk!=="Unknown"&&e.sdk!=="unknown"&&(s["appium:platformVersion"]=e.sdk),e.name&&(s["appium:deviceName"]=e.name),s}function Ho(e){return JSON.stringify(Bo(e),null,2)}const Vo=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,Wo=/^(?:\d{1,3}\.){3}\d{1,3}$/;function qo(e){const s=e.trim();return!s||Vo.test(s)||!Wo.test(s)?!1:s.split(".").every(n=>{const a=Number(n);return Number.isInteger(a)&&a>=0&&a<=255})}function Ko(e){return e.ip&&qo(e.ip)?e.ip.trim():null}const ga=({udid:e,currentTeamId:s,teams:n,onDone:a,className:r})=>{const{toast:i}=Ue(),[c,h]=l.useState(!1);async function d(o){h(!0);try{await X.setDeviceTeam(e,o)}catch(u){h(!1),i((u==null?void 0:u.message)||"Failed to update team","error");return}h(!1),i(o?"Device assigned":"Device returned to shared pool","success"),a(!0)}return t.jsxs(na,{selectSize:"sm",className:r,autoFocus:!0,"aria-label":"Team",disabled:c,defaultValue:s??"",onBlur:()=>a(!1),onChange:o=>d(o.target.value||null),children:[t.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([o,u])=>t.jsx("option",{value:o,children:u},o))]})};function ja(e,s){const[n,a]=l.useState(!1),[r,i]=l.useState(!1),[c,h]=l.useState(!1),{me:d}=hr(),{toast:o}=Ue(),u=(d==null?void 0:d.role)==="ADMIN"||(d==null?void 0:d.role)==="SUPER_ADMIN",p=Date.now(),y=Ft(e,p),f=y==="reserved",g=Do(e,d,p),k=Mo(e,d),b=Uo(e.host),U=Ko(e),N=async($,m)=>{var S;try{await((S=navigator.clipboard)==null?void 0:S.writeText($)),o(m,"success")}catch{o("Failed to copy","error")}},w=async()=>{await X.releaseReservation(e.udid,e.host),s()},C=async()=>{await X.blockDevice(e.udid,e.host),s()},j=async()=>{await X.unblockDevice(e.udid,e.host),s()},A=async()=>{e.userBlocked?await j():await C()},T=t.jsxs(t.Fragment,{children:[n&&t.jsx(Io,{device:e,onClose:()=>a(!1),onReserved:()=>s()}),r&&t.jsx(_o,{device:e,onClose:()=>i(!1),onUpdated:()=>s()})]});return{kind:y,reserved:f,activity:g,control:k,isAdmin:u,editingTeam:c,setEditingTeam:h,openReservation:()=>a(!0),openTagManager:()=>i(!0),release:w,toggleMaintenance:A,copy:N,serverUrl:b,ip:U,dialogs:T}}const ba=({device:e,actions:s,navigate:n,reasonId:a})=>{const{kind:r,reserved:i,control:c}=s;return t.jsxs(t.Fragment,{children:[t.jsx(F,{variant:"tonal",size:"sm",disabled:!c.enabled,"aria-describedby":c.enabled?void 0:a,onClick:()=>{c.enabled&&n(`/devices/${e.udid}/control`)},children:"Control"}),i?t.jsx(F,{variant:"secondary",size:"sm",onClick:s.release,children:"Release"}):r==="ready"?t.jsx(F,{variant:"secondary",size:"sm",onClick:s.openReservation,children:"Reserve"}):null]})},wa=({device:e,actions:s})=>{const[n,a]=l.useState(!1),r=l.useRef(null),{isAdmin:i,serverUrl:c,ip:h,copy:d}=s;return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:r,type:"button",className:"dc2-more",onClick:()=>a(o=>!o),"aria-label":"More actions",children:t.jsx(ha,{size:14})}),t.jsx(ns,{open:n,onClose:()=>a(!1),anchorRef:r,children:t.jsxs(Vs,{children:[t.jsx(ke,{icon:t.jsx(Pe,{size:12}),onClick:()=>{a(!1),d(e.udid,"UDID copied")},children:"Copy UDID"}),c!=="—"&&t.jsx(ke,{icon:t.jsx(Pe,{size:12}),onClick:()=>{a(!1),d(c,"Server URL copied")},children:"Copy server URL"}),h&&t.jsx(ke,{icon:t.jsx(Pe,{size:12}),onClick:()=>{a(!1),d(h,"IP address copied")},children:"Copy IP address"}),t.jsx(ke,{icon:t.jsx(Pe,{size:12}),onClick:()=>{a(!1),d(Ho(e),"Session capabilities copied")},children:"Copy capabilities"}),i&&t.jsxs(t.Fragment,{children:[t.jsx(aa,{}),t.jsx(ke,{onClick:()=>{a(!1),s.openTagManager()},children:"Manage tags…"}),t.jsx(ke,{onClick:()=>{a(!1),s.setEditingTeam(!0)},children:"Assign team…"}),t.jsx(ke,{onClick:()=>{a(!1),s.toggleMaintenance()},children:e.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},Xo=({device:e})=>{const s={phone:Es,tablet:Or,tv:mr}[zo(e)],n=e.deviceType==="emulator"||e.deviceType==="simulator";return t.jsx(s,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},Yo=({device:e,reloadDevices:s,navigate:n,teams:a})=>{var p,y,f;const r=ja(e,s),{kind:i,activity:c,control:h}=r,d=`dc2-reason-${e.udid}`,o=ot(e),u=Tt(e,a);return t.jsxs("div",{className:`dc2 dc2-${i}`,children:[t.jsxs("div",{className:`dc2-band dc2-band-${i}`,children:[t.jsxs("span",{className:"dc2-band-label",children:[t.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),va[i]]}),c&&t.jsx("span",{className:"dc2-band-activity",title:c,children:c})]}),t.jsxs("div",{className:`dc2-body${i==="offline"?" dc2-dim":""}`,children:[t.jsxs("div",{className:"dc2-head",children:[t.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:t.jsx(Xo,{device:e})}),t.jsxs("div",{className:"dc2-id",children:[t.jsx("div",{className:"dc2-title",title:`${o}
|
|
217
|
+
${e.udid}`,children:o}),t.jsx("div",{className:"dc2-subtitle",children:xa(e)})]})]}),t.jsxs("div",{className:"dc2-meta",children:[t.jsx($o,{device:e}),r.editingTeam?t.jsx(ga,{className:"dc2-team-picker",udid:e.udid,currentTeamId:e.teamId??null,teams:a??new Map,onDone:g=>{r.setEditingTeam(!1),g&&s()}}):u&&t.jsx(Qt,{tone:"accent",className:"dc2-team",title:`Team: ${u}`,children:u}),(p=e.tags)==null?void 0:p.slice(0,2).map(g=>t.jsxs("span",{className:"dc2-tag",title:g,children:["#",g]},g)),(((y=e.tags)==null?void 0:y.length)||0)>2&&t.jsxs("span",{className:"dc2-tag",children:["+",(((f=e.tags)==null?void 0:f.length)||0)-2]})]})]}),t.jsxs("div",{className:"dc2-foot",children:[t.jsx(ba,{device:e,actions:r,navigate:n,reasonId:d}),!h.enabled&&t.jsx("span",{id:d,className:"dc2-unavailable",title:h.reason,children:h.reason}),t.jsx("span",{className:"dc2-spacer"}),t.jsx(wa,{device:e,actions:r})]}),r.dialogs]})};function Go(e){const s=Bt(),{search:n}=ds();return t.jsx(Yo,{device:e.device,reloadDevices:e.reloadDevices,navigate:a=>s(`${a}${n}`),teams:e.teams})}class Zo extends vt.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){X.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:vt.Children.toArray(this.props.devices.map(s=>t.jsx(Go,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const Jo={status:"all",platform:"all",type:"all",q:""},ka=["all",...As],Na=["all","android","ios","tvos"],Ca=["all","real","virtual"];function ws(e,s){return s.includes(e)?e:s[0]}function Qo(e){const s=e.get("q")??"";return{status:ws(e.get("status"),ka),platform:ws(e.get("platform"),Na),type:ws(e.get("type"),Ca),q:s.trim()?s:""}}function ec(e){const s=new URLSearchParams;return e.status!=="all"&&s.set("status",e.status),e.platform!=="all"&&s.set("platform",e.platform),e.type!=="all"&&s.set("type",e.type),e.q.trim()&&s.set("q",e.q),s}function Pt(e){return e.deviceType==="simulator"||e.deviceType==="emulator"?!0:!e.deviceType&&e.realDevice===!1}function Ks(e){const s=(e.platform||"").toLowerCase();return s==="android"||s==="ios"||s==="tvos"?s:null}function tc(e){const s=e.deviceType==="emulator"?"Emulator":e.deviceType==="simulator"?"Simulator":"";return[ot(e),e.name,e.manufacturer,e.model,us(e.platform),e.sdk,s,e.teamName,e.udid].filter(Boolean).join(" ").toLowerCase()}function ts(e,s,n,a){if(a!=="status"&&s.status!=="all"&&Ft(e,n)!==s.status||a!=="platform"&&s.platform!=="all"&&Ks(e)!==s.platform||a!=="type"&&s.type!=="all"&&s.type==="virtual"!==Pt(e))return!1;const r=s.q.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return!0;const i=tc(e);return r.every(c=>i.includes(c))}const ks=e=>Object.fromEntries(e.map(s=>[s,0]));function sc(e,s,n){const a=ks(ka),r=ks(Na),i=ks(Ca);for(const c of e){if(ts(c,s,n,"status")&&(a.all+=1,a[Ft(c,n)]+=1),ts(c,s,n,"platform")){r.all+=1;const h=Ks(c);h&&(r[h]+=1)}ts(c,s,n,"type")&&(i.all+=1,i[Pt(c)?"virtual":"real"]+=1)}return{status:a,platform:r,type:i}}function nc(e){return e.some(s=>Ks(s)==="tvos")}function ac(e){return e.status!=="all"||e.platform!=="all"||e.type!=="all"||e.q.trim()!==""}function rc(e,s){const n=a=>a===1?"device":"devices";return e===s?`${s} ${n(s)}`:`${e} of ${s} ${n(s)}`}const Ds={key:"status",dir:"asc"},ic=["status","device","platform","type","team","host"],oc=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),pt=(e,s)=>oc.compare(e,s);function cc(e,s,n,a){switch(n){case"status":return As.indexOf(Ft(e,a.now))-As.indexOf(Ft(s,a.now));case"device":return pt(ot(e),ot(s));case"platform":return pt(e.platform||"",s.platform||"")||pt(e.sdk||"",s.sdk||"");case"type":return Number(Pt(e))-Number(Pt(s));case"team":return pt(Tt(e,a.teams)??"",Tt(s,a.teams)??"");case"host":return pt(e.host||"",s.host||"")}}function lc(e,s,n){const a=s.dir==="desc"?-1:1;return e.slice().sort((r,i)=>{if(s.key==="team"){const c=Tt(r,n.teams)===null,h=Tt(i,n.teams)===null;if(c!==h)return c?1:-1}return a*cc(r,i,s.key,n)||pt(ot(r),ot(i))||pt(r.udid,i.udid)})}function dc(e){const s=e.get("sort");return!s||!ic.includes(s)?Ds:{key:s,dir:e.get("dir")==="desc"?"desc":"asc"}}function uc(e,s){e.delete("sort"),e.delete("dir"),!(s.key===Ds.key&&s.dir===Ds.dir)&&(e.set("sort",s.key),s.dir==="desc"&&e.set("dir","desc"))}const $t=({sortKey:e,label:s,sort:n,onSortChange:a})=>{const r=n.key===e,i=r?n.dir:"asc";return t.jsx(as,{scope:"col","aria-sort":r?i==="asc"?"ascending":"descending":"none",children:t.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>a(r?{key:e,dir:i==="asc"?"desc":"asc"}:{key:e,dir:"asc"}),children:[s,r&&(i==="asc"?t.jsx(qs,{size:12,"aria-hidden":"true"}):t.jsx(Ws,{size:12,"aria-hidden":"true"}))]})})},hc=({device:e,reloadDevices:s,navigate:n,teams:a,showHost:r})=>{const i=ja(e,s),{kind:c,activity:h,control:d}=i,o=ot(e),u=xa(e),p=Tt(e,a),y=`${us(e.platform)} ${e.sdk??""}`,f=e.tags??[],g=`devtable-reason-${e.udid}`;return t.jsxs(ra,{className:`devtable-row${c==="offline"?" is-offline":""}`,children:[t.jsxs(ft,{children:[t.jsxs("div",{className:"devtable-line",children:[t.jsx(Fr,{kind:c,className:"devtable-status-dot"})," ",va[c]]}),h&&t.jsx("div",{className:"devtable-muted devtable-line",title:h,children:h})]}),t.jsxs(as,{scope:"row",className:"devtable-rowheader",title:`${o}
|
|
218
|
+
${e.udid}`,children:[t.jsx("div",{className:"devtable-title devtable-line",children:o}),t.jsx("div",{className:"devtable-muted devtable-line",title:u,children:u})]}),t.jsx(ft,{title:y,children:y}),t.jsx(ft,{children:Pt(e)?"Virtual":"Real"}),t.jsx(ft,{title:i.editingTeam?void 0:p??"Shared",children:i.editingTeam?t.jsx(ga,{udid:e.udid,currentTeamId:e.teamId??null,teams:a,onDone:k=>{i.setEditingTeam(!1),k&&s()}}):p??"Shared"}),t.jsxs(ft,{title:f.join(", "),children:[f.slice(0,2).map(k=>t.jsxs("span",{className:"devtable-tag",children:["#",k]},k)),f.length>2&&t.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),r&&t.jsx(ft,{title:e.host,children:e.host}),t.jsx(ft,{className:"devtable-actions",title:d.enabled?void 0:d.reason,children:t.jsxs("div",{className:"devtable-actions-inner",children:[t.jsx(ba,{device:e,actions:i,navigate:n,reasonId:g}),!d.enabled&&t.jsx("span",{id:g,className:"sr-only",children:d.reason}),t.jsx(wa,{device:e,actions:i})]})}),i.dialogs]})};function mc({devices:e,reloadDevices:s,sort:n,onSortChange:a,navigate:r,teams:i}){const c=new Set(e.map(d=>d.host)).size>1||n.key==="host",h=lc(e,n,{now:Date.now(),teams:i});return t.jsxs(Pr,{className:"devtable",children:[t.jsxs("caption",{className:"sr-only",children:["Devices, ",e.length," shown"]}),t.jsxs("colgroup",{children:[t.jsx("col",{className:"devtable-col-status"}),t.jsx("col",{}),t.jsx("col",{className:"devtable-col-platform"}),t.jsx("col",{className:"devtable-col-type"}),t.jsx("col",{className:"devtable-col-team"}),t.jsx("col",{className:"devtable-col-tags"}),c&&t.jsx("col",{className:"devtable-col-host"}),t.jsx("col",{className:"devtable-col-actions"})]}),t.jsx(Ur,{children:t.jsxs(ra,{children:[t.jsx($t,{sortKey:"status",label:"Status",sort:n,onSortChange:a}),t.jsx($t,{sortKey:"device",label:"Device",sort:n,onSortChange:a}),t.jsx($t,{sortKey:"platform",label:"Platform",sort:n,onSortChange:a}),t.jsx($t,{sortKey:"type",label:"Type",sort:n,onSortChange:a}),t.jsx($t,{sortKey:"team",label:"Team",sort:n,onSortChange:a}),t.jsx(as,{scope:"col",children:"Tags"}),c&&t.jsx($t,{sortKey:"host",label:"Host",sort:n,onSortChange:a}),t.jsx(as,{scope:"col",children:"Actions"})]})}),t.jsx(Br,{children:h.map(d=>t.jsx(hc,{device:d,reloadDevices:s,navigate:r,teams:i,showHost:c},d.udid))})]})}function fc(e){const s=Bt(),{search:n}=ds(),[a,r]=l.useState(new Map);return l.useEffect(()=>{X.listTeams().then(i=>r(new Map(i.map(c=>[c.id,c.name])))).catch(()=>{})},[]),t.jsx(mc,{devices:e.devices,reloadDevices:e.reloadDevices,sort:e.sort,onSortChange:e.onSortChange,navigate:i=>s(`${i}${n}`),teams:a})}const pc=({onCommand:e,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:a})=>{const[r,i]=l.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[c,h]=l.useState(""),[d,o]=l.useState([]),[u,p]=l.useState(-1),[y,f]=l.useState(!1),g=l.useRef(null),k=l.useRef(null);l.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[r]);const b=N=>{const w=N.trim();if((w.startsWith("{")||w.startsWith("["))&&(w.endsWith("}")||w.endsWith("]")))try{const C=JSON.parse(w);return JSON.stringify(C,null,2)}catch{}return N},U=async N=>{if(N.key==="Enter"&&!y){const w=c.trim();if(!w)return;if(h(""),i(C=>[...C,{type:"command",content:`${s} ${w}`,timestamp:Date.now()}]),o(C=>[...C,w]),p(-1),f(!0),w==="clear"){i([]),f(!1);return}if(w==="help"){let C="";a==="android"?C=`
|
|
219
|
+
Android Allowed Commands:
|
|
220
|
+
• System Info: getprop, ip addr, date, uptime, whoami, cat /proc/meminfo, cat /proc/cpuinfo
|
|
221
|
+
• Process Mgmt: ps, top
|
|
222
|
+
• File System: ls
|
|
223
|
+
• Network: netstat
|
|
224
|
+
• Diagnostics: dumpsys [battery|wifi|power]
|
|
225
|
+
• Packages: pm list packages
|
|
226
|
+
One command per line, in plain words: no ; | & $ quotes or redirection.
|
|
227
|
+
`:(a==="ios"||a==="tvos")&&(C=`
|
|
228
|
+
iOS Allowed Commands:
|
|
229
|
+
• Real Device (go-ios):
|
|
230
|
+
apps, info
|
|
231
|
+
• Simulator (xcrun simctl):
|
|
232
|
+
listapps, get_app_container, getenv
|
|
233
|
+
• Simulator System (no arguments):
|
|
234
|
+
ls, ps, date, uptime, whoami, id
|
|
235
|
+
One command per line, in plain words: no ; | & $ quotes or redirection.
|
|
236
|
+
`),i(j=>[...j,{type:"output",content:C.trim(),timestamp:Date.now()}]),f(!1);return}try{const C=await e(w),j=b(C||"(No output)");i(A=>[...A,{type:"output",content:j,timestamp:Date.now()}])}catch(C){i(j=>[...j,{type:"error",content:C.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var C;return(C=k.current)==null?void 0:C.focus()},10)}}else if(N.key==="ArrowUp"){if(N.preventDefault(),d.length>0){const w=u===-1?d.length-1:Math.max(0,u-1);p(w),h(d[w])}}else if(N.key==="ArrowDown"&&(N.preventDefault(),u!==-1)){const w=u+1;w>=d.length?(p(-1),h("")):(p(w),h(d[w]))}};return t.jsxs("div",{className:"terminal-container theme-dark",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:[us(a)," shell"]}),t.jsx("div",{className:"terminal-actions",children:t.jsx("button",{className:"terminal-action-btn",onClick:()=>i([]),title:"Clear terminal",children:"CLEAR"})})]}),t.jsxs("div",{className:"terminal-history",ref:g,onClick:()=>{var N;return(N=k.current)==null?void 0:N.focus()},children:[r.map((N,w)=>t.jsx("div",{className:`terminal-line ${N.type}`,children:N.content},w)),y&&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:k,className:"terminal-input",value:c,onChange:N=>h(N.target.value),onKeyDown:U,disabled:y,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Je(e,s){var n;s(e),(n=e.children)==null||n.forEach(a=>Je(a,s))}function Ze(e,...s){var n;for(const a of s){const r=(n=e.attributes)==null?void 0:n[a];if(r!=null&&r!=="")return String(r)}}function Rt(e){var s;return((s=e.type)==null?void 0:s.split(".").pop())||e.type||""}function vc(e,s){const n=[];return Je(e,a=>{Ze(a,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(a)}),n}function yc(e,s){const n=[];return Je(e,a=>{Ze(a,"resource-id","resourceId","identifier")===s&&n.push(a)}),n}function Ms(e,s){const n=[];return Je(e,a=>{(a.type===s||Rt(a)===s)&&n.push(a)}),n}function xc(e,s){const n=[];return Je(e,a=>{Ze(a,"name")===s&&n.push(a)}),n}function gc(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 jc(e,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const a=[];for(const i of n){const c=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(i);if(!c)return null;a.push({type:c[1],index:parseInt(c[2],10)})}if(a[0].type!==e.type&&a[0].type!==Rt(e)||a[0].index!==1)return null;let r=e;for(let i=1;i<a.length&&r;i++){const{type:c,index:h}=a[i];let d=0,o;for(const u of r.children||[])if((u.type===c||Rt(u)===c)&&(d+=1,d===h)){o=u;break}r=o}return r?[r]:[]}function bc(e,s){const n=jc(e,s);if(n!==null)return{kind:"matched",nodes:n};const a=gc(s);if(a){const r=[];return Je(e,i=>{if(a.tag&&i.type!==a.tag&&Rt(i)!==a.tag)return;Ze(i,a.attrKey)===a.attrValue&&r.push(i)}),{kind:"matched",nodes:r}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function wc(e,s){const n=s.trim(),a=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(a){const[,c,h,d]=a,o=[];return Je(e,u=>{if(u.type!==c&&Rt(u)!==c)return;Ze(u,h)===d&&o.push(u)}),{kind:"matched",nodes:o}}const r=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(r){const[,c,h]=r,d=parseInt(h,10),o=[];return Je(e,u=>{(u.type===c||Rt(u)===c)&&o.push(u)}),{kind:"matched",nodes:o[d-1]?[o[d-1]]:[]}}const i=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return i?Ms(e,i[1]).length>0?{kind:"matched",nodes:Ms(e,i[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function kc(e,s){const a=s.trim().split(/\s+AND\s+/i).map(c=>c.trim()),r=[];for(const c of a){const h=/^(\w+)\s*==\s*"([^"]*)"$/.exec(c);if(!h)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};r.push({key:h[1],value:h[2]})}const i=[];return Je(e,c=>{for(const h of r){let d;if(h.key==="type"?d=c.type:h.key==="label"?d=Ze(c,"label")??c.label:h.key==="name"?d=Ze(c,"name")??c.name:h.key==="value"?d=Ze(c,"value")??c.value:d=Ze(c,h.key),d!==h.value)return}i.push(c)}),{kind:"matched",nodes:i}}function zs(e,s,n){const a=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(a){case"accessibility id":return{kind:"matched",nodes:vc(e,n)};case"id":return{kind:"matched",nodes:yc(e,n)};case"class name":return{kind:"matched",nodes:Ms(e,n)};case"name":return{kind:"matched",nodes:xc(e,n)};case"xpath":return bc(e,n);case"-ios class chain":return wc(e,n);case"-ios predicate string":return kc(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Cn(e){return{"accessibility id":1,id:2,"-ios predicate string":3,"-ios class chain":4,"-android uiautomator":3,"class name":8,xpath:9,name:10,"link text":10}[e.toLowerCase()]??7}function Ls(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 a=(s.match(/\//g)||[]).length;return a>7?{level:"fragile",reason:`${a}-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 Sa(e){return[...e].sort((s,n)=>Cn(s.strategy)-Cn(n.strategy))}const Yt=e=>e===!0||e==="true",Nc=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,Cc=/(EditText|AutoCompleteTextView)$/;function $a(e){const s=e.attributes||{};return Yt(s.clickable)||Yt(s["long-clickable"])||Yt(s.checkable)||Yt(s.scrollable)||Cc.test(e.type||"")||Nc.test(e.type||"")}function Sc(e){const s=e.attributes||{};return String(e.text||s["content-desc"]||e.label||s.label||s.name||"").trim()}function $c(e,s){const n="Unique locator",a=Sa(e.suggestedLocators||[]),r=a[0];if(!r)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const i=zs(s.hierarchy,r.strategy,r.value),c=`${r.strategy} ${r.value}`;if(i.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${r.strategy} locators here`};const h=y=>y.length===1&&y[0].xpath===e.xpath;if(h(i.nodes))return{id:"unique",label:n,status:"pass",detail:`${c} matches only this element`};const d=a.slice(1).find(y=>{const f=zs(s.hierarchy,y.strategy,y.value);return f.kind==="matched"&&h(f.nodes)}),o=d?`; use ${d.strategy} ${d.value} instead`:"",u=i.nodes.length,p=u===0?"matches nothing in this capture":`matches ${u} elements`;return{id:"unique",label:n,status:"fail",detail:`${c} ${p}${o}`}}function Tc(e){const s=Sa(e.suggestedLocators||[])[0];if(!s)return null;const{level:n,reason:a}=Ls(s.strategy,s.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:a}}function Rc(e,s){const{screenWidth:n,screenHeight:a}=s.metadata||{screenWidth:0,screenHeight:0};if(!n||!a)return null;const{x:r,y:i,width:c,height:h}=e.rect,d="On screen";return r+c<=0||i+h<=0||r>=n||i>=a?{id:"onscreen",label:d,status:"warn",detail:"Off screen — scroll it into view first"}:r<0||i<0||r+c>n||i+h>a?{id:"onscreen",label:d,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:d,status:"pass",detail:"Fully inside the screen"}}function Ec(e,s){var h,d;const n=$a(e),a=!(((h=e.attributes)==null?void 0:h.enabled)===!1||((d=e.attributes)==null?void 0:d.enabled)==="false"),r=e.rect.width>0&&e.rect.height>0,i=Sc(e);return[$c(e,s),Tc(e),n?{id:"interactive",label:"Interactive",status:"pass",detail:"Can be tapped, typed into or scrolled"}:{id:"interactive",label:"Interactive",status:"info",detail:"Not interactive — a tap here goes to whatever is under it"},a?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},r?{id:"size",label:"Has size",status:"pass",detail:`${e.rect.width} × ${e.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},Rc(e,s),n?i?{id:"name",label:"Accessible name",status:"pass",detail:`“${i.slice(0,40)}”`}:{id:"name",label:"Accessible name",status:"warn",detail:"No accessible name — screen readers and accessibility-id locators have nothing to use"}:null].filter(o=>o!==null)}function Ac(e){return{pass:e.filter(s=>s.status==="pass").length,warn:e.filter(s=>s.status==="warn").length,fail:e.filter(s=>s.status==="fail").length}}function Dc(e,s){const n=Math.max(0,Math.round((s-e)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const a=Math.floor(n/60);return a<60?`Captured ${a} min ago`:`Captured ${Math.floor(a/60)} h ago`}function Mc(e,s){return e>0&&s>e}function Ta(e){var i,c,h,d,o;const s=(e.type||"").toLowerCase(),n=((i=e.attributes)==null?void 0:i.clickable)==="true"||((c=e.attributes)==null?void 0:c.clickable)===!0,a=((h=e.attributes)==null?void 0:h.scrollable)==="true"||((d=e.attributes)==null?void 0:d.scrollable)===!0,r=((o=e.children)==null?void 0:o.length)||0;return s.includes("button")||s.includes("btn")||n&&r===0?{role:"Button",key:"button"}:s.includes("edit")||s.includes("input")||s.includes("field")?{role:"Text input",key:"input"}:s.includes("image")||s.includes("img")||s.includes("imageview")?{role:"Image",key:"image"}:s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?{role:"Scrollable list",key:"list"}:s.includes("text")||s.includes("label")?{role:"Text label",key:"text"}:s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?{role:"Navigation bar",key:"nav"}:r>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const Ra={button:t.jsx(Xi,{size:13}),input:t.jsx(ho,{size:13}),image:t.jsx(Ei,{size:13}),list:t.jsx(fa,{size:13}),text:t.jsx(go,{size:13}),toggle:t.jsx(vo,{size:13}),nav:t.jsx(Ji,{size:13}),container:t.jsx(ia,{size:13}),element:t.jsx(ui,{size:13})};function Ea(e,s){if(!s)return!0;const n=s.toLowerCase().trim(),a={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"]},r=(e.type||"").toLowerCase(),i=(e.text||e.label||e.value||"").toLowerCase(),c=(e.name||"").toLowerCase(),h=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[d,o]of Object.entries(a))if(n.includes(d)&&o.some(u=>r.includes(u)))return!0;return r.includes(n)||i.includes(n)||c.includes(n)||h.includes(n)}const Fe=e=>typeof e=="string"?e.trim():typeof e=="number"?String(e):"";function zc(e){const s=Fe(e),n=s.indexOf(":id/");return n>=0?s.slice(n+4):s}function Aa(e){return(e.type||"").split(".").pop()||""}function rs(e){var s;return[e.type,(s=e.attributes)==null?void 0:s["resource-id"],e.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
|
|
237
|
+
`)}function yt(e){const s=e.attributes||{};return Fe(e.text)||Fe(s["content-desc"])||Fe(e.label)||Fe(s.label)||zc(s["resource-id"])||Fe(s.name)||Aa(e)||"Element"}const Lc=e=>{const s=e.attributes||{};return!!(Fe(e.text)||Fe(s["content-desc"])||Fe(e.label)||Fe(s.label))};function Ic(e){var s;return(((s=e.children)==null?void 0:s.length)??0)===1&&!$a(e)&&!Lc(e)}function Da(e){const s=[e];let n=e;for(;Ic(n);)n=n.children[0],s.push(n);return s}function Ma(e,s){const n=new Set;if(!e||!s.trim())return n;const a=r=>{var i;Ea(r,s)&&n.add(r.xpath),(i=r.children)==null||i.forEach(a)};return a(e),n}function _c(e,s){const n=new Set;if(!e||!s.trim())return n;const a=r=>{let i=!1;for(const c of r.children||[])a(c)&&(i=!0);return i&&n.add(r.xpath),i||Ea(r,s)};return a(e),n}function Oc(e,s,n=""){if(!e)return[];const a=!!n.trim(),r=a?Ma(e,n):null,i=a?_c(e,n):null,c=o=>!a||o.some(u=>r.has(u.xpath)||i.has(u.xpath)),h=[],d=(o,u,p)=>{const y=o.map(Da).filter(c);y.forEach((f,g)=>{var w;const k=f[f.length-1],b=(((w=k.children)==null?void 0:w.length)??0)>0,U=a&&i.has(k.xpath),N=b&&(s.has(k.xpath)||U);h.push({key:k.xpath,nodes:f,level:u,setSize:y.length,posInSet:g+1,hasChildren:b,expanded:N,collapsible:N&&!U,parentKey:p}),N&&d(k.children,u+1,k.xpath)})};return d([e],1,null),h}function Fc(e,s=3){const n=new Set,a=(r,i)=>{var d;const c=Da(r),h=c[c.length-1];i>s||!((d=h.children)!=null&&d.length)||(n.add(h.xpath),h.children.forEach(o=>a(o,i+1)))};return e&&a(e,1),n}function ss(e,s){if(!e)return null;if(e.xpath===s)return[e];for(const n of e.children||[]){const a=ss(n,s);if(a)return[e,...a]}return null}function Sn(e,s){return e.findIndex(n=>n.nodes.some(a=>a.xpath===s))}function Pc(e,s,n){var r;const a=e[s];if(!a)return null;switch(n){case"ArrowDown":return s<e.length-1?{focus:s+1}:null;case"ArrowUp":return s>0?{focus:s-1}:null;case"ArrowRight":return a.hasChildren?a.expanded?((r=e[s+1])==null?void 0:r.parentKey)===a.key?{focus:s+1}:null:{toggle:a.key}:null;case"ArrowLeft":{if(a.collapsible)return{toggle:a.key};const i=e.findIndex(c=>c.key===a.parentKey);return i>=0?{focus:i}:null}case"Home":return{focus:0};case"End":return{focus:e.length-1};case"Enter":case" ":return{select:a.nodes[a.nodes.length-1]};default:return null}}const Uc=10;function Bc({rows:e,selectedXpath:s,hoveredXpath:n,matches:a,onToggle:r,onSelect:i,onHover:c,revealSeq:h=0}){const d=l.useRef(null),[o,u]=l.useState(null),p=l.useRef(0),y=l.useRef(null),f=s?Sn(e,s):-1,g=o?e.findIndex(j=>j.key===o):-1,k=g>=0?g:Math.max(f,0),b=j=>{var A;return((A=d.current)==null?void 0:A.querySelector(`[data-row="${j}"]`))??null},U=j=>j.nodes[j.nodes.length-1],N=j=>{var $;const A=e[j];if(!A)return;u(A.key),p.current=j;const T=b(j);T==null||T.focus({preventScroll:!0}),($=T==null?void 0:T.scrollIntoView)==null||$.call(T,{block:"nearest"})};l.useEffect(()=>{y.current=s},[s,h]),l.useEffect(()=>{var T,$;const j=y.current;if(!j)return;const A=Sn(e,j);A<0||(($=(T=b(A))==null?void 0:T.scrollIntoView)==null||$.call(T,{block:"nearest"}),y.current=null)}),l.useEffect(()=>{var T,$;if(!o||e.some(m=>m.key===o))return;const j=Math.min(p.current,e.length-1),A=!document.activeElement||document.activeElement===document.body;u(((T=e[j])==null?void 0:T.key)??null),A&&j>=0&&(($=b(j))==null||$.focus({preventScroll:!0}))});const w=j=>{const A=j.target;if(A.getAttribute("role")!=="treeitem")return;const T=Pc(e,Number(A.dataset.row),j.key);T&&(j.preventDefault(),"focus"in T?N(T.focus):"toggle"in T?r(T.toggle):i(T.select))},C=j=>{var A;(A=d.current)!=null&&A.contains(j.relatedTarget)||(c(null),u(null))};return t.jsx("div",{ref:d,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:w,onBlur:C,children:e.map((j,A)=>{const T=U(j),$=v=>!!v&&j.nodes.some(z=>z.xpath===v),m=$(s),S=!m&&$(n),I=yt(T),B=Aa(T),L=!!B&&B!==I,Y=j.nodes.map(v=>yt(v)).join(", "),te=L?`${Y}, ${B}`:Y,Z=j.expanded&&!j.collapsible,H=(v,z)=>`omni-tree-row__part${z?" is-target":""}${a.has(v.xpath)?" is-match":""}${v.xpath===s?" is-current":""}`;return t.jsxs("div",{"data-row":A,role:"treeitem","aria-level":j.level,"aria-setsize":j.setSize,"aria-posinset":j.posInSet,"aria-selected":m,"aria-expanded":j.hasChildren?j.expanded:void 0,"aria-label":te,tabIndex:A===k?0:-1,className:`omni-tree-row${m?" is-selected":""}${S?" is-hovered":""}`,onClick:()=>i(T),onFocus:v=>{v.target===v.currentTarget&&(u(j.key),p.current=A,c(T))},onMouseEnter:()=>c(T),onMouseLeave:()=>c(null),children:[t.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[t.jsx("span",{className:"omni-tree-row__indent",style:{width:(j.level-1)*Uc}}),t.jsx("span",{className:`omni-tree-row__caret${Z?" is-locked":""}`,onClick:j.hasChildren?v=>{v.stopPropagation(),Z||r(j.key)}:void 0,children:j.hasChildren&&(j.expanded?t.jsx(fr,{size:12}):t.jsx(Vr,{size:12}))}),t.jsx("span",{className:"omni-tree-row__icon",children:Ra[Ta(T).key]})]}),t.jsxs("span",{className:"omni-tree-row__label",children:[j.nodes.length>1&&t.jsx("span",{className:"omni-tree-row__head",children:j.nodes.slice(0,-1).map((v,z)=>t.jsxs(vt.Fragment,{children:[z>0&&t.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),t.jsx("span",{className:H(v,!1),title:rs(v),onClick:V=>{V.stopPropagation(),i(v)},onMouseEnter:()=>c(v),onMouseLeave:()=>c(T),children:yt(v)})]},v.xpath))}),t.jsxs("span",{className:"omni-tree-row__tail",children:[j.nodes.length>1&&t.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),t.jsxs("span",{className:"omni-tree-row__name",children:[t.jsx("span",{className:H(T,!0),title:rs(T),children:yt(T)}),L&&t.jsx("span",{className:"omni-tree-row__type",children:B})]})]})]}),j.hasChildren&&!j.expanded&&t.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:T.children.length})]},j.key)})})}const $n=4;function Hc({path:e,onSelect:s,focusCurrent:n=!1}){const[a,r]=l.useState(!1),i=l.useRef(null),c=l.useRef(null);if(l.useEffect(()=>{var u;n&&((u=c.current)==null||u.focus())},[]),l.useEffect(()=>{var u;a&&((u=i.current)==null||u.focus())},[a]),!e.length)return null;const h=e[e.length-1],d=e.slice(0,-1),o=!a&&d.length>$n?d.length-$n:0;return t.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:t.jsxs("ol",{children:[o>0&&t.jsx("li",{children:t.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${d.length} ancestors`,onClick:()=>r(!0),children:"…"})}),d.slice(o).map((u,p)=>t.jsx("li",{children:t.jsx("button",{ref:p===0?i:void 0,type:"button",className:"omni-crumb",title:rs(u),"aria-label":yt(u),onClick:()=>s(u),children:yt(u)})},u.xpath)),t.jsx("li",{children:t.jsx("span",{ref:c,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:rs(h),children:yt(h)})})]})})}const is=.4,Vc=240,Wc=340,Tn=.02,os=12,za="xenon.omni.split";function La(e){if(!(e>0))return{min:0,max:1};const s=Math.min(1,Vc/e);return{min:s,max:Math.max(s,(e-Wc)/e)}}function qc(e,s){const{min:n,max:a}=La(s),r=Number.isFinite(e)?e:is;return Math.min(a,Math.max(n,r))}function Kc(e){try{const s=Number.parseFloat((e==null?void 0:e.getItem(za))??"");return s>0&&s<1?s:is}catch{return is}}function Xc(e,s){try{e==null||e.setItem(za,String(Math.round(s*1e3)/1e3))}catch{}}function Rn(){try{return window.localStorage}catch{return null}}const Yc=3;function Gc({share:e,limits:s,containerRef:n,onChange:a,onCommit:r,onReset:i}){const[c,h]=l.useState(!1),d=l.useRef(e);d.current=e;const o=l.useRef(!0),u=l.useRef(!1),p=l.useRef(0),y=l.useRef(e),f=N=>Math.min(s.max,Math.max(s.min,N)),g=N=>Math.round(N*100),k=()=>{o.current||(o.current=!0,h(!1),u.current&&r(d.current))},b=N=>{var C;const w=(C=n.current)==null?void 0:C.getBoundingClientRect();return!w||w.width<=os?d.current:f(y.current+(N-p.current)/(w.width-os))},U=N=>{const w=N.key==="ArrowLeft"?e-Tn:N.key==="ArrowRight"?e+Tn:N.key==="Home"?s.min:N.key==="End"?s.max:null;w!==null&&(N.preventDefault(),r(f(Math.round(w*1e3)/1e3)))};return t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":g(e),"aria-valuemin":g(s.min),"aria-valuemax":g(s.max),tabIndex:0,className:`omni-split-divider${c?" is-dragging":""}`,onKeyDown:U,onDoubleClick:i,onPointerDown:N=>{var w,C;(C=(w=N.currentTarget).setPointerCapture)==null||C.call(w,N.pointerId),o.current=!1,u.current=!1,p.current=N.clientX,y.current=d.current,h(!0)},onPointerMove:N=>{if(!c||!u.current&&Math.abs(N.clientX-p.current)<Yc)return;const w=b(N.clientX);w!==d.current&&(u.current=!0,a(w))},onPointerUp:N=>{var w,C;(C=(w=N.currentTarget).releasePointerCapture)==null||C.call(w,N.pointerId),k()},onPointerCancel:N=>{var w,C;(C=(w=N.currentTarget).releasePointerCapture)==null||C.call(w,N.pointerId),k()},onLostPointerCapture:k,children:t.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function En(e,s,n,a){var N,w,C,j,A,T,$;const{strategy:r,value:i}=a,c=(e.text||e.name||((N=e.type)==null?void 0:N.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",h=c.charAt(0).toLowerCase()+c.slice(1),d=((w=e.type)==null?void 0:w.toLowerCase().includes("edit"))||((C=e.type)==null?void 0:C.toLowerCase().includes("input"))||((j=e.type)==null?void 0:j.toLowerCase().includes("field"))||((A=e.type)==null?void 0:A.toLowerCase().includes("textfield")),o=((T=e.attributes)==null?void 0:T.scrollable)==="true"||(($=e.attributes)==null?void 0:$.scrollable)===!0,u=r.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
|
|
238
|
+
`:r.toLowerCase().startsWith("-android")&&s!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
|
|
239
|
+
`:"",p={"accessibility id":`~${i}`,id:s==="ios"?`-ios predicate string:label == "${i}"`:`android=new UiSelector().resourceId("${i}")`,xpath:`${i}`,"-ios predicate string":`-ios predicate string:${i}`,"-ios class chain":`-ios class chain:${i}`,"-android uiautomator":`android=${i}`},y={"accessibility id":`AppiumBy.accessibilityId("${i}")`,id:`AppiumBy.id("${i}")`,xpath:`AppiumBy.xpath("${i}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${i}")`,"-ios class chain":`AppiumBy.iOSClassChain("${i}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${i}")`,"class name":`AppiumBy.className("${i}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${i}"`,id:`AppiumBy.ID, "${i}"`,xpath:`AppiumBy.XPATH, "${i}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${i}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${i}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${i}'`,"class name":`AppiumBy.CLASS_NAME, "${i}"`},g=y[r.toLowerCase()],k=f[r.toLowerCase()],b=p[r.toLowerCase()];return n==="java"?g?`${u}// Appium Java Client 9.x + Selenium 4 + TestNG
|
|
240
|
+
import io.appium.java_client.AppiumBy;
|
|
241
|
+
import io.appium.java_client.${s==="android"?"AndroidDriver":s==="ios"?"IOSDriver":"AppiumDriver"};
|
|
242
|
+
import org.openqa.selenium.WebElement;
|
|
243
|
+
import org.testng.annotations.Test;
|
|
244
|
+
|
|
245
|
+
@Test
|
|
246
|
+
public void test_${h}() {
|
|
247
|
+
WebElement element = driver.findElement(${g});
|
|
248
|
+
${o?'((Scrollable) element).scrollTo("target text");':d?`element.clear();
|
|
249
|
+
element.sendKeys("your text here");`:"element.click();"}
|
|
250
|
+
// Add assertions here via TestNG Assert or Hamcrest
|
|
251
|
+
}`:`// Strategy "${r}" not supported in Appium Java Client`:n==="python"?k?`${u}# Appium Python Client 4.x + pytest
|
|
252
|
+
from appium.webdriver.common.appiumby import AppiumBy
|
|
253
|
+
import pytest
|
|
254
|
+
|
|
255
|
+
def test_${h}(self):
|
|
256
|
+
element = self.driver.find_element(${k})
|
|
257
|
+
${d?`element.clear()
|
|
258
|
+
element.send_keys("your text here")`:"element.click()"}
|
|
259
|
+
# Add assertions here via assert or pytest.assert`:`# Strategy "${r}" not supported in Appium Python Client`:n==="javascript"?b?`${u}// WebdriverIO 9.x + @wdio/appium-service
|
|
260
|
+
describe('${h} test', () => {
|
|
261
|
+
it('should interact with ${h}', async () => {
|
|
262
|
+
const element = await $('${b}');
|
|
263
|
+
await element.waitForDisplayed({ timeout: 5000 });
|
|
264
|
+
${d?`await element.clearValue();
|
|
265
|
+
await element.addValue("your text here");`:"await element.click();"}
|
|
266
|
+
// Add assertions here via expect(element)
|
|
267
|
+
});
|
|
268
|
+
});`:`// Strategy "${r}" not supported in WebdriverIO mobile`:b?`${u}// WebdriverIO 9.x standalone
|
|
269
|
+
const element = await driver.$('${b}');
|
|
270
|
+
await element.waitForExist({ timeout: 5000 });
|
|
271
|
+
${d?`await driver.$('target').clearValue();
|
|
272
|
+
await element.addValue("your text here");`:"await element.click();"}
|
|
273
|
+
// Assert with expect(element).toBeDisplayed()`:`// Strategy "${r}" not supported in WebdriverIO mobile`}const Zc={pass:t.jsx(ca,{size:13}),warn:t.jsx(Ge,{size:13}),fail:t.jsx(la,{size:13}),info:t.jsx(Qn,{size:13})},Jc={pass:"passed",warn:"warning",fail:"failed",info:"note"},Qc={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},el=({sessionId:e,udid:s,streamUrl:n,embedded:a=!1,overlayTarget:r=null,onModeChange:i,deviceActionAt:c=0})=>{var nn,an,rn,on,cn,ln;const[h,d]=l.useState(!0),[o,u]=l.useState(null),[p,y]=l.useState(null),[f,g]=l.useState(null),[k,b]=l.useState(0),U=l.useRef(!1),[N,w]=l.useState(null),[C,j]=l.useState(()=>new Set),[A,T]=l.useState(""),[$,m]=l.useState(null),[S,I]=l.useState("info"),[B,L]=l.useState(0),[Y,te]=l.useState(0),[Z,H]=l.useState(()=>Date.now()),v=l.useRef(0),z=l.useRef(null),[V,M]=l.useState("java"),[W,ne]=l.useState(null),[q,se]=l.useState({width:0,height:0}),[ie,be]=l.useState({width:0,height:0}),[E,oe]=l.useState(!1),[Q,ae]=l.useState("inspect");l.useEffect(()=>{i==null||i(Q)},[Q,i]);const[De,ue]=l.useState({}),[fe,Be]=l.useState({}),[Qe,wt]=l.useState(null),[pe,He]=l.useState(null),[_e,Se]=l.useState(null),et=l.useRef(null),kt=l.useRef(null),Ve=l.useRef(null),$e=l.useRef(null),Te=l.useRef(null),[ct,We]=l.useState(()=>Kc(Rn())),[tt,lt]=l.useState(0);l.useEffect(()=>{const x=Te.current;if(!x||typeof ResizeObserver>"u")return;const R=new ResizeObserver(([D])=>lt(Math.max(0,D.contentRect.width-os)));return R.observe(x),()=>R.disconnect()},[]);const Oe=qc(ct,tt),qe=x=>{We(x),Xc(Rn(),x)},Me=l.useCallback(()=>{var Ke,Xe,nt;if(!et.current)return;const x=et.current.getBoundingClientRect(),R=x.width,D=x.height,O=(Ke=o==null?void 0:o.hierarchy)==null?void 0:Ke.rect;let G=((Xe=o==null?void 0:o.metadata)==null?void 0:Xe.screenWidth)||q.width||1,P=((nt=o==null?void 0:o.metadata)==null?void 0:nt.screenHeight)||q.height||1;O&&O.width>0&&O.height>0&&(G=O.width,P=O.height);const le=G/P;let Ie,ze;R/D>le?(ze=D,Ie=ze*le):(Ie=R,ze=Ie/le),be({width:Ie,height:ze})},[o,q]);l.useEffect(()=>(Me(),window.addEventListener("resize",Me),()=>window.removeEventListener("resize",Me)),[Me]),l.useEffect(()=>{s&&ce()},[s]);const dt=l.useCallback(async(x,R,D)=>{if(pe!=null&&pe.sessionId){wt(x);try{const O=await X.verifyLocator(pe.basePath,pe.sessionId,{strategy:x,selector:R,action:D});Be(G=>({...G,[x]:O})),D==="tap"&&te(Date.now())}catch(O){Be(G=>({...G,[x]:{found:!1,count:0,error:(O==null?void 0:O.message)||String(O)}}))}finally{wt(null)}}},[pe]),_=l.useRef(null);l.useEffect(()=>{const x=!!f&&f.xpath===_.current;_.current=(f==null?void 0:f.xpath)??null;const R=(f==null?void 0:f.suggestedLocators)??[];ne(D=>{const O=x&&D?R.find(P=>P.strategy===D.strategy):null,G=R.find(P=>P.strategy==="accessibility id"||P.strategy==="id");return O||G||R[0]||null}),ue({}),Be({}),Se(null)},[f]);const ee=l.useCallback((x,R)=>{if(!(o!=null&&o.hierarchy))return;const D=zs(o.hierarchy,x,R);ue(O=>({...O,[x]:D})),Se(x)},[o]),ce=async()=>{if(!s)return;const x=++v.current,R=()=>x===v.current;d(!0),y(null),X.getAppiumSession(s).then(D=>{R()&&He({sessionId:(D==null?void 0:D.sessionId)??null,basePath:(D==null?void 0:D.basePath)??""})}).catch(()=>{R()&&He({sessionId:null,basePath:""})});try{const D=await X.getInspectorSnapshot(s);if(!R())return;if(!(D!=null&&D.hierarchy)){u(null),y((D==null?void 0:D.error)||"Failed to capture snapshot");return}const O=D.udid||s,G=O===z.current;z.current=O,vn.unstable_batchedUpdates(()=>{u(D),L(Date.now()),j(Fc(D.hierarchy)),g(P=>{var le;return P&&G?((le=ss(D.hierarchy,P.xpath))==null?void 0:le.pop())??null:null}),b(P=>P+1)})}catch(D){if(!R())return;u(null),y(D.message||"Failed to capture snapshot")}finally{R()&&d(!1)}};l.useEffect(()=>{const x=setInterval(()=>H(Date.now()),1e4);return()=>clearInterval(x)},[]);const Re=x=>{const{naturalWidth:R,naturalHeight:D}=x.currentTarget;se({width:R,height:D})},ut=()=>oe(!0),fs=x=>{oe(!1);const{naturalWidth:R,naturalHeight:D}=x.currentTarget;R>0&&D>0&&se({width:R,height:D})},Nt=n&&!E,Et=x=>{if(Q!=="interact"||!s)return;const R=x.currentTarget.getBoundingClientRect();$e.current={x:x.clientX-R.left,y:x.clientY-R.top,time:Date.now()}},K=async x=>{var un,hn,mn;if(Q!=="interact"||!s||!$e.current)return;const R=$e.current,D=x.currentTarget.getBoundingClientRect(),O=x.clientX-D.left,G=x.clientY-D.top,P=Date.now()-R.time,le=ie.width,Ie=ie.height,ze=(un=o==null?void 0:o.hierarchy)==null?void 0:un.rect;let Ke=((hn=o==null?void 0:o.metadata)==null?void 0:hn.screenWidth)||q.width,Xe=((mn=o==null?void 0:o.metadata)==null?void 0:mn.screenHeight)||q.height;if(ze&&ze.width>0&&ze.height>0&&(Ke=ze.width,Xe=ze.height),!Ke||!Xe||le===0||Ie===0)return;const nt=(Kt,fn)=>({x:Math.round(Kt/le*Ke),y:Math.round(fn/Ie*Xe),px:Kt/le,py:fn/Ie}),Ce=nt(R.x,R.y),dn=nt(O,G),xs=Math.sqrt(Math.pow(O-R.x,2)+Math.pow(G-R.y,2));if(!(Ce.px<0||Ce.px>1||Ce.py<0||Ce.py>1)){try{P<500&&xs<10?await X.tap(s,Ce.x,Ce.y):P>=500&&xs<10?await X.touchAndHold(s,Ce.x,Ce.y,P):xs>=10&&await X.swipe(s,Ce.x,Ce.y,dn.x,dn.y),te(Date.now())}catch(Kt){console.error("Interaction failed:",Kt)}$e.current=null}},re=x=>{j(R=>{const D=new Set(R);return D.has(x)?D.delete(x):D.add(x),D})},ye=()=>{const x=new Set,R=D=>{var O;x.add(D.xpath),(O=D.children)==null||O.forEach(R)};o!=null&&o.hierarchy&&R(o.hierarchy),j(x)},he=()=>j(new Set),Ee=(x,R)=>{navigator.clipboard.writeText(x),m(R),setTimeout(()=>m(null),2e3)},me=x=>{var D;let R=1;return(D=x.children)==null||D.forEach(O=>R+=me(O)),R},we=x=>{if(!x)return[];const R={},D=O=>{var P;const G=Ta(O);R[G.role]||(R[G.role]={key:G.key,count:0}),R[G.role].count+=1,(P=O.children)==null||P.forEach(D)};return D(x),Object.entries(R).map(([O,G])=>({role:O,key:G.key,count:G.count})).sort((O,G)=>G.count-O.count)},xe=l.useMemo(()=>Oc(o==null?void 0:o.hierarchy,C,A),[o,C,A]),ve=l.useMemo(()=>Ma(o==null?void 0:o.hierarchy,A),[o,A]),ht=ve.size===0?"No matches":ve.size===1?"1 match":`${ve.size} matches`;l.useEffect(()=>{if(!f||!(o!=null&&o.hierarchy))return;const x=ss(o.hierarchy,f.xpath);!x||x.length<2||j(R=>{const D=x.slice(0,-1).filter(G=>!R.has(G.xpath));if(!D.length)return R;const O=new Set(R);return D.forEach(G=>O.add(G.xpath)),O})},[k]),l.useEffect(()=>{U.current=!1});const st=x=>{g(x),b(R=>R+1),I("info")},Ht=x=>{U.current=!0,st(x)},At=x=>{A.trim()&&!x.trim()&&b(R=>R+1),T(x)},Ct=()=>{var O,G,P;const x=(O=o==null?void 0:o.hierarchy)==null?void 0:O.rect;if(x&&x.width>0&&x.height>0)return{w:x.width,h:x.height};const R=((G=o==null?void 0:o.metadata)==null?void 0:G.screenWidth)||q.width,D=((P=o==null?void 0:o.metadata)==null?void 0:P.screenHeight)||q.height;return R>0&&D>0?{w:R,h:D}:null},Vt=x=>{const R=Ct();if(!R)return[];const D=[],{w:O,h:G}=R,P=(le,Ie)=>{var Ke,Xe,nt;const ze=!le.children||le.children.length===0;((Ke=le.rect)==null?void 0:Ke.width)>0&&((Xe=le.rect)==null?void 0:Xe.height)>0&&ze&&D.push(t.jsx("div",{className:"omni-hit-area",style:{left:`${le.rect.x/O*100}%`,top:`${le.rect.y/G*100}%`,width:`${le.rect.width/O*100}%`,height:`${le.rect.height/G*100}%`,zIndex:Ie},onClick:Ce=>{Ce.stopPropagation(),st(le)},onMouseEnter:()=>w(le),onMouseLeave:()=>w(null)},le.xpath)),(nt=le.children)==null||nt.forEach(Ce=>P(Ce,Ie+1))};return o!=null&&o.hierarchy&&P(o.hierarchy,1),D},tn=()=>{const x=Ct();if(!_e||!x)return[];const R=De[_e];if(!R||R.kind!=="matched"||R.nodes.length===0)return[];const{w:D,h:O}=x,G=R.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return R.nodes.filter(P=>P.rect&&P.rect.width>0&&P.rect.height>0).map((P,le)=>t.jsx("div",{className:G,style:{left:`${P.rect.x/D*100}%`,top:`${P.rect.y/O*100}%`,width:`${P.rect.width/D*100}%`,height:`${P.rect.height/O*100}%`}},`match-${_e}-${le}`))},Wt=(x,R)=>{const D=Ct();if(!(x!=null&&x.rect)||!D)return null;const{w:O,h:G}=D;return t.jsx("div",{className:`omni-frame-${R}`,style:{left:`${x.rect.x/O*100}%`,top:`${x.rect.y/G*100}%`,width:`${x.rect.width/O*100}%`,height:`${x.rect.height/G*100}%`}})},ps=o!=null&&o.hierarchy?me(o.hierarchy):0,qt=f&&(o!=null&&o.hierarchy)?Ec(f,o):null,mt=qt?Ac(qt):null,vs=Mc(B,Math.max(c,Y)),ys=o!=null&&o.hierarchy&&Q==="inspect"?t.jsxs("div",{className:`omni-overlay${vs?" is-stale":""}`,children:[Vt(o.hierarchy),tn(),Wt(N,"hover"),Wt(f,"select")]}):null,dr={stable:{icon:t.jsx(Xt,{size:10}),cls:"stable"},moderate:{icon:t.jsx(Ge,{size:10}),cls:"moderate"},fragile:{icon:t.jsx(St,{size:10}),cls:"fragile"},"very-fragile":{icon:t.jsx(St,{size:10}),cls:"very-fragile"}},sn=a&&(o!=null&&o.hierarchy)?we(o.hierarchy):[];return t.jsxs("div",{className:`omni-inspector-container ${a?"omni-embedded":""}`,children:[a&&r&&ys?vn.createPortal(ys,r):null,t.jsxs("div",{className:"omni-main-content",children:[!a&&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 ${Q==="inspect"?"active":""}`,onClick:()=>ae("inspect"),title:"Inspection mode (highlight elements)",children:[t.jsx(gn,{size:12}),t.jsx("span",{children:"Inspect"})]}),t.jsxs("button",{className:`omni-mode-btn ${Q==="interact"?"active":""}`,onClick:()=>ae("interact"),title:"Interaction mode (direct control)",children:[t.jsx(kn,{size:12}),t.jsx("span",{children:"Interact"})]})]})]}),t.jsxs("button",{className:"omni-refresh-btn",onClick:ce,disabled:h,children:[t.jsx(It,{size:12,className:h?"animate-spin":""}),h?"Capturing...":"Refresh"]})]}),t.jsxs("div",{className:"omni-screenshot-container",ref:et,children:[h&&!Nt&&t.jsxs("div",{className:"omni-loading-overlay",children:[t.jsx("div",{className:"omni-spinner"}),t.jsx("span",{children:"Capturing screen..."})]}),!o&&!h&&!Nt&&t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(js,{size:40}),t.jsx("span",{children:"Click Refresh to capture"})]}),Nt&&t.jsxs("div",{className:`omni-screenshot-wrapper ${Q==="interact"?"interactable":""}`,onMouseDown:Et,onMouseUp:K,children:[t.jsx(ta,{ref:Ve,src:n,onLoad:fs,onError:ut,className:"omni-screenshot-img",style:Q==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),ys]}),!Nt&&(o==null?void 0:o.screenshot)&&t.jsxs("div",{className:`omni-screenshot-wrapper ${Q==="interact"?"interactable":""}`,onMouseDown:Et,onMouseUp:K,children:[t.jsx("img",{ref:kt,src:`data:image/png;base64,${o.screenshot}`,onLoad:Re,className:"omni-screenshot-img",style:Q==="interact"?{pointerEvents:"none"}:{},draggable:!1}),Q==="inspect"&&t.jsxs("div",{className:`omni-overlay${vs?" is-stale":""}`,children:[Vt(o.hierarchy),tn(),Wt(N,"hover"),Wt(f,"select")]})]})]})]}),t.jsxs("div",{className:"omni-split",ref:Te,children:[t.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${Oe*100}% - ${Oe*os}px)`},children:[t.jsxs("div",{className:"omni-tree-header",children:[t.jsxs("div",{className:"omni-tree-title",children:[t.jsx(ia,{size:14}),t.jsx("span",{children:"Source"})]}),t.jsxs("div",{className:"omni-tree-actions",children:[t.jsx("button",{onClick:ye,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:t.jsx(yi,{size:12})}),t.jsx("button",{onClick:he,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:t.jsx(pi,{size:12})}),a&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>ae(Q==="inspect"?"interact":"inspect"),className:`omni-action-btn ${Q==="inspect"?"active":""}`,title:Q==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":Q==="inspect"?"Inspect mode":"Interact mode","aria-pressed":Q==="inspect",children:Q==="inspect"?t.jsx(gn,{size:12}):t.jsx(kn,{size:12})}),t.jsx("button",{onClick:ce,className:"omni-action-btn",title:h?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:h,children:t.jsx(It,{size:12,className:h?"animate-spin":""})})]})]})]}),p&&!h&&t.jsxs("div",{className:"omni-tree-error",role:"alert",children:[t.jsx(St,{size:12}),t.jsx("span",{children:p}),t.jsx("button",{type:"button",onClick:ce,className:"omni-tree-error-retry",children:"Retry"})]}),o&&!h&&!p&&(vs?t.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[t.jsx(Ge,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:"The screen may have changed since this capture."}),t.jsx("button",{type:"button",onClick:ce,className:"omni-capture-refresh",children:"Refresh"})]}):t.jsxs("div",{className:"omni-capture-meta",children:[t.jsxs("span",{children:[ps," ",ps===1?"element":"elements"]}),o.hierarchySource&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{className:"omni-capture-source",title:o.hierarchySource==="appium-session"?`From Appium session ${o.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:o.hierarchySource==="appium-session"?"Session":"Device"})]}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:Dc(B,Z)})]})),t.jsxs("div",{className:"omni-tree-search",children:[t.jsx(Hs,{size:14}),t.jsx("input",{type:"text",placeholder:"Search elements",value:A,onChange:x=>At(x.target.value),"aria-label":"Search elements"}),A&&t.jsx("button",{onClick:()=>At(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),t.jsx("div",{role:"status",className:"sr-only",children:A.trim()?ht:""}),A.trim()&&t.jsxs("div",{className:"omni-search-hint",children:[ht," · try a role: button, input, image"]}),t.jsx("div",{className:"omni-tree-content",children:o!=null&&o.hierarchy?t.jsx(Bc,{rows:xe,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(N==null?void 0:N.xpath)??null,matches:ve,onToggle:re,onSelect:st,onHover:w,revealSeq:k}):t.jsx("div",{className:"omni-empty-state small",children:t.jsx("span",{children:"No hierarchy loaded"})})})]}),t.jsx(Gc,{share:Oe,limits:La(tt),containerRef:Te,onChange:We,onCommit:qe,onReset:()=>qe(is)}),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 ${S==="info"?"active":""}`,onClick:()=>I("info"),role:"tab","aria-selected":S==="info",children:[t.jsx(Oi,{size:12})," ",t.jsx("span",{children:"Info"})]}),t.jsxs("button",{className:`omni-details-tab ${S==="checks"?"active":""}`,onClick:()=>I("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":S==="checks",children:[t.jsx(Hr,{size:12})," ",t.jsx("span",{children:"Checks"})]}),t.jsxs("button",{className:`omni-details-tab ${S==="code"?"active":""}`,onClick:()=>I("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":S==="code",children:[t.jsx(wn,{size:12})," ",t.jsx("span",{children:"Code gen"})]})]}),t.jsx("div",{className:"omni-details-content",children:f?t.jsxs(t.Fragment,{children:[S==="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:f.type})]}),f.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:f.text})]}),t.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[t.jsx("span",{className:"omni-info-key",children:"Path"}),t.jsx(Hc,{path:(o==null?void 0:o.hierarchy)&&ss(o.hierarchy,f.xpath)||[f],onSelect:Ht,focusCurrent:U.current},f.xpath)]})]})]}),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(x=>t.jsxs("div",{className:"omni-layout-item",children:[t.jsx("span",{className:"omni-layout-label",children:x.toUpperCase()}),t.jsx("span",{className:"omni-layout-value",children:f.rect[x]})]},x))})]}),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"})]}),!(pe!=null&&pe.sessionId)&&((rn=f.suggestedLocators)==null?void 0:rn.length)>0&&t.jsxs("p",{className:"omni-locators-note",children:[t.jsx(Qn,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),t.jsxs("div",{className:"omni-locators-list",children:[!((on=f.suggestedLocators)!=null&&on.length)&&t.jsx("div",{className:"omni-locators-empty",children:f===(o==null?void 0:o.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),(cn=f.suggestedLocators)==null?void 0:cn.map(x=>{const R=Ls(x.strategy,x.value),D=dr[R.level],O=De[x.strategy];let G=null;return O&&(O.kind==="unsupported"?G=t.jsxs("span",{className:"omni-match-badge unsupported",title:O.reason||"Cannot evaluate without a real driver",children:[t.jsx(ua,{size:10})," preview unavailable"]}):O.nodes.length===0?G=t.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[t.jsx(St,{size:10})," 0 matches"]}):O.nodes.length===1?G=t.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[t.jsx(Xt,{size:10})," unique"]}):G=t.jsxs("span",{className:"omni-match-badge multi",title:`${O.nodes.length} elements match — selector is not unique`,children:[t.jsx(Ge,{size:10})," ",O.nodes.length," matches"]})),t.jsx("div",{className:`omni-locator-row ${(W==null?void 0:W.strategy)===x.strategy?"selected-for-code":""}`,onClick:()=>ne(x),title:"Click to use in Code gen",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:x.strategy}),t.jsxs("span",{className:`omni-stability-badge ${D.cls}`,title:R.reason,children:[D.icon,R.level]}),G]}),t.jsx("code",{className:"omni-locator-value",children:x.value}),t.jsx("span",{className:"omni-stability-reason",children:R.reason}),(()=>{const P=fe[x.strategy];return P?P.error?t.jsxs("span",{className:"omni-verify-line is-error",children:[t.jsx(St,{size:10})," Appium error: ",P.error]}):P.found?P.count>1?t.jsxs("span",{className:"omni-verify-line is-warn",children:[t.jsx(Ge,{size:10})," Ambiguous — Appium found"," ",P.count," elements",P.actionError?` · ${P.actionError}`:""]}):t.jsxs("span",{className:"omni-verify-line is-ok",children:[t.jsx(Xt,{size:10})," Appium found 1 element",P.elapsedMs!=null?` in ${P.elapsedMs}ms`:"",P.actionPerformed&&P.actionPerformed!=="none"?` · ${P.actionPerformed} ok`:"",P.actionError?` · action failed: ${P.actionError}`:""]}):t.jsxs("span",{className:"omni-verify-line is-error",children:[t.jsx(St,{size:10})," Appium found 0 elements"]}):null})(),t.jsxs("div",{className:"omni-locator-actions",children:[t.jsxs(F,{type:"button",variant:_e===x.strategy?"tonal":"secondary",size:"sm",onClick:P=>{P.stopPropagation(),ee(x.strategy,x.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[t.jsx(ki,{size:12,"aria-hidden":"true"}),"Test"]}),t.jsxs(F,{type:"button",variant:"secondary",size:"sm",disabled:!(pe!=null&&pe.sessionId)||Qe===x.strategy,onClick:P=>{P.stopPropagation(),dt(x.strategy,x.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[Qe===x.strategy?t.jsx(It,{size:12,className:"animate-spin","aria-hidden":"true"}):t.jsx(Xt,{size:12,"aria-hidden":"true"}),"Verify"]}),t.jsxs(F,{type:"button",variant:"secondary",size:"sm",disabled:!(pe!=null&&pe.sessionId)||Qe===x.strategy,onClick:P=>{P.stopPropagation(),dt(x.strategy,x.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[t.jsx(oa,{size:12,"aria-hidden":"true"}),"Tap"]}),t.jsxs(F,{type:"button",variant:"secondary",size:"sm",onClick:P=>{P.stopPropagation(),Ee(x.value,x.strategy)},title:"Copy the locator's value","aria-label":$===x.strategy?"Copied":"Copy locator",children:[$===x.strategy?t.jsx(Ot,{size:12,"aria-hidden":"true"}):t.jsx(Pe,{size:12,"aria-hidden":"true"}),$===x.strategy?"Copied":"Copy"]})]})]})},x.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(f.attributes||{}).filter(([x,R])=>R!=null&&R!=="").map(([x,R])=>t.jsxs("div",{className:"omni-attr-row",children:[t.jsx("span",{className:"omni-attr-key",children:x}),t.jsx("span",{className:"omni-attr-value",children:String(R)})]},x))})]})]}),S==="checks"&&qt&&mt&&t.jsxs("div",{className:"omni-checks-panel",children:[t.jsxs("p",{className:"omni-checks-summary",children:[t.jsxs("span",{className:"is-pass",children:[t.jsx(ca,{size:12,"aria-hidden":"true"})," ",mt.pass," passed"]}),mt.warn>0&&t.jsxs("span",{className:"is-warn",children:[t.jsx(Ge,{size:12,"aria-hidden":"true"})," ",mt.warn," ",mt.warn===1?"warning":"warnings"]}),mt.fail>0&&t.jsxs("span",{className:"is-fail",children:[t.jsx(la,{size:12,"aria-hidden":"true"})," ",mt.fail," failed"]})]}),t.jsx("ul",{className:"omni-checks-list",children:qt.map(x=>t.jsxs("li",{className:`omni-check is-${x.status}`,children:[t.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:Zc[x.status]}),t.jsxs("div",{className:"omni-check-body",children:[t.jsxs("div",{className:"omni-check-label",children:[x.label,t.jsxs("span",{className:"sr-only",children:[": ",Jc[x.status]]})]}),t.jsx("div",{className:"omni-check-detail",children:x.detail})]})]},x.id))})]}),S==="code"&&t.jsxs("div",{className:"omni-codegen-panel",children:[t.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(x=>t.jsx("button",{className:`omni-fw-btn ${V===x?"active":""}`,onClick:()=>M(x),children:Qc[x]},x))}),W?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(na,{selectSize:"sm",value:W.strategy,onChange:x=>{var D;const R=(D=f.suggestedLocators)==null?void 0:D.find(O=>O.strategy===x.target.value);R&&ne(R)},className:"flex-1",children:(ln=f.suggestedLocators)==null?void 0:ln.map(x=>t.jsxs("option",{value:x.strategy,children:[x.strategy," — ",Ls(x.strategy,x.value).level]},x.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:V==="java"?"Java / TestNG":V==="python"?"Python / unittest":V==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),t.jsx("button",{className:"omni-copy-btn",onClick:()=>Ee(En(f,(o==null?void 0:o.platform)==="android"?"android":(o==null?void 0:o.platform)==="ios"?"ios":"unknown",V,W),"code"),children:$==="code"?t.jsx(Ot,{size:12}):t.jsx(Pe,{size:12})})]}),t.jsx("pre",{className:"omni-codegen-pre theme-dark",children:t.jsx("code",{children:En(f,(o==null?void 0:o.platform)==="android"?"android":(o==null?void 0:o.platform)==="ios"?"ios":"unknown",V,W)})})]})]}):t.jsxs("div",{className:"omni-empty-state small",children:[t.jsx(wn,{size:24}),t.jsx("span",{children:"No locators available for this element"})]})]})]}):o!=null&&o.hierarchy?t.jsxs("div",{className:"omni-summary-panel",children:[t.jsxs("div",{className:"omni-summary-hero",children:[t.jsx(js,{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:ps})]}),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:((nn=o.metadata)==null?void 0:nn.screenWidth)??q.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:((an=o.metadata)==null?void 0:an.screenHeight)??q.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:o.platform||"—"})]})]})]}),sn.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:sn.slice(0,8).map(x=>t.jsxs("div",{className:"omni-summary-role",children:[t.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:Ra[x.key]}),t.jsx("span",{className:"omni-summary-role__name",children:x.role}),t.jsx("span",{className:"omni-summary-role__count",children:x.count})]},x.role))})]})]}):t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(js,{size:32}),t.jsx("span",{children:h?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},An=5e3;function tl(e,s=!0){const[n,a]=l.useState("unknown"),r=l.useRef("unknown");return l.useEffect(()=>{if(!e||!s){a("unknown"),r.current="unknown";return}let i=!1,c;const h=u=>{i||u===r.current||(r.current=u,a(u))},d=async()=>{if(!i){if(c&&(clearTimeout(c),c=void 0),typeof document<"u"&&document.visibilityState==="hidden"){c=setTimeout(d,An);return}try{const u=await X.getDisplayState(e);h((u==null?void 0:u.state)??"unknown")}catch{}i||(c=setTimeout(d,An))}};d();const o=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",o),()=>{i=!0,c&&clearTimeout(c),document.removeEventListener("visibilitychange",o)}},[e,s]),n}function sl(e,s){const n=l.useRef(e),a=l.useRef(s);n.current=e,a.current=s,l.useEffect(()=>{const r=()=>n.current(),i=c=>{var h;c.persisted&&((h=a.current)==null||h.call(a))};return window.addEventListener("pagehide",r),window.addEventListener("pageshow",i),()=>{window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",i)}},[])}const nl=/^(INPUT|TEXTAREA|SELECT)$/,Xs=l.createContext(null);function al(e){const s=l.useContext(Xs),n=l.useRef(e);n.current=e;const a=e!==null;l.useEffect(()=>{if(!(!s||!a))return s.register(()=>{var r;return((r=n.current)==null?void 0:r.call(n))??!1})},[s,a])}function Ia(e){const s=l.useContext(Xs),n=l.useRef(e);return n.current=e,l.useCallback(()=>s?s.close():n.current(),[s])}function rl({labelledBy:e,onClose:s,children:n,style:a,...r}){const i=l.useRef(null),c=l.useRef(s);c.current=s;const h=l.useMemo(()=>{const o=new Set;return{register(u){return o.add(u),()=>{o.delete(u)}},close(){for(const u of Array.from(o))if(u())return;c.current()}}},[]),d=l.useRef(h);return l.useEffect(()=>{const o=i.current;if(!o)return;const u=document.activeElement,p=[];for(let f=o;f.parentElement&&f!==document.body;f=f.parentElement)for(const g of Array.from(f.parentElement.children))g===f||g.hasAttribute("inert")||g.matches("[aria-live], script, style, link, template")||(g.setAttribute("inert",""),p.push(g));o.contains(document.activeElement)||o.focus();const y=f=>{if(f.key!=="Escape"||f.defaultPrevented)return;const g=f.target;nl.test(g.tagName)||g.isContentEditable||(f.preventDefault(),d.current.close())};return o.addEventListener("keydown",y),()=>{o.removeEventListener("keydown",y),p.forEach(f=>f.removeAttribute("inert")),u&&u.isConnected&&u!==document.body&&u.focus()}},[]),t.jsx("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":e,tabIndex:-1,style:{outline:"none",...a},...r,children:t.jsx(Xs.Provider,{value:h,children:n})})}const _a="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Ys(e){var s;try{return(s=navigator.clipboard)!=null&&s.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}const Dn=5e3,il=500,ol=1e4,cl=10,ll=50;function dl(e,s,n){const a=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[r,i]=l.useState([]),[c,h]=l.useState(!1),[d,o]=l.useState(null),[u,p]=l.useState(!1),y=l.useRef(null),f=l.useRef(0),g=l.useRef(void 0),k=l.useRef(()=>{}),b=l.useRef([]),U=l.useRef(void 0),N=l.useRef(0),w=l.useRef(void 0),C=l.useCallback(()=>{if(b.current.length===0)return;const $=b.current;b.current=[],i(m=>{const S=m.concat($);return S.length>Dn?S.slice(-Dn):S})},[]),j=l.useCallback(()=>{U.current===void 0&&(U.current=window.setTimeout(()=>{U.current=void 0,C()},ll))},[C]),A=l.useCallback(()=>{b.current=[],i([])},[]);l.useEffect(()=>{if(!s){h(!1),o(null),p(!1);return}o(null),p(!1),f.current=0;const $={cancelled:!1},m=()=>{if($.cancelled)return;if(f.current>=cl){p(!0);return}const I=Math.min(il*2**f.current,ol);f.current+=1,g.current=window.setTimeout(S,I)},S=async()=>{if(!$.cancelled)try{const I=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/ticket`,{method:"POST",credentials:"include"});if($.cancelled)return;if(!I.ok){m();return}const{ticket:B}=await I.json();if($.cancelled)return;if(!B){m();return}const L=window.location.protocol==="https:"?"wss":"ws",[Y,te]=a.split("|"),Z=(Y?`&levels=${encodeURIComponent(Y)}`:"")+(te?`&process=${encodeURIComponent(te)}`:""),H=new WebSocket(`${L}://${window.location.host}/xenon/api/control/${encodeURIComponent(e)}/logcat?ticket=${encodeURIComponent(B)}${Z}`);y.current=H,H.onopen=()=>{f.current=0,w.current!==1012&&(b.current=[],i([])),w.current=void 0,h(!0)},H.onmessage=v=>{try{const z=JSON.parse(v.data);b.current.push({...z,seq:N.current++}),j()}catch{}},H.onclose=v=>{if(h(!1),w.current=v.code,C(),v.code===1008){$.cancelled=!0,o(v.reason||"access denied");return}if(v.code===1012){m();return}console.warn(`[logcat] WS closed unexpectedly (code ${v.code}) — retrying`),m()},H.onerror=()=>H.close()}catch{m()}};return k.current=()=>{$.cancelled=!1,f.current=0,o(null),p(!1),S()},S(),()=>{var I;$.cancelled=!0,g.current!==void 0&&window.clearTimeout(g.current),U.current!==void 0&&(window.clearTimeout(U.current),U.current=void 0),C(),(I=y.current)==null||I.close(),y.current=null}},[e,s,a,C,j]);const T=l.useCallback(()=>{k.current()},[]);return{records:r,connected:c,clear:A,deniedReason:d,exhausted:u,retry:T}}const Ut=["V","D","I","W","E","F"];function ul(e){const s=[];let n="",a=!1,r=!1;for(const i of e){if(i==='"'){a=!a,r=!0;continue}if(!a&&/\s/.test(i)){(r||n)&&s.push(n),n="",r=!1;continue}n+=i,r=!0}return(r||n)&&s.push(n),s.filter(i=>i.length>0)}function Oa(e,s={}){const n=s.caseSensitive===!0,a=c=>n?c:c.toLowerCase(),r=n?{caseSensitive:!0}:{},i=[];for(const c of ul(e)){const[h,...d]=c.split(":"),o=d.join(":"),u=h.toLowerCase();o&&u==="level"?r.minLevel=o.toUpperCase():o&&u==="tag"?r.tag=a(o):o&&u==="package"?r.pkg=a(o):o&&u==="-tag"?(r.excludeTags=r.excludeTags||[]).push(a(o)):o&&u==="-package"?(r.excludePkgs=r.excludePkgs||[]).push(a(o)):i.push(c)}return i.length&&(r.text=a(i.join(" "))),r}function Fa(e,s){if(e.synthetic)return!0;if(s.minLevel){const a=Ut.indexOf(s.minLevel),r=Ut.indexOf(e.level);if(a>=0&&r>=0&&r<a)return!1}const n=a=>s.caseSensitive?a:a.toLowerCase();if(s.tag&&!n(e.tag).includes(s.tag)||s.pkg&&!n(e.pkg??"").includes(s.pkg)||s.text&&!n(e.message).includes(s.text))return!1;if(s.excludeTags){const a=n(e.tag);if(s.excludeTags.some(r=>a.includes(r)))return!1}if(s.excludePkgs){const a=n(e.pkg??"");if(a&&s.excludePkgs.some(r=>a.includes(r)))return!1}return!0}function Pa(e){const s=[];let n="",a=!1;for(const r of e){if(r==='"'&&(a=!a),!a&&/\s/.test(r)){n&&s.push(n),n="";continue}n+=r}return n&&s.push(n),s}function Ua(e){const[s,...n]=e.replace(/"/g,"").split(":");return{key:s.toLowerCase(),value:n.join(":")}}function Ba(e){const s=e.split('"').map(n=>n.trim()).reduce((n,a)=>a.length>n.length?a:n,"");return/\s/.test(s)?`"${s}"`:s}function Mn(e,s,n){const a=Ba(n);if(!a)return e;const r=`${s}:${a}`,i=[];let c=!1;for(const h of Pa(e)){const d=Ua(h);if(d.key===s&&d.value){c||i.push(r),c=!0;continue}i.push(h)}return c||i.push(r),i.join(" ")}function hl(e,s,n){const a=Ba(n);if(!a)return e;const r=a.replace(/"/g,""),i=Pa(e);return i.some(h=>{const d=Ua(h);return d.key===`-${s}`&&d.value===r})?e:[...i,`-${s}:${a}`].join(" ")}function ml(e,s){const n=e.trim().split(/\s+/).filter(Boolean).filter(a=>{const[r,...i]=a.split(":");return!(i.join(":")&&r.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const Ns=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],zn=["V","D","I","W","E","F"];function fl(e){if(!e)return Ns.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=zn.indexOf(e.toUpperCase());return s<0?Ns.map(n=>n.ios):Ns.filter(n=>zn.indexOf(n.android)>=s).map(n=>n.ios)}function pl(e){const s=Oa(e,{caseSensitive:!0});return{levels:fl(s.minLevel),process:s.pkg||void 0}}const Ln=Ut,vl={V:"Verbose",D:"Debug",I:"Info",W:"Warning",E:"Error",F:"Fatal"};function yl(e,s){const n={V:0,D:0,I:0,W:0,E:0,F:0},a={...s,minLevel:void 0};for(let r=0;r<e.length;r++){const i=e[r];i.synthetic||Object.prototype.hasOwnProperty.call(n,i.level)&&Fa(i,a)&&(n[i.level]+=1)}return n}function xl(e,s,n){return(e==="ios"?["D","I","E","F"]:s.F>0||(n||"").toUpperCase()==="F"?["V","D","I","W","E","F"]:["V","D","I","W","E"]).map(r=>({level:r,name:Ha(r,e)}))}function gl(e,s){if(!s)return null;const n=Ln.indexOf(s.toUpperCase());if(n<0)return null;const a=e.find(r=>Ln.indexOf(r.level)>=n);return a?a.level:null}function Ha(e,s){return e==="F"?s==="ios"?"Fault":"Fatal":vl[e]??e}const Is=5e5;function cs(e){return`${new Date(e.ts).toISOString()} ${e.pid} ${e.level}/${e.tag}: ${e.message}`}function jl(e){return{lines:[],startedAt:e,dropped:0}}function bl(e,s){for(const n of s){if(e.lines.length>=Is){e.dropped+=1;continue}e.lines.push(cs(n))}return e}function wl(e,s,n){const a=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(e.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-e.startedAt)/1e3).toFixed(1)}s`,`# lines: ${e.lines.length}`];e.dropped>0&&a.push(`# TRUNCATED: ${e.dropped} further line(s) were dropped after the ${Is}-line cap. This capture is INCOMPLETE.`);const r=e.lines.join(`
|
|
274
|
+
`),i=e.dropped>0?`
|
|
275
|
+
# --- TRUNCATED: ${e.dropped} line(s) not captured (cap ${Is}) ---`:"";return`${a.join(`
|
|
276
|
+
`)}
|
|
277
|
+
|
|
278
|
+
${r}${i}
|
|
279
|
+
`}function kl(e,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${e}-${n}.txt`}const Cs={selected:new Set,anchor:null,active:null};function Va(e,s,n){const a=e.indexOf(s),r=e.indexOf(n);return a<0||r<0?null:e.slice(Math.min(a,r),Math.max(a,r)+1)}function Wa(e){return{selected:new Set([e]),anchor:e,active:e}}function Nl(e,s,n,a){if(a.range&&e.anchor!==null){const r=Va(n,e.anchor,s);if(r)return{selected:new Set(r),anchor:e.anchor,active:s}}if(a.toggle){const r=new Set(Array.from(e.selected));return r.has(s)?r.delete(s):r.add(s),{selected:r,anchor:s,active:s}}return Wa(s)}function Cl(e,s,n,a){if(!s.length)return e;const r=e.active===null?-1:s.indexOf(e.active),i=r<0?n===1?0:s.length-1:Math.max(0,Math.min(s.length-1,r+n)),c=s[i];if(!a)return Wa(c);const h=e.anchor!==null&&s.indexOf(e.anchor)>=0?e.anchor:e.active??c,d=Va(s,h,c)??[c];return{selected:new Set(d),anchor:h,active:c}}function Sl(e,s){const n=[];if(s.size)for(let a=0;a<e.length;a++)s.has(e[a].seq)&&n.push(cs(e[a]));return{text:n.join(`
|
|
280
|
+
`),count:n.length}}const qa=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"});function rt(e){return e.toLocaleString("en-US")}function $l(e){return qa.format(e)}function Tl(e){const s=(Math.floor(e)%1e3+1e3)%1e3;return`${qa.format(e)}.${String(s).padStart(3,"0")}`}const Rl=[["tag:Wifi","lines whose tag contains Wifi"],["package:com.example","lines from that app"],["level:W","warnings and above"],["-tag:chatty","hide a tag"]];function El(e){const s=l.useRef(null),n=l.useRef(null),a=l.useRef(null),[r,i]=l.useState(!1),[c,h]=l.useState(!1);l.useEffect(()=>{var p,y;c&&((y=(p=a.current)==null?void 0:p.querySelector('[role^="menuitem"]:not(:disabled)'))==null||y.focus())},[c]);const d=()=>{var p;h(!1),(p=n.current)==null||p.focus()},o=p=>()=>{d(),p()},u=e.status==="Offline"||e.status==="Denied";return t.jsxs("div",{className:"log-toolbar",children:[t.jsxs("div",{className:"log-status",role:"status",title:e.statusDetail??void 0,children:[t.jsx("span",{className:`log-live-dot${e.status==="Live"?" active":""}${u?" is-error":""}`,"aria-hidden":"true"}),e.status]}),t.jsxs("div",{className:"log-filter",children:[t.jsx(jn,{ref:e.filterRef,type:"text",className:"log-field log-filter-input",placeholder:"tag:Wifi package:com.example text",value:e.query,onChange:p=>e.onQueryChange(p.target.value),"aria-label":"Filter logs",spellCheck:!1,autoComplete:"off"}),t.jsxs("span",{className:"log-field-buttons",children:[e.query&&t.jsx("button",{type:"button",className:"log-field-btn",onClick:()=>e.onQueryChange(""),"aria-label":"Clear filter",title:"Clear filter",children:t.jsx(Bs,{size:12,"aria-hidden":"true"})}),t.jsx("button",{ref:s,type:"button",className:"log-field-btn",onClick:()=>i(p=>!p),"aria-label":"Filter syntax","aria-haspopup":"dialog","aria-expanded":r,title:"Filter syntax",children:t.jsx(ua,{size:13,"aria-hidden":"true"})})]}),t.jsx(ns,{open:r,onClose:()=>i(!1),anchorRef:s,placement:"bottom-start",children:t.jsxs("div",{className:"log-syntax",children:[t.jsxs("p",{children:["Terms are combined. Quote a value with spaces: ",t.jsx("code",{children:'package:"Food Truck"'}),"."]}),t.jsx("dl",{children:Rl.map(([p,y])=>t.jsxs("div",{children:[t.jsx("dt",{children:t.jsx("code",{children:p})}),t.jsx("dd",{children:y})]},p))}),t.jsx("p",{children:"Other words search the message."})]})})]}),t.jsxs("div",{className:"log-find",children:[t.jsx(jn,{ref:e.findRef,type:"text",className:"log-field log-find-input",placeholder:"Find",value:e.find,onChange:p=>e.onFindChange(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),e.onStep(p.shiftKey?-1:1))},"aria-label":"Find in logs",spellCheck:!1,autoComplete:"off"}),e.find&&t.jsx("span",{className:"log-find-count","aria-live":"polite",children:e.hitCount?`${e.activeHit+1}/${e.hitCount}`:"0/0"})]}),t.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>e.onStep(-1),disabled:!e.hitCount,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:t.jsx(qs,{size:14,"aria-hidden":"true"})}),t.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>e.onStep(1),disabled:!e.hitCount,"aria-label":"Next match",title:"Next match (Enter)",children:t.jsx(Ws,{size:14,"aria-hidden":"true"})}),t.jsx("span",{className:"log-toolbar-divider","aria-hidden":"true"}),t.jsxs("div",{className:"log-actions",children:[t.jsxs(F,{type:"button",variant:"secondary",size:"sm",onClick:e.onTogglePause,children:[e.following?t.jsx(qr,{size:13,"aria-hidden":"true"}):t.jsx(Kr,{size:13,"aria-hidden":"true"}),e.following?"Pause":"Resume"]}),t.jsxs(F,{type:"button",variant:"secondary",size:"sm",className:`log-record${e.recording?" is-recording":""}`,onClick:e.onToggleRecording,"aria-pressed":e.recording,children:[e.recording?t.jsx(sa,{size:12,"aria-hidden":"true"}):t.jsx(Er,{size:12,"aria-hidden":"true"}),e.recording?`Stop · ${rt(e.recordedLines)} lines`:"Record"]}),t.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:e.onExport,"aria-label":"Export shown lines",title:"Export shown lines",children:t.jsx(da,{size:14,"aria-hidden":"true"})}),t.jsx(F,{ref:n,type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>h(p=>!p),"aria-label":"More options","aria-haspopup":"menu","aria-expanded":c,title:"More options",children:t.jsx(ha,{size:14,"aria-hidden":"true"})}),t.jsx(ns,{open:c,onClose:d,anchorRef:n,placement:"bottom-end",children:t.jsx("div",{ref:a,children:t.jsxs(Vs,{children:[t.jsx(ke,{checkbox:!0,checked:e.caseSensitive,onClick:o(e.onToggleCase),children:"Match case"}),t.jsx(ke,{checkbox:!0,checked:e.wrap,onClick:o(e.onToggleWrap),children:"Wrap long lines"}),t.jsx(aa,{}),e.canCopySelected&&t.jsx(ke,{onClick:o(e.onCopySelected),children:"Copy selected lines"}),t.jsx(ke,{onClick:o(e.onClearLines),children:"Clear lines"})]})})})]})]})}function Al({platform:e,counts:s,minLevel:n,shown:a,total:r,onChoose:i}){const c=xl(e,s,n),h=gl(c,n),d=h===null?-1:Ut.indexOf(h);return t.jsxs("div",{className:"log-levels",children:[t.jsxs("div",{className:"log-level-buttons",role:"group","aria-label":"Log levels",children:[t.jsx(F,{type:"button",variant:"ghost",size:"sm",className:"log-level-btn","aria-label":"All levels","aria-pressed":h===null,onClick:()=>i(""),children:"All"}),c.map(({level:o,name:u})=>{const p=s[o],f=`${u} ${o==="F"?"only":"and above"}, ${rt(p)} ${u.toLowerCase()} line${p===1?"":"s"}`,g=d>=0&&Ut.indexOf(o)>=d;return t.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:`log-level-btn lvl-${o}${g?" is-included":""}${p?" has-lines":""}`,"aria-label":f,"aria-pressed":h===o,onClick:()=>i(h===o?"":o),children:[u,t.jsx("span",{className:"log-level-count",children:rt(p)})]},o)})]}),t.jsxs("span",{className:"log-shown",children:[rt(a)," of ",rt(r)," shown"]})]})}const Dl=/[.*+?^${}()|[\]\\]/g;function Ml(e,s,n){if(!s||!e)return[{text:e,hit:!1}];const a=new RegExp(s.replace(Dl,"\\$&"),n?"g":"gi"),r=[];let i=0,c;for(;(c=a.exec(e))!==null;)c.index>i&&r.push({text:e.slice(i,c.index),hit:!1}),r.push({text:c[0],hit:!0}),i=c.index+c[0].length;return r.length?(i<e.length&&r.push({text:e.slice(i),hit:!1}),r):[{text:e,hit:!1}]}const In=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function zl(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Ll(e){return e?In[zl(e)%In.length]:"var(--text-muted)"}function _n({text:e,find:s,caseSensitive:n}){if(!s)return t.jsx(t.Fragment,{children:e});const a=Ml(e,s,n);return a.length===1&&!a[0].hit?t.jsx(t.Fragment,{children:e}):t.jsx(t.Fragment,{children:a.map((r,i)=>r.hit?t.jsx("mark",{className:"log-mark",children:r.text},i):t.jsx(l.Fragment,{children:r.text},i))})}const Il=l.memo(function({record:s,index:n,setSize:a,start:r,id:i,selected:c,active:h,hit:d,activeHit:o,find:u,caseSensitive:p,measureRef:y}){const f=["log-row",`lvl-${s.level}`,s.synthetic?"is-synthetic":"",d?"is-hit":"",o?"is-active-hit":"",h?"is-active":""].filter(Boolean).join(" ");return t.jsxs("div",{ref:y,role:"option",id:i,"aria-selected":c,"aria-setsize":a,"aria-posinset":n+1,"data-index":n,"data-seq":s.seq,className:f,style:{transform:`translateY(${r}px)`},children:[t.jsx("span",{className:"log-time",children:$l(s.ts)}),t.jsx("span",{className:"log-badge",children:s.level}),!s.synthetic&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"log-tag",title:s.tag,style:{color:Ll(s.tag)},children:t.jsx(_n,{text:s.tag,find:u,caseSensitive:p})}),t.jsx("span",{className:"log-pkg",title:s.pkg,children:s.pkg??""})]}),t.jsx("span",{className:"log-msg",children:t.jsx(_n,{text:s.message,find:u,caseSensitive:p})})]})}),On=24,_l=1e3,Ol=250,Fl=20,Pl=38,Fn=720,Ul=["PageUp","PageDown","Home"," "];let Bl=0;function Hl(e){const[s,n]=l.useState(!0);return l.useLayoutEffect(()=>{const a=e.current;if(!a)return;n(a.offsetWidth>=Fn);const r=window.ResizeObserver;if(!r)return;const i=new r(c=>n(c[0].contentRect.width>=Fn));return i.observe(a),()=>i.disconnect()},[e]),s}const Vl=l.forwardRef(function(s,n){const{records:a,wrap:r,find:i,caseSensitive:c,hits:h,activeHit:d,following:o,newLines:u}=s,p=l.useRef(null),[y]=l.useState(()=>`log-lines-${++Bl}`),f=l.useRef(null),g=l.useRef(o);g.current=o;const k=l.useRef(s);k.current=s;const b=Hl(p),U=s.selection.active,N=l.useMemo(()=>U===null?-1:a.findIndex(v=>v.seq===U),[a,U]),w=kr({count:a.length,getScrollElement:()=>p.current,estimateSize:()=>b?Fl:Pl,getItemKey:v=>a[v].seq,overscan:10,rangeExtractor:v=>{const z=Cr(v);return N>=0&&z.indexOf(N)<0&&(z.push(N),z.sort((V,M)=>V-M)),z},anchorTo:o?"start":"end",scrollToFn:(v,z,V)=>{const M=V.scrollElement,W=v+(z.adjustments??0);f.current=M?Math.max(0,Math.min(W,M.scrollHeight-M.clientHeight)):W,Nr(v,z,V)}}),C=l.useRef(`${r}|${b}`);l.useLayoutEffect(()=>{var z;const v=`${r}|${b}`;C.current!==v&&(C.current=v,w.measure(),(z=p.current)==null||z.querySelectorAll("[data-index]").forEach(V=>w.measureElement(V)))},[r,b,w]);const j=w.getTotalSize(),A=a.length?a[a.length-1].seq:-1,T=l.useRef(a);T.current=a;const $=l.useRef(null),[m,S]=l.useState(!1),I=l.useRef(()=>{});I.current=()=>{const v=p.current,z=T.current,V=v&&z.length?w.getVirtualItemForOffset(v.scrollTop):void 0;$.current=V&&z[V.index]?z[V.index].seq:null},l.useLayoutEffect(()=>{const v=$.current,z=s.oldestSeq;!g.current&&v!==null&&z!==null&&v<z&&(S(!0),w.scrollToOffset(0)),I.current()},[a,s.oldestSeq,w]),l.useEffect(()=>{o&&S(!1)},[o]);const B=l.useRef(0),L=l.useRef(!1);l.useLayoutEffect(()=>{!o||!a.length||L.current||Date.now()-B.current<Ol||w.scrollToOffset(j)},[o,A,a.length,j,w]),l.useEffect(()=>{const v=p.current;if(!v)return;let z=v.scrollTop;const V=()=>{B.current=Date.now()},M=ie=>{ie.target===v&&(L.current=!0,V())},W=()=>{L.current&&V(),L.current=!1},ne=ie=>{Ul.indexOf(ie.key)>=0&&V()},q=()=>{I.current();const ie=v.scrollTop,be=ie>z;if(z=ie,f.current!==null&&Math.abs(ie-f.current)<2||(f.current=null,!L.current&&Date.now()-B.current>_l))return;const E=v.scrollHeight-v.clientHeight-ie;g.current&&E>On?k.current.onPause():!g.current&&be&&E<=On&&k.current.onFollow()},se={passive:!0};return v.addEventListener("wheel",V,se),v.addEventListener("touchstart",V,se),v.addEventListener("touchmove",V,se),v.addEventListener("pointerdown",M),window.addEventListener("pointerup",W),v.addEventListener("keydown",ne),v.addEventListener("scroll",q,se),()=>{v.removeEventListener("wheel",V),v.removeEventListener("touchstart",V),v.removeEventListener("touchmove",V),v.removeEventListener("pointerdown",M),window.removeEventListener("pointerup",W),v.removeEventListener("keydown",ne),v.removeEventListener("scroll",q)}},[]),l.useImperativeHandle(n,()=>({reveal:v=>w.scrollToIndex(v,{align:"center"}),focus:()=>{var v;return(v=p.current)==null?void 0:v.focus({preventScroll:!0})}}),[w]);const Y=v=>`${y}-${v}`,te=v=>{var W,ne,q,se;const z=v.target.closest("[data-seq]");if(!z||!((W=p.current)!=null&&W.contains(z))||(((q=(ne=window.getSelection)==null?void 0:ne.call(window))==null?void 0:q.toString())??"")!=="")return;const V=Number(z.getAttribute("data-seq")),M=Nl(s.selection,V,a.map(ie=>ie.seq),{range:v.shiftKey,toggle:v.metaKey||v.ctrlKey});s.onSelect(M,a.find(ie=>ie.seq===V)??null,"click"),M.selected.size&&g.current&&s.onPause(),v.shiftKey&&((se=p.current)==null||se.focus({preventScroll:!0}))},Z=v=>{v.shiftKey&&v.preventDefault()},H=v=>{var V,M;const z=v.metaKey||v.ctrlKey;if((v.key==="ArrowDown"||v.key==="ArrowUp")&&!z&&!v.altKey){v.preventDefault();const W=a.map(se=>se.seq);if(!W.length)return;const ne=Cl(s.selection,W,v.key==="ArrowDown"?1:-1,v.shiftKey),q=ne.active===null?-1:W.indexOf(ne.active);if(s.onSelect(ne,q>=0?a[q]:null,"key"),q<0)return;q!==W.length-1&&g.current&&s.onPause(),w.scrollToIndex(q,{align:"auto"})}else if(v.key==="Enter"&&!z){const W=N>=0?a[N]:void 0;if(!W)return;v.preventDefault(),s.onOpenDetails(W)}else if(v.key==="End"&&!z)v.preventDefault(),s.onFollow(),w.scrollToOffset(j);else if(z&&!v.altKey&&(v.key==="c"||v.key==="C")){if(!s.selection.selected.size||(((M=(V=window.getSelection)==null?void 0:V.call(window))==null?void 0:M.toString())??"")!=="")return;v.preventDefault(),s.onCopy()}};return t.jsxs("div",{className:"log-list-wrap",children:[m&&!o&&t.jsx("div",{className:"log-dropped-note",children:"Older lines were dropped while paused"}),t.jsx("div",{ref:p,role:"listbox","aria-label":"Log lines","aria-multiselectable":"true",tabIndex:0,"aria-activedescendant":N>=0?Y(a[N].seq):void 0,className:`log-list${r?"":" is-nowrap"}`,onClick:te,onMouseDown:Z,onKeyDown:H,children:t.jsx("div",{className:"log-list-sizer",style:{height:j},children:w.getVirtualItems().map(v=>{const z=a[v.index];return t.jsx(Il,{record:z,index:v.index,setSize:a.length,start:v.start,id:Y(z.seq),selected:s.selection.selected.has(z.seq),active:s.selection.active===z.seq,hit:h.has(v.index),activeHit:d===v.index,find:i,caseSensitive:c,measureRef:w.measureElement},z.seq)})})}),!o&&t.jsx(F,{type:"button",variant:"secondary",size:"sm",className:"log-new-pill",onClick:()=>k.current.onFollow(),children:u>0?`${rt(u)} new line${u===1?"":"s"} · Jump to latest`:"Jump to latest"})]})});function Wl({record:e,platform:s,inBuffer:n,onCopyLine:a,onCopyMessage:r,onShowOnlyTag:i,onHideTag:c,onShowOnlyApp:h,onClose:d}){const o=!!e.synthetic;return t.jsxs("section",{className:"log-details","aria-label":"Line details",children:[t.jsxs("header",{className:"log-details-head",children:[t.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"log-details-close","aria-label":"Close details",title:"Close details (Esc)",onClick:d,children:t.jsx(Bs,{size:14,"aria-hidden":"true"})}),t.jsx("h3",{className:"log-details-title",children:o?"Added by Xenon":`${Ha(e.level,s)} · ${e.tag}`})]}),o&&t.jsx("p",{className:"log-details-note",children:"Xenon added this line. It didn’t come from the phone."}),t.jsxs("dl",{className:"log-details-fields",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Time"}),t.jsx("dd",{children:Tl(e.ts)})]}),!o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("dt",{children:"App"}),t.jsx("dd",{children:e.pkg??"Unknown"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Process ID"}),t.jsx("dd",{children:e.pid})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Thread ID"}),t.jsx("dd",{children:e.tid})]})]})]}),!n&&t.jsx("p",{className:"log-details-left",children:"This line has left the buffer"}),t.jsx("pre",{className:"log-details-msg",children:e.message}),t.jsxs("div",{className:"log-details-actions",children:[t.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:a,children:"Copy line"}),!o&&t.jsxs(t.Fragment,{children:[t.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:r,children:"Copy message"}),e.tag&&t.jsxs(t.Fragment,{children:[t.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Show only this tag"}),t.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:c,children:"Hide this tag"})]}),e.pkg&&t.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:h,children:"Show only this app"})]})]})]})}function Pn(e,s){const n=URL.createObjectURL(new Blob([e],{type:"text/plain"})),a=document.createElement("a");a.href=n,a.download=s,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(n),0)}async function ql(e){var a;if(await Ys(e))return!0;if(typeof document.execCommand!="function")return!1;const s=document.activeElement,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n),(a=s==null?void 0:s.focus)==null||a.call(s,{preventScroll:!0})}}const Kl=e=>e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable;function Xl({udid:e,platform:s}){const n=(s||"").toLowerCase(),a=n==="ios",r=n==="android"||a,i=a?"ios":"android",{toast:c}=Ue(),[h,d]=l.useState(""),o=l.useMemo(()=>a?pl(h):void 0,[a,h]),{records:u,connected:p,clear:y,deniedReason:f,exhausted:g,retry:k}=dl(e,r,o),[b,U]=l.useState(!1),[N,w]=l.useState(!0),[C,j]=l.useState(""),[A,T]=l.useState(0),[$,m]=l.useState(Cs),[S,I]=l.useState(null),B=l.useRef(null),L=l.useRef(null),Y=l.useRef(null),te=l.useRef(null),Z=l.useRef(u);Z.current=u;const[H,v]=l.useState(!0),[z,V]=l.useState(null),M=l.useRef(H);M.current=H;const W=l.useCallback(()=>{if(!M.current)return;M.current=!1;const _=Z.current;V(_.length?_[_.length-1].seq:-1),v(!1)},[]),ne=l.useCallback(()=>{M.current=!0,V(null),v(!0)},[]),q=l.useRef(null),[se,ie]=l.useState(!1),[be,E]=l.useState(0),oe=l.useRef(-1),Q=l.useMemo(()=>Oa(h,{caseSensitive:b}),[h,b]),ae=l.useMemo(()=>u.filter(_=>Fa(_,Q)),[u,Q]),De=l.useMemo(()=>yl(u,Q),[u,Q]),ue=l.useMemo(()=>{if(!C)return[];const _=b?C:C.toLowerCase(),ee=[];return ae.forEach((ce,Re)=>{(b?`${ce.tag} ${ce.message}`:`${ce.tag} ${ce.message}`.toLowerCase()).includes(_)&&ee.push(Re)}),ee},[ae,C,b]),fe=ue.length?Math.min(A,ue.length-1):0,Be=l.useMemo(()=>new Set(ue),[ue]),Qe=l.useCallback(_=>{var ce;if(!ue.length)return;const ee=(fe+_+ue.length)%ue.length;T(ee),W(),(ce=te.current)==null||ce.reveal(ue[ee])},[ue,fe,W]),wt=l.useMemo(()=>{if(z===null)return 0;let _=0;for(let ee=ae.length-1;ee>=0&&ae[ee].seq>z;ee--)_++;return _},[ae,z]),pe=l.useCallback(()=>{if(!ae.length){c("No lines to export","info");return}Pn(ae.map(cs).join(`
|
|
281
|
+
`),`logcat-${e}-${Date.now()}.txt`)},[ae,e,c]);l.useEffect(()=>{const _=q.current;if(!_||!u.length)return;const ee=u.filter(Re=>Re.seq>oe.current);if(!ee.length)return;const ce=oe.current+1;oe.current>=0&&ee[0].seq>ce&&(_.dropped+=ee[0].seq-ce),bl(_,ee),oe.current=ee[ee.length-1].seq,E(_.lines.length)},[u]);const He=l.useCallback(()=>{const _=q.current;if(!_){oe.current=u.length?u[u.length-1].seq:-1,q.current=jl(Date.now()),E(0),ie(!0);return}const ee=wl(_,Date.now(),e);q.current=null,ie(!1),E(0),Pn(ee,kl(e,_.startedAt))},[u,e]),[_e,Se]=l.useState(!1),et=Ia(()=>{});al(se?()=>q.current?(Se(!0),!0):!1:null);const kt=()=>{Se(!1),q.current&&He(),et()},Ve=l.useCallback(async(_,ee)=>{await ql(_)?c(ee,"success"):c("Your browser blocked copying here.","error")},[c]),$e=l.useMemo(()=>{if(!$.selected.size)return 0;let _=0;for(let ee=0;ee<ae.length;ee++)$.selected.has(ae[ee].seq)&&_++;return _},[ae,$.selected]),Te=l.useCallback(()=>{const{text:_,count:ee}=Sl(ae,$.selected);ee&&Ve(_,`Copied ${rt(ee)} line${ee===1?"":"s"}`)},[ae,$.selected,Ve]),ct=l.useCallback((_,ee,ce)=>{m(_),I(ce==="click"?ee:Re=>Re&&ee?ee:Re)},[]),We=l.useCallback(()=>{y(),m(Cs)},[y]),tt=_=>{var ce,Re,ut;const ee=_.metaKey||_.ctrlKey;_.key==="/"&&!ee&&!Kl(_.target)?(_.preventDefault(),(ce=L.current)==null||ce.focus()):ee&&!_.altKey&&(_.key==="f"||_.key==="F")?(_.preventDefault(),(Re=Y.current)==null||Re.focus(),(ut=Y.current)==null||ut.select()):_.key==="Escape"&&(S?(_.preventDefault(),I(null)):$.selected.size&&(_.preventDefault(),m(Cs)))},lt=l.useRef(tt);if(lt.current=tt,l.useEffect(()=>{const _=B.current;if(!_)return;const ee=ce=>lt.current(ce);return _.addEventListener("keydown",ee),()=>_.removeEventListener("keydown",ee)},[r]),!r)return t.jsx("div",{className:"logcat-root",children:t.jsx(Wr,{title:"Live logs are not available here",description:"Live logs work on Android and iOS phones."})});const Oe=f?"Denied":g?"Offline":p?"Live":"Connecting",qe=!!S&&u.length>0&&S.seq>=u[0].seq&&S.seq<=u[u.length-1].seq;let Me=null;ae.length||(u.length?Me=t.jsxs("div",{className:"log-state",children:[t.jsxs("p",{children:["No lines match ",t.jsx("code",{children:h})]}),t.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:()=>d(""),children:"Clear filter"})]}):Oe==="Connecting"?Me=t.jsx("div",{className:"log-state",children:t.jsx("p",{children:"Waiting for the phone’s first log line…"})}):Oe==="Live"&&(Me=t.jsx("div",{className:"log-state",children:t.jsx("p",{children:"Connected. Lines appear here as the phone logs them."})})));const dt=t.jsxs(F,{type:"button",variant:"secondary",size:"sm",onClick:k,children:[t.jsx(It,{size:13,"aria-hidden":"true"})," Reconnect"]});return t.jsxs("div",{className:"logcat-root",ref:B,children:[t.jsx(El,{status:Oe,statusDetail:f,query:h,onQueryChange:d,filterRef:L,find:C,onFindChange:_=>{j(_),T(0)},findRef:Y,hitCount:ue.length,activeHit:fe,onStep:Qe,following:H,onTogglePause:H?W:ne,recording:se,recordedLines:be,onToggleRecording:He,onExport:pe,caseSensitive:b,onToggleCase:()=>U(_=>!_),wrap:N,onToggleWrap:()=>w(_=>!_),canCopySelected:$e>0,onCopySelected:Te,onClearLines:We}),t.jsx(Al,{platform:i,counts:De,minLevel:Q.minLevel,shown:ae.length,total:u.length,onChoose:_=>d(ml(h,_))}),t.jsxs("div",{className:"log-body theme-dark",children:[f&&t.jsxs("div",{className:"log-banner is-denied",role:"alert",children:[t.jsx(Ge,{size:14,"aria-hidden":"true"}),t.jsxs("span",{children:["Access denied — ",f]}),dt]}),!f&&g&&t.jsxs("div",{className:"log-banner is-exhausted",role:"alert",children:[t.jsx(Ge,{size:14,"aria-hidden":"true"}),t.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect to try again."}),dt]}),t.jsxs("div",{className:"log-main",children:[t.jsx(Vl,{ref:te,records:ae,oldestSeq:u.length?u[0].seq:null,wrap:N,find:C,caseSensitive:b,hits:Be,activeHit:ue.length?ue[fe]:null,following:H,newLines:wt,onPause:W,onFollow:ne,selection:$,onSelect:ct,onOpenDetails:I,onCopy:Te}),Me]}),S&&t.jsx(Wl,{record:S,platform:i,inBuffer:qe,onCopyLine:()=>Ve(cs(S),"Copied the line"),onCopyMessage:()=>Ve(S.message,"Copied the message"),onShowOnlyTag:()=>d(Mn(h,"tag",S.tag)),onHideTag:()=>d(hl(h,"tag",S.tag)),onShowOnlyApp:()=>d(Mn(h,"package",S.pkg??"")),onClose:()=>I(null)})]}),t.jsx(hs,{open:_e,title:"Stop recording?",onClose:()=>Se(!1),footer:t.jsxs(t.Fragment,{children:[t.jsx(F,{type:"button",variant:"secondary",onClick:()=>Se(!1),autoFocus:!0,children:"Keep recording"}),t.jsx(F,{type:"button",onClick:kt,children:"Save and close"})]}),children:t.jsxs("p",{children:[rt(be)," line",be===1?"":"s"," recorded so far. Closing device control ends the recording. Save and close downloads it first."]})})]})}function Ka(e){const s=e==null?void 0:e.message;return typeof s=="string"?s.trim():""}function Le(e,s){const n=Ka(s);return n?`Couldn’t ${e}: ${n}`:`Couldn’t ${e}.`}function Yl(e,s){return e==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Le("read the clipboard",s)}function Gl(e,s){const n=s.trim().toLowerCase();return[...e].sort((a,r)=>a.localeCompare(r)).filter(a=>!n||a.toLowerCase().includes(n))}const Zl=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Jl(e){return Zl.test(e.trim())}function Gs(e){const s=(e||"").toLowerCase();return s==="android"?"android":s==="ios"||s==="tvos"?"ios":null}function Ql(e,s){const n=Gs(s);return n?e.filter(a=>(a.platform||"").toLowerCase()===n):[]}function ed(e){return[e.version,e.packageName].filter(Boolean).join(" · ")}function td(e){return Gs(e)==="android"?"Android":"iOS"}function sd(e){return Gs(e)==="android"?".apk":".ipa,.app"}function nd({udid:e,platform:s,deviceName:n}){const{toast:a,removeToast:r}=Ue(),i=Bt(),[c,h]=l.useState([]),[d,o]=l.useState("loading"),[u,p]=l.useState(""),[y,f]=l.useState(""),[g,k]=l.useState(!1),[b,U]=l.useState(!1),[N,w]=l.useState([]),[C,j]=l.useState("loading"),[A,T]=l.useState(null),[$,m]=l.useState(null),S=l.useRef(null),I=l.useRef(null),B=l.useRef(null),L=l.useCallback(async()=>{o("loading");try{const E=await X.listApps(e);h(Array.isArray(E)?E:[]),o("ready")}catch(E){p(Ka(E)),o("error")}},[e]);l.useEffect(()=>{L()},[L]);const Y=E=>setTimeout(L,E);l.useEffect(()=>{if(!$)return;const E=setTimeout(()=>m(null),1500);return()=>clearTimeout(E)},[$]);const te=async()=>{j("loading");try{const E=await X.getApps();w(Array.isArray(E)?E:[]),j("ready")}catch{j("error")}},Z=()=>{g||(U(!0),te())},H=()=>{var E;U(!1),(E=S.current)==null||E.focus()};l.useEffect(()=>{var oe;if(!b||C==="loading")return;const E=(oe=I.current)==null?void 0:oe.querySelector('[role="menuitem"]:not(:disabled)');E==null||E.focus()},[b,C]);const v=async(E,oe)=>{k(!0);const Q=a(`Installing ${E} on ${n}…`,"loading",0);try{const ae=await oe();ae!=null&&ae.success?(a(`Installed ${E} on ${n}`,"success"),Y(5e3)):a(Le(`install ${E}`,{message:ae==null?void 0:ae.error}),"error")}catch(ae){a(Le(`install ${E}`,ae),"error")}finally{r(Q),k(!1)}},z=E=>{H(),v(E.name,()=>X.installRepositoryApp(e,E.id))},V=E=>{var Q;const oe=(Q=E.target.files)==null?void 0:Q[0];E.target.value="",oe&&v(oe.name,()=>X.uploadAndInstallApp(e,oe))},M=async()=>{const E=A;if(T(null),!E)return;const oe=a(`Uninstalling ${E} from ${n}…`,"loading",0);try{await X.uninstallApp(e,E),a(`Uninstalled ${E} from ${n}`,"success"),Y(3e3)}catch(Q){a(Le(`uninstall ${E}`,Q),"error")}finally{r(oe)}},W=async(E,oe)=>{var ae,De;if(await Ys(E)){m(E);return}const Q=(ae=oe.closest("li"))==null?void 0:ae.querySelector(".actions-app-id");Q&&((De=window.getSelection())==null||De.selectAllChildren(Q)),a(_a,"info")},ne=Gl(c,y),q=y.trim(),se=d==="ready"&&ne.length===0&&Jl(q)&&!c.includes(q),ie=Ql(N,s),be=(E,oe)=>t.jsxs("li",{className:"actions-app-row",children:[t.jsx("span",{className:"actions-app-id",children:E}),oe&&t.jsx("span",{className:"actions-app-note",children:oe}),t.jsxs("span",{className:"actions-app-tools",children:[t.jsx(F,{variant:"ghost",size:"icon","aria-label":$===E?"Copied":`Copy ${E}`,title:$===E?"Copied":"Copy package ID",onClick:Q=>W(E,Q.currentTarget),children:$===E?t.jsx(Ot,{size:13,"aria-hidden":"true"}):t.jsx(Pe,{size:13,"aria-hidden":"true"})}),t.jsx(F,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${E}`,onClick:()=>T(E),children:"Uninstall"})]})]},E);return t.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[t.jsxs("div",{className:"actions-section-head",children:[t.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[t.jsx(Gi,{size:15,"aria-hidden":"true"})," Apps"]}),t.jsxs("div",{className:"actions-section-tools",children:[t.jsxs(F,{ref:S,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":b,"aria-disabled":g||void 0,onClick:Z,children:[g?t.jsx(gt,{className:"animate-spin",size:13,"aria-hidden":"true"}):t.jsx(zi,{size:13,"aria-hidden":"true"}),"Install from library"]}),t.jsxs(F,{variant:"secondary",size:"sm","aria-disabled":g||void 0,onClick:()=>{var E;return!g&&((E=B.current)==null?void 0:E.click())},children:[t.jsx(Xr,{size:13,"aria-hidden":"true"})," Upload file"]}),t.jsx("input",{ref:B,type:"file",hidden:!0,"aria-label":"App file to upload",accept:sd(s),onChange:V})]})]}),t.jsx(ns,{open:b,onClose:H,anchorRef:S,placement:"bottom-end",children:t.jsx("div",{ref:I,className:"actions-library-menu",children:t.jsxs(Vs,{children:[C==="loading"&&t.jsx(ke,{disabled:!0,onClick:()=>{},children:"Loading…"}),C==="error"&&t.jsx(ke,{onClick:te,children:"Couldn’t load the library. Retry"}),C==="ready"&&ie.length===0&&t.jsxs(t.Fragment,{children:[t.jsxs(ke,{disabled:!0,onClick:()=>{},children:["No ",td(s)," apps in the library yet"]}),t.jsx(ke,{onClick:()=>i("/apps"),children:"Open the Apps library"})]}),C==="ready"&&ie.map(E=>t.jsx(ke,{note:ed(E)||void 0,onClick:()=>z(E),children:E.name},E.id))]})})}),t.jsxs("div",{className:"actions-apps-tools",children:[t.jsxs("div",{className:"actions-search",children:[t.jsx(Hs,{size:13,className:"actions-search-icon","aria-hidden":"true"}),t.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${c.length} installed apps`,value:y,onChange:E=>f(E.target.value)})]}),t.jsx(F,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:L,children:t.jsx(Jt,{size:13,"aria-hidden":"true"})})]}),d==="loading"&&c.length===0&&t.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),d==="error"&&t.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",u?`: ${u}`:".",t.jsx(F,{variant:"secondary",size:"sm",onClick:L,children:"Retry"})]}),d==="ready"&&c.length===0&&t.jsx("p",{className:"actions-list-note",children:"No apps installed"}),d==="ready"&&c.length>0&&ne.length===0&&!se&&t.jsxs("p",{className:"actions-list-note",children:["No apps match “",q,"”"]}),t.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[ne.map(E=>be(E)),se&&be(q,"Not in the list")]}),t.jsx(hs,{open:A!==null,title:"Uninstall app?",onClose:()=>T(null),footer:t.jsxs(t.Fragment,{children:[t.jsx(F,{variant:"secondary",onClick:()=>T(null),children:"Cancel"}),t.jsx(F,{variant:"danger",onClick:M,children:"Uninstall"})]}),children:t.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",t.jsx("code",{children:A})," from"," ",t.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const ad=[{direction:"up",Icon:qs},{direction:"down",Icon:Ws},{direction:"left",Icon:Gr},{direction:"right",Icon:Zr}];function rd({onSwipe:e}){return t.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[t.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[t.jsx(Ti,{size:15,"aria-hidden":"true"})," Swipe"]}),t.jsx("div",{className:"actions-swipe-buttons",children:ad.map(({direction:s,Icon:n})=>t.jsx(F,{variant:"secondary",size:"icon","aria-label":`Swipe ${s}`,title:`Swipe ${s}`,onClick:()=>e(s),children:t.jsx(n,{size:14,"aria-hidden":"true"})},s))})]})}function id(e,s,n){const a=s/2,r=n/2,i=s*.4,c=n*.4,[h,d,o,u]={up:[a,r+c,a,r-c],down:[a,r-c,a,r+c],left:[a+i,r,a-i,r],right:[a-i,r,a+i,r]}[e].map(Math.round);return{startX:h,startY:d,endX:o,endY:u}}function od({udid:e,platform:s}){const n=s!=="android",{toast:a}=Ue(),[r,i]=l.useState(""),[c,h]=l.useState(!1),[d,o]=l.useState(""),[u,p]=l.useState(null),[y,f]=l.useState(""),[g,k]=l.useState(!1),b=l.useRef(null);l.useEffect(()=>{if(!y)return;const j=setTimeout(()=>f(""),2e3);return()=>clearTimeout(j)},[y]),l.useEffect(()=>{if(!g)return;const j=setTimeout(()=>k(!1),1500);return()=>clearTimeout(j)},[g]);const U=async()=>{if(!(!r.trim()||c)){h(!0);try{await X.typeText(e,r),i(""),f("Sent")}catch(j){a(Le("send the text",j),"error")}finally{h(!1)}}},N=async()=>{p("read");try{const j=await X.getClipboard(e),A=typeof(j==null?void 0:j.content)=="string"?j.content:"";o(A),A||f("The device clipboard is empty")}catch(j){a(Yl(s,j),"error")}finally{p(null)}},w=async()=>{if(d){p("write");try{await X.setClipboard(e,d),f("Written to the device")}catch(j){a(Le("write the clipboard",j),"error")}finally{p(null)}}},C=async()=>{var j;if(await Ys(d)){k(!0);return}(j=b.current)==null||j.select(),a(_a,"info")};return t.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[t.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[t.jsx(Di,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),t.jsxs("div",{className:"actions-field-row",children:[t.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),t.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:r,onChange:j=>i(j.target.value),onKeyDown:j=>j.key==="Enter"&&U()}),t.jsxs(F,{variant:"secondary",size:"md",onClick:U,disabled:!r.trim()||c,children:[c&&t.jsx(gt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),t.jsxs("div",{className:"actions-field-row",children:[t.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),t.jsx("input",{id:"actions-clipboard",ref:b,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:d,onChange:j=>o(j.target.value)}),t.jsxs(F,{variant:"secondary",size:"md",onClick:N,disabled:u!==null,children:[u==="read"&&t.jsx(gt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&t.jsxs(F,{variant:"secondary",size:"md",onClick:w,disabled:!d||u!==null,children:[u==="write"&&t.jsx(gt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),t.jsx(F,{variant:"ghost",size:"icon","aria-label":g?"Copied":"Copy clipboard text",title:g?"Copied":"Copy to your clipboard",onClick:C,disabled:!d,children:g?t.jsx(Ot,{size:14,"aria-hidden":"true"}):t.jsx(Pe,{size:14,"aria-hidden":"true"})})]}),!n&&t.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),t.jsx("p",{className:"actions-status",role:"status",children:y})]})}function cd({udid:e,platform:s,deviceName:n,screenWidth:a,screenHeight:r}){const{toast:i}=Ue(),c=async h=>{const d=id(h,a,r);try{await X.swipe(e,d.startX,d.startY,d.endX,d.endY)}catch(o){i(Le(`swipe ${h}`,o),"error")}};return t.jsxs("div",{className:"actions-panel",children:[t.jsx(nd,{udid:e,platform:s,deviceName:n}),t.jsx(od,{udid:e,platform:s}),t.jsx(rd,{onSwipe:c})]})}const ld=[{id:"RECT",label:"Rect"},{id:"CIRCLE",label:"Circle"},{id:"ARROW",label:"Arrow"},{id:"FREEHAND",label:"Draw"}];function dd({shape:e,color:s,marks:n,saving:a,onShape:r,onColor:i,onUndo:c,onClear:h,onCancel:d,onSave:o}){return t.jsxs("div",{className:"shots-actions",role:"toolbar","aria-label":"Annotate",children:[t.jsxs("div",{className:"shots-shapes",children:[ld.map(u=>t.jsx(F,{variant:"secondary",size:"sm","aria-pressed":e===u.id,className:e===u.id?"is-pressed":void 0,onClick:()=>r(u.id),children:u.label},u.id)),t.jsx("input",{type:"color",className:"shots-color",value:s,onChange:u=>i(u.target.value),"aria-label":"Mark colour",title:"Mark colour"})]}),t.jsx(F,{variant:"ghost",size:"sm",onClick:c,disabled:!n||a,children:"Undo mark"}),t.jsx(F,{variant:"ghost",size:"sm",onClick:h,disabled:!n||a,children:"Clear marks"}),t.jsx("span",{className:"shots-actions-gap"}),t.jsx(F,{variant:"secondary",size:"sm",onClick:d,disabled:a,children:"Cancel"}),t.jsxs(F,{size:"sm",onClick:o,disabled:!n||a,children:[a&&t.jsx(gt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Save copy"]})]})}function jt(e){return`Screenshot ${e.n}`}const it=e=>String(e).padStart(2,"0");function Un(e){return`${it(e.getHours())}:${it(e.getMinutes())}:${it(e.getSeconds())}`}function ud(e,s){return e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()}function _s(e,s=Date.now()){const n=new Date(e);return ud(n,new Date(s))?`Today ${Un(n)}`:`${n.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} ${Un(n)}`}function hd(e,s){return!e||!s?"":e>s?"Landscape":"Portrait"}function md(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Xa(e,s=Date.now()){const n=[jt(e)];e.markedFrom!==void 0&&n.push(`marked copy of ${e.markedFrom}`),n.push(_s(e.takenAt,s));const a=hd(e.width,e.height);return a&&n.push(a,`${e.width} × ${e.height}`),n.push(md(e.bytes)),n.join(" · ")}function Ya(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"device"}function Ga(e){const s=new Date(e);return`${s.getFullYear()}-${it(s.getMonth()+1)}-${it(s.getDate())}`}function Za(e,s){const n=new Date(s.takenAt),a=`${it(n.getHours())}-${it(n.getMinutes())}-${it(n.getSeconds())}`,r=s.markedFrom!==void 0?"-marked":"";return`${Ya(e)}-screenshot-${s.n}${r}-${Ga(s.takenAt)}-${a}.png`}function fd(e,s=Date.now()){return`${Ya(e)}-screenshots-${Ga(s)}.zip`}async function pd(e){const s=globalThis.ClipboardItem,n=navigator.clipboard;if(!s||typeof(n==null?void 0:n.write)!="function")return!1;try{const a=e.type==="image/png"?e:new Blob([e],{type:"image/png"});return await n.write([new s({"image/png":a})]),!0}catch{return!1}}var Ne=Uint8Array,Ae=Uint16Array,Zs=Int32Array,Js=new Ne([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Qs=new Ne([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Bn=new Ne([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ja=function(e,s){for(var n=new Ae(31),a=0;a<31;++a)n[a]=s+=1<<e[a-1];for(var r=new Zs(n[30]),a=1;a<30;++a)for(var i=n[a];i<n[a+1];++i)r[i]=i-n[a]<<5|a;return{b:n,r}},Qa=Ja(Js,2),vd=Qa.b,Os=Qa.r;vd[28]=258,Os[258]=28;var yd=Ja(Qs,0),Hn=yd.r,Fs=new Ae(32768);for(var de=0;de<32768;++de){var at=(de&43690)>>1|(de&21845)<<1;at=(at&52428)>>2|(at&13107)<<2,at=(at&61680)>>4|(at&3855)<<4,Fs[de]=((at&65280)>>8|(at&255)<<8)>>1}var _t=function(e,s,n){for(var a=e.length,r=0,i=new Ae(s);r<a;++r)e[r]&&++i[e[r]-1];var c=new Ae(s);for(r=1;r<s;++r)c[r]=c[r-1]+i[r-1]<<1;var h;if(n){h=new Ae(1<<s);var d=15-s;for(r=0;r<a;++r)if(e[r])for(var o=r<<4|e[r],u=s-e[r],p=c[e[r]-1]++<<u,y=p|(1<<u)-1;p<=y;++p)h[Fs[p]>>d]=o}else for(h=new Ae(a),r=0;r<a;++r)e[r]&&(h[r]=Fs[c[e[r]-1]++]>>15-e[r]);return h},bt=new Ne(288);for(var de=0;de<144;++de)bt[de]=8;for(var de=144;de<256;++de)bt[de]=9;for(var de=256;de<280;++de)bt[de]=7;for(var de=280;de<288;++de)bt[de]=8;var ls=new Ne(32);for(var de=0;de<32;++de)ls[de]=5;var xd=_t(bt,9,0),gd=_t(ls,5,0),er=function(e){return(e+7)/8|0},tr=function(e,s,n){return(n==null||n>e.length)&&(n=e.length),new Ne(e.subarray(s,n))},jd=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ms=function(e,s,n){var a=new Error(s||jd[e]);if(a.code=e,Error.captureStackTrace&&Error.captureStackTrace(a,ms),!n)throw a;return a},Ye=function(e,s,n){n<<=s&7;var a=s/8|0;e[a]|=n,e[a+1]|=n>>8},Mt=function(e,s,n){n<<=s&7;var a=s/8|0;e[a]|=n,e[a+1]|=n>>8,e[a+2]|=n>>16},Ss=function(e,s){for(var n=[],a=0;a<e.length;++a)e[a]&&n.push({s:a,f:e[a]});var r=n.length,i=n.slice();if(!r)return{t:nr,l:0};if(r==1){var c=new Ne(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(j,A){return j.f-A.f}),n.push({s:-1,f:25001});var h=n[0],d=n[1],o=0,u=1,p=2;for(n[0]={s:-1,f:h.f+d.f,l:h,r:d};u!=r-1;)h=n[n[o].f<n[p].f?o++:p++],d=n[o!=u&&n[o].f<n[p].f?o++:p++],n[u++]={s:-1,f:h.f+d.f,l:h,r:d};for(var y=i[0].s,a=1;a<r;++a)i[a].s>y&&(y=i[a].s);var f=new Ae(y+1),g=Ps(n[u-1],f,0);if(g>s){var a=0,k=0,b=g-s,U=1<<b;for(i.sort(function(A,T){return f[T.s]-f[A.s]||A.f-T.f});a<r;++a){var N=i[a].s;if(f[N]>s)k+=U-(1<<g-f[N]),f[N]=s;else break}for(k>>=b;k>0;){var w=i[a].s;f[w]<s?k-=1<<s-f[w]++-1:++a}for(;a>=0&&k;--a){var C=i[a].s;f[C]==s&&(--f[C],++k)}g=s}return{t:new Ne(f),l:g}},Ps=function(e,s,n){return e.s==-1?Math.max(Ps(e.l,s,n+1),Ps(e.r,s,n+1)):s[e.s]=n},Vn=function(e){for(var s=e.length;s&&!e[--s];);for(var n=new Ae(++s),a=0,r=e[0],i=1,c=function(d){n[a++]=d},h=1;h<=s;++h)if(e[h]==r&&h!=s)++i;else{if(!r&&i>2){for(;i>138;i-=138)c(32754);i>2&&(c(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(c(r),--i;i>6;i-=6)c(8304);i>2&&(c(i-3<<5|8208),i=0)}for(;i--;)c(r);i=1,r=e[h]}return{c:n.subarray(0,a),n:s}},zt=function(e,s){for(var n=0,a=0;a<s.length;++a)n+=e[a]*s[a];return n},sr=function(e,s,n){var a=n.length,r=er(s+2);e[r]=a&255,e[r+1]=a>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var i=0;i<a;++i)e[r+i+4]=n[i];return(r+4+a)*8},Wn=function(e,s,n,a,r,i,c,h,d,o,u){Ye(s,u++,n),++r[256];for(var p=Ss(r,15),y=p.t,f=p.l,g=Ss(i,15),k=g.t,b=g.l,U=Vn(y),N=U.c,w=U.n,C=Vn(k),j=C.c,A=C.n,T=new Ae(19),$=0;$<N.length;++$)++T[N[$]&31];for(var $=0;$<j.length;++$)++T[j[$]&31];for(var m=Ss(T,7),S=m.t,I=m.l,B=19;B>4&&!S[Bn[B-1]];--B);var L=o+5<<3,Y=zt(r,bt)+zt(i,ls)+c,te=zt(r,y)+zt(i,k)+c+14+3*B+zt(T,S)+2*T[16]+3*T[17]+7*T[18];if(d>=0&&L<=Y&&L<=te)return sr(s,u,e.subarray(d,d+o));var Z,H,v,z;if(Ye(s,u,1+(te<Y)),u+=2,te<Y){Z=_t(y,f,0),H=y,v=_t(k,b,0),z=k;var V=_t(S,I,0);Ye(s,u,w-257),Ye(s,u+5,A-1),Ye(s,u+10,B-4),u+=14;for(var $=0;$<B;++$)Ye(s,u+3*$,S[Bn[$]]);u+=3*B;for(var M=[N,j],W=0;W<2;++W)for(var ne=M[W],$=0;$<ne.length;++$){var q=ne[$]&31;Ye(s,u,V[q]),u+=S[q],q>15&&(Ye(s,u,ne[$]>>5&127),u+=ne[$]>>12)}}else Z=xd,H=bt,v=gd,z=ls;for(var $=0;$<h;++$){var se=a[$];if(se>255){var q=se>>18&31;Mt(s,u,Z[q+257]),u+=H[q+257],q>7&&(Ye(s,u,se>>23&31),u+=Js[q]);var ie=se&31;Mt(s,u,v[ie]),u+=z[ie],ie>3&&(Mt(s,u,se>>5&8191),u+=Qs[ie])}else Mt(s,u,Z[se]),u+=H[se]}return Mt(s,u,Z[256]),u+H[256]},bd=new Zs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nr=new Ne(0),wd=function(e,s,n,a,r,i){var c=i.z||e.length,h=new Ne(a+c+5*(1+Math.ceil(c/7e3))+r),d=h.subarray(a,h.length-r),o=i.l,u=(i.r||0)&7;if(s){u&&(d[0]=i.r>>3);for(var p=bd[s-1],y=p>>13,f=p&8191,g=(1<<n)-1,k=i.p||new Ae(32768),b=i.h||new Ae(g+1),U=Math.ceil(n/3),N=2*U,w=function(fe){return(e[fe]^e[fe+1]<<U^e[fe+2]<<N)&g},C=new Zs(25e3),j=new Ae(288),A=new Ae(32),T=0,$=0,m=i.i||0,S=0,I=i.w||0,B=0;m+2<c;++m){var L=w(m),Y=m&32767,te=b[L];if(k[Y]=te,b[L]=Y,I<=m){var Z=c-m;if((T>7e3||S>24576)&&(Z>423||!o)){u=Wn(e,d,0,C,j,A,$,S,B,m-B,u),S=T=$=0,B=m;for(var H=0;H<286;++H)j[H]=0;for(var H=0;H<30;++H)A[H]=0}var v=2,z=0,V=f,M=Y-te&32767;if(Z>2&&L==w(m-M))for(var W=Math.min(y,Z)-1,ne=Math.min(32767,m),q=Math.min(258,Z);M<=ne&&--V&&Y!=te;){if(e[m+v]==e[m+v-M]){for(var se=0;se<q&&e[m+se]==e[m+se-M];++se);if(se>v){if(v=se,z=M,se>W)break;for(var ie=Math.min(M,se-2),be=0,H=0;H<ie;++H){var E=m-M+H&32767,oe=k[E],Q=E-oe&32767;Q>be&&(be=Q,te=E)}}}Y=te,te=k[Y],M+=Y-te&32767}if(z){C[S++]=268435456|Os[v]<<18|Hn[z];var ae=Os[v]&31,De=Hn[z]&31;$+=Js[ae]+Qs[De],++j[257+ae],++A[De],I=m+v,++T}else C[S++]=e[m],++j[e[m]]}}for(m=Math.max(m,I);m<c;++m)C[S++]=e[m],++j[e[m]];u=Wn(e,d,o,C,j,A,$,S,B,m-B,u),o||(i.r=u&7|d[u/8|0]<<3,u-=7,i.h=b,i.p=k,i.i=m,i.w=I)}else{for(var m=i.w||0;m<c+o;m+=65535){var ue=m+65535;ue>=c&&(d[u/8|0]=o,ue=c),u=sr(d,u+1,e.subarray(m,ue))}i.i=c}return tr(h,0,a+er(u)+r)},kd=function(){for(var e=new Int32Array(256),s=0;s<256;++s){for(var n=s,a=9;--a;)n=(n&1&&-306674912)^n>>>1;e[s]=n}return e}(),Nd=function(){var e=-1;return{p:function(s){for(var n=e,a=0;a<s.length;++a)n=kd[n&255^s[a]]^n>>>8;e=n},d:function(){return~e}}},Cd=function(e,s,n,a,r){if(!r&&(r={l:1},s.dictionary)){var i=s.dictionary.subarray(-32768),c=new Ne(i.length+e.length);c.set(i),c.set(e,i.length),e=c,r.w=i.length}return wd(e,s.level==null?6:s.level,s.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+s.mem,n,a,r)},ar=function(e,s){var n={};for(var a in e)n[a]=e[a];for(var a in s)n[a]=s[a];return n},je=function(e,s,n){for(;n;++s)e[s]=n,n>>>=8};function Sd(e,s){return Cd(e,s||{},0,0)}var rr=function(e,s,n,a){for(var r in e){var i=e[r],c=s+r,h=a;Array.isArray(i)&&(h=ar(a,i[1]),i=i[0]),ArrayBuffer.isView(i)?n[c]=[i,h]:(n[c+="/"]=[new Ne(0),h],rr(i,c,n,a))}},qn=typeof TextEncoder<"u"&&new TextEncoder,$d=typeof TextDecoder<"u"&&new TextDecoder,Td=0;try{$d.decode(nr,{stream:!0}),Td=1}catch{}function Kn(e,s){var n;if(qn)return qn.encode(e);for(var a=e.length,r=new Ne(e.length+(e.length>>1)),i=0,c=function(o){r[i++]=o},n=0;n<a;++n){if(i+5>r.length){var h=new Ne(i+8+(a-n<<1));h.set(r),r=h}var d=e.charCodeAt(n);d<128||s?c(d):d<2048?(c(192|d>>6),c(128|d&63)):d>55295&&d<57344?(d=65536+(d&1047552)|e.charCodeAt(++n)&1023,c(240|d>>18),c(128|d>>12&63),c(128|d>>6&63),c(128|d&63)):(c(224|d>>12),c(128|d>>6&63),c(128|d&63))}return tr(r,0,i)}var Us=function(e){var s=0;if(e)for(var n in e){var a=e[n].length;a>65535&&ms(9),s+=a+4}return s},Xn=function(e,s,n,a,r,i,c,h){var d=a.length,o=n.extra,u=h&&h.length,p=Us(o);je(e,s,c!=null?33639248:67324752),s+=4,c!=null&&(e[s++]=20,e[s++]=n.os),e[s]=20,s+=2,e[s++]=n.flag<<1|(i<0&&8),e[s++]=r&&8,e[s++]=n.compression&255,e[s++]=n.compression>>8;var y=new Date(n.mtime==null?Date.now():n.mtime),f=y.getFullYear()-1980;if((f<0||f>119)&&ms(10),je(e,s,f<<25|y.getMonth()+1<<21|y.getDate()<<16|y.getHours()<<11|y.getMinutes()<<5|y.getSeconds()>>1),s+=4,i!=-1&&(je(e,s,n.crc),je(e,s+4,i<0?-i-2:i),je(e,s+8,n.size)),je(e,s+12,d),je(e,s+14,p),s+=16,c!=null&&(je(e,s,u),je(e,s+6,n.attrs),je(e,s+10,c),s+=14),e.set(a,s),s+=d,p)for(var g in o){var k=o[g],b=k.length;je(e,s,+g),je(e,s+2,b),e.set(k,s+4),s+=4+b}return u&&(e.set(h,s),s+=u),s},Rd=function(e,s,n,a,r){je(e,s,101010256),je(e,s+8,n),je(e,s+10,n),je(e,s+12,a),je(e,s+16,r)};function Ed(e,s){s||(s={});var n={},a=[];rr(e,"",n,s);var r=0,i=0;for(var c in n){var h=n[c],d=h[0],o=h[1],u=o.level==0?0:8,p=Kn(c),y=p.length,f=o.comment,g=f&&Kn(f),k=g&&g.length,b=Us(o.extra);y>65535&&ms(11);var U=u?Sd(d,o):d,N=U.length,w=Nd();w.p(d),a.push(ar(o,{size:d.length,crc:w.d(),c:U,f:p,m:g,u:y!=c.length||g&&f.length!=k,o:r,compression:u})),r+=30+y+b+N,i+=76+2*(y+b)+(k||0)+N}for(var C=new Ne(i+22),j=r,A=i-r,T=0;T<a.length;++T){var p=a[T];Xn(C,p.o,p,p.f,p.u,p.c.length);var $=30+p.f.length+Us(p.extra);C.set(p.c,p.o+$),Xn(C,r,p,p.f,p.u,p.c.length,p.o,p.m),r+=16+$+(p.m?p.m.length:0)}return Rd(C,r,a.length,A,j),C}function Ad(e,s="image/png"){const n=atob(e),a=new Uint8Array(n.length);for(let r=0;r<n.length;r++)a[r]=n.charCodeAt(r);return new Blob([a],{type:s})}async function Dd(e){return typeof e.arrayBuffer=="function"?new Uint8Array(await e.arrayBuffer()):new Promise((s,n)=>{const a=new FileReader;a.onload=()=>s(new Uint8Array(a.result)),a.onerror=()=>n(a.error),a.readAsArrayBuffer(e)})}function Md(e){return new Promise((s,n)=>{const a=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(a),s(r)},r.onerror=()=>{URL.revokeObjectURL(a),n(new Error("the picture could not be read"))},r.src=a})}function zd(e,s){return Promise.race([e,new Promise((n,a)=>setTimeout(()=>a(new Error("timed out")),s))])}async function en(e){if(typeof createImageBitmap=="function"){const n=await createImageBitmap(e);return{source:n,width:n.width,height:n.height}}const s=await zd(Md(e),3e3);return{source:s,width:s.naturalWidth,height:s.naturalHeight}}async function Ld(e){try{const{width:s,height:n}=await en(e);return{width:s,height:n}}catch{return{width:0,height:0}}}function ir(e,s,n){return new Promise((a,r)=>{e.toBlob(i=>i?a(i):r(new Error("the picture could not be made")),s,n)})}const Id=320;async function _d(e,s=Id){try{const{source:n,width:a,height:r}=await en(e);if(!a||!r)return e;const i=Math.min(1,s/Math.max(a,r)),c=document.createElement("canvas");c.width=Math.max(1,Math.round(a*i)),c.height=Math.max(1,Math.round(r*i));const h=c.getContext("2d");return h?(h.drawImage(n,0,0,c.width,c.height),await ir(c,"image/jpeg",.8)):e}catch{return e}}async function Od(e,s){const{source:n,width:a,height:r}=await en(e);if(!a||!r)throw new Error("the picture could not be read");const i=document.createElement("canvas");i.width=a,i.height=r;const c=i.getContext("2d");if(!c)throw new Error("this browser cannot draw here");return c.drawImage(n,0,0,a,r),s.forEach(h=>Jr(c,a,r,h)),ir(i,"image/png")}function Fd(e){const s=new Map;return e.map(n=>{const a=(s.get(n)??0)+1;if(s.set(n,a),a===1)return n;const r=n.lastIndexOf(".");return r>0?`${n.slice(0,r)}-${a}${n.slice(r)}`:`${n}-${a}`})}async function Pd(e,s){const n=Fd(s.map(c=>Za(e,c))),a={},r=await Promise.all(s.map(c=>Dd(c.png)));n.forEach((c,h)=>{a[c]=r[h]});const i=Ed(a,{level:0});return new Blob([i],{type:"application/zip"})}function Yn(e,s){const n=URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=s,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function or({capture:e,actualSize:s,onToggleSize:n,annotate:a}){const r=e.width&&e.height?e.width/e.height:void 0;return t.jsx("div",{className:`shots-picture${s&&!a?" is-actual":""}`,children:t.jsxs("div",{className:"shots-picture-frame",children:[t.jsx("img",{src:e.url,alt:jt(e),draggable:!1,onClick:a?void 0:n,className:n&&!a?"is-zoomable":void 0}),a&&t.jsx(Qr,{enabled:!0,shape:a.shape,color:a.color,committed:a.marks,onCommittedChange:a.onMarksChange,onCommit:()=>{},mediaAspect:r})]})})}function Ud({a:e,b:s}){return t.jsx("div",{className:"shots-compare",children:[e,s].map((n,a)=>t.jsxs("figure",{className:"shots-compare-side",children:[t.jsx("span",{className:"shots-compare-tag","aria-hidden":"true",children:a===0?"A":"B"}),n?t.jsxs(t.Fragment,{children:[t.jsx(or,{capture:n}),t.jsx("figcaption",{className:"shots-details",children:Xa(n)})]}):t.jsx("p",{className:"shots-compare-empty",children:"Pick a screenshot in the list to compare with."})]},a))})}function Bd({captures:e,activeId:s,compare:n,taking:a,onTake:r,onPick:i,onDelete:c}){const h=l.useRef(null),d=Date.now(),o=y=>{var g,k;const f=(g=h.current)==null?void 0:g.querySelector(`[data-capture="${y}"]`);f==null||f.focus(),(k=f==null?void 0:f.scrollIntoView)==null||k.call(f,{block:"nearest"})},u=y=>{if(!e.length)return;const f=Math.max(0,e.findIndex(k=>k.id===s));let g=null;if(y.key==="ArrowDown"||y.key==="ArrowRight")g=Math.min(e.length-1,f+1);else if(y.key==="ArrowUp"||y.key==="ArrowLeft")g=Math.max(0,f-1);else if(y.key==="Home")g=0;else if(y.key==="End")g=e.length-1;else if((y.key==="Delete"||y.key==="Backspace")&&s&&!n){y.preventDefault(),c(s);return}g!==null&&(y.preventDefault(),i(e[g].id),o(e[g].id))},p=y=>n?n.a===y?"A":n.b===y?"B":null:null;return t.jsxs("div",{className:"shots-rail",children:[t.jsxs(F,{className:"shots-take",size:"md",onClick:r,disabled:a,children:[a?t.jsx(gt,{className:"animate-spin",size:14,"aria-hidden":"true"}):t.jsx(Lt,{size:14,"aria-hidden":"true"}),a?"Taking screenshot…":"Take screenshot"]}),t.jsxs("div",{ref:h,className:"shots-list",role:"listbox","aria-label":n?"Screenshots, pick the right side":"Screenshots",onKeyDown:u,children:[a&&t.jsx("div",{className:"shots-thumb is-pending","aria-hidden":"true"}),e.map(y=>{const f=y.id===s,g=p(y.id);return t.jsxs("div",{"data-capture":y.id,role:"option","aria-selected":f,tabIndex:f||!s&&y===e[0]?0:-1,className:`shots-thumb${f?" is-active":""}${g?" is-compared":""}`,"aria-label":`${jt(y)}${y.markedFrom!==void 0?`, marked copy of ${y.markedFrom}`:""}, ${_s(y.takenAt,d)}${g?`, side ${g}`:""}`,onClick:()=>i(y.id),children:[t.jsx("img",{src:y.thumbUrl,alt:"",draggable:!1}),g&&t.jsx("span",{className:"shots-thumb-side",children:g}),t.jsxs("span",{className:"shots-thumb-label",children:[t.jsxs("span",{className:"shots-thumb-n",children:[y.markedFrom!==void 0&&t.jsx(ma,{size:10,"aria-hidden":"true"}),y.n]}),t.jsx("span",{className:"shots-thumb-time",children:_s(y.takenAt,d).replace("Today ","")})]})]},y.id)})]})]})}var Gt,Hd=new Uint8Array(16);function Vd(){if(!Gt&&(Gt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Gt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Gt(Hd)}const Wd=/^(?:[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 qd(e){return typeof e=="string"&&Wd.test(e)}var ge=[];for(var $s=0;$s<256;++$s)ge.push(($s+256).toString(16).substr(1));function Kd(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(ge[e[s+0]]+ge[e[s+1]]+ge[e[s+2]]+ge[e[s+3]]+"-"+ge[e[s+4]]+ge[e[s+5]]+"-"+ge[e[s+6]]+ge[e[s+7]]+"-"+ge[e[s+8]]+ge[e[s+9]]+"-"+ge[e[s+10]]+ge[e[s+11]]+ge[e[s+12]]+ge[e[s+13]]+ge[e[s+14]]+ge[e[s+15]]).toLowerCase();if(!qd(n))throw TypeError("Stringified UUID is invalid");return n}function Xd(e,s,n){e=e||{};var a=e.random||(e.rng||Vd)();return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Kd(a)}const xt=50,Gn=6e3;function Ts(e){const s=URL.createObjectURL(e.png),n=e.thumb===e.png?s:URL.createObjectURL(e.thumb);return{...e,url:s,thumbUrl:n}}function Zt(e){URL.revokeObjectURL(e.url),e.thumbUrl!==e.url&&URL.revokeObjectURL(e.thumbUrl)}function Zn({url:e,thumbUrl:s,...n}){return n}function Yd(e,s){return s.takenAt-e.takenAt||s.n-e.n}function Gd(e,s=pr){const{toast:n}=Ue(),[a,r]=l.useState([]),[i,c]=l.useState(null),[h,d]=l.useState(!1),[o,u]=l.useState(!0),[p,y]=l.useState(!1),f=l.useRef(null),g=l.useRef([]);g.current=a;const k=l.useRef(0),b=l.useRef(!0);l.useEffect(()=>{b.current=!0;let m=!1;return d(!1),r([]),c(null),k.current=0,(async()=>{var L;const S=await s();let I=[];try{I=await S.list(e)}catch{I=[]}if(m)return;f.current=S;const B=I.slice(0,xt).map(Ts);k.current=B.reduce((Y,te)=>Math.max(Y,te.n),0),u(S.persistent),r(B),c(((L=B[0])==null?void 0:L.id)??null),d(!0)})(),()=>{m=!0}},[e]),l.useEffect(()=>()=>{b.current=!1,g.current.forEach(Zt)},[]);const U=l.useCallback(async m=>{const S=f.current;if(S)try{await S.put(m)}catch{n(`Couldn’t keep ${jt(m)} in this browser. It’s here until you leave the page.`,"error")}},[n]),N=l.useCallback((m,S)=>{var Y,te;const I=[...m,...g.current].sort(Yd),B=I.slice(xt),L=I.slice(0,xt);B.forEach(Zt),B.length&&((Y=f.current)==null||Y.delete(B.map(Z=>Z.id)).catch(()=>{})),g.current=L,r(L),c(L.some(Z=>Z.id===S)?S:((te=L[0])==null?void 0:te.id)??null)},[]),w=l.useCallback(async(m,S={})=>{const[I,B]=await Promise.all([Ld(m),_d(m)]);if(!b.current)return;k.current+=1;const L={id:Xd(),udid:e,n:k.current,takenAt:Date.now(),width:I.width,height:I.height,bytes:m.size,png:m,thumb:B,...S};N([Ts(L)],L.id),await U(L)},[e,N,U]),C=l.useCallback(async()=>{y(!0);try{let m;try{m=await X.getScreenshot(e)}catch(S){n(Le("take a screenshot",S),"error");return}if(!(m!=null&&m.screenshot)){const S=(m==null?void 0:m.error)||(m==null?void 0:m.message);n(S?Le("take a screenshot",{message:S}):"Couldn’t take a screenshot. The phone sent no picture.","error");return}await w(Ad(m.screenshot))}finally{b.current&&y(!1)}},[e,n,w]),j=l.useCallback((m,S)=>w(S,{markedFrom:m.n}),[w]),A=l.useCallback(async m=>{if(!b.current||!m.length)return;const S=m.filter(B=>!g.current.some(L=>L.id===B.id));N(S.map(Ts),m[0].id);const I=f.current;await Promise.all(S.map(B=>I==null?void 0:I.put(B).catch(()=>{})))},[N]),T=l.useCallback(async m=>{var te;const S=g.current,I=S.findIndex(Z=>Z.id===m);if(I<0)return;const B=S[I],L=S.filter(Z=>Z.id!==m);g.current=L,r(L),c(Z=>{var H;return Z===m?((H=L[I]??L[I-1])==null?void 0:H.id)??null:Z}),Zt(B);const Y=Zn(B);n(`Deleted ${jt(B)}`,"info",Gn,{label:"Undo",onClick:()=>void A([Y])}),await((te=f.current)==null?void 0:te.delete([m]).catch(()=>{}))},[n,A]),$=l.useCallback(async()=>{var I;const m=g.current;if(!m.length)return;g.current=[],r([]),c(null),m.forEach(Zt);const S=m.map(Zn);n(`Cleared ${m.length} screenshot${m.length===1?"":"s"}`,"info",Gn,{label:"Undo",onClick:()=>void A(S)}),await((I=f.current)==null?void 0:I.clear(e).catch(()=>{}))},[e,n,A]);return{captures:a,selectedId:i,select:c,ready:h,persistent:o,taking:p,take:C,addMarkedCopy:j,remove:T,clearAll:$}}function Zd({udid:e,deviceName:s,openStore:n}){const{toast:a}=Ue(),r=Gd(e,n),{captures:i,selectedId:c,select:h}=r,d=i.find(M=>M.id===c)??null,[o,u]=l.useState("view"),[p,y]=l.useState(null),[f,g]=l.useState(!1),[k,b]=l.useState("RECT"),[U,N]=l.useState(Ar.color),[w,C]=l.useState([]),[j,A]=l.useState(!1),[T,$]=l.useState(!1),m=l.useCallback(()=>{u("view"),C([]),y(null)},[]);l.useEffect(()=>{o!=="view"&&(d?o==="compare"&&p&&!i.some(M=>M.id===p)&&y(null):m())},[o,d,p,i,m]);const S=l.useRef(null),I=l.useRef(o);I.current=o,l.useEffect(()=>{const M=S.current;if(!M)return;const W=ne=>{ne.key!=="Escape"||ne.defaultPrevented||I.current==="view"||(ne.preventDefault(),m())};return M.addEventListener("keydown",W),()=>M.removeEventListener("keydown",W)},[m]);const B=M=>{if(o==="compare"){M!==c&&y(M);return}o==="annotate"&&M!==c&&m(),h(M)},L=()=>{if(!d)return;const M=i.indexOf(d),W=i[M+1]??i[M-1]??null;C([]),y((W==null?void 0:W.id)??null),u("compare")},Y=async()=>{d&&(await pd(d.png)?a(`Copied ${jt(d)}`,"success"):a("Your browser can’t copy pictures on this address. Use Download instead.","error"))},te=()=>{d&&Yn(d.png,Za(s,d))},Z=async()=>{$(!0);try{Yn(await Pd(s,i),fd(s))}catch(M){a(Le("make the zip",M),"error")}finally{$(!1)}},H=async()=>{if(!(!d||!w.length)){A(!0);try{const M=await Od(d.png,w);await r.addMarkedCopy(d,M),a(`Saved a marked copy of ${jt(d)}`,"success"),m()}catch(M){a(Le("save the marked copy",M),"error")}finally{A(!1)}}},v=i.length,z=r.persistent?v>=xt?`${v} of ${xt} kept · the oldest goes when you take another`:`${v} of ${xt} kept`:"Kept until you leave this page",V=i.find(M=>M.id===p)??null;return t.jsxs("div",{ref:S,className:"shots-root",children:[t.jsxs("header",{className:"shots-head",children:[t.jsxs("h4",{className:"shots-title",children:[t.jsx(Lt,{size:14,"aria-hidden":"true"}),"Screenshots"]}),r.ready&&t.jsx("span",{className:"shots-kept",title:r.persistent?"This browser keeps the newest 50 screenshots of each phone.":"This browser isn’t saving screenshots here, for example in a private window.",children:z}),t.jsx("span",{className:"shots-actions-gap"}),o==="compare"?t.jsx(F,{variant:"secondary",size:"sm",onClick:m,children:"Done"}):t.jsxs(F,{variant:"secondary",size:"sm",onClick:L,disabled:v<2||o==="annotate",children:[t.jsx(bi,{size:13,"aria-hidden":"true"}),"Compare"]}),t.jsxs(F,{variant:"secondary",size:"sm",onClick:Z,disabled:!v||T,children:[T?t.jsx(gt,{className:"animate-spin",size:13,"aria-hidden":"true"}):t.jsx(Si,{size:13,"aria-hidden":"true"}),"Download all"]}),t.jsx(F,{variant:"secondary",size:"sm",onClick:()=>{m(),r.clearAll()},disabled:!v,children:"Clear all"})]}),r.ready&&!v&&!r.taking?t.jsxs("div",{className:"shots-empty",children:[t.jsx(Lt,{size:22,"aria-hidden":"true"}),t.jsx("p",{className:"shots-empty-title",children:"No screenshots yet"}),t.jsxs("p",{className:"shots-empty-hint",children:["Take one to keep it here. This browser keeps the newest ",xt," for this phone."]}),t.jsxs(F,{size:"md",onClick:()=>void r.take(),children:[t.jsx(Lt,{size:14,"aria-hidden":"true"}),"Take screenshot"]})]}):r.ready?t.jsxs("div",{className:"shots-body",children:[t.jsx(Bd,{captures:i,activeId:o==="compare"?p??c:c,compare:o==="compare"&&c?{a:c,b:p}:void 0,taking:r.taking,onTake:()=>void r.take(),onPick:B,onDelete:M=>void r.remove(M)}),t.jsx("section",{className:"shots-preview","aria-label":"Preview",children:d&&o==="compare"?t.jsx(Ud,{a:d,b:V}):d?t.jsxs(t.Fragment,{children:[t.jsx(or,{capture:d,actualSize:f,onToggleSize:()=>g(M=>!M),annotate:o==="annotate"?{shape:k,color:U,marks:w,onMarksChange:C}:void 0}),t.jsxs("footer",{className:"shots-footer",children:[t.jsx("p",{className:"shots-details",children:Xa(d)}),o==="annotate"?t.jsx(dd,{shape:k,color:U,marks:w.length,saving:j,onShape:b,onColor:N,onUndo:()=>C(M=>M.slice(0,-1)),onClear:()=>C([]),onCancel:m,onSave:()=>void H()}):t.jsxs("div",{className:"shots-actions",children:[t.jsxs(F,{variant:"secondary",size:"sm",onClick:()=>void Y(),children:[t.jsx(Pe,{size:13,"aria-hidden":"true"}),"Copy"]}),t.jsxs(F,{variant:"secondary",size:"sm",onClick:()=>{g(!1),u("annotate")},children:[t.jsx(ma,{size:13,"aria-hidden":"true"}),"Annotate"]}),t.jsxs(F,{variant:"secondary",size:"sm",onClick:te,children:[t.jsx(da,{size:13,"aria-hidden":"true"}),"Download"]}),t.jsxs(F,{variant:"ghost",size:"sm","aria-pressed":f,onClick:()=>g(M=>!M),children:[f?t.jsx(Vi,{size:13,"aria-hidden":"true"}):t.jsx(Pi,{size:13,"aria-hidden":"true"}),"Actual size"]}),t.jsx("span",{className:"shots-actions-gap"}),t.jsxs(F,{variant:"ghost",size:"sm",className:"shots-delete",onClick:()=>void r.remove(d.id),children:[t.jsx(ei,{size:13,"aria-hidden":"true"}),"Delete"]})]})]})]}):null})]}):null]})}const Rs=e=>!!e.session_id&&!String(e.session_id).startsWith("manual_"),Jd=e=>e.realDevice===!1&&(e.platform==="ios"||e.platform==="tvos");function Qd({device:e,onClose:s,titleId:n}){const a=Ia(s),{toast:r}=Ue(),i=K=>re=>{gr(re)||r(Le(K,re),"error")},c=Bt(),{tab:h}=ea(),d=ds(),o=l.useRef(null),[u,p]=l.useState({width:0,height:0}),[y,f]=l.useState("inspect"),[g,k]=l.useState(null),[b,U]=l.useState(h||"actions"),N=b==="omni"&&y==="inspect",[w,C]=l.useState(!0),[j,A]=l.useState(!1),[T,$]=l.useState(0),[m,S]=l.useState(e),[I,B]=l.useState(0),L=l.useCallback(()=>B(Date.now()),[]),Y=ot(m);l.useEffect(()=>{vr(m.udid,Y),document.title=yr(d.pathname)},[m.udid,Y,d.pathname]);const[te,Z]=l.useState(!1),[H,v]=l.useState(!1),[z,V]=l.useState(null),[M,W]=l.useState(!1),[ne,q]=l.useState(null),se=l.useRef(!1),ie=10,[be,E]=l.useState(!1),[oe,Q]=l.useState(!1),ae=tl(m==null?void 0:m.udid,!H),De=()=>{navigator.clipboard.writeText(m.udid).catch(()=>{}),E(!0),setTimeout(()=>E(!1),1500)},ue=l.useRef(""),fe=l.useRef(null),[Be,Qe]=l.useState(!1);l.useEffect(()=>{b&&(!h||h!==b)&&c(`/devices/${e.udid}/control/${b}${d.search}`,{replace:!0})},[b,h,e.udid,c,d.search]);const[wt,pe]=l.useState(0);sl(()=>{X.leaveStream(m.udid).catch(()=>{})},()=>pe(K=>K+1));const He=l.useCallback(async()=>{try{await X.startStream(e.udid,{player:"mjpeg"})}catch(K){console.error("Switching the stream to MJPEG failed:",K)}},[e.udid]),_e=l.useCallback(async K=>{se.current||(se.current=!0,console.warn("H.264 stream failed; falling back to MJPEG"),W(!1),q(null),Z(!1),K!=null&&K.streamEnded||await He(),W(!0))},[He]);l.useEffect(()=>{let K=!1;return se.current=!1,(async()=>{try{A(!0),W(!1),q(null),V(null);const ye=Rs(m),he=await X.startStream(m.udid,ye?{player:"mjpeg"}:void 0);if((he==null?void 0:he.error)==="simulator_needs_test"){K||(V(he.message||"The live preview is not available."),v(!0));return}if(!ye&&(he!=null&&he.h264Path)&&zr(m.platform,he.type,xr())==="h264"){const we=await Lr(m.udid,he.h264Path).catch(()=>null);K||(we?q(we):await He())}const me=(await X.getDevices()).find(we=>we.udid===m.udid);me&&S(me)}catch(ye){console.error("Auto-start stream failed:",ye)}finally{K||(A(!1),W(!0))}})(),()=>{K=!0,X.leaveStream(m.udid).catch(()=>{})}},[e.udid,wt]);const Se=Jd(e)&&Rs(e)?e.session_id:null,et=l.useRef(Se);l.useEffect(()=>{if(et.current===Se)return;if(et.current=Se,S(e),v(!1),Z(!1),$(0),q(null),Se){V(null),W(!0),lt(Date.now());return}let K=!1;return fetch(`/xenon/api/control/${encodeURIComponent(e.udid)}/stream/status`).then(re=>re.ok?re.json():null).catch(()=>null).then(re=>{K||(V((re==null?void 0:re.lastError)||"The live preview is not available."),v(!0))}),()=>{K=!0}},[Se]);const kt=parseInt(m.screenWidth||"1080",10),Ve=parseInt(m.screenHeight||"1920",10),$e=Math.min(kt,Ve),Te=Math.max(kt,Ve),ct=$e/Te,We=l.useCallback(()=>{const K=!w,re=K?window.innerHeight*.55:window.innerHeight*.7,ye=620,Ee=window.innerWidth>900;let me;K?me=Ee?Math.min(window.innerWidth*.8,window.innerWidth-ye):window.innerWidth*.8:me=window.innerWidth*.45;const we=w?ct:1/ct;let xe,ve;w?(xe=re,ve=xe*we,ve>me&&(ve=me,xe=ve/we)):(ve=me,xe=ve/we,xe>re&&(xe=re,ve=xe*we)),p({width:ve,height:xe})},[ct,w]);l.useEffect(()=>(We(),window.addEventListener("resize",We),()=>window.removeEventListener("resize",We)),[We]),l.useEffect(()=>{const K=async()=>{if(ue.current.length>0){const ye=ue.current;ue.current="";try{await X.typeText(m.udid,ye)}catch(he){console.error("Keyboard buffering flush failed:",he)}finally{L()}}},re=ye=>{const he=document.activeElement;if(he&&(he.tagName==="INPUT"||he.tagName==="TEXTAREA"||he.isContentEditable)||!Be&&b!=="terminal")return;const me=ye.key;me==="Enter"?(fe.current&&clearTimeout(fe.current),K(),X.pressKey(m.udid,m.platform==="android"?66:"enter").finally(L)):me==="Backspace"?(fe.current&&clearTimeout(fe.current),K(),X.pressKey(m.udid,m.platform==="android"?67:"backspace").finally(L)):me.length===1&&(ue.current+=me,fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{K()},50))};return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re),fe.current&&clearTimeout(fe.current)}},[m.udid,m.platform,Be,b,L]);const[tt,lt]=l.useState(Date.now()),Oe=()=>{const K=T>0?`r=${T}&`:"";return Rs(m)?`/xenon/api/session/${m.session_id}/live_video?${K}t=${tt}`:`/xenon/api/control/${m.udid}/stream?${K}t=${tt}`};l.useEffect(()=>{T>0&<(Date.now())},[T]),l.useEffect(()=>{if(te||H)return;const K=setTimeout(()=>{ne?_e():v(!0)},3e4);return()=>clearTimeout(K)},[te,H,T,ne,_e]);const qe=l.useRef(null),Me=K=>{const re=K.currentTarget.getBoundingClientRect();return{x:K.clientX-re.left,y:K.clientY-re.top}},dt=K=>{const re=Me(K);qe.current={x:re.x,y:re.y,time:Date.now()}},_=async K=>{var Ct;if(!qe.current)return;const re=qe.current,ye=Me(K),he=Date.now()-re.time,Ee=(Ct=o.current)==null?void 0:Ct.getBoundingClientRect(),me=(Ee==null?void 0:Ee.width)||u.width,we=(Ee==null?void 0:Ee.height)||u.height;let xe,ve,ht,st;w?(xe=re.x/me*$e,ve=re.y/we*Te,ht=ye.x/me*$e,st=ye.y/we*Te):(xe=re.x/me*Te,ve=re.y/we*$e,ht=ye.x/me*Te,st=ye.y/we*$e);const Ht=Math.abs(ht-xe),At=Math.abs(st-ve);try{he<500&&Ht<10&&At<10?await X.tap(m.udid,Math.round(xe),Math.round(ve)):he>=500&&Ht<10&&At<10?await X.touchAndHold(m.udid,Math.round(xe),Math.round(ve),he):await X.swipe(m.udid,Math.round(xe),Math.round(ve),Math.round(ht),Math.round(st))}catch(Vt){console.error("Action failed:",Vt)}finally{L()}qe.current=null},ee=()=>X.pressKey(m.udid,m.platform==="android"?Dt.HOME:gs.HOME).catch(i("press Home")).finally(L),ce=()=>X.pressKey(m.udid,Dt.BACK).catch(i("press Back")).finally(L),Re=()=>X.pressKey(m.udid,Dt.APP_SWITCH).catch(i("open the app switcher")).finally(L),ut=()=>X.pressKey(m.udid,m.platform==="android"?Dt.VOLUME_UP:gs.VOLUME_UP).catch(i("press Volume up")).finally(L),fs=()=>X.pressKey(m.udid,m.platform==="android"?Dt.VOLUME_DOWN:gs.VOLUME_DOWN).catch(i("press Volume down")).finally(L),Nt=()=>X.lock(m.udid).catch(i("lock the device")).finally(L),Et=async()=>{Q(!0);try{await X.unlock(m.udid).catch(i("unlock the device"))}finally{L(),setTimeout(()=>Q(!1),2500)}};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:a,children:[t.jsx(yn,{size:18})," DEVICES"]}),t.jsxs("div",{className:"device-info-mini",children:[t.jsx("span",{className:`device-pill platform-pill ${m.platform}`,children:m.platform==="ios"?"Apple":"Android"}),t.jsxs("span",{className:"device-pill version-pill",children:["v",m.sdk]}),m.reservedUntil&&Date.now()<m.reservedUntil&&t.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${m.reservedBy}${m.reservationReason?`: ${m.reservationReason}`:""}`,children:["Reserved by ",m.reservedBy||"someone"]}),t.jsx("h2",{id:n,className:"device-name-text",children:Y}),t.jsxs("span",{className:"udid-chip",title:m.udid,children:[t.jsx("span",{className:"udid-chip__value",children:m.udid}),t.jsx("button",{type:"button",className:"udid-chip__copy",onClick:De,"aria-label":"Copy UDID",title:be?"Copied!":"Copy UDID",children:be?t.jsx(Ot,{size:12}):t.jsx(Pe,{size:12})})]})]})]}),t.jsxs("div",{className:`control-view-main ${w?"":"is-landscape"} ${b==="omni"?"omni-mode":""}`,children:[t.jsxs("div",{className:"device-preview-column",children:[t.jsx("div",{className:"device-screen-wrapper",children:t.jsxs("div",{ref:K=>{o.current=K,k(K)},className:`device-stream-canvas ${w?"":"landscape"} ${Be?"focused":""} ${N?"is-inspecting":""}`,style:{width:u.width,height:u.height,background:"var(--black)"},tabIndex:0,onFocus:()=>Qe(!0),onBlur:()=>Qe(!1),onMouseDown:N?void 0:dt,onMouseUp:N?void 0:_,children:[H?t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(Ge,{size:40,color:"var(--red, #f87171)"}),t.jsx("p",{style:{marginTop:16},children:z??"Stream unavailable"}),t.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{v(!1),$(0),z&&pe(K=>K+1)},children:"Retry"})]}):(j||!te)&&t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(It,{size:40,className:"animate-spin",color:"var(--color-accent)"}),t.jsx("p",{style:{marginTop:16},children:j?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!H&&ne&&t.jsx(Dr,{wsUrl:ne,className:"device-stream-image",onReady:()=>Z(!0),onFatal:_e}),!H&&!ne&&M&&t.jsx(ta,{src:Oe(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>Z(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),Z(!1),T>=ie){v(!0);return}setTimeout(()=>$(K=>K+1),2e3)}}),ae==="off"&&!H&&t.jsxs("div",{className:"device-screen-off",role:"status",children:[t.jsx(qi,{size:32}),t.jsx("p",{children:"Display is off"}),t.jsx("span",{children:"The stream is fine — the device is asleep."}),t.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:Et,disabled:oe,children:oe?"Waking…":"Wake device"})]})]})}),t.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":w?"vertical":"horizontal",children:[t.jsx("button",{className:`footer-action-btn ${w?"active":""}`,onClick:()=>C(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":w,children:t.jsx(no,{size:18})}),t.jsx("button",{className:`footer-action-btn ${w?"":"active"}`,onClick:()=>C(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!w,children:t.jsx(to,{size:18})}),t.jsx("div",{className:"footer-divider"}),t.jsx("button",{className:"footer-action-btn",onClick:ee,title:"Home","aria-label":"Home",children:t.jsx(Mr,{size:18})}),m.platform==="android"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"footer-action-btn",onClick:ce,title:"Back","aria-label":"Back",children:t.jsx(yn,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:Re,title:"App switcher","aria-label":"App switcher",children:t.jsx(sa,{size:18})})]}),t.jsx("div",{className:"footer-divider"}),t.jsx("button",{className:"footer-action-btn",onClick:ut,title:"Volume up","aria-label":"Volume up",children:t.jsx(ko,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:fs,title:"Volume down","aria-label":"Volume down",children:t.jsx(bo,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:Nt,title:"Lock device","aria-label":"Lock device",children:t.jsx(ti,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:Et,title:"Unlock device","aria-label":"Unlock device",children:t.jsx(Ii,{size:18})})]})]}),t.jsxs("div",{className:"device-interactions-column",children:[t.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[t.jsxs("button",{className:`tab-btn ${b==="actions"?"active":""}`,onClick:()=>U("actions"),role:"tab","aria-selected":b==="actions",children:[t.jsx(oa,{size:13}),t.jsx("span",{children:"Actions"})]}),t.jsxs("button",{className:`tab-btn ${b==="screenshot"?"active":""}`,onClick:()=>U("screenshot"),role:"tab","aria-selected":b==="screenshot",children:[t.jsx(Lt,{size:13}),t.jsx("span",{children:"Screenshot"})]}),t.jsxs("button",{className:`tab-btn ${b==="logs"?"active":""}`,onClick:()=>U("logs"),role:"tab","aria-selected":b==="logs",children:[t.jsx(fa,{size:13}),t.jsx("span",{children:"Logs"})]}),t.jsxs("button",{className:`tab-btn ${b==="terminal"?"active":""}`,onClick:()=>U("terminal"),role:"tab","aria-selected":b==="terminal",children:[t.jsx(Yr,{size:13}),t.jsx("span",{children:"Shell"})]}),t.jsxs("button",{className:`tab-btn ${b==="omni"?"active":""}`,onClick:()=>U("omni"),role:"tab","aria-selected":b==="omni",children:[t.jsx(Sr,{size:13}),t.jsx("span",{children:"Omni-Vision"})]})]}),t.jsx("div",{className:`interactions-scroll-area ${b==="terminal"?"terminal-mode":""} ${b==="screenshot"||b==="logs"?"screenshot-mode":""}`,children:t.jsxs("div",{className:"tab-content",children:[b==="omni"&&t.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:t.jsx(el,{sessionId:m.session_id?String(m.session_id):null,udid:m.udid,streamUrl:Oe(),embedded:!0,overlayTarget:g,onModeChange:f,deviceActionAt:I})}),b==="actions"&&t.jsx(cd,{udid:m.udid,platform:m.platform,deviceName:Y,screenWidth:$e,screenHeight:Te}),b==="screenshot"&&t.jsx("div",{className:"action-card screenshot-card",children:t.jsx(Zd,{udid:m.udid,deviceName:Y})}),b==="logs"&&t.jsx("div",{className:"action-card screenshot-card",children:t.jsx(Xl,{udid:m.udid,platform:m.platform})}),b==="terminal"&&t.jsx("div",{className:"action-card full-height",children:t.jsx(pc,{platform:(m.platform||"").toLowerCase(),prompt:`${(m.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${Y} (${m.udid}).
|
|
282
|
+
Internal Shell Environment.`,onCommand:async K=>{const re=await X.executeShell(m.udid,K);if(re.error)throw new Error(re.error);return re.output}})})]})})]})]}),m.session_id&&!String(m.session_id).startsWith("manual_")&&t.jsx($r,{sessionId:String(m.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const cr="xenon.devices.view";function lr(){try{return window.localStorage}catch{return null}}function eu(e,s){const n=e.get("view");return n==="table"||n==="cards"?n:s}function tu(e,s,n){s==="table"||s!==n?e.set("view",s):e.delete("view")}function Jn(e=lr()){try{return(e==null?void 0:e.getItem(cr))==="table"?"table":"cards"}catch{return"cards"}}function su(e,s=lr()){try{s==null||s.setItem(cr,e)}catch{}}class nu extends vt.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=vt.createRef(),this.containerRef=vt.createRef(),this.stickyGroupRef=vt.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,a=this.containerRef.current;!n||!a||(this.stickyObserver=new ResizeObserver(()=>{a.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var i,c;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const a=n.target;(i=a==null?void 0:a.closest)!=null&&i.call(a,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(c=this.searchRef.current)==null||c.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(Jo),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,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),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var s;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(s=this.stickyObserver)==null||s.disconnect()}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 X.getDevices(),n=this.getBusyDevicesCount(s),a=await X.getPendingSessionsCount(),r=await X.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:a,queueSummary:r,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}setFilters(s){this.props.onFiltersChange({...this.props.filters,...s})}getFiltered(){const s=Date.now();return this.state.devices.filter(n=>ts(n,this.props.filters,s))}render(){const s=this.getFiltered(),{udid:n}=this.props.params,a=n?this.state.devices.find(o=>o.udid===n):null,{filters:r}=this.props,i=sc(this.state.devices,r,Date.now()),c=[{value:"all",label:"Any platform",count:i.platform.all},{value:"android",label:"Android",count:i.platform.android},{value:"ios",label:"iOS",count:i.platform.ios}];(nc(this.state.devices)||r.platform==="tvos")&&c.push({value:"tvos",label:"tvOS",count:i.platform.tvos});const h=[{value:"all",label:"Any type",count:i.type.all},{value:"real",label:"Real devices",count:i.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:i.type.virtual}],d=`/devices${this.props.locationSearch}`;return t.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[t.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[t.jsx(wr,{icon:Es,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(xn,{size:"sm",label:"Status",value:r.status,onChange:o=>this.setFilters({status:o}),segments:[{value:"all",label:"All",count:i.status.all},{value:"ready",label:"Ready",tone:"ready",count:i.status.ready},{value:"busy",label:"Busy",tone:"busy",count:i.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:i.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:i.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:i.status.offline}]}),t.jsxs("div",{className:"de2-toolbar-row",children:[t.jsxs("div",{className:"de2-search-wrap",children:[t.jsx(Hs,{size:13,className:"de2-search-icon","aria-hidden":"true"}),t.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:r.q,onChange:o=>this.setFilters({q:o.target.value})}),t.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),t.jsx(bn,{name:"Platform",value:r.platform,anyValue:"all",options:c,onChange:o=>this.setFilters({platform:o})}),t.jsx(bn,{name:"Type",value:r.type,anyValue:"all",options:h,onChange:o=>this.setFilters({type:o})}),ac(r)&&t.jsx(F,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),t.jsxs("div",{className:"de2-result",children:[t.jsx(xn,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&t.jsx("span",{"aria-live":"polite",children:rc(s.length,this.state.devices.length)}),t.jsx(F,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:t.jsx(Jt,{size:13,"aria-hidden":"true"})})]})]})]})]}),s.length>0?this.props.view==="table"?t.jsx(fc,{devices:s,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):t.jsx(Zo,{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(Es,{size:32}):t.jsx(Jt,{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(F,{variant:"primary",onClick:()=>this.fetchDevices(),children:[t.jsx(Jt,{size:14}),"Manual sync"]})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"No devices match these filters"}),t.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),t.jsx(F,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"Loading devices…"}),t.jsx("p",{children:"Syncing the global device registry."})]})]}),a&&t.jsx(rl,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(d),children:t.jsx("div",{className:"device-control-modal",children:t.jsx(Qd,{device:a,titleId:"device-control-title",onClose:()=>this.props.navigate(d)})})})]})}}function Uu(){const e=ea(),s=Bt(),n=ds(),[a,r]=jr(),{on:i}=br(),c=Qo(a),h=eu(a,Jn()),d=dc(a),o=(u,p,y)=>{const f=ec(u);tu(f,p,Jn()),uc(f,y),r(f,{replace:!0})};return t.jsx(nu,{params:e,navigate:s,onSocketEvent:i,filters:c,onFiltersChange:u=>o(u,h,d),view:h,onViewChange:u=>{su(u),o(c,u,d)},sort:d,onSortChange:u=>o(c,h,u),locationSearch:n.search})}export{nu as DeviceExplorer,Uu as default};
|