@xenon-device-management/xenon 2.13.0 → 2.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +223 -488
  3. package/lib/package.json +1 -1
  4. package/lib/public/assets/{AnnotationOverlay-CzbFYtPI.js → AnnotationOverlay-BXruClDk.js} +1 -1
  5. package/lib/public/assets/{ApiKeyGate-CA5KFHHJ.js → ApiKeyGate-qTS4LPLC.js} +1 -1
  6. package/lib/public/assets/{BugReportButton-D-DSGg8C.js → BugReportButton-BoGhlI7F.js} +1 -1
  7. package/lib/public/assets/{DeviceMosaicView-paDEFU4B.js → DeviceMosaicView-8J0oYqMM.js} +1 -1
  8. package/lib/public/assets/{EmptyState-BE_5f8Vw.js → EmptyState-Cr17PdDv.js} +1 -1
  9. package/lib/public/assets/{FieldGroup-DqMf7Rf3.js → FieldGroup-Bvn08svv.js} +1 -1
  10. package/lib/public/assets/{FilterMenu-BQY75Su3.js → FilterMenu-DDSO8aDf.js} +1 -1
  11. package/lib/public/assets/{Menu-BiW3os9u.js → Menu-B-Qn2X3T.js} +1 -1
  12. package/lib/public/assets/{Modal-DfawTxih.js → Modal-Cg9V5JYU.js} +1 -1
  13. package/lib/public/assets/{RecordingPage-BvemyRiy.js → RecordingPage-BTUs9VTW.js} +1 -1
  14. package/lib/public/assets/{RecordingsPage-CXfw7wpd.js → RecordingsPage-DYcfxITK.js} +2 -2
  15. package/lib/public/assets/{SegmentedControl-B7m9kpom.js → SegmentedControl-Zy7suhT5.js} +1 -1
  16. package/lib/public/assets/{SettingCard-Cw6lDD0l.js → SettingCard-CWYmycoe.js} +1 -1
  17. package/lib/public/assets/{Table-DlEuFgv-.js → Table-io9fwa98.js} +1 -1
  18. package/lib/public/assets/{activity-CnLvNwae.js → activity-Bdf_uIWl.js} +1 -1
  19. package/lib/public/assets/ai-settings-Bce5SJob.js +21 -0
  20. package/lib/public/assets/{api-keys-DphSVzBr.js → api-keys-CPqtVpm3.js} +1 -1
  21. package/lib/public/assets/{apps-vUfu15lX.js → apps-BgZan0H9.js} +2 -2
  22. package/lib/public/assets/{arrow-left-CLQWAiCY.js → arrow-left-B27ckB31.js} +1 -1
  23. package/lib/public/assets/{arrow-right-K6A5e_Ee.js → arrow-right-DOF8ITCz.js} +1 -1
  24. package/lib/public/assets/{arrow-up-right-DUA_lq6f.js → arrow-up-right-eFG5KTFS.js} +1 -1
  25. package/lib/public/assets/{auth-shell-BYRHcZd6.js → auth-shell-DlC3_27j.js} +2 -2
  26. package/lib/public/assets/{builds-page-C0fTvIG8.js → builds-page-BuXpPfKo.js} +1 -1
  27. package/lib/public/assets/{button-BxnHCCsX.js → button-fIW8owMI.js} +1 -1
  28. package/lib/public/assets/{calendar-CqVsn28A.js → calendar-WNjmrF-a.js} +1 -1
  29. package/lib/public/assets/{check-R6V3bot0.js → check-BdTh1Sq7.js} +1 -1
  30. package/lib/public/assets/{chevron-right-BA2Fntu-.js → chevron-right-B4BKlsqk.js} +1 -1
  31. package/lib/public/assets/{circle-check-D4EzyGzs.js → circle-check-zJU80_EF.js} +1 -1
  32. package/lib/public/assets/{circle-x-Cf6AF2B2.js → circle-x-5Uwquo0h.js} +1 -1
  33. package/lib/public/assets/{clock-EZfet0sS.js → clock-BtUprDsZ.js} +1 -1
  34. package/lib/public/assets/{copy-Bc6P8v9V.js → copy-DGSbZI3u.js} +1 -1
  35. package/lib/public/assets/device-explorer-C-KnhMHI.js +279 -0
  36. package/lib/public/assets/{download-Bd8OGLzi.js → download-WG6l7BgD.js} +1 -1
  37. package/lib/public/assets/{forgot-password-CoE7Ugtx.js → forgot-password-DnudqFFo.js} +1 -1
  38. package/lib/public/assets/{index-BTYMAqNW.css → index-Bxoxt9sV.css} +1 -1
  39. package/lib/public/assets/{index-CHOr4JCs.js → index-DI1fGIyj.js} +43 -43
  40. package/lib/public/assets/{index-BiL0Enl_.js → index-HDQVe1gi.js} +1 -1
  41. package/lib/public/assets/{input-CJ8z3IO5.js → input-BjDRKCea.js} +1 -1
  42. package/lib/public/assets/{line-chart-CPK0ObjV.js → line-chart-C0zdgd0v.js} +1 -1
  43. package/lib/public/assets/{list-checks-mXGHUVbB.js → list-checks-BdW5CjM8.js} +1 -1
  44. package/lib/public/assets/{lock-BSXM1xvq.js → lock-Dy3L4I8E.js} +1 -1
  45. package/lib/public/assets/{login-Ct2iW066.js → login-BHbY9CLG.js} +1 -1
  46. package/lib/public/assets/maintenance-settings-zDVlOMVK.js +6 -0
  47. package/lib/public/assets/{monitor-D8WQK8md.js → monitor-8xjkeHHi.js} +1 -1
  48. package/lib/public/assets/{mouse-pointer-2-Cw2tWzDX.js → mouse-pointer-2-CXdKMXQ8.js} +1 -1
  49. package/lib/public/assets/{network-Ba_uFxWo.js → network-Cj8JOKON.js} +1 -1
  50. package/lib/public/assets/{overview-CxrZ7_6k.js → overview-CTg7F0im.js} +1 -1
  51. package/lib/public/assets/{page-header-Cm1XL49f.js → page-header--aTyJXq6.js} +1 -1
  52. package/lib/public/assets/{play-C0CuKLXj.js → play-B-FodgHV.js} +1 -1
  53. package/lib/public/assets/{plus-CIIvR_6Z.js → plus-CsIk10Cq.js} +1 -1
  54. package/lib/public/assets/{profile-page-BZ_e-Bgw.js → profile-page-DkFKkMfl.js} +1 -1
  55. package/lib/public/assets/{recording-group-store-BWeeNs2_.js → recording-group-store-WVM3hoXn.js} +1 -1
  56. package/lib/public/assets/{reset-password-lfNz8Rm1.js → reset-password-I2-zqLlI.js} +1 -1
  57. package/lib/public/assets/{runbook-page-Cnec3VSx.js → runbook-page-DJTVCJX7.js} +1 -1
  58. package/lib/public/assets/{select-CZuCnold.js → select-DvCSv25z.js} +1 -1
  59. package/lib/public/assets/{selector-detail-redirect-BG3pxFLw.js → selector-detail-redirect-BLVfMJs_.js} +1 -1
  60. package/lib/public/assets/{selector-health-page-DsyL58tb.js → selector-health-page-oqadRokn.js} +2 -2
  61. package/lib/public/assets/session-detail-page-CGn55Pvl.js +4 -0
  62. package/lib/public/assets/settings-MsVU2ukE.js +6 -0
  63. package/lib/public/assets/{stat-tile-DFhv8JoI.js → stat-tile-DV9Ix-4O.js} +1 -1
  64. package/lib/public/assets/{tablet-68J5f6zh.js → tablet-6b_SEN2X.js} +1 -1
  65. package/lib/public/assets/{teams-eHSyEpbD.js → teams-BjZyfuHh.js} +1 -1
  66. package/lib/public/assets/{trash-2-CcSsv4fS.js → trash-2-CTZpPSdd.js} +1 -1
  67. package/lib/public/assets/{upload-BYf26K71.js → upload-P3XzwQUb.js} +1 -1
  68. package/lib/public/assets/{use-builds-data-CHW-MhaP.js → use-builds-data-1cOCMf-z.js} +1 -1
  69. package/lib/public/assets/{use-password-reset-mode-DozShXkk.js → use-password-reset-mode-DgF9w088.js} +1 -1
  70. package/lib/public/assets/{users-CcSQRoK9.js → users-CiNTKUiz.js} +1 -1
  71. package/lib/public/assets/{users-BpYnpOl2.js → users-DMF9Mk5H.js} +1 -1
  72. package/lib/public/assets/{video-off-dFKgps73.js → video-off-CHp1KU_T.js} +1 -1
  73. package/lib/public/assets/webhook-settings-DiS8geIm.js +1 -0
  74. package/lib/public/assets/{zap-COC2tZaH.js → zap-DRz0tDq5.js} +1 -1
  75. package/lib/public/index.html +2 -2
  76. package/lib/schema.json +0 -25
  77. package/lib/src/app/routers/control.js +19 -4
  78. package/lib/src/app/routers/streamStartConflict.js +3 -0
  79. package/lib/src/data-service/device-service.js +40 -0
  80. package/lib/src/data-service/device-store.js +4 -1
  81. package/lib/src/data-service/prisma-store.js +2 -1
  82. package/lib/src/device-managers/ios/WDAClient.js +128 -16
  83. package/lib/src/device-utils.js +63 -13
  84. package/lib/src/middleware/deviceAccessGuard.js +63 -9
  85. package/lib/src/services/ServerManager.js +3 -0
  86. package/lib/src/services/SessionLifecycleService.js +16 -4
  87. package/lib/src/services/device-access/SessionOwnerResolver.js +26 -0
  88. package/lib/src/services/device-access/deviceAccessPolicy.js +38 -6
  89. package/lib/src/services/device-access/leaseHold.js +26 -0
  90. package/lib/src/services/device-access/ticketActorAccess.js +6 -0
  91. package/lib/src/services/lease/activeLeases.js +37 -0
  92. package/lib/src/services/recording/busy-precheck.js +24 -3
  93. package/lib/test/unit/device-access-lease.spec.js +270 -0
  94. package/lib/test/unit/lease/allocate-lease-branch.spec.js +22 -0
  95. package/lib/test/unit/lease/session-lease-proof.spec.js +59 -0
  96. package/lib/test/unit/lease-held-phone.spec.js +196 -0
  97. package/lib/test/unit/partial-config-file.spec.js +100 -0
  98. package/lib/test/unit/schema-required-args.spec.js +21 -16
  99. package/lib/test/unit/wda-client-session.spec.js +128 -0
  100. package/lib/test/unit/wda-clipboard-write.spec.js +135 -0
  101. package/lib/tsconfig.tsbuildinfo +1 -1
  102. package/package.json +1 -1
  103. package/schema.json +0 -25
  104. package/scripts/dev/readme-screenshots.js +231 -0
  105. package/scripts/generate-types-from-schema.js +6 -0
  106. package/scripts/lib/always-present-plugin-args.js +39 -0
  107. package/lib/public/assets/ai-settings-D7Te8o-a.js +0 -21
  108. package/lib/public/assets/device-explorer-BFXpRq6d.js +0 -279
  109. package/lib/public/assets/maintenance-settings-DaOs00P6.js +0 -6
  110. package/lib/public/assets/session-detail-page-ZZyGM413.js +0 -4
  111. package/lib/public/assets/settings-DGZ7B_AR.js +0 -6
  112. package/lib/public/assets/webhook-settings-DD1XjiOD.js +0 -1
@@ -1,279 +0,0 @@
1
- import{c as Q,j as s,r as u,C as pn,U as jr,X as G,t as Be,v as Ls,b as wr,u as $t,a as ts,T as kr,q as Ss,R as it,w as Sr,x as Cs,y as Fe,z as Os,I as ti,S as Ot,f as ot,A as Bt,B as Cr,i as si,D as Nr,E as Er,F as Tr,p as Ar}from"./index-CHOr4JCs.js";import{P as Rr}from"./page-header-Cm1XL49f.js";import{P as Wt,S as Mr,B as zr}from"./BugReportButton-D-DSGg8C.js";import{A as $r}from"./activity-CnLvNwae.js";import{h as Ir,M as ni,S as ii,C as _r,a as Nt,i as Dr,b as gn,H as Lr,A as wt,I as hs}from"./recording-group-store-BWeeNs2_.js";import{p as ss}from"./labels-C21SA4JG.js";import{B as P}from"./button-BxnHCCsX.js";import{S as ri}from"./select-CZuCnold.js";import{P as qt,M as Fs,a as be,b as ai}from"./Menu-BiW3os9u.js";import{M as ns}from"./Modal-DfawTxih.js";import{F as Vt}from"./FieldGroup-DqMf7Rf3.js";import{C as Or}from"./clock-EZfet0sS.js";import{P as Fr}from"./plus-CIIvR_6Z.js";import{C as $e}from"./copy-Bc6P8v9V.js";import{T as Pr}from"./tablet-68J5f6zh.js";import{S as Ur,a as vn}from"./SegmentedControl-B7m9kpom.js";import{T as Br,a as Wr,b as oi,c as Xt,d as Vr,e as st}from"./Table-DlEuFgv-.js";import{L as li,a as Hr}from"./list-checks-mXGHUVbB.js";import{C as Kr}from"./chevron-right-BA2Fntu-.js";import{M as yn}from"./mouse-pointer-2-Cw2tWzDX.js";import{Z as ci}from"./zap-COC2tZaH.js";import{C as At}from"./check-R6V3bot0.js";import{C as di}from"./circle-check-D4EzyGzs.js";import{C as ui}from"./circle-x-Cf6AF2B2.js";import{E as qr}from"./EmptyState-BE_5f8Vw.js";import{I as xn}from"./input-CJ8z3IO5.js";import{P as Xr,a as Yr}from"./play-C0CuKLXj.js";import{D as hi}from"./download-Bd8OGLzi.js";import{U as Gr,T as Jr}from"./upload-BYf26K71.js";import{A as Zr}from"./arrow-left-CLQWAiCY.js";import{A as Qr}from"./arrow-right-K6A5e_Ee.js";import{p as ea,A as ta}from"./AnnotationOverlay-CzbFYtPI.js";import{T as sa}from"./trash-2-CcSsv4fS.js";import{L as na}from"./lock-BSXM1xvq.js";import{F as bn}from"./FilterMenu-BQY75Su3.js";import"./utils-CDN07tui.js";import"./index-BiL0Enl_.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 ia=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ps=Q("arrow-down",ia);/**
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 ra=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Us=Q("arrow-up",ra);/**
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 aa=[["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"}]],oa=Q("battery-low",aa);/**
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 la=[["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"}]],ca=Q("battery-warning",la);/**
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 da=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],ua=Q("battery",da);/**
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 ha=[["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"}]],ma=Q("box",ha);/**
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 fa=[["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"}]],pa=Q("calendar-plus",fa);/**
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 ga=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],va=Q("chevrons-down-up",ga);/**
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 ya=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],xa=Q("chevrons-up-down",ya);/**
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 ba=[["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"}]],mi=Q("circle-question-mark",ba);/**
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 ja=[["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"}]],jn=Q("code-xml",ja);/**
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 wa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ka=Q("columns-2",wa);/**
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 Sa=[["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"}]],Ca=Q("crosshair",Sa);/**
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 Na=[["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"}]],fi=Q("ellipsis",Na);/**
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 Ea=[["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"}]],Ta=Q("folder-down",Ea);/**
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 Aa=[["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"}]],Ra=Q("hand",Aa);/**
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 Ma=[["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"}]],za=Q("image",Ma);/**
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 $a=[["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"}]],Ia=Q("keyboard",$a);/**
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 _a=[["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"}]],Da=Q("library",_a);/**
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 La=[["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"}]],Oa=Q("lock-open",La);/**
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 Fa=[["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"}]],Pa=Q("map-pin",Fa);/**
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 Ua=[["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"}]],Ba=Q("maximize-2",Ua);/**
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 Wa=[["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"}]],Va=Q("message-square",Wa);/**
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 Ha=[["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"}]],Ka=Q("minimize-2",Ha);/**
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 qa=[["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"}]],Xa=Q("moon-star",qa);/**
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 Ya=[["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"}]],Ga=Q("mouse-pointer-click",Ya);/**
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 Ja=[["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"}]],Za=Q("package",Ja);/**
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 Qa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],eo=Q("panel-top",Qa);/**
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 to=[["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"}]],pi=Q("pen-line",to);/**
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 so=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],no=Q("rectangle-horizontal",so);/**
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 io=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],ro=Q("rectangle-vertical",io);/**
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"}]],Et=Q("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 oo=[["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"}]],gi=Q("scroll-text",oo);/**
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 lo=[["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"}]],mt=Q("shield-alert",lo);/**
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 co=[["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"}]],uo=Q("tag",co);/**
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 ho=[["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"}]],ms=Q("target",ho);/**
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 mo=[["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"}]],fo=Q("text-cursor-input",mo);/**
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 po=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],go=Q("thermometer",po);/**
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 vo=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],yo=Q("toggle-left",vo);/**
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 xo=[["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"}]],wn=Q("touchpad",xo);/**
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 bo=[["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"}]],jo=Q("type",bo);/**
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 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"}]],ko=Q("volume-1",wo);/**
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 So=[["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"}]],Co=Q("volume-2",So);function No(e){return e>=50?"ready":e>=20?"warning":"error"}function Eo(e){return e>=50?s.jsx(ua,{size:10}):e>=20?s.jsx(oa,{size:10}):s.jsx(ca,{size:10})}function To(e){return e==="Normal"?"ready":e==="Critical"?"error":"warning"}const Ao=({device:e})=>{if(e.deviceType==="emulator"||e.deviceType==="simulator"||e.offline)return null;const n=typeof e.batteryLevel=="number",i=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!n&&!i?s.jsx("div",{className:"dc2-health",children:s.jsxs(Wt,{tone:"neutral",title:"Device does not report battery or thermal data",children:[s.jsx($r,{size:10}),"No telemetry"]})}):s.jsxs("div",{className:"dc2-health",children:[n&&s.jsxs(Wt,{tone:No(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[Eo(e.batteryLevel),e.batteryLevel,"%"]}),i&&s.jsxs(Wt,{tone:To(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[s.jsx(go,{size:10}),e.thermalStatus]})]})};function Ro(e){if(typeof e!="number")throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(e*1e3)%1e3,nanoseconds:t(e*1e6)%1e3}}const Mo=(e,t)=>t===1?e:`${e}s`,zo=1e-7;function vi(e,t={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);const n=[],i=(o,d)=>{const c=Math.floor(o*10**d+zo);return(Math.round(c)/10**d).toFixed(d)},r=(o,d,c,l)=>{if((n.length===0||!t.colonNotation)&&o===0&&!(t.colonNotation&&c==="m"))return;l=(l||o||"0").toString();let h,m;if(t.colonNotation){h=n.length>0?":":"",m="";const g=l.includes(".")?l.split(".")[0].length:l.length,f=n.length>0?2:1;l="0".repeat(Math.max(0,f-g))+l}else h="",m=t.verbose?" "+Mo(d,o):c;n.push(h+l+m)},a=Ro(e);if(r(Math.trunc(a.days/365),"year","y"),r(a.days%365,"day","d"),r(a.hours,"hour","h"),r(a.minutes,"minute","m"),t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3)if(r(a.seconds,"second","s"),t.formatSubMilliseconds)r(a.milliseconds,"millisecond","ms"),r(a.microseconds,"microsecond","µs"),r(a.nanoseconds,"nanosecond","ns");else{const o=a.milliseconds+a.microseconds/1e3+a.nanoseconds/1e6,d=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,c=o>=1?Math.round(o):Math.ceil(o),l=d?o.toFixed(d):c;r(Number.parseFloat(l),"millisecond","ms",l)}else{const o=e/1e3%60,d=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,c=i(o,d),l=t.keepDecimalsOnWholeSeconds?c:c.replace(/\.0+$/,"");r(Number.parseFloat(l),"second","s",l)}if(n.length===0)return"0"+(t.verbose?" milliseconds":"ms");if(t.compact)return n[0];if(typeof t.unitCount=="number"){const o=t.colonNotation?"":" ";return n.slice(0,Math.max(t.unitCount,1)).join(o)}return t.colonNotation?n.join(""):n.join(" ")}const fs=6e4;function $o(e){return!Number.isFinite(e)||e<=0?"expiring":e<fs?"under 1m":vi(Math.floor(e/fs)*fs,{unitCount:2})}const Ns=["ready","busy","reserved","maintenance","offline"],yi={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function Rt(e,t){return e.offline?"offline":e.userBlocked?"maintenance":e.busy?"busy":e.reservedUntil&&t<e.reservedUntil?"reserved":"ready"}function xi(e,t){const n=Ir(e);if(!e.busy||!n)return null;const i=String(n);return i.startsWith("manual_")?t!=null&&t.userId&&i===`manual_${t.userId}_${e.udid}`?"self":"other":"session"}const kn=e=>(e==null?void 0:e.role)==="ADMIN"||(e==null?void 0:e.role)==="SUPER_ADMIN";function Io(e,t,n){switch(xi(e,t)){case"session":return e.sessionStartTime&&e.sessionStartTime>0&&n>e.sessionStartTime?`Test session · ${vi(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===(t==null?void 0:t.email)||e.reservedBy===(t==null?void 0:t.name))?"you":e.reservedBy||"another user";return`${$o(e.reservedUntil-n)} left · by ${r}`}return null}function _o(e,t){if(e.offline)return{enabled:!1,reason:"Device is offline"};if(e.userBlocked&&!kn(t))return{enabled:!1,reason:"In maintenance"};const n=xi(e,t);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!kn(t)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function Ze(e){var t;return((t=e.marketingName)==null?void 0:t.trim())||e.name}function bi(e){const t=[ss(e.platform),e.sdk].filter(Boolean).join(" ");if(e.deviceType==="emulator")return`Emulator · ${t}`;if(e.deviceType==="simulator")return`Simulator · ${t}`;const i=[e.manufacturer?e.manufacturer.charAt(0).toUpperCase()+e.manufacturer.slice(1):"",e.model].filter(Boolean).join(" ");return i?`${i} · ${t}`:t}function Do(e){return e.formFactor==="tablet"||e.formFactor==="tv"?e.formFactor:"phone"}function gt(e,t){return e.teamId?(t==null?void 0:t.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"}],Oo=({device:e,onClose:t,onReserved:n})=>{const[i,r]=u.useState(""),[a,o]=u.useState("1h"),[d,c]=u.useState(""),[l,h]=u.useState(!1),[m,g]=u.useState(null),[f,p]=u.useState(null),k=async()=>{if(!i.trim()){g("Please enter your name/ID");return}h(!0),g(null),p(null);try{const C=await G.reserveDevice(e.udid,e.host,i,a,d);C.success?(n(),t()):p(C.error||"Failed to reserve device")}catch(C){p(C.message||"An unexpected error occurred")}finally{h(!1)}};return s.jsx(ns,{open:!0,onClose:t,width:520,title:s.jsxs(s.Fragment,{children:[s.jsx(pa,{size:16,className:"title-icon"}),"Reserve device"]}),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn-cancel",onClick:t,disabled:l,children:"Cancel"}),s.jsx("button",{className:"btn-reserve",onClick:k,disabled:l||!i.trim(),children:l?"Reserving...":"Confirm Reservation"})]}),children:s.jsxs("div",{className:"reservation-modal-body",children:[s.jsxs("div",{className:"device-id-badge",children:[s.jsx("span",{className:"label",children:"Device:"}),s.jsx("span",{className:"value",children:e.udid})]}),s.jsxs("p",{children:["Reserve ",s.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),s.jsx(Vt,{label:s.jsxs(s.Fragment,{children:[s.jsx(jr,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:m?s.jsxs(s.Fragment,{children:[s.jsx(pn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),m]}):void 0,children:s.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:i,onChange:C=>{r(C.target.value),m&&g(null)},disabled:l})}),s.jsx(Vt,{label:s.jsxs(s.Fragment,{children:[s.jsx(Or,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:s.jsx("div",{className:"duration-selector",children:Lo.map(C=>s.jsx("div",{className:`duration-option ${a===C.value?"active":""}`,onClick:()=>o(C.value),children:C.label},C.value))})}),s.jsx(Vt,{label:s.jsxs(s.Fragment,{children:[s.jsx(Va,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?s.jsxs(s.Fragment,{children:[s.jsx(pn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:s.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:d,onChange:C=>c(C.target.value),disabled:l})})]})})},Fo=({device:e,onClose:t,onUpdated:n})=>{const{toast:i}=Be(),[r,a]=u.useState(e.tags||[]),[o,d]=u.useState(""),[c,l]=u.useState(!1),h=u.useRef(null);u.useEffect(()=>{h.current&&h.current.focus()},[]);const m=()=>{const k=o.trim();k&&!r.includes(k)&&(a([...r,k]),d(""))},g=k=>{a(r.filter(C=>C!==k))},f=k=>{k.key==="Enter"&&m()},p=async()=>{l(!0);try{await G.updateDeviceTags(e.udid,e.host,r),n(),t()}catch(k){console.error("Failed to update tags",k),i("Error saving tags. Please try again.","error")}finally{l(!1)}};return s.jsx(ns,{open:!0,onClose:t,width:520,title:s.jsxs(s.Fragment,{children:[s.jsx(uo,{size:16,className:"title-icon"}),"Manage device tags"]}),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn-cancel",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn-save",onClick:p,disabled:c,children:c?"Saving...":"Apply Changes"})]}),children:s.jsxs("div",{className:"tag-modal-body",children:[s.jsxs("div",{className:"device-id-badge",children:[s.jsx("span",{className:"label",children:"Device:"}),s.jsx("span",{className:"value",children:e.udid})]}),s.jsx(Vt,{label:"Add new tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:s.jsxs("div",{className:"input-with-button",children:[s.jsx("input",{ref:h,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:o,onChange:k=>d(k.target.value),onKeyDown:f}),s.jsx("button",{className:"add-inline-btn",onClick:m,disabled:!o.trim(),children:s.jsx(Fr,{size:16})})]})}),s.jsxs("div",{className:"tags-display-section",children:[s.jsx("label",{children:"Current Tags"}),s.jsx("div",{className:"tags-list",children:r.length>0?r.map(k=>s.jsxs("div",{className:"tag-pill-editable",children:[k,s.jsx("button",{className:"remove-tag",onClick:()=>g(k),children:s.jsx(Ls,{size:12})})]},k)):s.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},Po="/wd/hub";function Uo(e){return e==="android"?"UiAutomator2":"XCUITest"}function Bo(e){return e==="android"?"Android":e==="tvos"?"tvOS":"iOS"}function Wo(e,t=Po){if(!e)return"—";try{const n=new URL(e.includes("://")?e:`http://${e}`),i=t.startsWith("/")?t:`/${t}`,r=n.pathname.replace(/\/$/,"");return r===i||r.endsWith(i)?`${n.protocol}//${n.host}${r}`:`${n.protocol}//${n.host}${i}`}catch{return e}}function Vo(e){const t={platformName:Bo(e.platform),"appium:automationName":Uo(e.platform),"appium:udid":e.udid};return e.sdk&&e.sdk!=="Unknown"&&e.sdk!=="unknown"&&(t["appium:platformVersion"]=e.sdk),e.name&&(t["appium:deviceName"]=e.name),t}function Ho(e){return JSON.stringify(Vo(e),null,2)}const Ko=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,qo=/^(?:\d{1,3}\.){3}\d{1,3}$/;function Xo(e){const t=e.trim();return!t||Ko.test(t)||!qo.test(t)?!1:t.split(".").every(n=>{const i=Number(n);return Number.isInteger(i)&&i>=0&&i<=255})}function Yo(e){return e.ip&&Xo(e.ip)?e.ip.trim():null}const ji=({udid:e,currentTeamId:t,teams:n,onDone:i,className:r})=>{const{toast:a}=Be(),[o,d]=u.useState(!1);async function c(l){d(!0);try{await G.setDeviceTeam(e,l),a(l?"Device assigned":"Device returned to shared pool","success"),i(!0)}catch(h){a((h==null?void 0:h.message)||"Failed to update team","error")}finally{d(!1)}}return s.jsxs(ri,{selectSize:"sm",className:r,autoFocus:!0,"aria-label":"Team",disabled:o,defaultValue:t??"",onBlur:()=>i(!1),onChange:l=>c(l.target.value||null),children:[s.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([l,h])=>s.jsx("option",{value:l,children:h},l))]})};function wi(e,t){const[n,i]=u.useState(!1),[r,a]=u.useState(!1),[o,d]=u.useState(!1),{me:c}=wr(),{toast:l}=Be(),h=(c==null?void 0:c.role)==="ADMIN"||(c==null?void 0:c.role)==="SUPER_ADMIN",m=Date.now(),g=Rt(e,m),f=g==="reserved",p=Io(e,c,m),k=_o(e,c),C=Wo(e.host),R=Yo(e),w=async(T,S)=>{var E;try{await((E=navigator.clipboard)==null?void 0:E.writeText(T)),l(S,"success")}catch{l("Failed to copy","error")}},b=async()=>{await G.releaseReservation(e.udid,e.host),t()},N=async()=>{await G.blockDevice(e.udid,e.host),t()},y=async()=>{await G.unblockDevice(e.udid,e.host),t()},A=async()=>{e.userBlocked?await y():await N()},v=s.jsxs(s.Fragment,{children:[n&&s.jsx(Oo,{device:e,onClose:()=>i(!1),onReserved:()=>t()}),r&&s.jsx(Fo,{device:e,onClose:()=>a(!1),onUpdated:()=>t()})]});return{kind:g,reserved:f,activity:p,control:k,isAdmin:h,editingTeam:o,setEditingTeam:d,openReservation:()=>i(!0),openTagManager:()=>a(!0),release:b,toggleMaintenance:A,copy:w,serverUrl:C,ip:R,dialogs:v}}const ki=({device:e,actions:t,navigate:n,reasonId:i})=>{const{kind:r,reserved:a,control:o}=t;return s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"tonal",size:"sm",disabled:!o.enabled,"aria-describedby":o.enabled?void 0:i,onClick:()=>{o.enabled&&n(`/devices/${e.udid}/control`)},children:"Control"}),a?s.jsx(P,{variant:"secondary",size:"sm",onClick:t.release,children:"Release"}):r==="ready"?s.jsx(P,{variant:"secondary",size:"sm",onClick:t.openReservation,children:"Reserve"}):null]})},Si=({device:e,actions:t})=>{const[n,i]=u.useState(!1),r=u.useRef(null),{isAdmin:a,serverUrl:o,ip:d,copy:c}=t;return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:r,type:"button",className:"dc2-more",onClick:()=>i(l=>!l),"aria-label":"More actions",children:s.jsx(fi,{size:14})}),s.jsx(qt,{open:n,onClose:()=>i(!1),anchorRef:r,children:s.jsxs(Fs,{children:[s.jsx(be,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(e.udid,"UDID copied")},children:"Copy UDID"}),o!=="—"&&s.jsx(be,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(o,"Server URL copied")},children:"Copy server URL"}),d&&s.jsx(be,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(d,"IP address copied")},children:"Copy IP address"}),s.jsx(be,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(Ho(e),"Session capabilities copied")},children:"Copy capabilities"}),a&&s.jsxs(s.Fragment,{children:[s.jsx(ai,{}),s.jsx(be,{onClick:()=>{i(!1),t.openTagManager()},children:"Manage tags…"}),s.jsx(be,{onClick:()=>{i(!1),t.setEditingTeam(!0)},children:"Assign team…"}),s.jsx(be,{onClick:()=>{i(!1),t.toggleMaintenance()},children:e.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},Go=({device:e})=>{const t={phone:Ss,tablet:Pr,tv:kr}[Do(e)],n=e.deviceType==="emulator"||e.deviceType==="simulator";return s.jsx(t,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},Jo=({device:e,reloadDevices:t,navigate:n,teams:i})=>{var m,g,f;const r=wi(e,t),{kind:a,activity:o,control:d}=r,c=`dc2-reason-${e.udid}`,l=Ze(e),h=gt(e,i);return s.jsxs("div",{className:`dc2 dc2-${a}`,children:[s.jsxs("div",{className:`dc2-band dc2-band-${a}`,children:[s.jsxs("span",{className:"dc2-band-label",children:[s.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),yi[a]]}),o&&s.jsx("span",{className:"dc2-band-activity",title:o,children:o})]}),s.jsxs("div",{className:`dc2-body${a==="offline"?" dc2-dim":""}`,children:[s.jsxs("div",{className:"dc2-head",children:[s.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:s.jsx(Go,{device:e})}),s.jsxs("div",{className:"dc2-id",children:[s.jsx("div",{className:"dc2-title",title:`${l}
217
- ${e.udid}`,children:l}),s.jsx("div",{className:"dc2-subtitle",children:bi(e)})]})]}),s.jsxs("div",{className:"dc2-meta",children:[s.jsx(Ao,{device:e}),r.editingTeam?s.jsx(ji,{className:"dc2-team-picker",udid:e.udid,currentTeamId:e.teamId??null,teams:i??new Map,onDone:p=>{r.setEditingTeam(!1),p&&t()}}):h&&s.jsx(Wt,{tone:"accent",className:"dc2-team",title:`Team: ${h}`,children:h}),(m=e.tags)==null?void 0:m.slice(0,2).map(p=>s.jsxs("span",{className:"dc2-tag",title:p,children:["#",p]},p)),(((g=e.tags)==null?void 0:g.length)||0)>2&&s.jsxs("span",{className:"dc2-tag",children:["+",(((f=e.tags)==null?void 0:f.length)||0)-2]})]})]}),s.jsxs("div",{className:"dc2-foot",children:[s.jsx(ki,{device:e,actions:r,navigate:n,reasonId:c}),!d.enabled&&s.jsx("span",{id:c,className:"dc2-unavailable",title:d.reason,children:d.reason}),s.jsx("span",{className:"dc2-spacer"}),s.jsx(Si,{device:e,actions:r})]}),r.dialogs]})};function Zo(e){const t=$t(),{search:n}=ts();return s.jsx(Jo,{device:e.device,reloadDevices:e.reloadDevices,navigate:i=>t(`${i}${n}`),teams:e.teams})}class Qo extends it.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){G.listTeams().then(t=>{this.setState({teamsMap:new Map(t.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return s.jsx("div",{className:"device-explorer-card-container",children:it.Children.toArray(this.props.devices.map(t=>s.jsx(Zo,{device:t,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const el={status:"all",platform:"all",type:"all",q:""},Ci=["all",...Ns],Ni=["all","android","ios","tvos"],Ei=["all","real","virtual"];function ps(e,t){return t.includes(e)?e:t[0]}function tl(e){const t=e.get("q")??"";return{status:ps(e.get("status"),Ci),platform:ps(e.get("platform"),Ni),type:ps(e.get("type"),Ei),q:t.trim()?t:""}}function sl(e){const t=new URLSearchParams;return e.status!=="all"&&t.set("status",e.status),e.platform!=="all"&&t.set("platform",e.platform),e.type!=="all"&&t.set("type",e.type),e.q.trim()&&t.set("q",e.q),t}function Mt(e){return e.deviceType==="simulator"||e.deviceType==="emulator"?!0:!e.deviceType&&e.realDevice===!1}function Bs(e){const t=(e.platform||"").toLowerCase();return t==="android"||t==="ios"||t==="tvos"?t:null}function nl(e){const t=e.deviceType==="emulator"?"Emulator":e.deviceType==="simulator"?"Simulator":"";return[Ze(e),e.name,e.manufacturer,e.model,ss(e.platform),e.sdk,t,e.teamName,e.udid].filter(Boolean).join(" ").toLowerCase()}function Ht(e,t,n,i){if(i!=="status"&&t.status!=="all"&&Rt(e,n)!==t.status||i!=="platform"&&t.platform!=="all"&&Bs(e)!==t.platform||i!=="type"&&t.type!=="all"&&t.type==="virtual"!==Mt(e))return!1;const r=t.q.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return!0;const a=nl(e);return r.every(o=>a.includes(o))}const gs=e=>Object.fromEntries(e.map(t=>[t,0]));function il(e,t,n){const i=gs(Ci),r=gs(Ni),a=gs(Ei);for(const o of e){if(Ht(o,t,n,"status")&&(i.all+=1,i[Rt(o,n)]+=1),Ht(o,t,n,"platform")){r.all+=1;const d=Bs(o);d&&(r[d]+=1)}Ht(o,t,n,"type")&&(a.all+=1,a[Mt(o)?"virtual":"real"]+=1)}return{status:i,platform:r,type:a}}function rl(e){return e.some(t=>Bs(t)==="tvos")}function al(e){return e.status!=="all"||e.platform!=="all"||e.type!=="all"||e.q.trim()!==""}function ol(e,t){const n=i=>i===1?"device":"devices";return e===t?`${t} ${n(t)}`:`${e} of ${t} ${n(t)}`}const Es={key:"status",dir:"asc"},ll=["status","device","platform","type","team","host"],cl=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),nt=(e,t)=>cl.compare(e,t);function dl(e,t,n,i){switch(n){case"status":return Ns.indexOf(Rt(e,i.now))-Ns.indexOf(Rt(t,i.now));case"device":return nt(Ze(e),Ze(t));case"platform":return nt(e.platform||"",t.platform||"")||nt(e.sdk||"",t.sdk||"");case"type":return Number(Mt(e))-Number(Mt(t));case"team":return nt(gt(e,i.teams)??"",gt(t,i.teams)??"");case"host":return nt(e.host||"",t.host||"")}}function ul(e,t,n){const i=t.dir==="desc"?-1:1;return e.slice().sort((r,a)=>{if(t.key==="team"){const o=gt(r,n.teams)===null,d=gt(a,n.teams)===null;if(o!==d)return o?1:-1}return i*dl(r,a,t.key,n)||nt(Ze(r),Ze(a))||nt(r.udid,a.udid)})}function hl(e){const t=e.get("sort");return!t||!ll.includes(t)?Es:{key:t,dir:e.get("dir")==="desc"?"desc":"asc"}}function ml(e,t){e.delete("sort"),e.delete("dir"),!(t.key===Es.key&&t.dir===Es.dir)&&(e.set("sort",t.key),t.dir==="desc"&&e.set("dir","desc"))}const ft=({sortKey:e,label:t,sort:n,onSortChange:i})=>{const r=n.key===e,a=r?n.dir:"asc";return s.jsx(Xt,{scope:"col","aria-sort":r?a==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>i(r?{key:e,dir:a==="asc"?"desc":"asc"}:{key:e,dir:"asc"}),children:[t,r&&(a==="asc"?s.jsx(Us,{size:12,"aria-hidden":"true"}):s.jsx(Ps,{size:12,"aria-hidden":"true"}))]})})},fl=({device:e,reloadDevices:t,navigate:n,teams:i,showHost:r})=>{const a=wi(e,t),{kind:o,activity:d,control:c}=a,l=Ze(e),h=bi(e),m=gt(e,i),g=`${ss(e.platform)} ${e.sdk??""}`,f=e.tags??[],p=`devtable-reason-${e.udid}`;return s.jsxs(oi,{className:`devtable-row${o==="offline"?" is-offline":""}`,children:[s.jsxs(st,{children:[s.jsxs("div",{className:"devtable-line",children:[s.jsx(Ur,{kind:o,className:"devtable-status-dot"})," ",yi[o]]}),d&&s.jsx("div",{className:"devtable-muted devtable-line",title:d,children:d})]}),s.jsxs(Xt,{scope:"row",className:"devtable-rowheader",title:`${l}
218
- ${e.udid}`,children:[s.jsx("div",{className:"devtable-title devtable-line",children:l}),s.jsx("div",{className:"devtable-muted devtable-line",title:h,children:h})]}),s.jsx(st,{title:g,children:g}),s.jsx(st,{children:Mt(e)?"Virtual":"Real"}),s.jsx(st,{title:a.editingTeam?void 0:m??"Shared",children:a.editingTeam?s.jsx(ji,{udid:e.udid,currentTeamId:e.teamId??null,teams:i,onDone:k=>{a.setEditingTeam(!1),k&&t()}}):m??"Shared"}),s.jsxs(st,{title:f.join(", "),children:[f.slice(0,2).map(k=>s.jsxs("span",{className:"devtable-tag",children:["#",k]},k)),f.length>2&&s.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),r&&s.jsx(st,{title:e.host,children:e.host}),s.jsx(st,{className:"devtable-actions",title:c.enabled?void 0:c.reason,children:s.jsxs("div",{className:"devtable-actions-inner",children:[s.jsx(ki,{device:e,actions:a,navigate:n,reasonId:p}),!c.enabled&&s.jsx("span",{id:p,className:"sr-only",children:c.reason}),s.jsx(Si,{device:e,actions:a})]})}),a.dialogs]})};function pl({devices:e,reloadDevices:t,sort:n,onSortChange:i,navigate:r,teams:a}){const o=new Set(e.map(c=>c.host)).size>1||n.key==="host",d=ul(e,n,{now:Date.now(),teams:a});return s.jsxs(Br,{className:"devtable",children:[s.jsxs("caption",{className:"sr-only",children:["Devices, ",e.length," shown"]}),s.jsxs("colgroup",{children:[s.jsx("col",{className:"devtable-col-status"}),s.jsx("col",{}),s.jsx("col",{className:"devtable-col-platform"}),s.jsx("col",{className:"devtable-col-type"}),s.jsx("col",{className:"devtable-col-team"}),s.jsx("col",{className:"devtable-col-tags"}),o&&s.jsx("col",{className:"devtable-col-host"}),s.jsx("col",{className:"devtable-col-actions"})]}),s.jsx(Wr,{children:s.jsxs(oi,{children:[s.jsx(ft,{sortKey:"status",label:"Status",sort:n,onSortChange:i}),s.jsx(ft,{sortKey:"device",label:"Device",sort:n,onSortChange:i}),s.jsx(ft,{sortKey:"platform",label:"Platform",sort:n,onSortChange:i}),s.jsx(ft,{sortKey:"type",label:"Type",sort:n,onSortChange:i}),s.jsx(ft,{sortKey:"team",label:"Team",sort:n,onSortChange:i}),s.jsx(Xt,{scope:"col",children:"Tags"}),o&&s.jsx(ft,{sortKey:"host",label:"Host",sort:n,onSortChange:i}),s.jsx(Xt,{scope:"col",children:"Actions"})]})}),s.jsx(Vr,{children:d.map(c=>s.jsx(fl,{device:c,reloadDevices:t,navigate:r,teams:a,showHost:o},c.udid))})]})}function gl(e){const t=$t(),{search:n}=ts(),[i,r]=u.useState(new Map);return u.useEffect(()=>{G.listTeams().then(a=>r(new Map(a.map(o=>[o.id,o.name])))).catch(()=>{})},[]),s.jsx(pl,{devices:e.devices,reloadDevices:e.reloadDevices,sort:e.sort,onSortChange:e.onSortChange,navigate:a=>t(`${a}${n}`),teams:i})}const vl=({onCommand:e,prompt:t="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:i})=>{const[r,a]=u.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[o,d]=u.useState(""),[c,l]=u.useState([]),[h,m]=u.useState(-1),[g,f]=u.useState(!1),p=u.useRef(null),k=u.useRef(null);u.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[r]);const C=w=>{const b=w.trim();if((b.startsWith("{")||b.startsWith("["))&&(b.endsWith("}")||b.endsWith("]")))try{const N=JSON.parse(b);return JSON.stringify(N,null,2)}catch{}return w},R=async w=>{if(w.key==="Enter"&&!g){const b=o.trim();if(!b)return;if(d(""),a(N=>[...N,{type:"command",content:`${t} ${b}`,timestamp:Date.now()}]),l(N=>[...N,b]),m(-1),f(!0),b==="clear"){a([]),f(!1);return}if(b==="help"){let N="";i==="android"?N=`
219
- Android Allowed Commands:
220
- • System Info: getprop, ip addr, date, uptime, cat /proc/meminfo, cat /proc/cpuinfo
221
- • Process Mgmt: ps, top
222
- • File System: ls
223
- • Diagnostics: dumpsys [battery|wifi|power]
224
- • Packages: pm list packages
225
- `:(i==="ios"||i==="tvos")&&(N=`
226
- iOS Allowed Commands:
227
- • Real Device (go-ios):
228
- apps, info, list, syslog, deviceinfo, diagnostics
229
- • Simulator (xcrun simctl):
230
- listapps, get_app_container, list, getenv
231
- • Simulator System:
232
- ls, ps, top, date, uptime, whoami
233
- `),a(y=>[...y,{type:"output",content:N.trim(),timestamp:Date.now()}]),f(!1);return}try{const N=await e(b),y=C(N||"(No output)");a(A=>[...A,{type:"output",content:y,timestamp:Date.now()}])}catch(N){a(y=>[...y,{type:"error",content:N.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var N;return(N=k.current)==null?void 0:N.focus()},10)}}else if(w.key==="ArrowUp"){if(w.preventDefault(),c.length>0){const b=h===-1?c.length-1:Math.max(0,h-1);m(b),d(c[b])}}else if(w.key==="ArrowDown"&&(w.preventDefault(),h!==-1)){const b=h+1;b>=c.length?(m(-1),d("")):(m(b),d(c[b]))}};return s.jsxs("div",{className:"terminal-container theme-dark",children:[s.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),s.jsxs("header",{className:"terminal-header",children:[s.jsxs("div",{className:"terminal-controls",children:[s.jsx("div",{className:"dot red"}),s.jsx("div",{className:"dot yellow"}),s.jsx("div",{className:"dot green"})]}),s.jsxs("div",{className:"terminal-title",children:[ss(i)," shell"]}),s.jsx("div",{className:"terminal-actions",children:s.jsx("button",{className:"terminal-action-btn",onClick:()=>a([]),title:"Clear terminal",children:"CLEAR"})})]}),s.jsxs("div",{className:"terminal-history",ref:p,onClick:()=>{var w;return(w=k.current)==null?void 0:w.focus()},children:[r.map((w,b)=>s.jsx("div",{className:`terminal-line ${w.type}`,children:w.content},b)),g&&s.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),s.jsxs("div",{className:"terminal-input-area",children:[s.jsx("span",{className:"terminal-prompt",children:t}),s.jsx("input",{ref:k,className:"terminal-input",value:o,onChange:w=>d(w.target.value),onKeyDown:R,disabled:g,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ue(e,t){var n;t(e),(n=e.children)==null||n.forEach(i=>Ue(i,t))}function Pe(e,...t){var n;for(const i of t){const r=(n=e.attributes)==null?void 0:n[i];if(r!=null&&r!=="")return String(r)}}function vt(e){var t;return((t=e.type)==null?void 0:t.split(".").pop())||e.type||""}function yl(e,t){const n=[];return Ue(e,i=>{Pe(i,"content-desc","contentDescription","accessibilityId","name","label")===t&&n.push(i)}),n}function xl(e,t){const n=[];return Ue(e,i=>{Pe(i,"resource-id","resourceId","identifier")===t&&n.push(i)}),n}function Ts(e,t){const n=[];return Ue(e,i=>{(i.type===t||vt(i)===t)&&n.push(i)}),n}function bl(e,t){const n=[];return Ue(e,i=>{Pe(i,"name")===t&&n.push(i)}),n}function jl(e){const t=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return t?{tag:t[1]==="*"?null:t[1],attrKey:t[2],attrValue:t[4]}:null}function wl(e,t){const n=t.split("/").filter(Boolean);if(n.length===0)return null;const i=[];for(const a of n){const o=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(a);if(!o)return null;i.push({type:o[1],index:parseInt(o[2],10)})}if(i[0].type!==e.type&&i[0].type!==vt(e)||i[0].index!==1)return null;let r=e;for(let a=1;a<i.length&&r;a++){const{type:o,index:d}=i[a];let c=0,l;for(const h of r.children||[])if((h.type===o||vt(h)===o)&&(c+=1,c===d)){l=h;break}r=l}return r?[r]:[]}function kl(e,t){const n=wl(e,t);if(n!==null)return{kind:"matched",nodes:n};const i=jl(t);if(i){const r=[];return Ue(e,a=>{if(i.tag&&a.type!==i.tag&&vt(a)!==i.tag)return;Pe(a,i.attrKey)===i.attrValue&&r.push(a)}),{kind:"matched",nodes:r}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Sl(e,t){const n=t.trim(),i=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(i){const[,o,d,c]=i,l=[];return Ue(e,h=>{if(h.type!==o&&vt(h)!==o)return;Pe(h,d)===c&&l.push(h)}),{kind:"matched",nodes:l}}const r=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(r){const[,o,d]=r,c=parseInt(d,10),l=[];return Ue(e,h=>{(h.type===o||vt(h)===o)&&l.push(h)}),{kind:"matched",nodes:l[c-1]?[l[c-1]]:[]}}const a=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return a?Ts(e,a[1]).length>0?{kind:"matched",nodes:Ts(e,a[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Cl(e,t){const i=t.trim().split(/\s+AND\s+/i).map(o=>o.trim()),r=[];for(const o of i){const d=/^(\w+)\s*==\s*"([^"]*)"$/.exec(o);if(!d)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};r.push({key:d[1],value:d[2]})}const a=[];return Ue(e,o=>{for(const d of r){let c;if(d.key==="type"?c=o.type:d.key==="label"?c=Pe(o,"label")??o.label:d.key==="name"?c=Pe(o,"name")??o.name:d.key==="value"?c=Pe(o,"value")??o.value:c=Pe(o,d.key),c!==d.value)return}a.push(o)}),{kind:"matched",nodes:a}}function As(e,t,n){const i=t.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(i){case"accessibility id":return{kind:"matched",nodes:yl(e,n)};case"id":return{kind:"matched",nodes:xl(e,n)};case"class name":return{kind:"matched",nodes:Ts(e,n)};case"name":return{kind:"matched",nodes:bl(e,n)};case"xpath":return kl(e,n);case"-ios class chain":return Sl(e,n);case"-ios predicate string":return Cl(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${t}" not yet supported by snapshot matcher`}}}function Sn(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 Rs(e,t){const n=e.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(t)?{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(t)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(t)&&!t.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(t)?{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(t.startsWith("/hierarchy")||t.startsWith("/")&&!t.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(t))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const i=(t.match(/\//g)||[]).length;return i>7?{level:"fragile",reason:`${i}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:t.includes("@content-desc")||t.includes("@resource-id")||t.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"?t.includes("resourceId")||t.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:t.includes("textContains")||t.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 Ti(e){return[...e].sort((t,n)=>Sn(t.strategy)-Sn(n.strategy))}const Ft=e=>e===!0||e==="true",Nl=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,El=/(EditText|AutoCompleteTextView)$/;function Ai(e){const t=e.attributes||{};return Ft(t.clickable)||Ft(t["long-clickable"])||Ft(t.checkable)||Ft(t.scrollable)||El.test(e.type||"")||Nl.test(e.type||"")}function Tl(e){const t=e.attributes||{};return String(e.text||t["content-desc"]||e.label||t.label||t.name||"").trim()}function Al(e,t){const n="Unique locator",i=Ti(e.suggestedLocators||[]),r=i[0];if(!r)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const a=As(t.hierarchy,r.strategy,r.value),o=`${r.strategy} ${r.value}`;if(a.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${r.strategy} locators here`};const d=g=>g.length===1&&g[0].xpath===e.xpath;if(d(a.nodes))return{id:"unique",label:n,status:"pass",detail:`${o} matches only this element`};const c=i.slice(1).find(g=>{const f=As(t.hierarchy,g.strategy,g.value);return f.kind==="matched"&&d(f.nodes)}),l=c?`; use ${c.strategy} ${c.value} instead`:"",h=a.nodes.length,m=h===0?"matches nothing in this capture":`matches ${h} elements`;return{id:"unique",label:n,status:"fail",detail:`${o} ${m}${l}`}}function Rl(e){const t=Ti(e.suggestedLocators||[])[0];if(!t)return null;const{level:n,reason:i}=Rs(t.strategy,t.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:i}}function Ml(e,t){const{screenWidth:n,screenHeight:i}=t.metadata||{screenWidth:0,screenHeight:0};if(!n||!i)return null;const{x:r,y:a,width:o,height:d}=e.rect,c="On screen";return r+o<=0||a+d<=0||r>=n||a>=i?{id:"onscreen",label:c,status:"warn",detail:"Off screen — scroll it into view first"}:r<0||a<0||r+o>n||a+d>i?{id:"onscreen",label:c,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:c,status:"pass",detail:"Fully inside the screen"}}function zl(e,t){var d,c;const n=Ai(e),i=!(((d=e.attributes)==null?void 0:d.enabled)===!1||((c=e.attributes)==null?void 0:c.enabled)==="false"),r=e.rect.width>0&&e.rect.height>0,a=Tl(e);return[Al(e,t),Rl(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"},i?{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"},Ml(e,t),n?a?{id:"name",label:"Accessible name",status:"pass",detail:`“${a.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(l=>l!==null)}function $l(e){return{pass:e.filter(t=>t.status==="pass").length,warn:e.filter(t=>t.status==="warn").length,fail:e.filter(t=>t.status==="fail").length}}function Il(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const i=Math.floor(n/60);return i<60?`Captured ${i} min ago`:`Captured ${Math.floor(i/60)} h ago`}function _l(e,t){return e>0&&t>e}function Ri(e){var a,o,d,c,l;const t=(e.type||"").toLowerCase(),n=((a=e.attributes)==null?void 0:a.clickable)==="true"||((o=e.attributes)==null?void 0:o.clickable)===!0,i=((d=e.attributes)==null?void 0:d.scrollable)==="true"||((c=e.attributes)==null?void 0:c.scrollable)===!0,r=((l=e.children)==null?void 0:l.length)||0;return t.includes("button")||t.includes("btn")||n&&r===0?{role:"Button",key:"button"}:t.includes("edit")||t.includes("input")||t.includes("field")?{role:"Text input",key:"input"}:t.includes("image")||t.includes("img")||t.includes("imageview")?{role:"Image",key:"image"}:t.includes("scroll")||t.includes("recyclerview")||t.includes("listview")||i?{role:"Scrollable list",key:"list"}:t.includes("text")||t.includes("label")?{role:"Text label",key:"text"}:t.includes("switch")||t.includes("toggle")||t.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:t.includes("nav")||t.includes("toolbar")||t.includes("tabbar")?{role:"Navigation bar",key:"nav"}:r>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const Mi={button:s.jsx(Ga,{size:13}),input:s.jsx(fo,{size:13}),image:s.jsx(za,{size:13}),list:s.jsx(gi,{size:13}),text:s.jsx(jo,{size:13}),toggle:s.jsx(yo,{size:13}),nav:s.jsx(eo,{size:13}),container:s.jsx(li,{size:13}),element:s.jsx(ma,{size:13})};function zi(e,t){if(!t)return!0;const n=t.toLowerCase().trim(),i={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(),a=(e.text||e.label||e.value||"").toLowerCase(),o=(e.name||"").toLowerCase(),d=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[c,l]of Object.entries(i))if(n.includes(c)&&l.some(h=>r.includes(h)))return!0;return r.includes(n)||a.includes(n)||o.includes(n)||d.includes(n)}const ze=e=>typeof e=="string"?e.trim():typeof e=="number"?String(e):"";function Dl(e){const t=ze(e),n=t.indexOf(":id/");return n>=0?t.slice(n+4):t}function $i(e){return(e.type||"").split(".").pop()||""}function Yt(e){var t;return[e.type,(t=e.attributes)==null?void 0:t["resource-id"],e.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
234
- `)}function rt(e){const t=e.attributes||{};return ze(e.text)||ze(t["content-desc"])||ze(e.label)||ze(t.label)||Dl(t["resource-id"])||ze(t.name)||$i(e)||"Element"}const Ll=e=>{const t=e.attributes||{};return!!(ze(e.text)||ze(t["content-desc"])||ze(e.label)||ze(t.label))};function Ol(e){var t;return(((t=e.children)==null?void 0:t.length)??0)===1&&!Ai(e)&&!Ll(e)}function Ii(e){const t=[e];let n=e;for(;Ol(n);)n=n.children[0],t.push(n);return t}function _i(e,t){const n=new Set;if(!e||!t.trim())return n;const i=r=>{var a;zi(r,t)&&n.add(r.xpath),(a=r.children)==null||a.forEach(i)};return i(e),n}function Fl(e,t){const n=new Set;if(!e||!t.trim())return n;const i=r=>{let a=!1;for(const o of r.children||[])i(o)&&(a=!0);return a&&n.add(r.xpath),a||zi(r,t)};return i(e),n}function Pl(e,t,n=""){if(!e)return[];const i=!!n.trim(),r=i?_i(e,n):null,a=i?Fl(e,n):null,o=l=>!i||l.some(h=>r.has(h.xpath)||a.has(h.xpath)),d=[],c=(l,h,m)=>{const g=l.map(Ii).filter(o);g.forEach((f,p)=>{var b;const k=f[f.length-1],C=(((b=k.children)==null?void 0:b.length)??0)>0,R=i&&a.has(k.xpath),w=C&&(t.has(k.xpath)||R);d.push({key:k.xpath,nodes:f,level:h,setSize:g.length,posInSet:p+1,hasChildren:C,expanded:w,collapsible:w&&!R,parentKey:m}),w&&c(k.children,h+1,k.xpath)})};return c([e],1,null),d}function Ul(e,t=3){const n=new Set,i=(r,a)=>{var c;const o=Ii(r),d=o[o.length-1];a>t||!((c=d.children)!=null&&c.length)||(n.add(d.xpath),d.children.forEach(l=>i(l,a+1)))};return e&&i(e,1),n}function Kt(e,t){if(!e)return null;if(e.xpath===t)return[e];for(const n of e.children||[]){const i=Kt(n,t);if(i)return[e,...i]}return null}function Cn(e,t){return e.findIndex(n=>n.nodes.some(i=>i.xpath===t))}function Bl(e,t,n){var r;const i=e[t];if(!i)return null;switch(n){case"ArrowDown":return t<e.length-1?{focus:t+1}:null;case"ArrowUp":return t>0?{focus:t-1}:null;case"ArrowRight":return i.hasChildren?i.expanded?((r=e[t+1])==null?void 0:r.parentKey)===i.key?{focus:t+1}:null:{toggle:i.key}:null;case"ArrowLeft":{if(i.collapsible)return{toggle:i.key};const a=e.findIndex(o=>o.key===i.parentKey);return a>=0?{focus:a}:null}case"Home":return{focus:0};case"End":return{focus:e.length-1};case"Enter":case" ":return{select:i.nodes[i.nodes.length-1]};default:return null}}const Wl=10;function Vl({rows:e,selectedXpath:t,hoveredXpath:n,matches:i,onToggle:r,onSelect:a,onHover:o,revealSeq:d=0}){const c=u.useRef(null),[l,h]=u.useState(null),m=u.useRef(0),g=u.useRef(null),f=t?Cn(e,t):-1,p=l?e.findIndex(y=>y.key===l):-1,k=p>=0?p:Math.max(f,0),C=y=>{var A;return((A=c.current)==null?void 0:A.querySelector(`[data-row="${y}"]`))??null},R=y=>y.nodes[y.nodes.length-1],w=y=>{var T;const A=e[y];if(!A)return;h(A.key),m.current=y;const v=C(y);v==null||v.focus({preventScroll:!0}),(T=v==null?void 0:v.scrollIntoView)==null||T.call(v,{block:"nearest"})};u.useEffect(()=>{g.current=t},[t,d]),u.useEffect(()=>{var v,T;const y=g.current;if(!y)return;const A=Cn(e,y);A<0||((T=(v=C(A))==null?void 0:v.scrollIntoView)==null||T.call(v,{block:"nearest"}),g.current=null)}),u.useEffect(()=>{var v,T;if(!l||e.some(S=>S.key===l))return;const y=Math.min(m.current,e.length-1),A=!document.activeElement||document.activeElement===document.body;h(((v=e[y])==null?void 0:v.key)??null),A&&y>=0&&((T=C(y))==null||T.focus({preventScroll:!0}))});const b=y=>{const A=y.target;if(A.getAttribute("role")!=="treeitem")return;const v=Bl(e,Number(A.dataset.row),y.key);v&&(y.preventDefault(),"focus"in v?w(v.focus):"toggle"in v?r(v.toggle):a(v.select))},N=y=>{var A;(A=c.current)!=null&&A.contains(y.relatedTarget)||(o(null),h(null))};return s.jsx("div",{ref:c,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:b,onBlur:N,children:e.map((y,A)=>{const v=R(y),T=j=>!!j&&y.nodes.some(O=>O.xpath===j),S=T(t),E=!S&&T(n),z=rt(v),D=$i(v),B=!!D&&D!==z,K=y.nodes.map(j=>rt(j)).join(", "),q=B?`${K}, ${D}`:K,te=y.expanded&&!y.collapsible,X=(j,O)=>`omni-tree-row__part${O?" is-target":""}${i.has(j.xpath)?" is-match":""}${j.xpath===t?" is-current":""}`;return s.jsxs("div",{"data-row":A,role:"treeitem","aria-level":y.level,"aria-setsize":y.setSize,"aria-posinset":y.posInSet,"aria-selected":S,"aria-expanded":y.hasChildren?y.expanded:void 0,"aria-label":q,tabIndex:A===k?0:-1,className:`omni-tree-row${S?" is-selected":""}${E?" is-hovered":""}`,onClick:()=>a(v),onFocus:j=>{j.target===j.currentTarget&&(h(y.key),m.current=A,o(v))},onMouseEnter:()=>o(v),onMouseLeave:()=>o(null),children:[s.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[s.jsx("span",{className:"omni-tree-row__indent",style:{width:(y.level-1)*Wl}}),s.jsx("span",{className:`omni-tree-row__caret${te?" is-locked":""}`,onClick:y.hasChildren?j=>{j.stopPropagation(),te||r(y.key)}:void 0,children:y.hasChildren&&(y.expanded?s.jsx(Sr,{size:12}):s.jsx(Kr,{size:12}))}),s.jsx("span",{className:"omni-tree-row__icon",children:Mi[Ri(v).key]})]}),s.jsxs("span",{className:"omni-tree-row__label",children:[y.nodes.length>1&&s.jsx("span",{className:"omni-tree-row__head",children:y.nodes.slice(0,-1).map((j,O)=>s.jsxs(it.Fragment,{children:[O>0&&s.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),s.jsx("span",{className:X(j,!1),title:Yt(j),onClick:V=>{V.stopPropagation(),a(j)},onMouseEnter:()=>o(j),onMouseLeave:()=>o(v),children:rt(j)})]},j.xpath))}),s.jsxs("span",{className:"omni-tree-row__tail",children:[y.nodes.length>1&&s.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),s.jsxs("span",{className:"omni-tree-row__name",children:[s.jsx("span",{className:X(v,!0),title:Yt(v),children:rt(v)}),B&&s.jsx("span",{className:"omni-tree-row__type",children:D})]})]})]}),y.hasChildren&&!y.expanded&&s.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:v.children.length})]},y.key)})})}const Nn=4;function Hl({path:e,onSelect:t,focusCurrent:n=!1}){const[i,r]=u.useState(!1),a=u.useRef(null),o=u.useRef(null);if(u.useEffect(()=>{var h;n&&((h=o.current)==null||h.focus())},[]),u.useEffect(()=>{var h;i&&((h=a.current)==null||h.focus())},[i]),!e.length)return null;const d=e[e.length-1],c=e.slice(0,-1),l=!i&&c.length>Nn?c.length-Nn:0;return s.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:s.jsxs("ol",{children:[l>0&&s.jsx("li",{children:s.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${c.length} ancestors`,onClick:()=>r(!0),children:"…"})}),c.slice(l).map((h,m)=>s.jsx("li",{children:s.jsx("button",{ref:m===0?a:void 0,type:"button",className:"omni-crumb",title:Yt(h),"aria-label":rt(h),onClick:()=>t(h),children:rt(h)})},h.xpath)),s.jsx("li",{children:s.jsx("span",{ref:o,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Yt(d),children:rt(d)})})]})})}const Gt=.4,Kl=240,ql=340,En=.02,Jt=12,Di="xenon.omni.split";function Li(e){if(!(e>0))return{min:0,max:1};const t=Math.min(1,Kl/e);return{min:t,max:Math.max(t,(e-ql)/e)}}function Xl(e,t){const{min:n,max:i}=Li(t),r=Number.isFinite(e)?e:Gt;return Math.min(i,Math.max(n,r))}function Yl(e){try{const t=Number.parseFloat((e==null?void 0:e.getItem(Di))??"");return t>0&&t<1?t:Gt}catch{return Gt}}function Gl(e,t){try{e==null||e.setItem(Di,String(Math.round(t*1e3)/1e3))}catch{}}function Tn(){try{return window.localStorage}catch{return null}}const Jl=3;function Zl({share:e,limits:t,containerRef:n,onChange:i,onCommit:r,onReset:a}){const[o,d]=u.useState(!1),c=u.useRef(e);c.current=e;const l=u.useRef(!0),h=u.useRef(!1),m=u.useRef(0),g=u.useRef(e),f=w=>Math.min(t.max,Math.max(t.min,w)),p=w=>Math.round(w*100),k=()=>{l.current||(l.current=!0,d(!1),h.current&&r(c.current))},C=w=>{var N;const b=(N=n.current)==null?void 0:N.getBoundingClientRect();return!b||b.width<=Jt?c.current:f(g.current+(w-m.current)/(b.width-Jt))},R=w=>{const b=w.key==="ArrowLeft"?e-En:w.key==="ArrowRight"?e+En:w.key==="Home"?t.min:w.key==="End"?t.max:null;b!==null&&(w.preventDefault(),r(f(Math.round(b*1e3)/1e3)))};return s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":p(e),"aria-valuemin":p(t.min),"aria-valuemax":p(t.max),tabIndex:0,className:`omni-split-divider${o?" is-dragging":""}`,onKeyDown:R,onDoubleClick:a,onPointerDown:w=>{var b,N;(N=(b=w.currentTarget).setPointerCapture)==null||N.call(b,w.pointerId),l.current=!1,h.current=!1,m.current=w.clientX,g.current=c.current,d(!0)},onPointerMove:w=>{if(!o||!h.current&&Math.abs(w.clientX-m.current)<Jl)return;const b=C(w.clientX);b!==c.current&&(h.current=!0,i(b))},onPointerUp:w=>{var b,N;(N=(b=w.currentTarget).releasePointerCapture)==null||N.call(b,w.pointerId),k()},onPointerCancel:w=>{var b,N;(N=(b=w.currentTarget).releasePointerCapture)==null||N.call(b,w.pointerId),k()},onLostPointerCapture:k,children:s.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function An(e,t,n,i){var w,b,N,y,A,v,T;const{strategy:r,value:a}=i,o=(e.text||e.name||((w=e.type)==null?void 0:w.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",d=o.charAt(0).toLowerCase()+o.slice(1),c=((b=e.type)==null?void 0:b.toLowerCase().includes("edit"))||((N=e.type)==null?void 0:N.toLowerCase().includes("input"))||((y=e.type)==null?void 0:y.toLowerCase().includes("field"))||((A=e.type)==null?void 0:A.toLowerCase().includes("textfield")),l=((v=e.attributes)==null?void 0:v.scrollable)==="true"||((T=e.attributes)==null?void 0:T.scrollable)===!0,h=r.toLowerCase().startsWith("-ios")&&t!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
235
- `:r.toLowerCase().startsWith("-android")&&t!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
236
- `:"",m={"accessibility id":`~${a}`,id:t==="ios"?`-ios predicate string:label == "${a}"`:`android=new UiSelector().resourceId("${a}")`,xpath:`${a}`,"-ios predicate string":`-ios predicate string:${a}`,"-ios class chain":`-ios class chain:${a}`,"-android uiautomator":`android=${a}`},g={"accessibility id":`AppiumBy.accessibilityId("${a}")`,id:`AppiumBy.id("${a}")`,xpath:`AppiumBy.xpath("${a}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${a}")`,"-ios class chain":`AppiumBy.iOSClassChain("${a}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${a}")`,"class name":`AppiumBy.className("${a}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${a}"`,id:`AppiumBy.ID, "${a}"`,xpath:`AppiumBy.XPATH, "${a}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${a}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${a}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${a}'`,"class name":`AppiumBy.CLASS_NAME, "${a}"`},p=g[r.toLowerCase()],k=f[r.toLowerCase()],C=m[r.toLowerCase()];return n==="java"?p?`${h}// Appium Java Client 9.x + Selenium 4 + TestNG
237
- import io.appium.java_client.AppiumBy;
238
- import io.appium.java_client.${t==="android"?"AndroidDriver":t==="ios"?"IOSDriver":"AppiumDriver"};
239
- import org.openqa.selenium.WebElement;
240
- import org.testng.annotations.Test;
241
-
242
- @Test
243
- public void test_${d}() {
244
- WebElement element = driver.findElement(${p});
245
- ${l?'((Scrollable) element).scrollTo("target text");':c?`element.clear();
246
- element.sendKeys("your text here");`:"element.click();"}
247
- // Add assertions here via TestNG Assert or Hamcrest
248
- }`:`// Strategy "${r}" not supported in Appium Java Client`:n==="python"?k?`${h}# Appium Python Client 4.x + pytest
249
- from appium.webdriver.common.appiumby import AppiumBy
250
- import pytest
251
-
252
- def test_${d}(self):
253
- element = self.driver.find_element(${k})
254
- ${c?`element.clear()
255
- element.send_keys("your text here")`:"element.click()"}
256
- # Add assertions here via assert or pytest.assert`:`# Strategy "${r}" not supported in Appium Python Client`:n==="javascript"?C?`${h}// WebdriverIO 9.x + @wdio/appium-service
257
- describe('${d} test', () => {
258
- it('should interact with ${d}', async () => {
259
- const element = await $('${C}');
260
- await element.waitForDisplayed({ timeout: 5000 });
261
- ${c?`await element.clearValue();
262
- await element.addValue("your text here");`:"await element.click();"}
263
- // Add assertions here via expect(element)
264
- });
265
- });`:`// Strategy "${r}" not supported in WebdriverIO mobile`:C?`${h}// WebdriverIO 9.x standalone
266
- const element = await driver.$('${C}');
267
- await element.waitForExist({ timeout: 5000 });
268
- ${c?`await driver.$('target').clearValue();
269
- await element.addValue("your text here");`:"await element.click();"}
270
- // Assert with expect(element).toBeDisplayed()`:`// Strategy "${r}" not supported in WebdriverIO mobile`}const Ql={pass:s.jsx(di,{size:13}),warn:s.jsx(Fe,{size:13}),fail:s.jsx(ui,{size:13}),info:s.jsx(ti,{size:13})},ec={pass:"passed",warn:"warning",fail:"failed",info:"note"},tc={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},sc=({sessionId:e,udid:t,streamUrl:n,embedded:i=!1,overlayTarget:r=null,onModeChange:a,deviceActionAt:o=0})=>{var nn,rn,an,on,ln,cn;const[d,c]=u.useState(!0),[l,h]=u.useState(null),[m,g]=u.useState(null),[f,p]=u.useState(null),[k,C]=u.useState(0),R=u.useRef(!1),[w,b]=u.useState(null),[N,y]=u.useState(()=>new Set),[A,v]=u.useState(""),[T,S]=u.useState(null),[E,z]=u.useState("info"),[D,B]=u.useState(0),[K,q]=u.useState(0),[te,X]=u.useState(()=>Date.now()),j=u.useRef(0),O=u.useRef(null),[V,L]=u.useState("java"),[Y,re]=u.useState(null),[H,J]=u.useState({width:0,height:0}),[oe,xe]=u.useState({width:0,height:0}),[$,le]=u.useState(!1),[ee,ne]=u.useState("inspect");u.useEffect(()=>{a==null||a(ee)},[ee,a]);const[ge,de]=u.useState({}),[ke,Ae]=u.useState({}),[We,dt]=u.useState(null),[fe,Re]=u.useState(null),[Ie,_e]=u.useState(null),Qe=u.useRef(null),yt=u.useRef(null),Ve=u.useRef(null),He=u.useRef(null),Ke=u.useRef(null),[xt,ut]=u.useState(()=>Yl(Tn())),[qe,ie]=u.useState(0);u.useEffect(()=>{const x=Ke.current;if(!x||typeof ResizeObserver>"u")return;const M=new ResizeObserver(([I])=>ie(Math.max(0,I.contentRect.width-Jt)));return M.observe(x),()=>M.disconnect()},[]);const ae=Xl(xt,qe),pe=x=>{ut(x),Gl(Tn(),x)},me=u.useCallback(()=>{var De,Le,Xe;if(!Qe.current)return;const x=Qe.current.getBoundingClientRect(),M=x.width,I=x.height,F=(De=l==null?void 0:l.hierarchy)==null?void 0:De.rect;let Z=((Le=l==null?void 0:l.metadata)==null?void 0:Le.screenWidth)||H.width||1,U=((Xe=l==null?void 0:l.metadata)==null?void 0:Xe.screenHeight)||H.height||1;F&&F.width>0&&F.height>0&&(Z=F.width,U=F.height);const ue=Z/U;let Ee,Ne;M/I>ue?(Ne=I,Ee=Ne*ue):(Ee=M,Ne=Ee/ue),xe({width:Ee,height:Ne})},[l,H]);u.useEffect(()=>(me(),window.addEventListener("resize",me),()=>window.removeEventListener("resize",me)),[me]),u.useEffect(()=>{t&&se()},[t]);const je=u.useCallback(async(x,M,I)=>{if(fe!=null&&fe.sessionId){dt(x);try{const F=await G.verifyLocator(fe.basePath,fe.sessionId,{strategy:x,selector:M,action:I});Ae(Z=>({...Z,[x]:F})),I==="tap"&&q(Date.now())}catch(F){Ae(Z=>({...Z,[x]:{found:!1,count:0,error:(F==null?void 0:F.message)||String(F)}}))}finally{dt(null)}}},[fe]),_=u.useRef(null);u.useEffect(()=>{const x=!!f&&f.xpath===_.current;_.current=(f==null?void 0:f.xpath)??null;const M=(f==null?void 0:f.suggestedLocators)??[];re(I=>{const F=x&&I?M.find(U=>U.strategy===I.strategy):null,Z=M.find(U=>U.strategy==="accessibility id"||U.strategy==="id");return F||Z||M[0]||null}),de({}),Ae({}),_e(null)},[f]);const W=u.useCallback((x,M)=>{if(!(l!=null&&l.hierarchy))return;const I=As(l.hierarchy,x,M);de(F=>({...F,[x]:I})),_e(x)},[l]),se=async()=>{if(!t)return;const x=++j.current,M=()=>x===j.current;c(!0),g(null),G.getAppiumSession(t).then(I=>{M()&&Re({sessionId:(I==null?void 0:I.sessionId)??null,basePath:(I==null?void 0:I.basePath)??""})}).catch(()=>{M()&&Re({sessionId:null,basePath:""})});try{const I=await G.getInspectorSnapshot(t);if(!M())return;if(!(I!=null&&I.hierarchy)){h(null),g((I==null?void 0:I.error)||"Failed to capture snapshot");return}const F=I.udid||t,Z=F===O.current;O.current=F,Cs.unstable_batchedUpdates(()=>{h(I),B(Date.now()),y(Ul(I.hierarchy)),p(U=>{var ue;return U&&Z?((ue=Kt(I.hierarchy,U.xpath))==null?void 0:ue.pop())??null:null}),C(U=>U+1)})}catch(I){if(!M())return;h(null),g(I.message||"Failed to capture snapshot")}finally{M()&&c(!1)}};u.useEffect(()=>{const x=setInterval(()=>X(Date.now()),1e4);return()=>clearInterval(x)},[]);const ce=x=>{const{naturalWidth:M,naturalHeight:I}=x.currentTarget;J({width:M,height:I})},Me=()=>le(!0),ht=x=>{le(!1);const{naturalWidth:M,naturalHeight:I}=x.currentTarget;M>0&&I>0&&J({width:M,height:I})},et=n&&!$,bt=x=>{if(ee!=="interact"||!t)return;const M=x.currentTarget.getBoundingClientRect();He.current={x:x.clientX-M.left,y:x.clientY-M.top,time:Date.now()}},jt=async x=>{var un,hn,mn;if(ee!=="interact"||!t||!He.current)return;const M=He.current,I=x.currentTarget.getBoundingClientRect(),F=x.clientX-I.left,Z=x.clientY-I.top,U=Date.now()-M.time,ue=oe.width,Ee=oe.height,Ne=(un=l==null?void 0:l.hierarchy)==null?void 0:un.rect;let De=((hn=l==null?void 0:l.metadata)==null?void 0:hn.screenWidth)||H.width,Le=((mn=l==null?void 0:l.metadata)==null?void 0:mn.screenHeight)||H.height;if(Ne&&Ne.width>0&&Ne.height>0&&(De=Ne.width,Le=Ne.height),!De||!Le||ue===0||Ee===0)return;const Xe=(Lt,fn)=>({x:Math.round(Lt/ue*De),y:Math.round(fn/Ee*Le),px:Lt/ue,py:fn/Ee}),Se=Xe(M.x,M.y),dn=Xe(F,Z),us=Math.sqrt(Math.pow(F-M.x,2)+Math.pow(Z-M.y,2));if(!(Se.px<0||Se.px>1||Se.py<0||Se.py>1)){try{U<500&&us<10?await G.tap(t,Se.x,Se.y):U>=500&&us<10?await G.touchAndHold(t,Se.x,Se.y,U):us>=10&&await G.swipe(t,Se.x,Se.y,dn.x,dn.y),q(Date.now())}catch(Lt){console.error("Interaction failed:",Lt)}He.current=null}},rs=x=>{y(M=>{const I=new Set(M);return I.has(x)?I.delete(x):I.add(x),I})},pr=()=>{const x=new Set,M=I=>{var F;x.add(I.xpath),(F=I.children)==null||F.forEach(M)};l!=null&&l.hierarchy&&M(l.hierarchy),y(x)},gr=()=>y(new Set),Gs=(x,M)=>{navigator.clipboard.writeText(x),S(M),setTimeout(()=>S(null),2e3)},Js=x=>{var I;let M=1;return(I=x.children)==null||I.forEach(F=>M+=Js(F)),M},vr=x=>{if(!x)return[];const M={},I=F=>{var U;const Z=Ri(F);M[Z.role]||(M[Z.role]={key:Z.key,count:0}),M[Z.role].count+=1,(U=F.children)==null||U.forEach(I)};return I(x),Object.entries(M).map(([F,Z])=>({role:F,key:Z.key,count:Z.count})).sort((F,Z)=>Z.count-F.count)},yr=u.useMemo(()=>Pl(l==null?void 0:l.hierarchy,N,A),[l,N,A]),It=u.useMemo(()=>_i(l==null?void 0:l.hierarchy,A),[l,A]),Zs=It.size===0?"No matches":It.size===1?"1 match":`${It.size} matches`;u.useEffect(()=>{if(!f||!(l!=null&&l.hierarchy))return;const x=Kt(l.hierarchy,f.xpath);!x||x.length<2||y(M=>{const I=x.slice(0,-1).filter(Z=>!M.has(Z.xpath));if(!I.length)return M;const F=new Set(M);return I.forEach(Z=>F.add(Z.xpath)),F})},[k]),u.useEffect(()=>{R.current=!1});const as=x=>{p(x),C(M=>M+1),z("info")},xr=x=>{R.current=!0,as(x)},Qs=x=>{A.trim()&&!x.trim()&&C(M=>M+1),v(x)},os=()=>{var F,Z,U;const x=(F=l==null?void 0:l.hierarchy)==null?void 0:F.rect;if(x&&x.width>0&&x.height>0)return{w:x.width,h:x.height};const M=((Z=l==null?void 0:l.metadata)==null?void 0:Z.screenWidth)||H.width,I=((U=l==null?void 0:l.metadata)==null?void 0:U.screenHeight)||H.height;return M>0&&I>0?{w:M,h:I}:null},en=x=>{const M=os();if(!M)return[];const I=[],{w:F,h:Z}=M,U=(ue,Ee)=>{var De,Le,Xe;const Ne=!ue.children||ue.children.length===0;((De=ue.rect)==null?void 0:De.width)>0&&((Le=ue.rect)==null?void 0:Le.height)>0&&Ne&&I.push(s.jsx("div",{className:"omni-hit-area",style:{left:`${ue.rect.x/F*100}%`,top:`${ue.rect.y/Z*100}%`,width:`${ue.rect.width/F*100}%`,height:`${ue.rect.height/Z*100}%`,zIndex:Ee},onClick:Se=>{Se.stopPropagation(),as(ue)},onMouseEnter:()=>b(ue),onMouseLeave:()=>b(null)},ue.xpath)),(Xe=ue.children)==null||Xe.forEach(Se=>U(Se,Ee+1))};return l!=null&&l.hierarchy&&U(l.hierarchy,1),I},tn=()=>{const x=os();if(!Ie||!x)return[];const M=ge[Ie];if(!M||M.kind!=="matched"||M.nodes.length===0)return[];const{w:I,h:F}=x,Z=M.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return M.nodes.filter(U=>U.rect&&U.rect.width>0&&U.rect.height>0).map((U,ue)=>s.jsx("div",{className:Z,style:{left:`${U.rect.x/I*100}%`,top:`${U.rect.y/F*100}%`,width:`${U.rect.width/I*100}%`,height:`${U.rect.height/F*100}%`}},`match-${Ie}-${ue}`))},_t=(x,M)=>{const I=os();if(!(x!=null&&x.rect)||!I)return null;const{w:F,h:Z}=I;return s.jsx("div",{className:`omni-frame-${M}`,style:{left:`${x.rect.x/F*100}%`,top:`${x.rect.y/Z*100}%`,width:`${x.rect.width/F*100}%`,height:`${x.rect.height/Z*100}%`}})},ls=l!=null&&l.hierarchy?Js(l.hierarchy):0,Dt=f&&(l!=null&&l.hierarchy)?zl(f,l):null,tt=Dt?$l(Dt):null,cs=_l(D,Math.max(o,K)),ds=l!=null&&l.hierarchy&&ee==="inspect"?s.jsxs("div",{className:`omni-overlay${cs?" is-stale":""}`,children:[en(l.hierarchy),tn(),_t(w,"hover"),_t(f,"select")]}):null,br={stable:{icon:s.jsx(Ot,{size:10}),cls:"stable"},moderate:{icon:s.jsx(Fe,{size:10}),cls:"moderate"},fragile:{icon:s.jsx(mt,{size:10}),cls:"fragile"},"very-fragile":{icon:s.jsx(mt,{size:10}),cls:"very-fragile"}},sn=i&&(l!=null&&l.hierarchy)?vr(l.hierarchy):[];return s.jsxs("div",{className:`omni-inspector-container ${i?"omni-embedded":""}`,children:[i&&r&&ds?Cs.createPortal(ds,r):null,s.jsxs("div",{className:"omni-main-content",children:[!i&&s.jsxs("div",{className:"omni-screenshot-panel",children:[s.jsxs("div",{className:"omni-screenshot-header",children:[s.jsxs("div",{className:"omni-header-left",children:[s.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),s.jsxs("div",{className:"omni-mode-toggle",children:[s.jsxs("button",{className:`omni-mode-btn ${ee==="inspect"?"active":""}`,onClick:()=>ne("inspect"),title:"Inspection mode (highlight elements)",children:[s.jsx(yn,{size:12}),s.jsx("span",{children:"Inspect"})]}),s.jsxs("button",{className:`omni-mode-btn ${ee==="interact"?"active":""}`,onClick:()=>ne("interact"),title:"Interaction mode (direct control)",children:[s.jsx(wn,{size:12}),s.jsx("span",{children:"Interact"})]})]})]}),s.jsxs("button",{className:"omni-refresh-btn",onClick:se,disabled:d,children:[s.jsx(Et,{size:12,className:d?"animate-spin":""}),d?"Capturing...":"Refresh"]})]}),s.jsxs("div",{className:"omni-screenshot-container",ref:Qe,children:[d&&!et&&s.jsxs("div",{className:"omni-loading-overlay",children:[s.jsx("div",{className:"omni-spinner"}),s.jsx("span",{children:"Capturing screen..."})]}),!l&&!d&&!et&&s.jsxs("div",{className:"omni-empty-state",children:[s.jsx(ms,{size:40}),s.jsx("span",{children:"Click Refresh to capture"})]}),et&&s.jsxs("div",{className:`omni-screenshot-wrapper ${ee==="interact"?"interactable":""}`,onMouseDown:bt,onMouseUp:jt,children:[s.jsx(ni,{ref:Ve,src:n,onLoad:ht,onError:Me,className:"omni-screenshot-img",style:ee==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),ds]}),!et&&(l==null?void 0:l.screenshot)&&s.jsxs("div",{className:`omni-screenshot-wrapper ${ee==="interact"?"interactable":""}`,onMouseDown:bt,onMouseUp:jt,children:[s.jsx("img",{ref:yt,src:`data:image/png;base64,${l.screenshot}`,onLoad:ce,className:"omni-screenshot-img",style:ee==="interact"?{pointerEvents:"none"}:{},draggable:!1}),ee==="inspect"&&s.jsxs("div",{className:`omni-overlay${cs?" is-stale":""}`,children:[en(l.hierarchy),tn(),_t(w,"hover"),_t(f,"select")]})]})]})]}),s.jsxs("div",{className:"omni-split",ref:Ke,children:[s.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${ae*100}% - ${ae*Jt}px)`},children:[s.jsxs("div",{className:"omni-tree-header",children:[s.jsxs("div",{className:"omni-tree-title",children:[s.jsx(li,{size:14}),s.jsx("span",{children:"Source"})]}),s.jsxs("div",{className:"omni-tree-actions",children:[s.jsx("button",{onClick:pr,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:s.jsx(xa,{size:12})}),s.jsx("button",{onClick:gr,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:s.jsx(va,{size:12})}),i&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>ne(ee==="inspect"?"interact":"inspect"),className:`omni-action-btn ${ee==="inspect"?"active":""}`,title:ee==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":ee==="inspect"?"Inspect mode":"Interact mode","aria-pressed":ee==="inspect",children:ee==="inspect"?s.jsx(yn,{size:12}):s.jsx(wn,{size:12})}),s.jsx("button",{onClick:se,className:"omni-action-btn",title:d?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:d,children:s.jsx(Et,{size:12,className:d?"animate-spin":""})})]})]})]}),m&&!d&&s.jsxs("div",{className:"omni-tree-error",role:"alert",children:[s.jsx(mt,{size:12}),s.jsx("span",{children:m}),s.jsx("button",{type:"button",onClick:se,className:"omni-tree-error-retry",children:"Retry"})]}),l&&!d&&!m&&(cs?s.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[s.jsx(Fe,{size:12,"aria-hidden":"true"}),s.jsx("span",{children:"The screen may have changed since this capture."}),s.jsx("button",{type:"button",onClick:se,className:"omni-capture-refresh",children:"Refresh"})]}):s.jsxs("div",{className:"omni-capture-meta",children:[s.jsxs("span",{children:[ls," ",ls===1?"element":"elements"]}),l.hierarchySource&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"omni-capture-source",title:l.hierarchySource==="appium-session"?`From Appium session ${l.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:l.hierarchySource==="appium-session"?"Session":"Device"})]}),s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{children:Il(D,te)})]})),s.jsxs("div",{className:"omni-tree-search",children:[s.jsx(Os,{size:14}),s.jsx("input",{type:"text",placeholder:"Search elements",value:A,onChange:x=>Qs(x.target.value),"aria-label":"Search elements"}),A&&s.jsx("button",{onClick:()=>Qs(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),s.jsx("div",{role:"status",className:"sr-only",children:A.trim()?Zs:""}),A.trim()&&s.jsxs("div",{className:"omni-search-hint",children:[Zs," · try a role: button, input, image"]}),s.jsx("div",{className:"omni-tree-content",children:l!=null&&l.hierarchy?s.jsx(Vl,{rows:yr,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(w==null?void 0:w.xpath)??null,matches:It,onToggle:rs,onSelect:as,onHover:b,revealSeq:k}):s.jsx("div",{className:"omni-empty-state small",children:s.jsx("span",{children:"No hierarchy loaded"})})})]}),s.jsx(Zl,{share:ae,limits:Li(qe),containerRef:Ke,onChange:ut,onCommit:pe,onReset:()=>pe(Gt)}),s.jsxs("div",{className:"omni-details-panel",children:[s.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[s.jsxs("button",{className:`omni-details-tab ${E==="info"?"active":""}`,onClick:()=>z("info"),role:"tab","aria-selected":E==="info",children:[s.jsx(Pa,{size:12})," ",s.jsx("span",{children:"Info"})]}),s.jsxs("button",{className:`omni-details-tab ${E==="checks"?"active":""}`,onClick:()=>z("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":E==="checks",children:[s.jsx(Hr,{size:12})," ",s.jsx("span",{children:"Checks"})]}),s.jsxs("button",{className:`omni-details-tab ${E==="code"?"active":""}`,onClick:()=>z("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":E==="code",children:[s.jsx(jn,{size:12})," ",s.jsx("span",{children:"Code gen"})]})]}),s.jsx("div",{className:"omni-details-content",children:f?s.jsxs(s.Fragment,{children:[E==="info"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Element info"}),s.jsxs("div",{className:"omni-info-table",children:[s.jsxs("div",{className:"omni-info-row",children:[s.jsx("span",{className:"omni-info-key",children:"Type"}),s.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&s.jsxs("div",{className:"omni-info-row",children:[s.jsx("span",{className:"omni-info-key",children:"Text"}),s.jsx("span",{className:"omni-info-value",children:f.text})]}),s.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[s.jsx("span",{className:"omni-info-key",children:"Path"}),s.jsx(Hl,{path:(l==null?void 0:l.hierarchy)&&Kt(l.hierarchy,f.xpath)||[f],onSelect:xr,focusCurrent:R.current},f.xpath)]})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Layout"}),s.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(x=>s.jsxs("div",{className:"omni-layout-item",children:[s.jsx("span",{className:"omni-layout-label",children:x.toUpperCase()}),s.jsx("span",{className:"omni-layout-value",children:f.rect[x]})]},x))})]}),s.jsxs("div",{className:"omni-section",children:[s.jsxs("div",{className:"omni-section-header",children:["Locators",s.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(fe!=null&&fe.sessionId)&&((an=f.suggestedLocators)==null?void 0:an.length)>0&&s.jsxs("p",{className:"omni-locators-note",children:[s.jsx(ti,{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."]}),s.jsxs("div",{className:"omni-locators-list",children:[!((on=f.suggestedLocators)!=null&&on.length)&&s.jsx("div",{className:"omni-locators-empty",children:f===(l==null?void 0:l.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."}),(ln=f.suggestedLocators)==null?void 0:ln.map(x=>{const M=Rs(x.strategy,x.value),I=br[M.level],F=ge[x.strategy];let Z=null;return F&&(F.kind==="unsupported"?Z=s.jsxs("span",{className:"omni-match-badge unsupported",title:F.reason||"Cannot evaluate without a real driver",children:[s.jsx(mi,{size:10})," preview unavailable"]}):F.nodes.length===0?Z=s.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[s.jsx(mt,{size:10})," 0 matches"]}):F.nodes.length===1?Z=s.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[s.jsx(Ot,{size:10})," unique"]}):Z=s.jsxs("span",{className:"omni-match-badge multi",title:`${F.nodes.length} elements match — selector is not unique`,children:[s.jsx(Fe,{size:10})," ",F.nodes.length," matches"]})),s.jsx("div",{className:`omni-locator-row ${(Y==null?void 0:Y.strategy)===x.strategy?"selected-for-code":""}`,onClick:()=>re(x),title:"Click to use in Code gen",children:s.jsxs("div",{className:"omni-locator-left",children:[s.jsxs("div",{className:"omni-locator-top",children:[s.jsx("span",{className:"omni-locator-strategy",children:x.strategy}),s.jsxs("span",{className:`omni-stability-badge ${I.cls}`,title:M.reason,children:[I.icon,M.level]}),Z]}),s.jsx("code",{className:"omni-locator-value",children:x.value}),s.jsx("span",{className:"omni-stability-reason",children:M.reason}),(()=>{const U=ke[x.strategy];return U?U.error?s.jsxs("span",{className:"omni-verify-line is-error",children:[s.jsx(mt,{size:10})," Appium error: ",U.error]}):U.found?U.count>1?s.jsxs("span",{className:"omni-verify-line is-warn",children:[s.jsx(Fe,{size:10})," Ambiguous — Appium found"," ",U.count," elements",U.actionError?` · ${U.actionError}`:""]}):s.jsxs("span",{className:"omni-verify-line is-ok",children:[s.jsx(Ot,{size:10})," Appium found 1 element",U.elapsedMs!=null?` in ${U.elapsedMs}ms`:"",U.actionPerformed&&U.actionPerformed!=="none"?` · ${U.actionPerformed} ok`:"",U.actionError?` · action failed: ${U.actionError}`:""]}):s.jsxs("span",{className:"omni-verify-line is-error",children:[s.jsx(mt,{size:10})," Appium found 0 elements"]}):null})(),s.jsxs("div",{className:"omni-locator-actions",children:[s.jsxs(P,{type:"button",variant:Ie===x.strategy?"tonal":"secondary",size:"sm",onClick:U=>{U.stopPropagation(),W(x.strategy,x.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[s.jsx(Ca,{size:12,"aria-hidden":"true"}),"Test"]}),s.jsxs(P,{type:"button",variant:"secondary",size:"sm",disabled:!(fe!=null&&fe.sessionId)||We===x.strategy,onClick:U=>{U.stopPropagation(),je(x.strategy,x.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[We===x.strategy?s.jsx(Et,{size:12,className:"animate-spin","aria-hidden":"true"}):s.jsx(Ot,{size:12,"aria-hidden":"true"}),"Verify"]}),s.jsxs(P,{type:"button",variant:"secondary",size:"sm",disabled:!(fe!=null&&fe.sessionId)||We===x.strategy,onClick:U=>{U.stopPropagation(),je(x.strategy,x.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[s.jsx(ci,{size:12,"aria-hidden":"true"}),"Tap"]}),s.jsxs(P,{type:"button",variant:"secondary",size:"sm",onClick:U=>{U.stopPropagation(),Gs(x.value,x.strategy)},title:"Copy the locator's value","aria-label":T===x.strategy?"Copied":"Copy locator",children:[T===x.strategy?s.jsx(At,{size:12,"aria-hidden":"true"}):s.jsx($e,{size:12,"aria-hidden":"true"}),T===x.strategy?"Copied":"Copy"]})]})]})},x.strategy)})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Attributes"}),s.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([x,M])=>M!=null&&M!=="").map(([x,M])=>s.jsxs("div",{className:"omni-attr-row",children:[s.jsx("span",{className:"omni-attr-key",children:x}),s.jsx("span",{className:"omni-attr-value",children:String(M)})]},x))})]})]}),E==="checks"&&Dt&&tt&&s.jsxs("div",{className:"omni-checks-panel",children:[s.jsxs("p",{className:"omni-checks-summary",children:[s.jsxs("span",{className:"is-pass",children:[s.jsx(di,{size:12,"aria-hidden":"true"})," ",tt.pass," passed"]}),tt.warn>0&&s.jsxs("span",{className:"is-warn",children:[s.jsx(Fe,{size:12,"aria-hidden":"true"})," ",tt.warn," ",tt.warn===1?"warning":"warnings"]}),tt.fail>0&&s.jsxs("span",{className:"is-fail",children:[s.jsx(ui,{size:12,"aria-hidden":"true"})," ",tt.fail," failed"]})]}),s.jsx("ul",{className:"omni-checks-list",children:Dt.map(x=>s.jsxs("li",{className:`omni-check is-${x.status}`,children:[s.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:Ql[x.status]}),s.jsxs("div",{className:"omni-check-body",children:[s.jsxs("div",{className:"omni-check-label",children:[x.label,s.jsxs("span",{className:"sr-only",children:[": ",ec[x.status]]})]}),s.jsx("div",{className:"omni-check-detail",children:x.detail})]})]},x.id))})]}),E==="code"&&s.jsxs("div",{className:"omni-codegen-panel",children:[s.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(x=>s.jsx("button",{className:`omni-fw-btn ${V===x?"active":""}`,onClick:()=>L(x),children:tc[x]},x))}),Y?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"omni-codegen-locator-selector",children:[s.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),s.jsx(ri,{selectSize:"sm",value:Y.strategy,onChange:x=>{var I;const M=(I=f.suggestedLocators)==null?void 0:I.find(F=>F.strategy===x.target.value);M&&re(M)},className:"flex-1",children:(cn=f.suggestedLocators)==null?void 0:cn.map(x=>s.jsxs("option",{value:x.strategy,children:[x.strategy," — ",Rs(x.strategy,x.value).level]},x.strategy))})]}),s.jsxs("div",{className:"omni-codegen-output",children:[s.jsxs("div",{className:"omni-codegen-header",children:[s.jsx("span",{className:"omni-codegen-lang",children:V==="java"?"Java / TestNG":V==="python"?"Python / unittest":V==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),s.jsx("button",{className:"omni-copy-btn",onClick:()=>Gs(An(f,(l==null?void 0:l.platform)==="android"?"android":(l==null?void 0:l.platform)==="ios"?"ios":"unknown",V,Y),"code"),children:T==="code"?s.jsx(At,{size:12}):s.jsx($e,{size:12})})]}),s.jsx("pre",{className:"omni-codegen-pre theme-dark",children:s.jsx("code",{children:An(f,(l==null?void 0:l.platform)==="android"?"android":(l==null?void 0:l.platform)==="ios"?"ios":"unknown",V,Y)})})]})]}):s.jsxs("div",{className:"omni-empty-state small",children:[s.jsx(jn,{size:24}),s.jsx("span",{children:"No locators available for this element"})]})]})]}):l!=null&&l.hierarchy?s.jsxs("div",{className:"omni-summary-panel",children:[s.jsxs("div",{className:"omni-summary-hero",children:[s.jsx(ms,{size:28}),s.jsxs("div",{children:[s.jsx("div",{className:"omni-summary-title",children:"No element selected"}),s.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),s.jsxs("div",{className:"omni-summary-stats",children:[s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),s.jsx("span",{className:"omni-summary-stat__value",children:ls})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),s.jsx("span",{className:"omni-summary-stat__value",children:((nn=l.metadata)==null?void 0:nn.screenWidth)??H.width??"—"})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),s.jsx("span",{className:"omni-summary-stat__value",children:((rn=l.metadata)==null?void 0:rn.screenHeight)??H.height??"—"})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),s.jsx("span",{className:"omni-summary-stat__value",children:l.platform||"—"})]})]})]}),sn.length>0&&s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"By role"}),s.jsx("div",{className:"omni-summary-roles",children:sn.slice(0,8).map(x=>s.jsxs("div",{className:"omni-summary-role",children:[s.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:Mi[x.key]}),s.jsx("span",{className:"omni-summary-role__name",children:x.role}),s.jsx("span",{className:"omni-summary-role__count",children:x.count})]},x.role))})]})]}):s.jsxs("div",{className:"omni-empty-state",children:[s.jsx(ms,{size:32}),s.jsx("span",{children:d?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},Rn=5e3;function nc(e,t=!0){const[n,i]=u.useState("unknown"),r=u.useRef("unknown");return u.useEffect(()=>{if(!e||!t){i("unknown"),r.current="unknown";return}let a=!1,o;const d=h=>{a||h===r.current||(r.current=h,i(h))},c=async()=>{if(!a){if(o&&(clearTimeout(o),o=void 0),typeof document<"u"&&document.visibilityState==="hidden"){o=setTimeout(c,Rn);return}try{const h=await G.getDisplayState(e);d((h==null?void 0:h.state)??"unknown")}catch{}a||(o=setTimeout(c,Rn))}};c();const l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{a=!0,o&&clearTimeout(o),document.removeEventListener("visibilitychange",l)}},[e,t]),n}function ic(e,t){const n=u.useRef(e),i=u.useRef(t);n.current=e,i.current=t,u.useEffect(()=>{const r=()=>n.current(),a=o=>{var d;o.persisted&&((d=i.current)==null||d.call(i))};return window.addEventListener("pagehide",r),window.addEventListener("pageshow",a),()=>{window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",a)}},[])}const rc=/^(INPUT|TEXTAREA|SELECT)$/,Ws=u.createContext(null);function ac(e){const t=u.useContext(Ws),n=u.useRef(e);n.current=e;const i=e!==null;u.useEffect(()=>{if(!(!t||!i))return t.register(()=>{var r;return((r=n.current)==null?void 0:r.call(n))??!1})},[t,i])}function Oi(e){const t=u.useContext(Ws),n=u.useRef(e);return n.current=e,u.useCallback(()=>t?t.close():n.current(),[t])}function oc({labelledBy:e,onClose:t,children:n,style:i,...r}){const a=u.useRef(null),o=u.useRef(t);o.current=t;const d=u.useMemo(()=>{const l=new Set;return{register(h){return l.add(h),()=>{l.delete(h)}},close(){for(const h of Array.from(l))if(h())return;o.current()}}},[]),c=u.useRef(d);return u.useEffect(()=>{const l=a.current;if(!l)return;const h=document.activeElement,m=[];for(let f=l;f.parentElement&&f!==document.body;f=f.parentElement)for(const p of Array.from(f.parentElement.children))p===f||p.hasAttribute("inert")||p.matches("[aria-live], script, style, link, template")||(p.setAttribute("inert",""),m.push(p));l.contains(document.activeElement)||l.focus();const g=f=>{if(f.key!=="Escape"||f.defaultPrevented)return;const p=f.target;rc.test(p.tagName)||p.isContentEditable||(f.preventDefault(),c.current.close())};return l.addEventListener("keydown",g),()=>{l.removeEventListener("keydown",g),m.forEach(f=>f.removeAttribute("inert")),h&&h.isConnected&&h!==document.body&&h.focus()}},[]),s.jsx("div",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":e,tabIndex:-1,style:{outline:"none",...i},...r,children:s.jsx(Ws.Provider,{value:d,children:n})})}const Fi="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Vs(e){var t;try{return(t=navigator.clipboard)!=null&&t.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}const Mn=5e3,lc=500,cc=1e4,dc=10,uc=50;function hc(e,t,n){const i=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[r,a]=u.useState([]),[o,d]=u.useState(!1),[c,l]=u.useState(null),[h,m]=u.useState(!1),g=u.useRef(null),f=u.useRef(0),p=u.useRef(void 0),k=u.useRef(()=>{}),C=u.useRef([]),R=u.useRef(void 0),w=u.useRef(0),b=u.useRef(void 0),N=u.useCallback(()=>{if(C.current.length===0)return;const T=C.current;C.current=[],a(S=>{const E=S.concat(T);return E.length>Mn?E.slice(-Mn):E})},[]),y=u.useCallback(()=>{R.current===void 0&&(R.current=window.setTimeout(()=>{R.current=void 0,N()},uc))},[N]),A=u.useCallback(()=>{C.current=[],a([])},[]);u.useEffect(()=>{if(!t){d(!1),l(null),m(!1);return}l(null),m(!1),f.current=0;const T={cancelled:!1},S=()=>{if(T.cancelled)return;if(f.current>=dc){m(!0);return}const z=Math.min(lc*2**f.current,cc);f.current+=1,p.current=window.setTimeout(E,z)},E=async()=>{if(!T.cancelled)try{const z=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/ticket`,{method:"POST",credentials:"include"});if(T.cancelled)return;if(!z.ok){S();return}const{ticket:D}=await z.json();if(T.cancelled)return;if(!D){S();return}const B=window.location.protocol==="https:"?"wss":"ws",[K,q]=i.split("|"),te=(K?`&levels=${encodeURIComponent(K)}`:"")+(q?`&process=${encodeURIComponent(q)}`:""),X=new WebSocket(`${B}://${window.location.host}/xenon/api/control/${encodeURIComponent(e)}/logcat?ticket=${encodeURIComponent(D)}${te}`);g.current=X,X.onopen=()=>{f.current=0,b.current!==1012&&(C.current=[],a([])),b.current=void 0,d(!0)},X.onmessage=j=>{try{const O=JSON.parse(j.data);C.current.push({...O,seq:w.current++}),y()}catch{}},X.onclose=j=>{if(d(!1),b.current=j.code,N(),j.code===1008){T.cancelled=!0,l(j.reason||"access denied");return}if(j.code===1012){S();return}console.warn(`[logcat] WS closed unexpectedly (code ${j.code}) — retrying`),S()},X.onerror=()=>X.close()}catch{S()}};return k.current=()=>{T.cancelled=!1,f.current=0,l(null),m(!1),E()},E(),()=>{var z;T.cancelled=!0,p.current!==void 0&&window.clearTimeout(p.current),R.current!==void 0&&(window.clearTimeout(R.current),R.current=void 0),N(),(z=g.current)==null||z.close(),g.current=null}},[e,t,i,N,y]);const v=u.useCallback(()=>{k.current()},[]);return{records:r,connected:o,clear:A,deniedReason:c,exhausted:h,retry:v}}const zt=["V","D","I","W","E","F"];function mc(e){const t=[];let n="",i=!1,r=!1;for(const a of e){if(a==='"'){i=!i,r=!0;continue}if(!i&&/\s/.test(a)){(r||n)&&t.push(n),n="",r=!1;continue}n+=a,r=!0}return(r||n)&&t.push(n),t.filter(a=>a.length>0)}function Pi(e,t={}){const n=t.caseSensitive===!0,i=o=>n?o:o.toLowerCase(),r=n?{caseSensitive:!0}:{},a=[];for(const o of mc(e)){const[d,...c]=o.split(":"),l=c.join(":"),h=d.toLowerCase();l&&h==="level"?r.minLevel=l.toUpperCase():l&&h==="tag"?r.tag=i(l):l&&h==="package"?r.pkg=i(l):l&&h==="-tag"?(r.excludeTags=r.excludeTags||[]).push(i(l)):l&&h==="-package"?(r.excludePkgs=r.excludePkgs||[]).push(i(l)):a.push(o)}return a.length&&(r.text=i(a.join(" "))),r}function Ui(e,t){if(e.synthetic)return!0;if(t.minLevel){const i=zt.indexOf(t.minLevel),r=zt.indexOf(e.level);if(i>=0&&r>=0&&r<i)return!1}const n=i=>t.caseSensitive?i:i.toLowerCase();if(t.tag&&!n(e.tag).includes(t.tag)||t.pkg&&!n(e.pkg??"").includes(t.pkg)||t.text&&!n(e.message).includes(t.text))return!1;if(t.excludeTags){const i=n(e.tag);if(t.excludeTags.some(r=>i.includes(r)))return!1}if(t.excludePkgs){const i=n(e.pkg??"");if(i&&t.excludePkgs.some(r=>i.includes(r)))return!1}return!0}function Bi(e){const t=[];let n="",i=!1;for(const r of e){if(r==='"'&&(i=!i),!i&&/\s/.test(r)){n&&t.push(n),n="";continue}n+=r}return n&&t.push(n),t}function Wi(e){const[t,...n]=e.replace(/"/g,"").split(":");return{key:t.toLowerCase(),value:n.join(":")}}function Vi(e){const t=e.split('"').map(n=>n.trim()).reduce((n,i)=>i.length>n.length?i:n,"");return/\s/.test(t)?`"${t}"`:t}function zn(e,t,n){const i=Vi(n);if(!i)return e;const r=`${t}:${i}`,a=[];let o=!1;for(const d of Bi(e)){const c=Wi(d);if(c.key===t&&c.value){o||a.push(r),o=!0;continue}a.push(d)}return o||a.push(r),a.join(" ")}function fc(e,t,n){const i=Vi(n);if(!i)return e;const r=i.replace(/"/g,""),a=Bi(e);return a.some(d=>{const c=Wi(d);return c.key===`-${t}`&&c.value===r})?e:[...a,`-${t}:${i}`].join(" ")}function pc(e,t){const n=e.trim().split(/\s+/).filter(Boolean).filter(i=>{const[r,...a]=i.split(":");return!(a.join(":")&&r.toLowerCase()==="level")});return t?["level:"+t.toUpperCase(),...n].join(" "):n.join(" ")}const vs=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],$n=["V","D","I","W","E","F"];function gc(e){if(!e)return vs.filter(n=>n.ios!=="Debug").map(n=>n.ios);const t=$n.indexOf(e.toUpperCase());return t<0?vs.map(n=>n.ios):vs.filter(n=>$n.indexOf(n.android)>=t).map(n=>n.ios)}function vc(e){const t=Pi(e,{caseSensitive:!0});return{levels:gc(t.minLevel),process:t.pkg||void 0}}const In=zt,yc={V:"Verbose",D:"Debug",I:"Info",W:"Warning",E:"Error",F:"Fatal"};function xc(e,t){const n={V:0,D:0,I:0,W:0,E:0,F:0},i={...t,minLevel:void 0};for(let r=0;r<e.length;r++){const a=e[r];a.synthetic||Object.prototype.hasOwnProperty.call(n,a.level)&&Ui(a,i)&&(n[a.level]+=1)}return n}function bc(e,t,n){return(e==="ios"?["D","I","E","F"]:t.F>0||(n||"").toUpperCase()==="F"?["V","D","I","W","E","F"]:["V","D","I","W","E"]).map(r=>({level:r,name:Hi(r,e)}))}function jc(e,t){if(!t)return null;const n=In.indexOf(t.toUpperCase());if(n<0)return null;const i=e.find(r=>In.indexOf(r.level)>=n);return i?i.level:null}function Hi(e,t){return e==="F"?t==="ios"?"Fault":"Fatal":yc[e]??e}const Ms=5e5;function Zt(e){return`${new Date(e.ts).toISOString()} ${e.pid} ${e.level}/${e.tag}: ${e.message}`}function wc(e){return{lines:[],startedAt:e,dropped:0}}function kc(e,t){for(const n of t){if(e.lines.length>=Ms){e.dropped+=1;continue}e.lines.push(Zt(n))}return e}function Sc(e,t,n){const i=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(e.startedAt).toISOString()}`,`# stopped: ${new Date(t).toISOString()}`,`# duration: ${((t-e.startedAt)/1e3).toFixed(1)}s`,`# lines: ${e.lines.length}`];e.dropped>0&&i.push(`# TRUNCATED: ${e.dropped} further line(s) were dropped after the ${Ms}-line cap. This capture is INCOMPLETE.`);const r=e.lines.join(`
271
- `),a=e.dropped>0?`
272
- # --- TRUNCATED: ${e.dropped} line(s) not captured (cap ${Ms}) ---`:"";return`${i.join(`
273
- `)}
274
-
275
- ${r}${a}
276
- `}function Cc(e,t){const n=new Date(t).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${e}-${n}.txt`}const ys={selected:new Set,anchor:null,active:null};function Ki(e,t,n){const i=e.indexOf(t),r=e.indexOf(n);return i<0||r<0?null:e.slice(Math.min(i,r),Math.max(i,r)+1)}function qi(e){return{selected:new Set([e]),anchor:e,active:e}}function Nc(e,t,n,i){if(i.range&&e.anchor!==null){const r=Ki(n,e.anchor,t);if(r)return{selected:new Set(r),anchor:e.anchor,active:t}}if(i.toggle){const r=new Set(Array.from(e.selected));return r.has(t)?r.delete(t):r.add(t),{selected:r,anchor:t,active:t}}return qi(t)}function Ec(e,t,n,i){if(!t.length)return e;const r=e.active===null?-1:t.indexOf(e.active),a=r<0?n===1?0:t.length-1:Math.max(0,Math.min(t.length-1,r+n)),o=t[a];if(!i)return qi(o);const d=e.anchor!==null&&t.indexOf(e.anchor)>=0?e.anchor:e.active??o,c=Ki(t,d,o)??[o];return{selected:new Set(c),anchor:d,active:o}}function Tc(e,t){const n=[];if(t.size)for(let i=0;i<e.length;i++)t.has(e[i].seq)&&n.push(Zt(e[i]));return{text:n.join(`
277
- `),count:n.length}}const Xi=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"});function Ge(e){return e.toLocaleString("en-US")}function Ac(e){return Xi.format(e)}function Rc(e){const t=(Math.floor(e)%1e3+1e3)%1e3;return`${Xi.format(e)}.${String(t).padStart(3,"0")}`}const Mc=[["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 zc(e){const t=u.useRef(null),n=u.useRef(null),i=u.useRef(null),[r,a]=u.useState(!1),[o,d]=u.useState(!1);u.useEffect(()=>{var m,g;o&&((g=(m=i.current)==null?void 0:m.querySelector('[role^="menuitem"]:not(:disabled)'))==null||g.focus())},[o]);const c=()=>{var m;d(!1),(m=n.current)==null||m.focus()},l=m=>()=>{c(),m()},h=e.status==="Offline"||e.status==="Denied";return s.jsxs("div",{className:"log-toolbar",children:[s.jsxs("div",{className:"log-status",role:"status",title:e.statusDetail??void 0,children:[s.jsx("span",{className:`log-live-dot${e.status==="Live"?" active":""}${h?" is-error":""}`,"aria-hidden":"true"}),e.status]}),s.jsxs("div",{className:"log-filter",children:[s.jsx(xn,{ref:e.filterRef,type:"text",className:"log-field log-filter-input",placeholder:"tag:Wifi package:com.example text",value:e.query,onChange:m=>e.onQueryChange(m.target.value),"aria-label":"Filter logs",spellCheck:!1,autoComplete:"off"}),s.jsxs("span",{className:"log-field-buttons",children:[e.query&&s.jsx("button",{type:"button",className:"log-field-btn",onClick:()=>e.onQueryChange(""),"aria-label":"Clear filter",title:"Clear filter",children:s.jsx(Ls,{size:12,"aria-hidden":"true"})}),s.jsx("button",{ref:t,type:"button",className:"log-field-btn",onClick:()=>a(m=>!m),"aria-label":"Filter syntax","aria-haspopup":"dialog","aria-expanded":r,title:"Filter syntax",children:s.jsx(mi,{size:13,"aria-hidden":"true"})})]}),s.jsx(qt,{open:r,onClose:()=>a(!1),anchorRef:t,placement:"bottom-start",children:s.jsxs("div",{className:"log-syntax",children:[s.jsxs("p",{children:["Terms are combined. Quote a value with spaces: ",s.jsx("code",{children:'package:"Food Truck"'}),"."]}),s.jsx("dl",{children:Mc.map(([m,g])=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:m})}),s.jsx("dd",{children:g})]},m))}),s.jsx("p",{children:"Other words search the message."})]})})]}),s.jsxs("div",{className:"log-find",children:[s.jsx(xn,{ref:e.findRef,type:"text",className:"log-field log-find-input",placeholder:"Find",value:e.find,onChange:m=>e.onFindChange(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),e.onStep(m.shiftKey?-1:1))},"aria-label":"Find in logs",spellCheck:!1,autoComplete:"off"}),e.find&&s.jsx("span",{className:"log-find-count","aria-live":"polite",children:e.hitCount?`${e.activeHit+1}/${e.hitCount}`:"0/0"})]}),s.jsx(P,{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:s.jsx(Us,{size:14,"aria-hidden":"true"})}),s.jsx(P,{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:s.jsx(Ps,{size:14,"aria-hidden":"true"})}),s.jsx("span",{className:"log-toolbar-divider","aria-hidden":"true"}),s.jsxs("div",{className:"log-actions",children:[s.jsxs(P,{type:"button",variant:"secondary",size:"sm",onClick:e.onTogglePause,children:[e.following?s.jsx(Xr,{size:13,"aria-hidden":"true"}):s.jsx(Yr,{size:13,"aria-hidden":"true"}),e.following?"Pause":"Resume"]}),s.jsxs(P,{type:"button",variant:"secondary",size:"sm",className:`log-record${e.recording?" is-recording":""}`,onClick:e.onToggleRecording,"aria-pressed":e.recording,children:[e.recording?s.jsx(ii,{size:12,"aria-hidden":"true"}):s.jsx(_r,{size:12,"aria-hidden":"true"}),e.recording?`Stop · ${Ge(e.recordedLines)} lines`:"Record"]}),s.jsx(P,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:e.onExport,"aria-label":"Export shown lines",title:"Export shown lines",children:s.jsx(hi,{size:14,"aria-hidden":"true"})}),s.jsx(P,{ref:n,type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>d(m=>!m),"aria-label":"More options","aria-haspopup":"menu","aria-expanded":o,title:"More options",children:s.jsx(fi,{size:14,"aria-hidden":"true"})}),s.jsx(qt,{open:o,onClose:c,anchorRef:n,placement:"bottom-end",children:s.jsx("div",{ref:i,children:s.jsxs(Fs,{children:[s.jsx(be,{checkbox:!0,checked:e.caseSensitive,onClick:l(e.onToggleCase),children:"Match case"}),s.jsx(be,{checkbox:!0,checked:e.wrap,onClick:l(e.onToggleWrap),children:"Wrap long lines"}),s.jsx(ai,{}),e.canCopySelected&&s.jsx(be,{onClick:l(e.onCopySelected),children:"Copy selected lines"}),s.jsx(be,{onClick:l(e.onClearLines),children:"Clear lines"})]})})})]})]})}function $c({platform:e,counts:t,minLevel:n,shown:i,total:r,onChoose:a}){const o=bc(e,t,n),d=jc(o,n),c=d===null?-1:zt.indexOf(d);return s.jsxs("div",{className:"log-levels",children:[s.jsxs("div",{className:"log-level-buttons",role:"group","aria-label":"Log levels",children:[s.jsx(P,{type:"button",variant:"ghost",size:"sm",className:"log-level-btn","aria-label":"All levels","aria-pressed":d===null,onClick:()=>a(""),children:"All"}),o.map(({level:l,name:h})=>{const m=t[l],f=`${h} ${l==="F"?"only":"and above"}, ${Ge(m)} ${h.toLowerCase()} line${m===1?"":"s"}`,p=c>=0&&zt.indexOf(l)>=c;return s.jsxs(P,{type:"button",variant:"ghost",size:"sm",className:`log-level-btn lvl-${l}${p?" is-included":""}${m?" has-lines":""}`,"aria-label":f,"aria-pressed":d===l,onClick:()=>a(d===l?"":l),children:[h,s.jsx("span",{className:"log-level-count",children:Ge(m)})]},l)})]}),s.jsxs("span",{className:"log-shown",children:[Ge(i)," of ",Ge(r)," shown"]})]})}function Ic(e){return typeof e=="object"?e.key:e}function _c(e,t){const n=e.length;return new Proxy(e,{get(i,r,a){if(typeof r=="string"){const o=r.charCodeAt(0);if(o>=48&&o<=57){const d=+r;if(Number.isInteger(d)&&d>=0&&d<n){let c=i[d];if(typeof c!="object"){const l=t[d*2];c=i[d]={index:d,key:c,start:l,size:t[d*2+1],end:l+t[d*2+1],lane:0}}return c}}if(r==="length")return n}return Reflect.get(i,r,a)}})}function pt(e,t,n){let i=n.initialDeps??[],r,a=!0;function o(){const d=e();return(d.length!==i.length||d.some((l,h)=>i[h]!==l))&&(i=d,r=t(...d),n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(r),a=!1),r}return o.updateDeps=d=>{i=d},o}function _n(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Dn=(e,t)=>Math.abs(e-t)<1.01,Dc=(e,t,n)=>{let i;return Object.assign(function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),n)},{cancel:()=>{e.clearTimeout(i)}})};let kt;const xs=()=>{if(kt!==void 0)return kt;if(typeof navigator>"u")return kt=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return kt=!0;const e=navigator.maxTouchPoints;return kt=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Ln=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Lc=e=>e,Yi=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(i);for(let a=0;a<i;a++)r[a]=t+a;return r},Oc=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const r=o=>{const{width:d,height:c}=o;t({width:Math.round(d),height:Math.round(c)})};if(r(Ln(n)),!i.ResizeObserver)return()=>{};const a=new i.ResizeObserver(o=>{const d=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const l=c.borderBoxSize[0];if(l){r({width:l.inlineSize,height:l.blockSize});return}}r(Ln(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(d):d()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},Qt={passive:!0},Fc=typeof window>"u"?!0:"onscrollend"in window,Pc=(e,t,n)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&Fc;let o=0;const d=a?null:Dc(r,()=>t(n(i),!1),e.options.isScrollingResetDelay),c=m=>()=>{o=n(i),d==null||d(),t(o,m)},l=c(!0),h=c(!1);return i.addEventListener("scroll",l,Qt),a&&i.addEventListener("scrollend",h,Qt),()=>{i.removeEventListener("scroll",l),a&&i.removeEventListener("scrollend",h),d==null||d.cancel()}},Uc=(e,t)=>Pc(e,t,n=>{const{horizontal:i,isRtl:r}=e.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),Bc=(e,t,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(e),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const i=n.indexFromElement(e),r=n.options.getItemKey(i),a=n.itemSizeCache.get(r);if(a!==void 0)return a}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Wc=(e,{adjustments:t=0,behavior:n},i)=>{var r,a;(a=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[i.options.horizontal?"left":"top"]:e+t,behavior:n})},Gi=Wc;function Vc(e,t,n,i){if(t===0)return!1;const r=i(0),a=new Set;let o=0;for(;o<e;){const c=n(o);if(c===r)break;a.add(c),o++}const d=e-o;if(d===0||d>=t)return!1;for(let c=0;c<d;c++)if(i(c)!==n(o+c))return!1;for(let c=d;c<t;c++)if(a.has(i(c)))return!1;return!0}class Hc{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const o=()=>{const d=a.target,c=this.indexFromElement(d);if(!d.isConnected){this.observer.unobserve(d);for(const[l,h]of this.elementsCache)if(h===d){this.elementsCache.delete(l);break}return}this.isIndexInRange(c)&&this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(d,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var a;return(a=i())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=i())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var i;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Lc,rangeExtractor:Yi,onChange:()=>{},measureElement:Bc,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in n){const g=n[m];g!==void 0&&(r[m]=g)}const a=this.options;let o=null,d=null,c=!1;if(a!==void 0&&a.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,g=r.count,f=this.getMeasurements(),p=((i=this._singleLaneMeasurements)==null?void 0:i.items)??f,k=N=>Ic(p[N]),C=m>0?k(0):null,R=m>0?k(m-1):null;if(g!==m||m>0&&g>0&&(r.getItemKey(0)!==C||r.getItemKey(g-1)!==R)){c=!0;const N=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;N&&(o=[N.key,this.getScrollOffset()-N.start]);const y=r.followOnAppend===!0?"auto":r.followOnAppend||null;y&&g>0&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||r.getItemKey(g-1)!==R)&&(g>m||Vc(m,g,k,r.getItemKey))&&(d=y)}}this.options=r,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,h=0;if(o&&this.scrollOffset!==null){const[m,g]=o,f=this.getMeasurements(),{count:p,getItemKey:k}=this.options;let C=0;for(;C<p&&k(C)!==m;)C++;if(C<p){const R=f[C];if(R){const w=Math.max(0,R.start+g);!d&&w!==this.scrollOffset&&(h=w-this.scrollOffset,this.scrollOffset=w,l=!0)}}}(l||d)&&(this.pendingScrollAnchor=[l?o[0]:null,l?o[1]:0,d,h])},this.notify=n=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=pt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n,i;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,d)=>{if(d&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(o-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=d?c===o?this.scrollDirection:c<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=d,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,d=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!xs()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",d,Qt),o.addEventListener("touchend",c,Qt),this.unsubs.push(()=>{o.removeEventListener("touchstart",d),o.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const a=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,a&&this.scrollElement&&this.options.enabled){const[o,d,c,l]=a;o!==null&&!c&&(xs()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((i=this.scrollState)==null?void 0:i.behavior)==="smooth"&&!Dn(this.getScrollOffset()-l,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;const{target:n,maxAtWrite:i}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>i+.5&&(this._clampedAdjustment=n>r+.5?{target:n,maxAtWrite:r}:null,this._scrollToOffset(n,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),i=this.getMaxScrollOffset();if(n<0||n>i)return;if(this._iosDeferredAdjustment<0&&n>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=pt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,i,r,a,o,d,c,l)=>(this.prevLanes!==void 0&&this.prevLanes!==d&&(this.lanesChangedFlag=!0),this.prevLanes=d,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:a,enabled:o,lanes:d,laneAssignmentMode:c,gap:l}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=pt(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:a,enabled:o,lanes:d,laneAssignmentMode:c,gap:l},h)=>{var m;const g=this.itemSizeCache;if(!o)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const w of this.laneAssignments.keys())w>=n&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),d===1){const w=n*2;let b=(m=this._singleLaneMeasurements)==null?void 0:m.flat;if(!b||b.length<w){const v=new Float64Array(w);b&&f>0&&v.set(b.subarray(0,f*2)),b=v}const N=f===0?new Array(n):this._singleLaneMeasurements.items.slice();let y;if(f===0)y=i+r;else{const v=f-1;y=b[v*2]+b[v*2+1]+l}for(let v=f;v<n;v++){const T=a(v);N[v]=T;const S=g.get(T),E=typeof S=="number"?S:this.options.estimateSize(v);b[v*2]=y,b[v*2+1]=E,y+=E+l}this._singleLaneMeasurements={flat:b,items:N};const A=_c(N,b);return this.measurementsCache=A,A}const p=this.measurementsCache.slice(0,f),k=new Array(d).fill(void 0),C=new Float64Array(d);let R=0;for(let w=0;w<f;w++){const b=p[w];b&&(k[b.lane]===void 0&&R++,k[b.lane]=w,C[b.lane]=b.end)}for(let w=f;w<n;w++){const b=a(w),N=this.laneAssignments.get(w);let y,A;const v=c==="estimate"||g.has(b);if(N!==void 0&&this.options.lanes>1){y=N;const z=k[y],D=z!==void 0?p[z]:void 0;A=D?D.end+l:i+r}else if(R===d){let z=0,D=C[0],B=k[0];for(let K=1;K<d;K++){const q=C[K];(q<D||q===D&&k[K]<B)&&(z=K,D=q,B=k[K])}y=z,A=D+l,v&&this.laneAssignments.set(w,y)}else y=w%this.options.lanes,A=i+r,v&&this.laneAssignments.set(w,y);const T=g.get(b),S=typeof T=="number"?T:this.options.estimateSize(w),E=A+S;p[w]={index:w,start:A,size:S,end:E,key:b,lane:y},k[y]===void 0&&R++,k[y]=w,C[y]=E}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=pt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,a)=>n.length===0||i===0?(this.range=null,null):(this.range=qc(n,i,r,a,a===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=pt(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,a,o)=>a===null||o===null?[]:n({startIndex:a,endIndex:o,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-a),d=Math.min(this.options.count-1,r+a);return n>=o&&n<=d}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,d)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(d))});return}const i=this.indexFromElement(n);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),a=this.elementsCache.get(r);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,a,o;if(!this.isIndexInRange(n))return;let d,c,l;const h=(r=this._singleLaneMeasurements)==null?void 0:r.flat;if(this.options.lanes===1&&h!=null)l=this.options.getItemKey(n),c=h[n*2],d=h[n*2+1];else{const f=this.measurementsCache[n];if(!f)return;l=f.key,c=f.start,d=f.size}const m=this.itemSizeCache.get(l)??d,g=i-m;if(g!==0){const f=this.options.anchorTo==="end"&&((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=f?this.getTotalSize():0,k=this.getScrollOffset()+this.scrollAdjustments,R=!this.itemSizeCache.has(l)?c<k:c+m<=k&&this.scrollDirection!=="backward",w=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:l,start:c,size:d,end:c+d,lane:0},g,this):R);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(l,i),this.itemSizeCacheVersion++;let b=!1;f?b=this.applyScrollAdjustment(this.getTotalSize()-p):w&&(b=this.applyScrollAdjustment(g)),this.notify(b),this._retryClampedAdjustment()}},this.getVirtualItems=pt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let a=0,o=n.length;a<o;a++){const d=n[a],c=i[d];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{var i;const r=this.getMeasurements();if(r.length===0)return;const a=(i=this._singleLaneMeasurements)==null?void 0:i.flat,o=this.options.lanes===1&&a!=null,d=Ji(0,r.length-1,o?c=>a[c*2]:c=>_n(r[c]).start,n);return _n(r[d])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,i,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=n>=o+a?"end":"start"),i==="center"?n+=(r-a)/2:i==="end"&&(n-=a);const d=this.getMaxScrollOffset();return Math.max(Math.min(d,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(i==="auto")if(o.end>=a+r-this.options.scrollPaddingEnd)i="end";else if(o.start<=a+this.options.scrollPaddingStart)i="start";else return[a,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const d=i==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(d,i,o.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const a=this.getOffsetForAlignment(n,i),o=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getOffsetForIndex(n,i);if(!a)return;const[o,d]=a,c=this.now();this.scrollState={index:n,align:d,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,a=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n,i;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,d=(n=this._singleLaneMeasurements)==null?void 0:n.flat;d!=null?a=d[o*2]+d[o*2+1]:a=((i=r[o])==null?void 0:i.end)??0}else{const o=Array(this.options.lanes).fill(null);let d=r.length-1;for(;d>=0&&o.some(c=>c===null);){const c=r[d];o[c.lane]===null&&(o[c.lane]=c.end),d--}a=Math.max(...o.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{behavior:r,adjustments:i},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){if(t===0)return!1;if(xs()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=t,!1;{const i=this.getScrollOffset()+this.scrollAdjustments+t,r=this.scrollElement,a=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=a!==null&&i>a+.5?{target:i,maxAtWrite:a}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,a=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&Dn(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const d=this.getSize()||600,c=Math.abs(r-this.getScrollOffset()),l=this.scrollState.behavior==="smooth"&&c>d;this.scrollState.lastTargetOffset=r,l||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:l?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Ji=(e,t,n,i)=>{for(;e<=t;){const r=(e+t)/2|0,a=n(r);if(a<i)e=r+1;else if(a>i)t=r-1;else return r}return e>0?e-1:0};function Kc(e,t,n){let i=0;for(;i<=t;){const r=(i+t)/2|0,a=e[r*2];if(a<n)i=r+1;else if(a>n)t=r-1;else return r}return i>0?i-1:0}function qc(e,t,n,i,r){const a=e.length-1;if(e.length<=i)return{startIndex:0,endIndex:a};if(i===1&&r!==null){const l=Kc(r,a,n);let h=l;const m=n+t;for(;h<a&&r[h*2]+r[h*2+1]<m;)h++;return{startIndex:l,endIndex:h}}let d=Ji(0,a,l=>e[l].start,n),c=d;if(i===1)for(;c<a&&e[c].end<n+t;)c++;else if(i>1){const l=Array(i).fill(0);for(;c<a&&l.some(m=>m<n+t);){const m=e[c];l[m.lane]=m.end,c++}const h=Array(i).fill(n+t);for(;d>=0&&h.some(m=>m>=n);){const m=e[d];h[m.lane]=m.start,d--}d=Math.max(0,d-d%i),c=Math.min(a,c+(i-1-c%i))}return{startIndex:d,endIndex:c}}const bs=typeof document<"u"?u.useLayoutEffect:u.useEffect;function Xc({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...i}){const r=u.useReducer(m=>m+1,0)[1],a=u.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;const o=u.useRef(!1),d=m=>{const g=a.current;if(!g.enabled||!g.container)return;const f=m.getTotalSize();if(f!==g.lastSize){g.lastSize=f;const p=m.options.horizontal?"width":"height";g.container.style[p]=`${f}px`}},c=m=>{const g=a.current;if(!g.enabled||!g.container)return;d(m);const f=!!m.options.horizontal,p=g.mode==="transform",k=f?"left":"top",C=m.options.scrollMargin,R=m.getVirtualItems();for(const w of R){const b=w.start-C,N=m.elementsCache.get(w.key);N&&g.lastPositions.get(N)!==b&&(g.lastPositions.set(N,b),p?N.style.transform=f?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:N.style[k]=`${b}px`)}},l={...i,onChange:(m,g)=>{var f;const p=a.current;let k=!0;if(p.enabled){c(m);const C=m.range,R=p.prevRange;k=!R||R.isScrolling!==m.isScrolling||R.startIndex!==(C==null?void 0:C.startIndex)||R.endIndex!==(C==null?void 0:C.endIndex),k&&(p.prevRange=C?{startIndex:C.startIndex,endIndex:C.endIndex,isScrolling:m.isScrolling}:null)}k&&(e&&g&&!o.current?Cs.flushSync(r):r()),(f=i.onChange)==null||f.call(i,m,g)}},[h]=u.useState(()=>{const m=new Hc(l),g=m.measureElement;return m.measureElement=f=>{o.current=!0;try{g(f)}finally{o.current=!1}},Object.assign(m,{containerRef:f=>{const p=a.current;if(p.container=f,p.lastSize=null,f&&p.enabled){const k=m.getTotalSize();p.lastSize=k;const C=m.options.horizontal?"width":"height";f.style[C]=`${k}px`}}})});return h.setOptions(l),bs(()=>h._didMount(),[]),bs(()=>(d(h),h._willUpdate())),bs(()=>{c(h)}),h}function Yc(e){return Xc({observeElementRect:Oc,observeElementOffset:Uc,scrollToFn:Gi,...e})}const Gc=/[.*+?^${}()|[\]\\]/g;function Jc(e,t,n){if(!t||!e)return[{text:e,hit:!1}];const i=new RegExp(t.replace(Gc,"\\$&"),n?"g":"gi"),r=[];let a=0,o;for(;(o=i.exec(e))!==null;)o.index>a&&r.push({text:e.slice(a,o.index),hit:!1}),r.push({text:o[0],hit:!0}),a=o.index+o[0].length;return r.length?(a<e.length&&r.push({text:e.slice(a),hit:!1}),r):[{text:e,hit:!1}]}const On=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Zc(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t>>>0}function Qc(e){return e?On[Zc(e)%On.length]:"var(--text-muted)"}function Fn({text:e,find:t,caseSensitive:n}){if(!t)return s.jsx(s.Fragment,{children:e});const i=Jc(e,t,n);return i.length===1&&!i[0].hit?s.jsx(s.Fragment,{children:e}):s.jsx(s.Fragment,{children:i.map((r,a)=>r.hit?s.jsx("mark",{className:"log-mark",children:r.text},a):s.jsx(u.Fragment,{children:r.text},a))})}const ed=u.memo(function({record:t,index:n,setSize:i,start:r,id:a,selected:o,active:d,hit:c,activeHit:l,find:h,caseSensitive:m,measureRef:g}){const f=["log-row",`lvl-${t.level}`,t.synthetic?"is-synthetic":"",c?"is-hit":"",l?"is-active-hit":"",d?"is-active":""].filter(Boolean).join(" ");return s.jsxs("div",{ref:g,role:"option",id:a,"aria-selected":o,"aria-setsize":i,"aria-posinset":n+1,"data-index":n,"data-seq":t.seq,className:f,style:{transform:`translateY(${r}px)`},children:[s.jsx("span",{className:"log-time",children:Ac(t.ts)}),s.jsx("span",{className:"log-badge",children:t.level}),!t.synthetic&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"log-tag",title:t.tag,style:{color:Qc(t.tag)},children:s.jsx(Fn,{text:t.tag,find:h,caseSensitive:m})}),s.jsx("span",{className:"log-pkg",title:t.pkg,children:t.pkg??""})]}),s.jsx("span",{className:"log-msg",children:s.jsx(Fn,{text:t.message,find:h,caseSensitive:m})})]})}),Pn=24,td=1e3,sd=250,nd=20,id=38,Un=720,rd=["PageUp","PageDown","Home"," "];let ad=0;function od(e){const[t,n]=u.useState(!0);return u.useLayoutEffect(()=>{const i=e.current;if(!i)return;n(i.offsetWidth>=Un);const r=window.ResizeObserver;if(!r)return;const a=new r(o=>n(o[0].contentRect.width>=Un));return a.observe(i),()=>a.disconnect()},[e]),t}const ld=u.forwardRef(function(t,n){const{records:i,wrap:r,find:a,caseSensitive:o,hits:d,activeHit:c,following:l,newLines:h}=t,m=u.useRef(null),[g]=u.useState(()=>`log-lines-${++ad}`),f=u.useRef(null),p=u.useRef(l);p.current=l;const k=u.useRef(t);k.current=t;const C=od(m),R=t.selection.active,w=u.useMemo(()=>R===null?-1:i.findIndex(j=>j.seq===R),[i,R]),b=Yc({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>C?nd:id,getItemKey:j=>i[j].seq,overscan:10,rangeExtractor:j=>{const O=Yi(j);return w>=0&&O.indexOf(w)<0&&(O.push(w),O.sort((V,L)=>V-L)),O},anchorTo:l?"start":"end",scrollToFn:(j,O,V)=>{const L=V.scrollElement,Y=j+(O.adjustments??0);f.current=L?Math.max(0,Math.min(Y,L.scrollHeight-L.clientHeight)):Y,Gi(j,O,V)}}),N=u.useRef(`${r}|${C}`);u.useLayoutEffect(()=>{var O;const j=`${r}|${C}`;N.current!==j&&(N.current=j,b.measure(),(O=m.current)==null||O.querySelectorAll("[data-index]").forEach(V=>b.measureElement(V)))},[r,C,b]);const y=b.getTotalSize(),A=i.length?i[i.length-1].seq:-1,v=u.useRef(i);v.current=i;const T=u.useRef(null),[S,E]=u.useState(!1),z=u.useRef(()=>{});z.current=()=>{const j=m.current,O=v.current,V=j&&O.length?b.getVirtualItemForOffset(j.scrollTop):void 0;T.current=V&&O[V.index]?O[V.index].seq:null},u.useLayoutEffect(()=>{const j=T.current,O=t.oldestSeq;!p.current&&j!==null&&O!==null&&j<O&&(E(!0),b.scrollToOffset(0)),z.current()},[i,t.oldestSeq,b]),u.useEffect(()=>{l&&E(!1)},[l]);const D=u.useRef(0),B=u.useRef(!1);u.useLayoutEffect(()=>{!l||!i.length||B.current||Date.now()-D.current<sd||b.scrollToOffset(y)},[l,A,i.length,y,b]),u.useEffect(()=>{const j=m.current;if(!j)return;let O=j.scrollTop;const V=()=>{D.current=Date.now()},L=oe=>{oe.target===j&&(B.current=!0,V())},Y=()=>{B.current&&V(),B.current=!1},re=oe=>{rd.indexOf(oe.key)>=0&&V()},H=()=>{z.current();const oe=j.scrollTop,xe=oe>O;if(O=oe,f.current!==null&&Math.abs(oe-f.current)<2||(f.current=null,!B.current&&Date.now()-D.current>td))return;const $=j.scrollHeight-j.clientHeight-oe;p.current&&$>Pn?k.current.onPause():!p.current&&xe&&$<=Pn&&k.current.onFollow()},J={passive:!0};return j.addEventListener("wheel",V,J),j.addEventListener("touchstart",V,J),j.addEventListener("touchmove",V,J),j.addEventListener("pointerdown",L),window.addEventListener("pointerup",Y),j.addEventListener("keydown",re),j.addEventListener("scroll",H,J),()=>{j.removeEventListener("wheel",V),j.removeEventListener("touchstart",V),j.removeEventListener("touchmove",V),j.removeEventListener("pointerdown",L),window.removeEventListener("pointerup",Y),j.removeEventListener("keydown",re),j.removeEventListener("scroll",H)}},[]),u.useImperativeHandle(n,()=>({reveal:j=>b.scrollToIndex(j,{align:"center"}),focus:()=>{var j;return(j=m.current)==null?void 0:j.focus({preventScroll:!0})}}),[b]);const K=j=>`${g}-${j}`,q=j=>{var Y,re,H,J;const O=j.target.closest("[data-seq]");if(!O||!((Y=m.current)!=null&&Y.contains(O))||(((H=(re=window.getSelection)==null?void 0:re.call(window))==null?void 0:H.toString())??"")!=="")return;const V=Number(O.getAttribute("data-seq")),L=Nc(t.selection,V,i.map(oe=>oe.seq),{range:j.shiftKey,toggle:j.metaKey||j.ctrlKey});t.onSelect(L,i.find(oe=>oe.seq===V)??null,"click"),L.selected.size&&p.current&&t.onPause(),j.shiftKey&&((J=m.current)==null||J.focus({preventScroll:!0}))},te=j=>{j.shiftKey&&j.preventDefault()},X=j=>{var V,L;const O=j.metaKey||j.ctrlKey;if((j.key==="ArrowDown"||j.key==="ArrowUp")&&!O&&!j.altKey){j.preventDefault();const Y=i.map(J=>J.seq);if(!Y.length)return;const re=Ec(t.selection,Y,j.key==="ArrowDown"?1:-1,j.shiftKey),H=re.active===null?-1:Y.indexOf(re.active);if(t.onSelect(re,H>=0?i[H]:null,"key"),H<0)return;H!==Y.length-1&&p.current&&t.onPause(),b.scrollToIndex(H,{align:"auto"})}else if(j.key==="Enter"&&!O){const Y=w>=0?i[w]:void 0;if(!Y)return;j.preventDefault(),t.onOpenDetails(Y)}else if(j.key==="End"&&!O)j.preventDefault(),t.onFollow(),b.scrollToOffset(y);else if(O&&!j.altKey&&(j.key==="c"||j.key==="C")){if(!t.selection.selected.size||(((L=(V=window.getSelection)==null?void 0:V.call(window))==null?void 0:L.toString())??"")!=="")return;j.preventDefault(),t.onCopy()}};return s.jsxs("div",{className:"log-list-wrap",children:[S&&!l&&s.jsx("div",{className:"log-dropped-note",children:"Older lines were dropped while paused"}),s.jsx("div",{ref:m,role:"listbox","aria-label":"Log lines","aria-multiselectable":"true",tabIndex:0,"aria-activedescendant":w>=0?K(i[w].seq):void 0,className:`log-list${r?"":" is-nowrap"}`,onClick:q,onMouseDown:te,onKeyDown:X,children:s.jsx("div",{className:"log-list-sizer",style:{height:y},children:b.getVirtualItems().map(j=>{const O=i[j.index];return s.jsx(ed,{record:O,index:j.index,setSize:i.length,start:j.start,id:K(O.seq),selected:t.selection.selected.has(O.seq),active:t.selection.active===O.seq,hit:d.has(j.index),activeHit:c===j.index,find:a,caseSensitive:o,measureRef:b.measureElement},O.seq)})})}),!l&&s.jsx(P,{type:"button",variant:"secondary",size:"sm",className:"log-new-pill",onClick:()=>k.current.onFollow(),children:h>0?`${Ge(h)} new line${h===1?"":"s"} · Jump to latest`:"Jump to latest"})]})});function cd({record:e,platform:t,inBuffer:n,onCopyLine:i,onCopyMessage:r,onShowOnlyTag:a,onHideTag:o,onShowOnlyApp:d,onClose:c}){const l=!!e.synthetic;return s.jsxs("section",{className:"log-details","aria-label":"Line details",children:[s.jsxs("header",{className:"log-details-head",children:[s.jsx(P,{type:"button",variant:"ghost",size:"icon",className:"log-details-close","aria-label":"Close details",title:"Close details (Esc)",onClick:c,children:s.jsx(Ls,{size:14,"aria-hidden":"true"})}),s.jsx("h3",{className:"log-details-title",children:l?"Added by Xenon":`${Hi(e.level,t)} · ${e.tag}`})]}),l&&s.jsx("p",{className:"log-details-note",children:"Xenon added this line. It didn’t come from the phone."}),s.jsxs("dl",{className:"log-details-fields",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Time"}),s.jsx("dd",{children:Rc(e.ts)})]}),!l&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"App"}),s.jsx("dd",{children:e.pkg??"Unknown"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Process ID"}),s.jsx("dd",{children:e.pid})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Thread ID"}),s.jsx("dd",{children:e.tid})]})]})]}),!n&&s.jsx("p",{className:"log-details-left",children:"This line has left the buffer"}),s.jsx("pre",{className:"log-details-msg",children:e.message}),s.jsxs("div",{className:"log-details-actions",children:[s.jsx(P,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Copy line"}),!l&&s.jsxs(s.Fragment,{children:[s.jsx(P,{type:"button",variant:"secondary",size:"sm",onClick:r,children:"Copy message"}),e.tag&&s.jsxs(s.Fragment,{children:[s.jsx(P,{type:"button",variant:"secondary",size:"sm",onClick:a,children:"Show only this tag"}),s.jsx(P,{type:"button",variant:"secondary",size:"sm",onClick:o,children:"Hide this tag"})]}),e.pkg&&s.jsx(P,{type:"button",variant:"secondary",size:"sm",onClick:d,children:"Show only this app"})]})]})]})}function Bn(e,t){const n=URL.createObjectURL(new Blob([e],{type:"text/plain"})),i=document.createElement("a");i.href=n,i.download=t,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),0)}async function dd(e){var i;if(await Vs(e))return!0;if(typeof document.execCommand!="function")return!1;const t=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),(i=t==null?void 0:t.focus)==null||i.call(t,{preventScroll:!0})}}const ud=e=>e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable;function hd({udid:e,platform:t}){const n=(t||"").toLowerCase(),i=n==="ios",r=n==="android"||i,a=i?"ios":"android",{toast:o}=Be(),[d,c]=u.useState(""),l=u.useMemo(()=>i?vc(d):void 0,[i,d]),{records:h,connected:m,clear:g,deniedReason:f,exhausted:p,retry:k}=hc(e,r,l),[C,R]=u.useState(!1),[w,b]=u.useState(!0),[N,y]=u.useState(""),[A,v]=u.useState(0),[T,S]=u.useState(ys),[E,z]=u.useState(null),D=u.useRef(null),B=u.useRef(null),K=u.useRef(null),q=u.useRef(null),te=u.useRef(h);te.current=h;const[X,j]=u.useState(!0),[O,V]=u.useState(null),L=u.useRef(X);L.current=X;const Y=u.useCallback(()=>{if(!L.current)return;L.current=!1;const _=te.current;V(_.length?_[_.length-1].seq:-1),j(!1)},[]),re=u.useCallback(()=>{L.current=!0,V(null),j(!0)},[]),H=u.useRef(null),[J,oe]=u.useState(!1),[xe,$]=u.useState(0),le=u.useRef(-1),ee=u.useMemo(()=>Pi(d,{caseSensitive:C}),[d,C]),ne=u.useMemo(()=>h.filter(_=>Ui(_,ee)),[h,ee]),ge=u.useMemo(()=>xc(h,ee),[h,ee]),de=u.useMemo(()=>{if(!N)return[];const _=C?N:N.toLowerCase(),W=[];return ne.forEach((se,ce)=>{(C?`${se.tag} ${se.message}`:`${se.tag} ${se.message}`.toLowerCase()).includes(_)&&W.push(ce)}),W},[ne,N,C]),ke=de.length?Math.min(A,de.length-1):0,Ae=u.useMemo(()=>new Set(de),[de]),We=u.useCallback(_=>{var se;if(!de.length)return;const W=(ke+_+de.length)%de.length;v(W),Y(),(se=q.current)==null||se.reveal(de[W])},[de,ke,Y]),dt=u.useMemo(()=>{if(O===null)return 0;let _=0;for(let W=ne.length-1;W>=0&&ne[W].seq>O;W--)_++;return _},[ne,O]),fe=u.useCallback(()=>{if(!ne.length){o("No lines to export","info");return}Bn(ne.map(Zt).join(`
278
- `),`logcat-${e}-${Date.now()}.txt`)},[ne,e,o]);u.useEffect(()=>{const _=H.current;if(!_||!h.length)return;const W=h.filter(ce=>ce.seq>le.current);if(!W.length)return;const se=le.current+1;le.current>=0&&W[0].seq>se&&(_.dropped+=W[0].seq-se),kc(_,W),le.current=W[W.length-1].seq,$(_.lines.length)},[h]);const Re=u.useCallback(()=>{const _=H.current;if(!_){le.current=h.length?h[h.length-1].seq:-1,H.current=wc(Date.now()),$(0),oe(!0);return}const W=Sc(_,Date.now(),e);H.current=null,oe(!1),$(0),Bn(W,Cc(e,_.startedAt))},[h,e]),[Ie,_e]=u.useState(!1),Qe=Oi(()=>{});ac(J?()=>H.current?(_e(!0),!0):!1:null);const yt=()=>{_e(!1),H.current&&Re(),Qe()},Ve=u.useCallback(async(_,W)=>{await dd(_)?o(W,"success"):o("Your browser blocked copying here.","error")},[o]),He=u.useMemo(()=>{if(!T.selected.size)return 0;let _=0;for(let W=0;W<ne.length;W++)T.selected.has(ne[W].seq)&&_++;return _},[ne,T.selected]),Ke=u.useCallback(()=>{const{text:_,count:W}=Tc(ne,T.selected);W&&Ve(_,`Copied ${Ge(W)} line${W===1?"":"s"}`)},[ne,T.selected,Ve]),xt=u.useCallback((_,W,se)=>{S(_),z(se==="click"?W:ce=>ce&&W?W:ce)},[]),ut=u.useCallback(()=>{g(),S(ys)},[g]),qe=_=>{var se,ce,Me;const W=_.metaKey||_.ctrlKey;_.key==="/"&&!W&&!ud(_.target)?(_.preventDefault(),(se=B.current)==null||se.focus()):W&&!_.altKey&&(_.key==="f"||_.key==="F")?(_.preventDefault(),(ce=K.current)==null||ce.focus(),(Me=K.current)==null||Me.select()):_.key==="Escape"&&(E?(_.preventDefault(),z(null)):T.selected.size&&(_.preventDefault(),S(ys)))},ie=u.useRef(qe);if(ie.current=qe,u.useEffect(()=>{const _=D.current;if(!_)return;const W=se=>ie.current(se);return _.addEventListener("keydown",W),()=>_.removeEventListener("keydown",W)},[r]),!r)return s.jsx("div",{className:"logcat-root",children:s.jsx(qr,{title:"Live logs are not available here",description:"Live logs work on Android and iOS phones."})});const ae=f?"Denied":p?"Offline":m?"Live":"Connecting",pe=!!E&&h.length>0&&E.seq>=h[0].seq&&E.seq<=h[h.length-1].seq;let me=null;ne.length||(h.length?me=s.jsxs("div",{className:"log-state",children:[s.jsxs("p",{children:["No lines match ",s.jsx("code",{children:d})]}),s.jsx(P,{type:"button",variant:"secondary",size:"sm",onClick:()=>c(""),children:"Clear filter"})]}):ae==="Connecting"?me=s.jsx("div",{className:"log-state",children:s.jsx("p",{children:"Waiting for the phone’s first log line…"})}):ae==="Live"&&(me=s.jsx("div",{className:"log-state",children:s.jsx("p",{children:"Connected. Lines appear here as the phone logs them."})})));const je=s.jsxs(P,{type:"button",variant:"secondary",size:"sm",onClick:k,children:[s.jsx(Et,{size:13,"aria-hidden":"true"})," Reconnect"]});return s.jsxs("div",{className:"logcat-root",ref:D,children:[s.jsx(zc,{status:ae,statusDetail:f,query:d,onQueryChange:c,filterRef:B,find:N,onFindChange:_=>{y(_),v(0)},findRef:K,hitCount:de.length,activeHit:ke,onStep:We,following:X,onTogglePause:X?Y:re,recording:J,recordedLines:xe,onToggleRecording:Re,onExport:fe,caseSensitive:C,onToggleCase:()=>R(_=>!_),wrap:w,onToggleWrap:()=>b(_=>!_),canCopySelected:He>0,onCopySelected:Ke,onClearLines:ut}),s.jsx($c,{platform:a,counts:ge,minLevel:ee.minLevel,shown:ne.length,total:h.length,onChoose:_=>c(pc(d,_))}),s.jsxs("div",{className:"log-body theme-dark",children:[f&&s.jsxs("div",{className:"log-banner is-denied",role:"alert",children:[s.jsx(Fe,{size:14,"aria-hidden":"true"}),s.jsxs("span",{children:["Access denied — ",f]}),je]}),!f&&p&&s.jsxs("div",{className:"log-banner is-exhausted",role:"alert",children:[s.jsx(Fe,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect to try again."}),je]}),s.jsxs("div",{className:"log-main",children:[s.jsx(ld,{ref:q,records:ne,oldestSeq:h.length?h[0].seq:null,wrap:w,find:N,caseSensitive:C,hits:Ae,activeHit:de.length?de[ke]:null,following:X,newLines:dt,onPause:Y,onFollow:re,selection:T,onSelect:xt,onOpenDetails:z,onCopy:Ke}),me]}),E&&s.jsx(cd,{record:E,platform:a,inBuffer:pe,onCopyLine:()=>Ve(Zt(E),"Copied the line"),onCopyMessage:()=>Ve(E.message,"Copied the message"),onShowOnlyTag:()=>c(zn(d,"tag",E.tag)),onHideTag:()=>c(fc(d,"tag",E.tag)),onShowOnlyApp:()=>c(zn(d,"package",E.pkg??"")),onClose:()=>z(null)})]}),s.jsx(ns,{open:Ie,title:"Stop recording?",onClose:()=>_e(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(P,{type:"button",variant:"secondary",onClick:()=>_e(!1),autoFocus:!0,children:"Keep recording"}),s.jsx(P,{type:"button",onClick:yt,children:"Save and close"})]}),children:s.jsxs("p",{children:[Ge(xe)," line",xe===1?"":"s"," recorded so far. Closing device control ends the recording. Save and close downloads it first."]})})]})}function Zi(e){const t=e==null?void 0:e.message;return typeof t=="string"?t.trim():""}function Te(e,t){const n=Zi(t);return n?`Couldn’t ${e}: ${n}`:`Couldn’t ${e}.`}function md(e,t){return e==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Te("read the clipboard",t)}function fd(e,t){const n=t.trim().toLowerCase();return[...e].sort((i,r)=>i.localeCompare(r)).filter(i=>!n||i.toLowerCase().includes(n))}const pd=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function gd(e){return pd.test(e.trim())}function Hs(e){const t=(e||"").toLowerCase();return t==="android"?"android":t==="ios"||t==="tvos"?"ios":null}function vd(e,t){const n=Hs(t);return n?e.filter(i=>(i.platform||"").toLowerCase()===n):[]}function yd(e){return[e.version,e.packageName].filter(Boolean).join(" · ")}function xd(e){return Hs(e)==="android"?"Android":"iOS"}function bd(e){return Hs(e)==="android"?".apk":".ipa,.app"}function jd({udid:e,platform:t,deviceName:n}){const{toast:i,removeToast:r}=Be(),a=$t(),[o,d]=u.useState([]),[c,l]=u.useState("loading"),[h,m]=u.useState(""),[g,f]=u.useState(""),[p,k]=u.useState(!1),[C,R]=u.useState(!1),[w,b]=u.useState([]),[N,y]=u.useState("loading"),[A,v]=u.useState(null),[T,S]=u.useState(null),E=u.useRef(null),z=u.useRef(null),D=u.useRef(null),B=u.useCallback(async()=>{l("loading");try{const $=await G.listApps(e);d(Array.isArray($)?$:[]),l("ready")}catch($){m(Zi($)),l("error")}},[e]);u.useEffect(()=>{B()},[B]);const K=$=>setTimeout(B,$);u.useEffect(()=>{if(!T)return;const $=setTimeout(()=>S(null),1500);return()=>clearTimeout($)},[T]);const q=async()=>{y("loading");try{const $=await G.getApps();b(Array.isArray($)?$:[]),y("ready")}catch{y("error")}},te=()=>{p||(R(!0),q())},X=()=>{var $;R(!1),($=E.current)==null||$.focus()};u.useEffect(()=>{var le;if(!C||N==="loading")return;const $=(le=z.current)==null?void 0:le.querySelector('[role="menuitem"]:not(:disabled)');$==null||$.focus()},[C,N]);const j=async($,le)=>{k(!0);const ee=i(`Installing ${$} on ${n}…`,"loading",0);try{const ne=await le();ne!=null&&ne.success?(i(`Installed ${$} on ${n}`,"success"),K(5e3)):i(Te(`install ${$}`,{message:ne==null?void 0:ne.error}),"error")}catch(ne){i(Te(`install ${$}`,ne),"error")}finally{r(ee),k(!1)}},O=$=>{X(),j($.name,()=>G.installRepositoryApp(e,$.id))},V=$=>{var ee;const le=(ee=$.target.files)==null?void 0:ee[0];$.target.value="",le&&j(le.name,()=>G.uploadAndInstallApp(e,le))},L=async()=>{const $=A;if(v(null),!$)return;const le=i(`Uninstalling ${$} from ${n}…`,"loading",0);try{await G.uninstallApp(e,$),i(`Uninstalled ${$} from ${n}`,"success"),K(3e3)}catch(ee){i(Te(`uninstall ${$}`,ee),"error")}finally{r(le)}},Y=async($,le)=>{var ne,ge;if(await Vs($)){S($);return}const ee=(ne=le.closest("li"))==null?void 0:ne.querySelector(".actions-app-id");ee&&((ge=window.getSelection())==null||ge.selectAllChildren(ee)),i(Fi,"info")},re=fd(o,g),H=g.trim(),J=c==="ready"&&re.length===0&&gd(H)&&!o.includes(H),oe=vd(w,t),xe=($,le)=>s.jsxs("li",{className:"actions-app-row",children:[s.jsx("span",{className:"actions-app-id",children:$}),le&&s.jsx("span",{className:"actions-app-note",children:le}),s.jsxs("span",{className:"actions-app-tools",children:[s.jsx(P,{variant:"ghost",size:"icon","aria-label":T===$?"Copied":`Copy ${$}`,title:T===$?"Copied":"Copy package ID",onClick:ee=>Y($,ee.currentTarget),children:T===$?s.jsx(At,{size:13,"aria-hidden":"true"}):s.jsx($e,{size:13,"aria-hidden":"true"})}),s.jsx(P,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${$}`,onClick:()=>v($),children:"Uninstall"})]})]},$);return s.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[s.jsxs("div",{className:"actions-section-head",children:[s.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[s.jsx(Za,{size:15,"aria-hidden":"true"})," Apps"]}),s.jsxs("div",{className:"actions-section-tools",children:[s.jsxs(P,{ref:E,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":C,"aria-disabled":p||void 0,onClick:te,children:[p?s.jsx(ot,{className:"animate-spin",size:13,"aria-hidden":"true"}):s.jsx(Da,{size:13,"aria-hidden":"true"}),"Install from library"]}),s.jsxs(P,{variant:"secondary",size:"sm","aria-disabled":p||void 0,onClick:()=>{var $;return!p&&(($=D.current)==null?void 0:$.click())},children:[s.jsx(Gr,{size:13,"aria-hidden":"true"})," Upload file"]}),s.jsx("input",{ref:D,type:"file",hidden:!0,"aria-label":"App file to upload",accept:bd(t),onChange:V})]})]}),s.jsx(qt,{open:C,onClose:X,anchorRef:E,placement:"bottom-end",children:s.jsx("div",{ref:z,className:"actions-library-menu",children:s.jsxs(Fs,{children:[N==="loading"&&s.jsx(be,{disabled:!0,onClick:()=>{},children:"Loading…"}),N==="error"&&s.jsx(be,{onClick:q,children:"Couldn’t load the library. Retry"}),N==="ready"&&oe.length===0&&s.jsxs(s.Fragment,{children:[s.jsxs(be,{disabled:!0,onClick:()=>{},children:["No ",xd(t)," apps in the library yet"]}),s.jsx(be,{onClick:()=>a("/apps"),children:"Open the Apps library"})]}),N==="ready"&&oe.map($=>s.jsx(be,{note:yd($)||void 0,onClick:()=>O($),children:$.name},$.id))]})})}),s.jsxs("div",{className:"actions-apps-tools",children:[s.jsxs("div",{className:"actions-search",children:[s.jsx(Os,{size:13,className:"actions-search-icon","aria-hidden":"true"}),s.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${o.length} installed apps`,value:g,onChange:$=>f($.target.value)})]}),s.jsx(P,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:B,children:s.jsx(Bt,{size:13,"aria-hidden":"true"})})]}),c==="loading"&&o.length===0&&s.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),c==="error"&&s.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",h?`: ${h}`:".",s.jsx(P,{variant:"secondary",size:"sm",onClick:B,children:"Retry"})]}),c==="ready"&&o.length===0&&s.jsx("p",{className:"actions-list-note",children:"No apps installed"}),c==="ready"&&o.length>0&&re.length===0&&!J&&s.jsxs("p",{className:"actions-list-note",children:["No apps match “",H,"”"]}),s.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[re.map($=>xe($)),J&&xe(H,"Not in the list")]}),s.jsx(ns,{open:A!==null,title:"Uninstall app?",onClose:()=>v(null),footer:s.jsxs(s.Fragment,{children:[s.jsx(P,{variant:"secondary",onClick:()=>v(null),children:"Cancel"}),s.jsx(P,{variant:"danger",onClick:L,children:"Uninstall"})]}),children:s.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",s.jsx("code",{children:A})," from"," ",s.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const wd=[{direction:"up",Icon:Us},{direction:"down",Icon:Ps},{direction:"left",Icon:Zr},{direction:"right",Icon:Qr}];function kd({onSwipe:e}){return s.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[s.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[s.jsx(Ra,{size:15,"aria-hidden":"true"})," Swipe"]}),s.jsx("div",{className:"actions-swipe-buttons",children:wd.map(({direction:t,Icon:n})=>s.jsx(P,{variant:"secondary",size:"icon","aria-label":`Swipe ${t}`,title:`Swipe ${t}`,onClick:()=>e(t),children:s.jsx(n,{size:14,"aria-hidden":"true"})},t))})]})}function Sd(e,t,n){const i=t/2,r=n/2,a=t*.4,o=n*.4,[d,c,l,h]={up:[i,r+o,i,r-o],down:[i,r-o,i,r+o],left:[i+a,r,i-a,r],right:[i-a,r,i+a,r]}[e].map(Math.round);return{startX:d,startY:c,endX:l,endY:h}}function Cd({udid:e,platform:t}){const n=t!=="android",{toast:i}=Be(),[r,a]=u.useState(""),[o,d]=u.useState(!1),[c,l]=u.useState(""),[h,m]=u.useState(null),[g,f]=u.useState(""),[p,k]=u.useState(!1),C=u.useRef(null);u.useEffect(()=>{if(!g)return;const y=setTimeout(()=>f(""),2e3);return()=>clearTimeout(y)},[g]),u.useEffect(()=>{if(!p)return;const y=setTimeout(()=>k(!1),1500);return()=>clearTimeout(y)},[p]);const R=async()=>{if(!(!r.trim()||o)){d(!0);try{await G.typeText(e,r),a(""),f("Sent")}catch(y){i(Te("send the text",y),"error")}finally{d(!1)}}},w=async()=>{m("read");try{const y=await G.getClipboard(e),A=typeof(y==null?void 0:y.content)=="string"?y.content:"";l(A),A||f("The device clipboard is empty")}catch(y){i(md(t,y),"error")}finally{m(null)}},b=async()=>{if(c){m("write");try{await G.setClipboard(e,c),f("Written to the device")}catch(y){i(Te("write the clipboard",y),"error")}finally{m(null)}}},N=async()=>{var y;if(await Vs(c)){k(!0);return}(y=C.current)==null||y.select(),i(Fi,"info")};return s.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[s.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[s.jsx(Ia,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),s.jsxs("div",{className:"actions-field-row",children:[s.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),s.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:r,onChange:y=>a(y.target.value),onKeyDown:y=>y.key==="Enter"&&R()}),s.jsxs(P,{variant:"secondary",size:"md",onClick:R,disabled:!r.trim()||o,children:[o&&s.jsx(ot,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),s.jsxs("div",{className:"actions-field-row",children:[s.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),s.jsx("input",{id:"actions-clipboard",ref:C,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:c,onChange:y=>l(y.target.value)}),s.jsxs(P,{variant:"secondary",size:"md",onClick:w,disabled:h!==null,children:[h==="read"&&s.jsx(ot,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&s.jsxs(P,{variant:"secondary",size:"md",onClick:b,disabled:!c||h!==null,children:[h==="write"&&s.jsx(ot,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),s.jsx(P,{variant:"ghost",size:"icon","aria-label":p?"Copied":"Copy clipboard text",title:p?"Copied":"Copy to your clipboard",onClick:N,disabled:!c,children:p?s.jsx(At,{size:14,"aria-hidden":"true"}):s.jsx($e,{size:14,"aria-hidden":"true"})})]}),!n&&s.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),s.jsx("p",{className:"actions-status",role:"status",children:g})]})}function Nd({udid:e,platform:t,deviceName:n,screenWidth:i,screenHeight:r}){const{toast:a}=Be(),o=async d=>{const c=Sd(d,i,r);try{await G.swipe(e,c.startX,c.startY,c.endX,c.endY)}catch(l){a(Te(`swipe ${d}`,l),"error")}};return s.jsxs("div",{className:"actions-panel",children:[s.jsx(jd,{udid:e,platform:t,deviceName:n}),s.jsx(Cd,{udid:e,platform:t}),s.jsx(kd,{onSwipe:o})]})}const Ed=[{id:"RECT",label:"Rect"},{id:"CIRCLE",label:"Circle"},{id:"ARROW",label:"Arrow"},{id:"FREEHAND",label:"Draw"}];function Td({shape:e,color:t,marks:n,saving:i,onShape:r,onColor:a,onUndo:o,onClear:d,onCancel:c,onSave:l}){return s.jsxs("div",{className:"shots-actions",role:"toolbar","aria-label":"Annotate",children:[s.jsxs("div",{className:"shots-shapes",children:[Ed.map(h=>s.jsx(P,{variant:"secondary",size:"sm","aria-pressed":e===h.id,className:e===h.id?"is-pressed":void 0,onClick:()=>r(h.id),children:h.label},h.id)),s.jsx("input",{type:"color",className:"shots-color",value:t,onChange:h=>a(h.target.value),"aria-label":"Mark colour",title:"Mark colour"})]}),s.jsx(P,{variant:"ghost",size:"sm",onClick:o,disabled:!n||i,children:"Undo mark"}),s.jsx(P,{variant:"ghost",size:"sm",onClick:d,disabled:!n||i,children:"Clear marks"}),s.jsx("span",{className:"shots-actions-gap"}),s.jsx(P,{variant:"secondary",size:"sm",onClick:c,disabled:i,children:"Cancel"}),s.jsxs(P,{size:"sm",onClick:l,disabled:!n||i,children:[i&&s.jsx(ot,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Save copy"]})]})}function lt(e){return`Screenshot ${e.n}`}const Je=e=>String(e).padStart(2,"0");function Wn(e){return`${Je(e.getHours())}:${Je(e.getMinutes())}:${Je(e.getSeconds())}`}function Ad(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function zs(e,t=Date.now()){const n=new Date(e);return Ad(n,new Date(t))?`Today ${Wn(n)}`:`${n.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} ${Wn(n)}`}function Rd(e,t){return!e||!t?"":e>t?"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 Qi(e,t=Date.now()){const n=[lt(e)];e.markedFrom!==void 0&&n.push(`marked copy of ${e.markedFrom}`),n.push(zs(e.takenAt,t));const i=Rd(e.width,e.height);return i&&n.push(i,`${e.width} × ${e.height}`),n.push(Md(e.bytes)),n.join(" · ")}function er(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"device"}function tr(e){const t=new Date(e);return`${t.getFullYear()}-${Je(t.getMonth()+1)}-${Je(t.getDate())}`}function sr(e,t){const n=new Date(t.takenAt),i=`${Je(n.getHours())}-${Je(n.getMinutes())}-${Je(n.getSeconds())}`,r=t.markedFrom!==void 0?"-marked":"";return`${er(e)}-screenshot-${t.n}${r}-${tr(t.takenAt)}-${i}.png`}function zd(e,t=Date.now()){return`${er(e)}-screenshots-${tr(t)}.zip`}async function $d(e){const t=globalThis.ClipboardItem,n=navigator.clipboard;if(!t||typeof(n==null?void 0:n.write)!="function")return!1;try{const i=e.type==="image/png"?e:new Blob([e],{type:"image/png"});return await n.write([new t({"image/png":i})]),!0}catch{return!1}}var we=Uint8Array,Ce=Uint16Array,Ks=Int32Array,qs=new we([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]),Xs=new we([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]),Vn=new we([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nr=function(e,t){for(var n=new Ce(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];for(var r=new Ks(n[30]),i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return{b:n,r}},ir=nr(qs,2),Id=ir.b,$s=ir.r;Id[28]=258,$s[258]=28;var _d=nr(Xs,0),Hn=_d.r,Is=new Ce(32768);for(var he=0;he<32768;++he){var Ye=(he&43690)>>1|(he&21845)<<1;Ye=(Ye&52428)>>2|(Ye&13107)<<2,Ye=(Ye&61680)>>4|(Ye&3855)<<4,Is[he]=((Ye&65280)>>8|(Ye&255)<<8)>>1}var Tt=function(e,t,n){for(var i=e.length,r=0,a=new Ce(t);r<i;++r)e[r]&&++a[e[r]-1];var o=new Ce(t);for(r=1;r<t;++r)o[r]=o[r-1]+a[r-1]<<1;var d;if(n){d=new Ce(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],m=o[e[r]-1]++<<h,g=m|(1<<h)-1;m<=g;++m)d[Is[m]>>c]=l}else for(d=new Ce(i),r=0;r<i;++r)e[r]&&(d[r]=Is[o[e[r]-1]++]>>15-e[r]);return d},ct=new we(288);for(var he=0;he<144;++he)ct[he]=8;for(var he=144;he<256;++he)ct[he]=9;for(var he=256;he<280;++he)ct[he]=7;for(var he=280;he<288;++he)ct[he]=8;var es=new we(32);for(var he=0;he<32;++he)es[he]=5;var Dd=Tt(ct,9,0),Ld=Tt(es,5,0),rr=function(e){return(e+7)/8|0},ar=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new we(e.subarray(t,n))},Od=["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"],is=function(e,t,n){var i=new Error(t||Od[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,is),!n)throw i;return i},Oe=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},St=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},js=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var r=n.length,a=n.slice();if(!r)return{t:lr,l:0};if(r==1){var o=new we(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(y,A){return y.f-A.f}),n.push({s:-1,f:25001});var d=n[0],c=n[1],l=0,h=1,m=2;for(n[0]={s:-1,f:d.f+c.f,l:d,r:c};h!=r-1;)d=n[n[l].f<n[m].f?l++:m++],c=n[l!=h&&n[l].f<n[m].f?l++:m++],n[h++]={s:-1,f:d.f+c.f,l:d,r:c};for(var g=a[0].s,i=1;i<r;++i)a[i].s>g&&(g=a[i].s);var f=new Ce(g+1),p=_s(n[h-1],f,0);if(p>t){var i=0,k=0,C=p-t,R=1<<C;for(a.sort(function(A,v){return f[v.s]-f[A.s]||A.f-v.f});i<r;++i){var w=a[i].s;if(f[w]>t)k+=R-(1<<p-f[w]),f[w]=t;else break}for(k>>=C;k>0;){var b=a[i].s;f[b]<t?k-=1<<t-f[b]++-1:++i}for(;i>=0&&k;--i){var N=a[i].s;f[N]==t&&(--f[N],++k)}p=t}return{t:new we(f),l:p}},_s=function(e,t,n){return e.s==-1?Math.max(_s(e.l,t,n+1),_s(e.r,t,n+1)):t[e.s]=n},Kn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Ce(++t),i=0,r=e[0],a=1,o=function(c){n[i++]=c},d=1;d<=t;++d)if(e[d]==r&&d!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(r),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(r);a=1,r=e[d]}return{c:n.subarray(0,i),n:t}},Ct=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},or=function(e,t,n){var i=n.length,r=rr(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<i;++a)e[r+a+4]=n[a];return(r+4+i)*8},qn=function(e,t,n,i,r,a,o,d,c,l,h){Oe(t,h++,n),++r[256];for(var m=js(r,15),g=m.t,f=m.l,p=js(a,15),k=p.t,C=p.l,R=Kn(g),w=R.c,b=R.n,N=Kn(k),y=N.c,A=N.n,v=new Ce(19),T=0;T<w.length;++T)++v[w[T]&31];for(var T=0;T<y.length;++T)++v[y[T]&31];for(var S=js(v,7),E=S.t,z=S.l,D=19;D>4&&!E[Vn[D-1]];--D);var B=l+5<<3,K=Ct(r,ct)+Ct(a,es)+o,q=Ct(r,g)+Ct(a,k)+o+14+3*D+Ct(v,E)+2*v[16]+3*v[17]+7*v[18];if(c>=0&&B<=K&&B<=q)return or(t,h,e.subarray(c,c+l));var te,X,j,O;if(Oe(t,h,1+(q<K)),h+=2,q<K){te=Tt(g,f,0),X=g,j=Tt(k,C,0),O=k;var V=Tt(E,z,0);Oe(t,h,b-257),Oe(t,h+5,A-1),Oe(t,h+10,D-4),h+=14;for(var T=0;T<D;++T)Oe(t,h+3*T,E[Vn[T]]);h+=3*D;for(var L=[w,y],Y=0;Y<2;++Y)for(var re=L[Y],T=0;T<re.length;++T){var H=re[T]&31;Oe(t,h,V[H]),h+=E[H],H>15&&(Oe(t,h,re[T]>>5&127),h+=re[T]>>12)}}else te=Dd,X=ct,j=Ld,O=es;for(var T=0;T<d;++T){var J=i[T];if(J>255){var H=J>>18&31;St(t,h,te[H+257]),h+=X[H+257],H>7&&(Oe(t,h,J>>23&31),h+=qs[H]);var oe=J&31;St(t,h,j[oe]),h+=O[oe],oe>3&&(St(t,h,J>>5&8191),h+=Xs[oe])}else St(t,h,te[J]),h+=X[J]}return St(t,h,te[256]),h+X[256]},Fd=new Ks([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),lr=new we(0),Pd=function(e,t,n,i,r,a){var o=a.z||e.length,d=new we(i+o+5*(1+Math.ceil(o/7e3))+r),c=d.subarray(i,d.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var m=Fd[t-1],g=m>>13,f=m&8191,p=(1<<n)-1,k=a.p||new Ce(32768),C=a.h||new Ce(p+1),R=Math.ceil(n/3),w=2*R,b=function(ke){return(e[ke]^e[ke+1]<<R^e[ke+2]<<w)&p},N=new Ks(25e3),y=new Ce(288),A=new Ce(32),v=0,T=0,S=a.i||0,E=0,z=a.w||0,D=0;S+2<o;++S){var B=b(S),K=S&32767,q=C[B];if(k[K]=q,C[B]=K,z<=S){var te=o-S;if((v>7e3||E>24576)&&(te>423||!l)){h=qn(e,c,0,N,y,A,T,E,D,S-D,h),E=v=T=0,D=S;for(var X=0;X<286;++X)y[X]=0;for(var X=0;X<30;++X)A[X]=0}var j=2,O=0,V=f,L=K-q&32767;if(te>2&&B==b(S-L))for(var Y=Math.min(g,te)-1,re=Math.min(32767,S),H=Math.min(258,te);L<=re&&--V&&K!=q;){if(e[S+j]==e[S+j-L]){for(var J=0;J<H&&e[S+J]==e[S+J-L];++J);if(J>j){if(j=J,O=L,J>Y)break;for(var oe=Math.min(L,J-2),xe=0,X=0;X<oe;++X){var $=S-L+X&32767,le=k[$],ee=$-le&32767;ee>xe&&(xe=ee,q=$)}}}K=q,q=k[K],L+=K-q&32767}if(O){N[E++]=268435456|$s[j]<<18|Hn[O];var ne=$s[j]&31,ge=Hn[O]&31;T+=qs[ne]+Xs[ge],++y[257+ne],++A[ge],z=S+j,++v}else N[E++]=e[S],++y[e[S]]}}for(S=Math.max(S,z);S<o;++S)N[E++]=e[S],++y[e[S]];h=qn(e,c,l,N,y,A,T,E,D,S-D,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=C,a.p=k,a.i=S,a.w=z)}else{for(var S=a.w||0;S<o+l;S+=65535){var de=S+65535;de>=o&&(c[h/8|0]=l,de=o),h=or(c,h+1,e.subarray(S,de))}a.i=o}return ar(d,0,i+rr(h)+r)},Ud=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Bd=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=Ud[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}},Wd=function(e,t,n,i,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new we(a.length+e.length);o.set(a),o.set(e,a.length),e=o,r.w=a.length}return Pd(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},cr=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},ye=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Vd(e,t){return Wd(e,t||{},0,0)}var dr=function(e,t,n,i){for(var r in e){var a=e[r],o=t+r,d=i;Array.isArray(a)&&(d=cr(i,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,d]:(n[o+="/"]=[new we(0),d],dr(a,o,n,i))}},Xn=typeof TextEncoder<"u"&&new TextEncoder,Hd=typeof TextDecoder<"u"&&new TextDecoder,Kd=0;try{Hd.decode(lr,{stream:!0}),Kd=1}catch{}function Yn(e,t){var n;if(Xn)return Xn.encode(e);for(var i=e.length,r=new we(e.length+(e.length>>1)),a=0,o=function(l){r[a++]=l},n=0;n<i;++n){if(a+5>r.length){var d=new we(a+8+(i-n<<1));d.set(r),r=d}var c=e.charCodeAt(n);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return ar(r,0,a)}var Ds=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;i>65535&&is(9),t+=i+4}return t},Gn=function(e,t,n,i,r,a,o,d){var c=i.length,l=n.extra,h=d&&d.length,m=Ds(l);ye(e,t,o!=null?33639248:67324752),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var g=new Date(n.mtime==null?Date.now():n.mtime),f=g.getFullYear()-1980;if((f<0||f>119)&&is(10),ye(e,t,f<<25|g.getMonth()+1<<21|g.getDate()<<16|g.getHours()<<11|g.getMinutes()<<5|g.getSeconds()>>1),t+=4,a!=-1&&(ye(e,t,n.crc),ye(e,t+4,a<0?-a-2:a),ye(e,t+8,n.size)),ye(e,t+12,c),ye(e,t+14,m),t+=16,o!=null&&(ye(e,t,h),ye(e,t+6,n.attrs),ye(e,t+10,o),t+=14),e.set(i,t),t+=c,m)for(var p in l){var k=l[p],C=k.length;ye(e,t,+p),ye(e,t+2,C),e.set(k,t+4),t+=4+C}return h&&(e.set(d,t),t+=h),t},qd=function(e,t,n,i,r){ye(e,t,101010256),ye(e,t+8,n),ye(e,t+10,n),ye(e,t+12,i),ye(e,t+16,r)};function Xd(e,t){t||(t={});var n={},i=[];dr(e,"",n,t);var r=0,a=0;for(var o in n){var d=n[o],c=d[0],l=d[1],h=l.level==0?0:8,m=Yn(o),g=m.length,f=l.comment,p=f&&Yn(f),k=p&&p.length,C=Ds(l.extra);g>65535&&is(11);var R=h?Vd(c,l):c,w=R.length,b=Bd();b.p(c),i.push(cr(l,{size:c.length,crc:b.d(),c:R,f:m,m:p,u:g!=o.length||p&&f.length!=k,o:r,compression:h})),r+=30+g+C+w,a+=76+2*(g+C)+(k||0)+w}for(var N=new we(a+22),y=r,A=a-r,v=0;v<i.length;++v){var m=i[v];Gn(N,m.o,m,m.f,m.u,m.c.length);var T=30+m.f.length+Ds(m.extra);N.set(m.c,m.o+T),Gn(N,r,m,m.f,m.u,m.c.length,m.o,m.m),r+=16+T+(m.m?m.m.length:0)}return qd(N,r,i.length,A,y),N}function Yd(e,t="image/png"){const n=atob(e),i=new Uint8Array(n.length);for(let r=0;r<n.length;r++)i[r]=n.charCodeAt(r);return new Blob([i],{type:t})}async function Gd(e){return typeof e.arrayBuffer=="function"?new Uint8Array(await e.arrayBuffer()):new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(new Uint8Array(i.result)),i.onerror=()=>n(i.error),i.readAsArrayBuffer(e)})}function Jd(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(i),t(r)},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("the picture could not be read"))},r.src=i})}function Zd(e,t){return Promise.race([e,new Promise((n,i)=>setTimeout(()=>i(new Error("timed out")),t))])}async function Ys(e){if(typeof createImageBitmap=="function"){const n=await createImageBitmap(e);return{source:n,width:n.width,height:n.height}}const t=await Zd(Jd(e),3e3);return{source:t,width:t.naturalWidth,height:t.naturalHeight}}async function Qd(e){try{const{width:t,height:n}=await Ys(e);return{width:t,height:n}}catch{return{width:0,height:0}}}function ur(e,t,n){return new Promise((i,r)=>{e.toBlob(a=>a?i(a):r(new Error("the picture could not be made")),t,n)})}const eu=320;async function tu(e,t=eu){try{const{source:n,width:i,height:r}=await Ys(e);if(!i||!r)return e;const a=Math.min(1,t/Math.max(i,r)),o=document.createElement("canvas");o.width=Math.max(1,Math.round(i*a)),o.height=Math.max(1,Math.round(r*a));const d=o.getContext("2d");return d?(d.drawImage(n,0,0,o.width,o.height),await ur(o,"image/jpeg",.8)):e}catch{return e}}async function su(e,t){const{source:n,width:i,height:r}=await Ys(e);if(!i||!r)throw new Error("the picture could not be read");const a=document.createElement("canvas");a.width=i,a.height=r;const o=a.getContext("2d");if(!o)throw new Error("this browser cannot draw here");return o.drawImage(n,0,0,i,r),t.forEach(d=>ea(o,i,r,d)),ur(a,"image/png")}function nu(e){const t=new Map;return e.map(n=>{const i=(t.get(n)??0)+1;if(t.set(n,i),i===1)return n;const r=n.lastIndexOf(".");return r>0?`${n.slice(0,r)}-${i}${n.slice(r)}`:`${n}-${i}`})}async function iu(e,t){const n=nu(t.map(o=>sr(e,o))),i={},r=await Promise.all(t.map(o=>Gd(o.png)));n.forEach((o,d)=>{i[o]=r[d]});const a=Xd(i,{level:0});return new Blob([a],{type:"application/zip"})}function Jn(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function hr({capture:e,actualSize:t,onToggleSize:n,annotate:i}){const r=e.width&&e.height?e.width/e.height:void 0;return s.jsx("div",{className:`shots-picture${t&&!i?" is-actual":""}`,children:s.jsxs("div",{className:"shots-picture-frame",children:[s.jsx("img",{src:e.url,alt:lt(e),draggable:!1,onClick:i?void 0:n,className:n&&!i?"is-zoomable":void 0}),i&&s.jsx(ta,{enabled:!0,shape:i.shape,color:i.color,committed:i.marks,onCommittedChange:i.onMarksChange,onCommit:()=>{},mediaAspect:r})]})})}function ru({a:e,b:t}){return s.jsx("div",{className:"shots-compare",children:[e,t].map((n,i)=>s.jsxs("figure",{className:"shots-compare-side",children:[s.jsx("span",{className:"shots-compare-tag","aria-hidden":"true",children:i===0?"A":"B"}),n?s.jsxs(s.Fragment,{children:[s.jsx(hr,{capture:n}),s.jsx("figcaption",{className:"shots-details",children:Qi(n)})]}):s.jsx("p",{className:"shots-compare-empty",children:"Pick a screenshot in the list to compare with."})]},i))})}function au({captures:e,activeId:t,compare:n,taking:i,onTake:r,onPick:a,onDelete:o}){const d=u.useRef(null),c=Date.now(),l=g=>{var p,k;const f=(p=d.current)==null?void 0:p.querySelector(`[data-capture="${g}"]`);f==null||f.focus(),(k=f==null?void 0:f.scrollIntoView)==null||k.call(f,{block:"nearest"})},h=g=>{if(!e.length)return;const f=Math.max(0,e.findIndex(k=>k.id===t));let p=null;if(g.key==="ArrowDown"||g.key==="ArrowRight")p=Math.min(e.length-1,f+1);else if(g.key==="ArrowUp"||g.key==="ArrowLeft")p=Math.max(0,f-1);else if(g.key==="Home")p=0;else if(g.key==="End")p=e.length-1;else if((g.key==="Delete"||g.key==="Backspace")&&t&&!n){g.preventDefault(),o(t);return}p!==null&&(g.preventDefault(),a(e[p].id),l(e[p].id))},m=g=>n?n.a===g?"A":n.b===g?"B":null:null;return s.jsxs("div",{className:"shots-rail",children:[s.jsxs(P,{className:"shots-take",size:"md",onClick:r,disabled:i,children:[i?s.jsx(ot,{className:"animate-spin",size:14,"aria-hidden":"true"}):s.jsx(Nt,{size:14,"aria-hidden":"true"}),i?"Taking screenshot…":"Take screenshot"]}),s.jsxs("div",{ref:d,className:"shots-list",role:"listbox","aria-label":n?"Screenshots, pick the right side":"Screenshots",onKeyDown:h,children:[i&&s.jsx("div",{className:"shots-thumb is-pending","aria-hidden":"true"}),e.map(g=>{const f=g.id===t,p=m(g.id);return s.jsxs("div",{"data-capture":g.id,role:"option","aria-selected":f,tabIndex:f||!t&&g===e[0]?0:-1,className:`shots-thumb${f?" is-active":""}${p?" is-compared":""}`,"aria-label":`${lt(g)}${g.markedFrom!==void 0?`, marked copy of ${g.markedFrom}`:""}, ${zs(g.takenAt,c)}${p?`, side ${p}`:""}`,onClick:()=>a(g.id),children:[s.jsx("img",{src:g.thumbUrl,alt:"",draggable:!1}),p&&s.jsx("span",{className:"shots-thumb-side",children:p}),s.jsxs("span",{className:"shots-thumb-label",children:[s.jsxs("span",{className:"shots-thumb-n",children:[g.markedFrom!==void 0&&s.jsx(pi,{size:10,"aria-hidden":"true"}),g.n]}),s.jsx("span",{className:"shots-thumb-time",children:zs(g.takenAt,c).replace("Today ","")})]})]},g.id)})]})]})}var Pt,ou=new Uint8Array(16);function lu(){if(!Pt&&(Pt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Pt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Pt(ou)}const cu=/^(?:[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 du(e){return typeof e=="string"&&cu.test(e)}var ve=[];for(var ws=0;ws<256;++ws)ve.push((ws+256).toString(16).substr(1));function uu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(ve[e[t+0]]+ve[e[t+1]]+ve[e[t+2]]+ve[e[t+3]]+"-"+ve[e[t+4]]+ve[e[t+5]]+"-"+ve[e[t+6]]+ve[e[t+7]]+"-"+ve[e[t+8]]+ve[e[t+9]]+"-"+ve[e[t+10]]+ve[e[t+11]]+ve[e[t+12]]+ve[e[t+13]]+ve[e[t+14]]+ve[e[t+15]]).toLowerCase();if(!du(n))throw TypeError("Stringified UUID is invalid");return n}function hu(e,t,n){e=e||{};var i=e.random||(e.rng||lu)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,uu(i)}const at=50,Zn=6e3;function ks(e){const t=URL.createObjectURL(e.png),n=e.thumb===e.png?t:URL.createObjectURL(e.thumb);return{...e,url:t,thumbUrl:n}}function Ut(e){URL.revokeObjectURL(e.url),e.thumbUrl!==e.url&&URL.revokeObjectURL(e.thumbUrl)}function Qn({url:e,thumbUrl:t,...n}){return n}function mu(e,t){return t.takenAt-e.takenAt||t.n-e.n}function fu(e,t=Cr){const{toast:n}=Be(),[i,r]=u.useState([]),[a,o]=u.useState(null),[d,c]=u.useState(!1),[l,h]=u.useState(!0),[m,g]=u.useState(!1),f=u.useRef(null),p=u.useRef([]);p.current=i;const k=u.useRef(0),C=u.useRef(!0);u.useEffect(()=>{C.current=!0;let S=!1;return c(!1),r([]),o(null),k.current=0,(async()=>{var B;const E=await t();let z=[];try{z=await E.list(e)}catch{z=[]}if(S)return;f.current=E;const D=z.slice(0,at).map(ks);k.current=D.reduce((K,q)=>Math.max(K,q.n),0),h(E.persistent),r(D),o(((B=D[0])==null?void 0:B.id)??null),c(!0)})(),()=>{S=!0}},[e]),u.useEffect(()=>()=>{C.current=!1,p.current.forEach(Ut)},[]);const R=u.useCallback(async S=>{const E=f.current;if(E)try{await E.put(S)}catch{n(`Couldn’t keep ${lt(S)} in this browser. It’s here until you leave the page.`,"error")}},[n]),w=u.useCallback((S,E)=>{var K,q;const z=[...S,...p.current].sort(mu),D=z.slice(at),B=z.slice(0,at);D.forEach(Ut),D.length&&((K=f.current)==null||K.delete(D.map(te=>te.id)).catch(()=>{})),p.current=B,r(B),o(B.some(te=>te.id===E)?E:((q=B[0])==null?void 0:q.id)??null)},[]),b=u.useCallback(async(S,E={})=>{const[z,D]=await Promise.all([Qd(S),tu(S)]);if(!C.current)return;k.current+=1;const B={id:hu(),udid:e,n:k.current,takenAt:Date.now(),width:z.width,height:z.height,bytes:S.size,png:S,thumb:D,...E};w([ks(B)],B.id),await R(B)},[e,w,R]),N=u.useCallback(async()=>{g(!0);try{let S;try{S=await G.getScreenshot(e)}catch(E){n(Te("take a screenshot",E),"error");return}if(!(S!=null&&S.screenshot)){const E=(S==null?void 0:S.error)||(S==null?void 0:S.message);n(E?Te("take a screenshot",{message:E}):"Couldn’t take a screenshot. The phone sent no picture.","error");return}await b(Yd(S.screenshot))}finally{C.current&&g(!1)}},[e,n,b]),y=u.useCallback((S,E)=>b(E,{markedFrom:S.n}),[b]),A=u.useCallback(async S=>{if(!C.current||!S.length)return;const E=S.filter(D=>!p.current.some(B=>B.id===D.id));w(E.map(ks),S[0].id);const z=f.current;await Promise.all(E.map(D=>z==null?void 0:z.put(D).catch(()=>{})))},[w]),v=u.useCallback(async S=>{var q;const E=p.current,z=E.findIndex(te=>te.id===S);if(z<0)return;const D=E[z],B=E.filter(te=>te.id!==S);p.current=B,r(B),o(te=>{var X;return te===S?((X=B[z]??B[z-1])==null?void 0:X.id)??null:te}),Ut(D);const K=Qn(D);n(`Deleted ${lt(D)}`,"info",Zn,{label:"Undo",onClick:()=>void A([K])}),await((q=f.current)==null?void 0:q.delete([S]).catch(()=>{}))},[n,A]),T=u.useCallback(async()=>{var z;const S=p.current;if(!S.length)return;p.current=[],r([]),o(null),S.forEach(Ut);const E=S.map(Qn);n(`Cleared ${S.length} screenshot${S.length===1?"":"s"}`,"info",Zn,{label:"Undo",onClick:()=>void A(E)}),await((z=f.current)==null?void 0:z.clear(e).catch(()=>{}))},[e,n,A]);return{captures:i,selectedId:a,select:o,ready:d,persistent:l,taking:m,take:N,addMarkedCopy:y,remove:v,clearAll:T}}function pu({udid:e,deviceName:t,openStore:n}){const{toast:i}=Be(),r=fu(e,n),{captures:a,selectedId:o,select:d}=r,c=a.find(L=>L.id===o)??null,[l,h]=u.useState("view"),[m,g]=u.useState(null),[f,p]=u.useState(!1),[k,C]=u.useState("RECT"),[R,w]=u.useState(Dr.color),[b,N]=u.useState([]),[y,A]=u.useState(!1),[v,T]=u.useState(!1),S=u.useCallback(()=>{h("view"),N([]),g(null)},[]);u.useEffect(()=>{l!=="view"&&(c?l==="compare"&&m&&!a.some(L=>L.id===m)&&g(null):S())},[l,c,m,a,S]);const E=u.useRef(null),z=u.useRef(l);z.current=l,u.useEffect(()=>{const L=E.current;if(!L)return;const Y=re=>{re.key!=="Escape"||re.defaultPrevented||z.current==="view"||(re.preventDefault(),S())};return L.addEventListener("keydown",Y),()=>L.removeEventListener("keydown",Y)},[S]);const D=L=>{if(l==="compare"){L!==o&&g(L);return}l==="annotate"&&L!==o&&S(),d(L)},B=()=>{if(!c)return;const L=a.indexOf(c),Y=a[L+1]??a[L-1]??null;N([]),g((Y==null?void 0:Y.id)??null),h("compare")},K=async()=>{c&&(await $d(c.png)?i(`Copied ${lt(c)}`,"success"):i("Your browser can’t copy pictures on this address. Use Download instead.","error"))},q=()=>{c&&Jn(c.png,sr(t,c))},te=async()=>{T(!0);try{Jn(await iu(t,a),zd(t))}catch(L){i(Te("make the zip",L),"error")}finally{T(!1)}},X=async()=>{if(!(!c||!b.length)){A(!0);try{const L=await su(c.png,b);await r.addMarkedCopy(c,L),i(`Saved a marked copy of ${lt(c)}`,"success"),S()}catch(L){i(Te("save the marked copy",L),"error")}finally{A(!1)}}},j=a.length,O=r.persistent?j>=at?`${j} of ${at} kept · the oldest goes when you take another`:`${j} of ${at} kept`:"Kept until you leave this page",V=a.find(L=>L.id===m)??null;return s.jsxs("div",{ref:E,className:"shots-root",children:[s.jsxs("header",{className:"shots-head",children:[s.jsxs("h4",{className:"shots-title",children:[s.jsx(Nt,{size:14,"aria-hidden":"true"}),"Screenshots"]}),r.ready&&s.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:O}),s.jsx("span",{className:"shots-actions-gap"}),l==="compare"?s.jsx(P,{variant:"secondary",size:"sm",onClick:S,children:"Done"}):s.jsxs(P,{variant:"secondary",size:"sm",onClick:B,disabled:j<2||l==="annotate",children:[s.jsx(ka,{size:13,"aria-hidden":"true"}),"Compare"]}),s.jsxs(P,{variant:"secondary",size:"sm",onClick:te,disabled:!j||v,children:[v?s.jsx(ot,{className:"animate-spin",size:13,"aria-hidden":"true"}):s.jsx(Ta,{size:13,"aria-hidden":"true"}),"Download all"]}),s.jsx(P,{variant:"secondary",size:"sm",onClick:()=>{S(),r.clearAll()},disabled:!j,children:"Clear all"})]}),r.ready&&!j&&!r.taking?s.jsxs("div",{className:"shots-empty",children:[s.jsx(Nt,{size:22,"aria-hidden":"true"}),s.jsx("p",{className:"shots-empty-title",children:"No screenshots yet"}),s.jsxs("p",{className:"shots-empty-hint",children:["Take one to keep it here. This browser keeps the newest ",at," for this phone."]}),s.jsxs(P,{size:"md",onClick:()=>void r.take(),children:[s.jsx(Nt,{size:14,"aria-hidden":"true"}),"Take screenshot"]})]}):r.ready?s.jsxs("div",{className:"shots-body",children:[s.jsx(au,{captures:a,activeId:l==="compare"?m??o:o,compare:l==="compare"&&o?{a:o,b:m}:void 0,taking:r.taking,onTake:()=>void r.take(),onPick:D,onDelete:L=>void r.remove(L)}),s.jsx("section",{className:"shots-preview","aria-label":"Preview",children:c&&l==="compare"?s.jsx(ru,{a:c,b:V}):c?s.jsxs(s.Fragment,{children:[s.jsx(hr,{capture:c,actualSize:f,onToggleSize:()=>p(L=>!L),annotate:l==="annotate"?{shape:k,color:R,marks:b,onMarksChange:N}:void 0}),s.jsxs("footer",{className:"shots-footer",children:[s.jsx("p",{className:"shots-details",children:Qi(c)}),l==="annotate"?s.jsx(Td,{shape:k,color:R,marks:b.length,saving:y,onShape:C,onColor:w,onUndo:()=>N(L=>L.slice(0,-1)),onClear:()=>N([]),onCancel:S,onSave:()=>void X()}):s.jsxs("div",{className:"shots-actions",children:[s.jsxs(P,{variant:"secondary",size:"sm",onClick:()=>void K(),children:[s.jsx($e,{size:13,"aria-hidden":"true"}),"Copy"]}),s.jsxs(P,{variant:"secondary",size:"sm",onClick:()=>{p(!1),h("annotate")},children:[s.jsx(pi,{size:13,"aria-hidden":"true"}),"Annotate"]}),s.jsxs(P,{variant:"secondary",size:"sm",onClick:q,children:[s.jsx(hi,{size:13,"aria-hidden":"true"}),"Download"]}),s.jsxs(P,{variant:"ghost",size:"sm","aria-pressed":f,onClick:()=>p(L=>!L),children:[f?s.jsx(Ka,{size:13,"aria-hidden":"true"}):s.jsx(Ba,{size:13,"aria-hidden":"true"}),"Actual size"]}),s.jsx("span",{className:"shots-actions-gap"}),s.jsxs(P,{variant:"ghost",size:"sm",className:"shots-delete",onClick:()=>void r.remove(c.id),children:[s.jsx(sa,{size:13,"aria-hidden":"true"}),"Delete"]})]})]})]}):null})]}):null]})}function gu({device:e,onClose:t,titleId:n}){const i=Oi(t),r=$t(),{tab:a}=si(),o=ts(),d=u.useRef(null),[c,l]=u.useState({width:0,height:0}),[h,m]=u.useState("inspect"),[g,f]=u.useState(null),[p,k]=u.useState(a||"actions"),C=p==="omni"&&h==="inspect",[R,w]=u.useState(!0),[b,N]=u.useState(!1),[y,A]=u.useState(0),[v,T]=u.useState(e),[S,E]=u.useState(0),z=u.useCallback(()=>E(Date.now()),[]),D=Ze(v);u.useEffect(()=>{Nr(v.udid,D),document.title=Er(o.pathname)},[v.udid,D,o.pathname]);const[B,K]=u.useState(!1),[q,te]=u.useState(!1),X=10,[j,O]=u.useState(!1),[V,L]=u.useState(!1),Y=nc(v==null?void 0:v.udid,!q),re=()=>{navigator.clipboard.writeText(v.udid).catch(()=>{}),O(!0),setTimeout(()=>O(!1),1500)},H=u.useRef(""),J=u.useRef(null),[oe,xe]=u.useState(!1);u.useEffect(()=>{p&&(!a||a!==p)&&r(`/devices/${e.udid}/control/${p}${o.search}`,{replace:!0})},[p,a,e.udid,r,o.search]);const[$,le]=u.useState(0);ic(()=>{G.leaveStream(v.udid).catch(()=>{})},()=>le(ie=>ie+1)),u.useEffect(()=>((async()=>{try{N(!0),await G.startStream(v.udid);const pe=(await G.getDevices()).find(me=>me.udid===v.udid);pe&&T(pe)}catch(ae){console.error("Auto-start stream failed:",ae)}finally{N(!1)}})(),()=>{G.leaveStream(v.udid).catch(()=>{})}),[e.udid,$]);const ee=parseInt(v.screenWidth||"1080",10),ne=parseInt(v.screenHeight||"1920",10),ge=Math.min(ee,ne),de=Math.max(ee,ne),ke=ge/de,Ae=u.useCallback(()=>{const ie=!R,ae=ie?window.innerHeight*.55:window.innerHeight*.7,pe=620,je=window.innerWidth>900;let _;ie?_=je?Math.min(window.innerWidth*.8,window.innerWidth-pe):window.innerWidth*.8:_=window.innerWidth*.45;const W=R?ke:1/ke;let se,ce;R?(se=ae,ce=se*W,ce>_&&(ce=_,se=ce/W)):(ce=_,se=ce/W,se>ae&&(se=ae,ce=se*W)),l({width:ce,height:se})},[ke,R]);u.useEffect(()=>(Ae(),window.addEventListener("resize",Ae),()=>window.removeEventListener("resize",Ae)),[Ae]),u.useEffect(()=>{const ie=async()=>{if(H.current.length>0){const pe=H.current;H.current="";try{await G.typeText(v.udid,pe)}catch(me){console.error("Keyboard buffering flush failed:",me)}finally{z()}}},ae=pe=>{const me=document.activeElement;if(me&&(me.tagName==="INPUT"||me.tagName==="TEXTAREA"||me.isContentEditable)||!oe&&p!=="terminal")return;const _=pe.key;_==="Enter"?(J.current&&clearTimeout(J.current),ie(),G.pressKey(v.udid,v.platform==="android"?66:"enter").finally(z)):_==="Backspace"?(J.current&&clearTimeout(J.current),ie(),G.pressKey(v.udid,v.platform==="android"?67:"backspace").finally(z)):_.length===1&&(H.current+=_,J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{ie()},50))};return window.addEventListener("keydown",ae),()=>{window.removeEventListener("keydown",ae),J.current&&clearTimeout(J.current)}},[v.udid,v.platform,oe,p,z]);const[We,dt]=u.useState(Date.now()),fe=()=>{const ie=y>0?`r=${y}&`:"";return v.session_id&&!String(v.session_id).startsWith("manual_")?`/xenon/api/session/${v.session_id}/live_video?${ie}t=${We}`:`/xenon/api/control/${v.udid}/stream?${ie}t=${We}`};u.useEffect(()=>{y>0&&dt(Date.now())},[y]),u.useEffect(()=>{if(B||q)return;const ie=setTimeout(()=>te(!0),3e4);return()=>clearTimeout(ie)},[B,q,y]);const Re=u.useRef(null),Ie=ie=>{const ae=ie.currentTarget.getBoundingClientRect();return{x:ie.clientX-ae.left,y:ie.clientY-ae.top}},_e=ie=>{const ae=Ie(ie);Re.current={x:ae.x,y:ae.y,time:Date.now()}},Qe=async ie=>{var jt;if(!Re.current)return;const ae=Re.current,pe=Ie(ie),me=Date.now()-ae.time,je=(jt=d.current)==null?void 0:jt.getBoundingClientRect(),_=(je==null?void 0:je.width)||c.width,W=(je==null?void 0:je.height)||c.height;let se,ce,Me,ht;R?(se=ae.x/_*ge,ce=ae.y/W*de,Me=pe.x/_*ge,ht=pe.y/W*de):(se=ae.x/_*de,ce=ae.y/W*ge,Me=pe.x/_*de,ht=pe.y/W*ge);const et=Math.abs(Me-se),bt=Math.abs(ht-ce);try{me<500&&et<10&&bt<10?await G.tap(v.udid,Math.round(se),Math.round(ce)):me>=500&&et<10&&bt<10?await G.touchAndHold(v.udid,Math.round(se),Math.round(ce),me):await G.swipe(v.udid,Math.round(se),Math.round(ce),Math.round(Me),Math.round(ht))}catch(rs){console.error("Action failed:",rs)}finally{z()}Re.current=null},yt=()=>G.pressKey(v.udid,v.platform==="android"?wt.HOME:hs.HOME).finally(z),Ve=()=>G.pressKey(v.udid,wt.BACK).finally(z),He=()=>G.pressKey(v.udid,wt.APP_SWITCH).finally(z),Ke=()=>G.pressKey(v.udid,v.platform==="android"?wt.VOLUME_UP:hs.VOLUME_UP).finally(z),xt=()=>G.pressKey(v.udid,v.platform==="android"?wt.VOLUME_DOWN:hs.VOLUME_DOWN).finally(z),ut=()=>G.lock(v.udid).finally(z),qe=async()=>{L(!0);try{await G.unlock(v.udid)}finally{z(),setTimeout(()=>L(!1),2500)}};return s.jsxs("div",{className:"device-control-view",children:[s.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),s.jsxs("header",{className:"control-view-top-bar",children:[s.jsxs("button",{className:"back-to-devices-btn",onClick:i,children:[s.jsx(gn,{size:18})," DEVICES"]}),s.jsxs("div",{className:"device-info-mini",children:[s.jsx("span",{className:`device-pill platform-pill ${v.platform}`,children:v.platform==="ios"?"Apple":"Android"}),s.jsxs("span",{className:"device-pill version-pill",children:["v",v.sdk]}),v.reservedUntil&&Date.now()<v.reservedUntil&&s.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${v.reservedBy}${v.reservationReason?`: ${v.reservationReason}`:""}`,children:["Reserved by ",v.reservedBy||"someone"]}),s.jsx("h2",{id:n,className:"device-name-text",children:D}),s.jsxs("span",{className:"udid-chip",title:v.udid,children:[s.jsx("span",{className:"udid-chip__value",children:v.udid}),s.jsx("button",{type:"button",className:"udid-chip__copy",onClick:re,"aria-label":"Copy UDID",title:j?"Copied!":"Copy UDID",children:j?s.jsx(At,{size:12}):s.jsx($e,{size:12})})]})]})]}),s.jsxs("div",{className:`control-view-main ${R?"":"is-landscape"} ${p==="omni"?"omni-mode":""}`,children:[s.jsxs("div",{className:"device-preview-column",children:[s.jsx("div",{className:"device-screen-wrapper",children:s.jsxs("div",{ref:ie=>{d.current=ie,f(ie)},className:`device-stream-canvas ${R?"":"landscape"} ${oe?"focused":""} ${C?"is-inspecting":""}`,style:{width:c.width,height:c.height,background:"var(--black)"},tabIndex:0,onFocus:()=>xe(!0),onBlur:()=>xe(!1),onMouseDown:C?void 0:_e,onMouseUp:C?void 0:Qe,children:[q?s.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[s.jsx(Fe,{size:40,color:"var(--red, #f87171)"}),s.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),s.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{te(!1),A(0)},children:"Retry"})]}):(b||!B)&&s.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[s.jsx(Et,{size:40,className:"animate-spin",color:"var(--color-accent)"}),s.jsx("p",{style:{marginTop:16},children:b?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!q&&s.jsx(ni,{src:fe(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>K(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),K(!1),y>=X){te(!0);return}setTimeout(()=>A(ie=>ie+1),2e3)}}),Y==="off"&&!q&&s.jsxs("div",{className:"device-screen-off",role:"status",children:[s.jsx(Xa,{size:32}),s.jsx("p",{children:"Display is off"}),s.jsx("span",{children:"The stream is fine — the device is asleep."}),s.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:qe,disabled:V,children:V?"Waking…":"Wake device"})]})]})}),s.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":R?"vertical":"horizontal",children:[s.jsx("button",{className:`footer-action-btn ${R?"active":""}`,onClick:()=>w(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":R,children:s.jsx(ro,{size:18})}),s.jsx("button",{className:`footer-action-btn ${R?"":"active"}`,onClick:()=>w(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!R,children:s.jsx(no,{size:18})}),s.jsx("div",{className:"footer-divider"}),s.jsx("button",{className:"footer-action-btn",onClick:yt,title:"Home","aria-label":"Home",children:s.jsx(Lr,{size:18})}),v.platform==="android"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"footer-action-btn",onClick:Ve,title:"Back","aria-label":"Back",children:s.jsx(gn,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:He,title:"App switcher","aria-label":"App switcher",children:s.jsx(ii,{size:18})})]}),s.jsx("div",{className:"footer-divider"}),s.jsx("button",{className:"footer-action-btn",onClick:Ke,title:"Volume up","aria-label":"Volume up",children:s.jsx(Co,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:xt,title:"Volume down","aria-label":"Volume down",children:s.jsx(ko,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:ut,title:"Lock device","aria-label":"Lock device",children:s.jsx(na,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:qe,title:"Unlock device","aria-label":"Unlock device",children:s.jsx(Oa,{size:18})})]})]}),s.jsxs("div",{className:"device-interactions-column",children:[s.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[s.jsxs("button",{className:`tab-btn ${p==="actions"?"active":""}`,onClick:()=>k("actions"),role:"tab","aria-selected":p==="actions",children:[s.jsx(ci,{size:13}),s.jsx("span",{children:"Actions"})]}),s.jsxs("button",{className:`tab-btn ${p==="screenshot"?"active":""}`,onClick:()=>k("screenshot"),role:"tab","aria-selected":p==="screenshot",children:[s.jsx(Nt,{size:13}),s.jsx("span",{children:"Screenshot"})]}),s.jsxs("button",{className:`tab-btn ${p==="logs"?"active":""}`,onClick:()=>k("logs"),role:"tab","aria-selected":p==="logs",children:[s.jsx(gi,{size:13}),s.jsx("span",{children:"Logs"})]}),s.jsxs("button",{className:`tab-btn ${p==="terminal"?"active":""}`,onClick:()=>k("terminal"),role:"tab","aria-selected":p==="terminal",children:[s.jsx(Jr,{size:13}),s.jsx("span",{children:"Shell"})]}),s.jsxs("button",{className:`tab-btn ${p==="omni"?"active":""}`,onClick:()=>k("omni"),role:"tab","aria-selected":p==="omni",children:[s.jsx(Mr,{size:13}),s.jsx("span",{children:"Omni-Vision"})]})]}),s.jsx("div",{className:`interactions-scroll-area ${p==="terminal"?"terminal-mode":""} ${p==="screenshot"||p==="logs"?"screenshot-mode":""}`,children:s.jsxs("div",{className:"tab-content",children:[p==="omni"&&s.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:s.jsx(sc,{sessionId:v.session_id?String(v.session_id):null,udid:v.udid,streamUrl:fe(),embedded:!0,overlayTarget:g,onModeChange:m,deviceActionAt:S})}),p==="actions"&&s.jsx(Nd,{udid:v.udid,platform:v.platform,deviceName:D,screenWidth:ge,screenHeight:de}),p==="screenshot"&&s.jsx("div",{className:"action-card screenshot-card",children:s.jsx(pu,{udid:v.udid,deviceName:D})}),p==="logs"&&s.jsx("div",{className:"action-card screenshot-card",children:s.jsx(hd,{udid:v.udid,platform:v.platform})}),p==="terminal"&&s.jsx("div",{className:"action-card full-height",children:s.jsx(vl,{platform:(v.platform||"").toLowerCase(),prompt:`${(v.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${D} (${v.udid}).
279
- Internal Shell Environment.`,onCommand:async ie=>{const ae=await G.executeShell(v.udid,ie);if(ae.error)throw new Error(ae.error);return ae.output}})})]})})]})]}),v.session_id&&!String(v.session_id).startsWith("manual_")&&s.jsx(zr,{sessionId:String(v.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const mr="xenon.devices.view";function fr(){try{return window.localStorage}catch{return null}}function vu(e,t){const n=e.get("view");return n==="table"||n==="cards"?n:t}function yu(e,t,n){t==="table"||t!==n?e.set("view",t):e.delete("view")}function ei(e=fr()){try{return(e==null?void 0:e.getItem(mr))==="table"?"table":"cards"}catch{return"cards"}}function xu(e,t=fr()){try{t==null||t.setItem(mr,e)}catch{}}class bu extends it.Component{constructor(t){super(t),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=it.createRef(),this.containerRef=it.createRef(),this.stickyGroupRef=it.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,i=this.containerRef.current;!n||!i||(this.stickyObserver=new ResizeObserver(()=>{i.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var a,o;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const i=n.target;(a=i==null?void 0:i.closest)!=null&&a.call(i,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(o=this.searchRef.current)==null||o.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(el),(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 t=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(t,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var t;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),(t=this.stickyObserver)==null||t.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(t){return t.filter(n=>n.busy).length}async fetchDevices(){try{const t=await G.getDevices(),n=this.getBusyDevicesCount(t),i=await G.getPendingSessionsCount(),r=await G.getQueueSummary();this.setState({devices:t,activeSessionsCount:n,pendingSessionsCount:i,queueSummary:r,loaded:!0})}catch(t){console.log(t),this.setState({loaded:!0})}}setFilters(t){this.props.onFiltersChange({...this.props.filters,...t})}getFiltered(){const t=Date.now();return this.state.devices.filter(n=>Ht(n,this.props.filters,t))}render(){const t=this.getFiltered(),{udid:n}=this.props.params,i=n?this.state.devices.find(l=>l.udid===n):null,{filters:r}=this.props,a=il(this.state.devices,r,Date.now()),o=[{value:"all",label:"Any platform",count:a.platform.all},{value:"android",label:"Android",count:a.platform.android},{value:"ios",label:"iOS",count:a.platform.ios}];(rl(this.state.devices)||r.platform==="tvos")&&o.push({value:"tvos",label:"tvOS",count:a.platform.tvos});const d=[{value:"all",label:"Any type",count:a.type.all},{value:"real",label:"Real devices",count:a.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:a.type.virtual}],c=`/devices${this.props.locationSearch}`;return s.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[s.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[s.jsx(Rr,{icon:Ss,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),s.jsxs("div",{className:"de2-toolbar",children:[s.jsx(vn,{size:"sm",label:"Status",value:r.status,onChange:l=>this.setFilters({status:l}),segments:[{value:"all",label:"All",count:a.status.all},{value:"ready",label:"Ready",tone:"ready",count:a.status.ready},{value:"busy",label:"Busy",tone:"busy",count:a.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:a.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:a.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:a.status.offline}]}),s.jsxs("div",{className:"de2-toolbar-row",children:[s.jsxs("div",{className:"de2-search-wrap",children:[s.jsx(Os,{size:13,className:"de2-search-icon","aria-hidden":"true"}),s.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:r.q,onChange:l=>this.setFilters({q:l.target.value})}),s.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),s.jsx(bn,{name:"Platform",value:r.platform,anyValue:"all",options:o,onChange:l=>this.setFilters({platform:l})}),s.jsx(bn,{name:"Type",value:r.type,anyValue:"all",options:d,onChange:l=>this.setFilters({type:l})}),al(r)&&s.jsx(P,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),s.jsxs("div",{className:"de2-result",children:[s.jsx(vn,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&s.jsx("span",{"aria-live":"polite",children:ol(t.length,this.state.devices.length)}),s.jsx(P,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:s.jsx(Bt,{size:13,"aria-hidden":"true"})})]})]})]})]}),t.length>0?this.props.view==="table"?s.jsx(gl,{devices:t,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):s.jsx(Qo,{devices:t,reloadDevices:()=>this.fetchDevices()}):s.jsxs("div",{className:"device-explorer-empty stagger-1",children:[s.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?s.jsx(Ss,{size:32}):s.jsx(Bt,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Global Device Registry Empty"}),s.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."}),s.jsxs(P,{variant:"primary",onClick:()=>this.fetchDevices(),children:[s.jsx(Bt,{size:14}),"Manual sync"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"No devices match these filters"}),s.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),s.jsx(P,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Loading devices…"}),s.jsx("p",{children:"Syncing the global device registry."})]})]}),i&&s.jsx(oc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(c),children:s.jsx("div",{className:"device-control-modal",children:s.jsx(gu,{device:i,titleId:"device-control-title",onClose:()=>this.props.navigate(c)})})})]})}}function ih(){const e=si(),t=$t(),n=ts(),[i,r]=Tr(),{on:a}=Ar(),o=tl(i),d=vu(i,ei()),c=hl(i),l=(h,m,g)=>{const f=sl(h);yu(f,m,ei()),ml(f,g),r(f,{replace:!0})};return s.jsx(bu,{params:e,navigate:t,onSocketEvent:a,filters:o,onFiltersChange:h=>l(h,d,c),view:d,onViewChange:h=>{xu(h),l(o,h,c)},sort:c,onSortChange:h=>l(o,d,h),locationSearch:n.search})}export{bu as DeviceExplorer,ih as default};