@kaeawc/auto-mobile 0.0.93 → 0.0.94

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 (228) hide show
  1. package/dist/build-info.json +12 -12
  2. package/dist/src/ble-peripheral.py +153 -0
  3. package/dist/src/{chunk-r6z1eztj.js → chunk-026y62r9.js} +11 -11
  4. package/dist/src/chunk-0jyfg947.js +4 -0
  5. package/dist/src/{chunk-8g1922rp.js → chunk-0zfpp1wh.js} +4 -4
  6. package/dist/src/{chunk-qf6nynk6.js → chunk-13qxf7ym.js} +5 -5
  7. package/dist/src/chunk-1scenrk7.js +4 -0
  8. package/dist/src/chunk-1vb5ph1k.js +4 -0
  9. package/dist/src/{chunk-710rxz9y.js → chunk-20g565q7.js} +3 -3
  10. package/dist/src/chunk-21h6dhdm.js +5 -0
  11. package/dist/src/chunk-25mfpthk.js +78 -0
  12. package/dist/src/{chunk-rbpdk7m0.js → chunk-2b39zyxc.js} +3 -3
  13. package/dist/src/chunk-2gzd6wbd.js +4 -0
  14. package/dist/src/{chunk-xgan0qqp.js → chunk-3dntffy9.js} +1 -1
  15. package/dist/src/chunk-3gfczcsn.js +4 -0
  16. package/dist/src/{chunk-dgrbdpb7.js → chunk-3h5jz1vb.js} +6 -6
  17. package/dist/src/{chunk-t6c8akcm.js → chunk-41zcy6b3.js} +3 -3
  18. package/dist/src/chunk-47n9m2de.js +4 -0
  19. package/dist/src/chunk-4vxeq0vd.js +58 -0
  20. package/dist/src/chunk-59dx6qaf.js +4 -0
  21. package/dist/src/chunk-5sdf9y92.js +4 -0
  22. package/dist/src/{chunk-58wzr3mt.js → chunk-5wk1t46v.js} +3 -3
  23. package/dist/src/{chunk-vy3bwm1d.js → chunk-661c50hh.js} +5 -5
  24. package/dist/src/chunk-68n6bjjd.js +21 -0
  25. package/dist/src/{chunk-v6pya0dm.js → chunk-69pmjdf2.js} +3 -3
  26. package/dist/src/{chunk-e98dqnc9.js → chunk-6hrj3jt6.js} +20 -20
  27. package/dist/src/{chunk-wbh8spm5.js → chunk-6myr26wx.js} +8 -8
  28. package/dist/src/chunk-6n96k09n.js +4 -0
  29. package/dist/src/chunk-6vwrbkre.js +4 -0
  30. package/dist/src/chunk-6wk0yrab.js +4 -0
  31. package/dist/src/chunk-6yhm9een.js +4 -0
  32. package/dist/src/{chunk-mjrps0ac.js → chunk-7k7gjg2t.js} +5 -5
  33. package/dist/src/chunk-7n5fz68h.js +4 -0
  34. package/dist/src/chunk-8cvnpnbp.js +4 -0
  35. package/dist/src/chunk-8kzv7rk7.js +4 -0
  36. package/dist/src/chunk-8nj68t1v.js +167 -0
  37. package/dist/src/{chunk-g7tmjbkt.js → chunk-96r3bpg7.js} +3 -3
  38. package/dist/src/chunk-97x887te.js +4 -0
  39. package/dist/src/{chunk-8ph29g99.js → chunk-99a6tbvd.js} +1 -1
  40. package/dist/src/chunk-9p5d2994.js +5 -0
  41. package/dist/src/{chunk-aabchzxk.js → chunk-9q265er0.js} +4 -4
  42. package/dist/src/{chunk-jh6vhqzx.js → chunk-9xgnrv5w.js} +3 -3
  43. package/dist/src/chunk-9xgsmshb.js +5 -0
  44. package/dist/src/chunk-a02d1wgv.js +4 -0
  45. package/dist/src/{chunk-ndt1ccxm.js → chunk-a9ps00a1.js} +10 -10
  46. package/dist/src/{chunk-5d2hft6c.js → chunk-aewdveet.js} +3 -3
  47. package/dist/src/{chunk-ycaj2sgf.js → chunk-b3tdtq7r.js} +6 -6
  48. package/dist/src/chunk-bn7jx7a2.js +4 -0
  49. package/dist/src/{chunk-3y6eykz9.js → chunk-bnyw27ja.js} +2 -2
  50. package/dist/src/{chunk-rqc9ap3x.js → chunk-bpwsg76p.js} +2 -2
  51. package/dist/src/chunk-bvranw3g.js +4 -0
  52. package/dist/src/chunk-c25a84zb.js +4 -0
  53. package/dist/src/chunk-c27yv1dx.js +5 -0
  54. package/dist/src/chunk-c3ewxm4x.js +5 -0
  55. package/dist/src/{chunk-rvvy1bte.js → chunk-cb1ga9rd.js} +5 -5
  56. package/dist/src/chunk-cn7fwy7k.js +4 -0
  57. package/dist/src/chunk-cnvy4a64.js +4 -0
  58. package/dist/src/{chunk-7rz9898k.js → chunk-cqhw4yr6.js} +3 -3
  59. package/dist/src/{chunk-g04bwyj3.js → chunk-ctmfshjc.js} +2 -2
  60. package/dist/src/chunk-ctwmhz13.js +4 -0
  61. package/dist/src/{chunk-waqwcjyn.js → chunk-d3jx9bz5.js} +2 -2
  62. package/dist/src/{chunk-ayp07wbb.js → chunk-d6rb08ga.js} +1 -1
  63. package/dist/src/chunk-ddqhj4eg.js +5 -0
  64. package/dist/src/{chunk-r7bpkgff.js → chunk-ddrhs1c3.js} +2 -2
  65. package/dist/src/chunk-dnjnh9p6.js +4 -0
  66. package/dist/src/{chunk-wyrkw6hw.js → chunk-dw5rwgya.js} +3 -3
  67. package/dist/src/{chunk-3xkpk44w.js → chunk-e0870khr.js} +3 -3
  68. package/dist/src/chunk-ea3k10kj.js +4 -0
  69. package/dist/src/chunk-emv82m1w.js +7 -0
  70. package/dist/src/chunk-f3m6pdnx.js +4 -0
  71. package/dist/src/chunk-f84z32cb.js +4 -0
  72. package/dist/src/chunk-fpczgf0z.js +4 -0
  73. package/dist/src/{chunk-2tqzq5qh.js → chunk-g2js4c2v.js} +18 -18
  74. package/dist/src/chunk-g3af2qbk.js +5 -0
  75. package/dist/src/{chunk-3qwrzxh0.js → chunk-gadtna7s.js} +6 -6
  76. package/dist/src/{chunk-ybbtagbt.js → chunk-gcyx407v.js} +3 -3
  77. package/dist/src/{chunk-bfw6125s.js → chunk-gfpntwc1.js} +3 -3
  78. package/dist/src/chunk-gmnm5e3e.js +4 -0
  79. package/dist/src/chunk-gp6vb5gf.js +4 -0
  80. package/dist/src/chunk-gppgy7pa.js +4 -0
  81. package/dist/src/chunk-hegfz0ae.js +5 -0
  82. package/dist/src/chunk-hpzxdp1k.js +17 -0
  83. package/dist/src/{chunk-qcxzr2my.js → chunk-j69g8b50.js} +3 -3
  84. package/dist/src/chunk-jvstjnqm.js +19 -0
  85. package/dist/src/chunk-jzqrv78s.js +4 -0
  86. package/dist/src/chunk-k2948b8d.js +4 -0
  87. package/dist/src/chunk-k4ftd40d.js +4 -0
  88. package/dist/src/{chunk-bxmsax22.js → chunk-kd9vfaxh.js} +3 -3
  89. package/dist/src/{chunk-s3jc6cwp.js → chunk-kdczmgwk.js} +3 -3
  90. package/dist/src/{chunk-t6bfvfkg.js → chunk-ke3wn14v.js} +1 -1
  91. package/dist/src/chunk-kh5n7m6w.js +4 -0
  92. package/dist/src/{chunk-6wt9rgjf.js → chunk-khejfph4.js} +3 -3
  93. package/dist/src/chunk-kny2xemh.js +4 -0
  94. package/dist/src/chunk-knyzw9md.js +4 -0
  95. package/dist/src/chunk-mbzpt2hp.js +4 -0
  96. package/dist/src/chunk-mm8rcxad.js +4 -0
  97. package/dist/src/chunk-nc4516tx.js +4 -0
  98. package/dist/src/{chunk-6bznss4t.js → chunk-ntfrqrqn.js} +5 -5
  99. package/dist/src/chunk-nz5h2j52.js +4 -0
  100. package/dist/src/chunk-p22s97qy.js +4 -0
  101. package/dist/src/chunk-p9kt1sgr.js +6 -0
  102. package/dist/src/{chunk-yb97j25b.js → chunk-pf282r5g.js} +4 -4
  103. package/dist/src/chunk-pnd4mrxy.js +4 -0
  104. package/dist/src/chunk-pqqteyj6.js +4 -0
  105. package/dist/src/{chunk-6xmss8er.js → chunk-qj1tbnv2.js} +6 -6
  106. package/dist/src/chunk-qnh9egwr.js +4 -0
  107. package/dist/src/chunk-qy3khhf8.js +8 -0
  108. package/dist/src/{chunk-z637nqg8.js → chunk-r0vp315h.js} +6 -6
  109. package/dist/src/chunk-r4j43b9s.js +237 -0
  110. package/dist/src/{chunk-1p7xf5kb.js → chunk-r54cxxze.js} +3 -3
  111. package/dist/src/{chunk-yf7ympyz.js → chunk-r6pvhj33.js} +92 -92
  112. package/dist/src/chunk-rb7aa5gr.js +54 -0
  113. package/dist/src/chunk-rdj50kb4.js +4 -0
  114. package/dist/src/chunk-rnd4vcas.js +4 -0
  115. package/dist/src/{chunk-w5b2jwk3.js → chunk-s3y3zfcx.js} +8 -8
  116. package/dist/src/chunk-s4g43k75.js +5 -0
  117. package/dist/src/chunk-sfqe223f.js +311 -0
  118. package/dist/src/{chunk-284ptqa4.js → chunk-sqdrxjw5.js} +5 -5
  119. package/dist/src/{chunk-zgja5f3p.js → chunk-t54k47em.js} +4 -4
  120. package/dist/src/{chunk-3sy6ahhz.js → chunk-tek4pnvv.js} +10 -10
  121. package/dist/src/chunk-tn74y7af.js +4 -0
  122. package/dist/src/{chunk-thbh3jew.js → chunk-tvq0nzam.js} +3 -3
  123. package/dist/src/{chunk-0jrrsnc9.js → chunk-tx4f0h9c.js} +4 -4
  124. package/dist/src/chunk-vdqag3fj.js +5 -0
  125. package/dist/src/chunk-vz5zzs57.js +4 -0
  126. package/dist/src/chunk-w4s2vfpj.js +4 -0
  127. package/dist/src/{chunk-4hw3665t.js → chunk-w5yypt53.js} +11 -11
  128. package/dist/src/{chunk-8037tzzj.js → chunk-w68v64vh.js} +3 -3
  129. package/dist/src/chunk-whwj0pdk.js +5 -0
  130. package/dist/src/chunk-wnmqt1dc.js +4 -0
  131. package/dist/src/{chunk-cyy71ggq.js → chunk-wpe46vsa.js} +3 -3
  132. package/dist/src/{chunk-w3vs79ex.js → chunk-wxdjeb4k.js} +19 -19
  133. package/dist/src/chunk-xcqzwf9j.js +247 -0
  134. package/dist/src/chunk-xezekwwn.js +5 -0
  135. package/dist/src/chunk-xf19m15s.js +4 -0
  136. package/dist/src/chunk-xghbxha4.js +4 -0
  137. package/dist/src/{chunk-00167wan.js → chunk-xn9m3xc2.js} +5 -5
  138. package/dist/src/{chunk-26k317v5.js → chunk-yqfz4vts.js} +3 -3
  139. package/dist/src/chunk-z8tvs8nk.js +5 -0
  140. package/dist/src/chunk-zm2rehqb.js +5 -0
  141. package/dist/src/chunk-zs6dqm35.js +4 -0
  142. package/dist/src/daemon/processEntry.js +2 -2
  143. package/dist/src/index.js +4 -4
  144. package/dist/src/runtime/bunRuntimeGuard.js +2 -2
  145. package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -2
  146. package/package.json +2 -2
  147. package/dist/src/chunk-0n6swkwg.js +0 -5
  148. package/dist/src/chunk-0qsy1qsx.js +0 -57
  149. package/dist/src/chunk-11m8wj8j.js +0 -237
  150. package/dist/src/chunk-23p5f095.js +0 -4
  151. package/dist/src/chunk-28re4xrg.js +0 -4
  152. package/dist/src/chunk-2f9rkmhx.js +0 -5
  153. package/dist/src/chunk-2fxdh48t.js +0 -4
  154. package/dist/src/chunk-2tbdrbt6.js +0 -4
  155. package/dist/src/chunk-32gvv9b4.js +0 -21
  156. package/dist/src/chunk-3f3t1x97.js +0 -8
  157. package/dist/src/chunk-3fspkbc7.js +0 -4
  158. package/dist/src/chunk-3vg455e6.js +0 -4
  159. package/dist/src/chunk-49bsqdx3.js +0 -4
  160. package/dist/src/chunk-5snsn9cf.js +0 -4
  161. package/dist/src/chunk-5tm9mn47.js +0 -54
  162. package/dist/src/chunk-5zc77a5t.js +0 -4
  163. package/dist/src/chunk-64j0majr.js +0 -19
  164. package/dist/src/chunk-65y8v4td.js +0 -17
  165. package/dist/src/chunk-6awz7vhq.js +0 -5
  166. package/dist/src/chunk-6ep7f5ge.js +0 -4
  167. package/dist/src/chunk-7cs2da62.js +0 -5
  168. package/dist/src/chunk-7g103b54.js +0 -4
  169. package/dist/src/chunk-7j5vj4pa.js +0 -4
  170. package/dist/src/chunk-7tw8x05v.js +0 -4
  171. package/dist/src/chunk-7zy586cb.js +0 -4
  172. package/dist/src/chunk-84nanf8s.js +0 -5
  173. package/dist/src/chunk-8gvwcv2p.js +0 -4
  174. package/dist/src/chunk-8thrmfat.js +0 -4
  175. package/dist/src/chunk-8zgzzs7k.js +0 -78
  176. package/dist/src/chunk-97b1zmaq.js +0 -4
  177. package/dist/src/chunk-9fth9ayh.js +0 -4
  178. package/dist/src/chunk-9j6anhjr.js +0 -4
  179. package/dist/src/chunk-bfjwqk8q.js +0 -4
  180. package/dist/src/chunk-bnhscm2n.js +0 -4
  181. package/dist/src/chunk-c1vs4g1n.js +0 -4
  182. package/dist/src/chunk-ct3e7yng.js +0 -4
  183. package/dist/src/chunk-ddzkz92z.js +0 -4
  184. package/dist/src/chunk-drdz8hee.js +0 -5
  185. package/dist/src/chunk-eersndy7.js +0 -5
  186. package/dist/src/chunk-eggq53ks.js +0 -4
  187. package/dist/src/chunk-f2dya7cs.js +0 -4
  188. package/dist/src/chunk-fbakd6cw.js +0 -4
  189. package/dist/src/chunk-fgb98zjj.js +0 -5
  190. package/dist/src/chunk-fmpad823.js +0 -5
  191. package/dist/src/chunk-g0xr8zw0.js +0 -4
  192. package/dist/src/chunk-g3rjs80x.js +0 -4
  193. package/dist/src/chunk-g78rtrfv.js +0 -4
  194. package/dist/src/chunk-gabgv3y5.js +0 -4
  195. package/dist/src/chunk-gmr45m8f.js +0 -4
  196. package/dist/src/chunk-gsyfebqj.js +0 -4
  197. package/dist/src/chunk-h5rpn9wr.js +0 -247
  198. package/dist/src/chunk-hb1x7v55.js +0 -4
  199. package/dist/src/chunk-hrfytkxh.js +0 -168
  200. package/dist/src/chunk-j4yjzbak.js +0 -4
  201. package/dist/src/chunk-jd6a5v6p.js +0 -5
  202. package/dist/src/chunk-kn5spq15.js +0 -4
  203. package/dist/src/chunk-m94qs0f0.js +0 -4
  204. package/dist/src/chunk-n03dmn5q.js +0 -5
  205. package/dist/src/chunk-n72qhwd9.js +0 -4
  206. package/dist/src/chunk-nr6y0n4y.js +0 -5
  207. package/dist/src/chunk-pcsen2vs.js +0 -4
  208. package/dist/src/chunk-ppfr0b8h.js +0 -4
  209. package/dist/src/chunk-q10bdnat.js +0 -4
  210. package/dist/src/chunk-q9xmq595.js +0 -4
  211. package/dist/src/chunk-qyqypn28.js +0 -5
  212. package/dist/src/chunk-r2epb56s.js +0 -4
  213. package/dist/src/chunk-r5bxavdx.js +0 -311
  214. package/dist/src/chunk-r8jf3d92.js +0 -4
  215. package/dist/src/chunk-rc0dbypm.js +0 -4
  216. package/dist/src/chunk-rhcty4ms.js +0 -4
  217. package/dist/src/chunk-rpvckv3p.js +0 -4
  218. package/dist/src/chunk-ry0mz41y.js +0 -4
  219. package/dist/src/chunk-sfv61xjb.js +0 -6
  220. package/dist/src/chunk-t7w8rctc.js +0 -4
  221. package/dist/src/chunk-v2wd4n3e.js +0 -5
  222. package/dist/src/chunk-w4zga19f.js +0 -4
  223. package/dist/src/chunk-w7hkv422.js +0 -5
  224. package/dist/src/chunk-xa73x2cx.js +0 -5
  225. package/dist/src/chunk-y2vs6jwg.js +0 -4
  226. package/dist/src/chunk-yattm52s.js +0 -4
  227. package/dist/src/chunk-yjawdzk8.js +0 -4
  228. package/dist/src/chunk-zs1sghs9.js +0 -4
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{f,Y,I}from"./chunk-58wzr3mt.js";import{mn,i,e}from"./chunk-z637nqg8.js";import{Bl}from"./chunk-qcxzr2my.js";import v from"fs";import g from"path";import{fileURLToPath as b}from"url";import{createHash as x}from"crypto";import{spawnSync as P}from"child_process";import{execFile as C}from"child_process";import{readFileSync as w,statSync as T}from"fs";import{dirname as R,join as l,resolve as u}from"path";var N={kind(t){let r=T(t,{throwIfNoEntry:!1});return r?.isDirectory()?"directory":r?.isFile()?"file":null},readFile(t){try{return w(t,"utf8")}catch(r){if(r instanceof Error&&"code"in r&&r.code==="ENOENT")return null;throw r}}},O="@kaeawc/auto-mobile",G=2000,A=(t,r,{cwd:n,timeoutMs:o})=>{let s=null;try{s=P("git",r,{cwd:n,encoding:"utf-8",timeout:o,killSignal:"SIGTERM"})}catch(a){}if(!s||s.status!==0||s.error)return null;return(typeof s.stdout==="string"?s.stdout:s.stdout.toString()).trim()},H=async(t,r,{cwd:n,timeoutMs:o})=>{try{return await new Promise((s)=>{C(t,r,{cwd:n,encoding:"utf8",timeout:o,killSignal:"SIGTERM"},(a,d)=>s(a?null:d.trim()))})}catch(s){return e.warn("Async git version probe failed",s),null}};class M{run;fs;runAsync;env;constructor(t=A,r=N,n=H,o=process.env){this.run=t;this.fs=r;this.runAsync=n;this.env=o}readVersion(t,r){if(t.split(/[\\/]/).includes("node_modules"))return null;let n=this.locate(t);if(!n?.toplevel||r(n.toplevel)!==O)return null;let o=this.readHead(n)??this.execute(t,["rev-parse","HEAD"]);if(!o)return null;return{shortSha:o.slice(0,12),dirty:!1,dirtyHash:null}}async readDirtyState(t){let r={cwd:t,timeoutMs:G},n=await this.runAsync("git",["status","--porcelain","--untracked-files=no"],r);if(n===null)return null;let o=n.length>0,s=null;if(o){let a=await this.runAsync("git",["diff","HEAD"],r);if(a)s=x("sha256").update(a).digest("hex").slice(0,12)}return{dirty:o,dirtyHash:s}}locate(t){let r=I(Y.GIT_DIR,this.env),n=I(Y.GIT_WORK_TREE,this.env),o=I(Y.GIT_COMMON_DIR,this.env);if(r===""||n===""||o==="")return{toplevel:this.execute(t,["rev-parse","--show-toplevel"]),dotgit:null};let s=o===void 0?void 0:u(t,o);if(r!==void 0)return{toplevel:n===void 0?this.execute(t,["rev-parse","--show-toplevel"]):u(t,n),dotgit:u(t,r),commonDirOverride:s};let a=this.findRoot(t);if(!a)return null;return{toplevel:n===void 0?a:u(t,n),dotgit:l(a,".git"),commonDirOverride:s}}findRoot(t){try{let r=u(t);while(!0){if(this.fs.kind(l(r,".git")))return r;let n=R(r);if(n===r)return null;r=n}}catch(r){return null}}resolveGitdir(t){if(this.fs.kind(t)==="directory")return t;let r=this.fs.readFile(t)?.replace(/\r?\n$/,"");if(!r?.startsWith("gitdir: ")||/[\r\n\0]/.test(r))return null;let n=r.slice(8);return n?u(R(t),n):null}resolveCommondir(t){let r=this.fs.readFile(l(t,"commondir"));if(r===null)return t;let n=r.replace(/\r?\n$/,"");return n&&!/[\r\n\0]/.test(n)?u(t,n):null}isValidRef(t){return t.startsWith("refs/")&&!/[\x00-\x20\x7f~^:?*\[\\]/.test(t)&&!t.includes("..")&&!t.includes("@{")&&!t.endsWith(".")&&t.split("/").every((r)=>!!r&&!r.startsWith(".")&&!r.endsWith(".lock"))}readRef(t,r,n){let o=/^refs\/(bisect|worktree|rewritten)\//.test(n)?t:r,s=this.fs.readFile(l(o,n));if(s!==null)return s.trim();let c=this.fs.readFile(l(o,"packed-refs"))?.split(/\r?\n/).find((p)=>p.endsWith(` ${n}`))?.match(/^([0-9a-f]{40}|[0-9a-f]{64}) (refs\/\S+)$/);return c?.[2]===n?c[1]:null}resolveHead(t,r){let n=this.fs.readFile(l(t,"HEAD"))?.trim(),o=new Set;while(n?.startsWith("ref: ")){let s=n.slice(5);if(!this.isValidRef(s)||o.has(s)||o.size>=32)return null;o.add(s),n=this.readRef(t,r,s)??void 0}return n&&/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(n)&&!/^0+$/.test(n)?n:null}readHead({dotgit:t,commonDirOverride:r}){try{let n=t&&this.resolveGitdir(t);if(!n)return null;let o=r??this.resolveCommondir(n);if(!o||this.fs.kind(l(o,"reftable")))return null;return this.resolveHead(n,o)}catch(n){return null}}execute(t,r){return this.run("git",r,{cwd:t,timeoutMs:G})}}var h=new M;var E=(t)=>{let r=t;for(let n=0;n<6;n++){let o=g.join(r,"package.json");if(v.existsSync(o))return o;let s=g.dirname(r);if(s===r)break;r=s}return null},y=()=>g.dirname(b(import.meta.url)),F=(t)=>Bl(()=>{let r=v.readFileSync(g.join(t,"package.json"),"utf-8");return JSON.parse(r).name??null},()=>null),L=()=>{let t=E(y())??E(process.cwd());if(!t)return null;return Bl(()=>{let r=v.readFileSync(t,"utf-8");return JSON.parse(r).version??null},()=>null)},W=(t=y(),r=h,n=F)=>r.readVersion(t,n),pn=(t)=>t.split("+")[0],$b=(t)=>t.replace(/(\+g[\da-f]+)\.dirty(?:\.[\da-f]+)?$/i,"$1"),mK=(t)=>/\+g[\da-f]+\.dirty\.[\da-f]+$/i.test(t),m=(t,r)=>{if(!r||r.shortSha.length===0)return t;let n=r.dirty?r.dirtyHash?`.dirty.${r.dirtyHash}`:".dirty":"";return`${t}+g${r.shortSha}${n}`};var j=(t,r,n,o)=>{if(n?.dirty&&n.dirtyHash)return m(t,{...r,...n});let s=m(t,{...r,dirty:!1});return(n?.dirty===!1?void 0:J(s,o))??(n?.dirty?m(t,{...r,...n}):s)},J=(t,r)=>{let n=r?.()?.trim();return n&&mK(n)&&$b(n)===t?n:void 0},k=(t)=>{let r=null,n,o,s=!1,a=()=>o??=n?.()??Promise.resolve();return{current(){if(r!==null)return r;let d=t.env.MCP_SERVER_VERSION;if(d)return r=d,r;let c=t.readPackageVersion()||t.env.npm_package_version||"unknown",p=c==="unknown"?null:t.readGitVersion();if(r=m(c,p),p)n=async()=>{let V=null;try{V=await t.readDirtyState()}catch(_){e.warn("Background git dirty-state resolution failed",_)}r=j(c,p,V,t.readLaunchVersion),s=!0},t.timer.setTimeout(()=>void a(),0);return r},isSettled(){return this.current(),n===void 0||s},async resolveSettled(){return this.current(),await a(),this.current()}}},K,D=()=>({env:{MCP_SERVER_VERSION:I(Y.MCP_SERVER_VERSION),npm_package_version:I(Y.NPM_PACKAGE_VERSION)},readPackageVersion:L,readGitVersion:()=>W(y(),mn.gitMetadataClient),readDirtyState:()=>(mn.gitMetadataClient??h).readDirtyState(y()),timer:{setTimeout(t,r){let n=i.setTimeout(t,r);return n.unref?.(),n}}}),S=()=>K??=k({...D(),readLaunchVersion:()=>I(f.DAEMON_LAUNCH_CHECKOUT_VERSION)}),LO=()=>k(D()).resolveSettled(),Cn=()=>S().current(),mJ=()=>S().isSettled(),fJ=()=>S().resolveSettled();
3
- export{pn,$b,mK,LO,Cn,mJ,fJ};
2
+ import{h,Y,I}from"./chunk-5wk1t46v.js";import{yn,i,e}from"./chunk-r0vp315h.js";import{Kl}from"./chunk-j69g8b50.js";import v from"fs";import m from"path";import{fileURLToPath as b}from"url";import{createHash as x}from"crypto";import{spawnSync as P}from"child_process";import{execFile as C}from"child_process";import{readFileSync as w,statSync as T}from"fs";import{dirname as R,join as l,resolve as u}from"path";var N={kind(t){let r=T(t,{throwIfNoEntry:!1});return r?.isDirectory()?"directory":r?.isFile()?"file":null},readFile(t){try{return w(t,"utf8")}catch(r){if(r instanceof Error&&"code"in r&&r.code==="ENOENT")return null;throw r}}},O="@kaeawc/auto-mobile",G=2000,A=(t,r,{cwd:n,timeoutMs:o})=>{let s=null;try{s=P("git",r,{cwd:n,encoding:"utf-8",timeout:o,killSignal:"SIGTERM"})}catch(a){}if(!s||s.status!==0||s.error)return null;return(typeof s.stdout==="string"?s.stdout:s.stdout.toString()).trim()},H=async(t,r,{cwd:n,timeoutMs:o})=>{try{return await new Promise((s)=>{C(t,r,{cwd:n,encoding:"utf8",timeout:o,killSignal:"SIGTERM"},(a,d)=>s(a?null:d.trim()))})}catch(s){return e.warn("Async git version probe failed",s),null}};class M{run;fs;runAsync;env;constructor(t=A,r=N,n=H,o=process.env){this.run=t;this.fs=r;this.runAsync=n;this.env=o}readVersion(t,r){if(t.split(/[\\/]/).includes("node_modules"))return null;let n=this.locate(t);if(!n?.toplevel||r(n.toplevel)!==O)return null;let o=this.readHead(n)??this.execute(t,["rev-parse","HEAD"]);if(!o)return null;return{shortSha:o.slice(0,12),dirty:!1,dirtyHash:null}}async readDirtyState(t){let r={cwd:t,timeoutMs:G},n=await this.runAsync("git",["status","--porcelain","--untracked-files=no"],r);if(n===null)return null;let o=n.length>0,s=null;if(o){let a=await this.runAsync("git",["diff","HEAD"],r);if(a)s=x("sha256").update(a).digest("hex").slice(0,12)}return{dirty:o,dirtyHash:s}}locate(t){let r=I(Y.GIT_DIR,this.env),n=I(Y.GIT_WORK_TREE,this.env),o=I(Y.GIT_COMMON_DIR,this.env);if(r===""||n===""||o==="")return{toplevel:this.execute(t,["rev-parse","--show-toplevel"]),dotgit:null};let s=o===void 0?void 0:u(t,o);if(r!==void 0)return{toplevel:n===void 0?this.execute(t,["rev-parse","--show-toplevel"]):u(t,n),dotgit:u(t,r),commonDirOverride:s};let a=this.findRoot(t);if(!a)return null;return{toplevel:n===void 0?a:u(t,n),dotgit:l(a,".git"),commonDirOverride:s}}findRoot(t){try{let r=u(t);while(!0){if(this.fs.kind(l(r,".git")))return r;let n=R(r);if(n===r)return null;r=n}}catch(r){return null}}resolveGitdir(t){if(this.fs.kind(t)==="directory")return t;let r=this.fs.readFile(t)?.replace(/\r?\n$/,"");if(!r?.startsWith("gitdir: ")||/[\r\n\0]/.test(r))return null;let n=r.slice(8);return n?u(R(t),n):null}resolveCommondir(t){let r=this.fs.readFile(l(t,"commondir"));if(r===null)return t;let n=r.replace(/\r?\n$/,"");return n&&!/[\r\n\0]/.test(n)?u(t,n):null}isValidRef(t){return t.startsWith("refs/")&&!/[\x00-\x20\x7f~^:?*\[\\]/.test(t)&&!t.includes("..")&&!t.includes("@{")&&!t.endsWith(".")&&t.split("/").every((r)=>!!r&&!r.startsWith(".")&&!r.endsWith(".lock"))}readRef(t,r,n){let o=/^refs\/(bisect|worktree|rewritten)\//.test(n)?t:r,s=this.fs.readFile(l(o,n));if(s!==null)return s.trim();let c=this.fs.readFile(l(o,"packed-refs"))?.split(/\r?\n/).find((f)=>f.endsWith(` ${n}`))?.match(/^([0-9a-f]{40}|[0-9a-f]{64}) (refs\/\S+)$/);return c?.[2]===n?c[1]:null}resolveHead(t,r){let n=this.fs.readFile(l(t,"HEAD"))?.trim(),o=new Set;while(n?.startsWith("ref: ")){let s=n.slice(5);if(!this.isValidRef(s)||o.has(s)||o.size>=32)return null;o.add(s),n=this.readRef(t,r,s)??void 0}return n&&/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(n)&&!/^0+$/.test(n)?n:null}readHead({dotgit:t,commonDirOverride:r}){try{let n=t&&this.resolveGitdir(t);if(!n)return null;let o=r??this.resolveCommondir(n);if(!o||this.fs.kind(l(o,"reftable")))return null;return this.resolveHead(n,o)}catch(n){return null}}execute(t,r){return this.run("git",r,{cwd:t,timeoutMs:G})}}var y=new M;var E=(t)=>{let r=t;for(let n=0;n<6;n++){let o=m.join(r,"package.json");if(v.existsSync(o))return o;let s=m.dirname(r);if(s===r)break;r=s}return null},g=()=>m.dirname(b(import.meta.url)),F=(t)=>Kl(()=>{let r=v.readFileSync(m.join(t,"package.json"),"utf-8");return JSON.parse(r).name??null},()=>null),L=()=>{let t=E(g())??E(process.cwd());if(!t)return null;return Kl(()=>{let r=v.readFileSync(t,"utf-8");return JSON.parse(r).version??null},()=>null)},W=(t=g(),r=y,n=F)=>r.readVersion(t,n),gn=(t)=>t.split("+")[0],eS=(t)=>t.replace(/(\+g[\da-f]+)\.dirty(?:\.[\da-f]+)?$/i,"$1"),MK=(t)=>/\+g[\da-f]+\.dirty\.[\da-f]+$/i.test(t),p=(t,r)=>{if(!r||r.shortSha.length===0)return t;let n=r.dirty?r.dirtyHash?`.dirty.${r.dirtyHash}`:".dirty":"";return`${t}+g${r.shortSha}${n}`};var j=(t,r,n,o)=>{if(n?.dirty&&n.dirtyHash)return p(t,{...r,...n});let s=p(t,{...r,dirty:!1});return(n?.dirty===!1?void 0:J(s,o))??(n?.dirty?p(t,{...r,...n}):s)},J=(t,r)=>{let n=r?.()?.trim();return n&&MK(n)&&eS(n)===t?n:void 0},k=(t)=>{let r=null,n,o,s=!1,a=()=>o??=n?.()??Promise.resolve();return{current(){if(r!==null)return r;let d=t.env.MCP_SERVER_VERSION;if(d)return r=d,r;let c=t.readPackageVersion()||t.env.npm_package_version||"unknown",f=c==="unknown"?null:t.readGitVersion();if(r=p(c,f),f)n=async()=>{let V=null;try{V=await t.readDirtyState()}catch(_){e.warn("Background git dirty-state resolution failed",_)}r=j(c,f,V,t.readLaunchVersion),s=!0},t.timer.setTimeout(()=>void a(),0);return r},isSettled(){return this.current(),n===void 0||s},async resolveSettled(){return this.current(),await a(),this.current()}}},K,D=()=>({env:{MCP_SERVER_VERSION:I(Y.MCP_SERVER_VERSION),npm_package_version:I(Y.NPM_PACKAGE_VERSION)},readPackageVersion:L,readGitVersion:()=>W(g(),yn.gitMetadataClient),readDirtyState:()=>(yn.gitMetadataClient??y).readDirtyState(g()),timer:{setTimeout(t,r){let n=i.setTimeout(t,r);return n.unref?.(),n}}}),S=()=>K??=k({...D(),readLaunchVersion:()=>I(h.DAEMON_LAUNCH_CHECKOUT_VERSION)}),nM=()=>k(D()).resolveSettled(),Nn=()=>S().current(),N8=()=>S().isSettled(),F8=()=>S().resolveSettled();
3
+ export{gn,eS,MK,nM,Nn,N8,F8};
4
4
 
5
- //# debugId=F23F8C727794436B64756E2164756E21
5
+ //# debugId=30EF591506D8522364756E2164756E21
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{i,vE,wae,we,qt,l,e}from"./chunk-z637nqg8.js";import{ra,sr,al,xT,kW,EW,OL,E3,ML,Ao}from"./chunk-0qsy1qsx.js";import{B}from"./chunk-yf7ympyz.js";import{no,Dr,H,J,jr,Wn,ni,o,P,nb,ib,Qm,Ip,Ut,fr,Ee,Zt,Hr,Ab,sO,x,E,Ws}from"./chunk-r5bxavdx.js";import{pP,mP}from"./chunk-4hw3665t.js";import{n3,rte,nte,ite,ote,qh,vw,bw,bv}from"./chunk-7rz9898k.js";import{il,Oe}from"./chunk-3xkpk44w.js";import{cs,ute,nW,xC,c3,mte}from"./chunk-qyqypn28.js";import{Ca,Wh,Wi}from"./chunk-fgb98zjj.js";import{Vo,BW,KC,wc,_3,Ma,Na,eg,NT,Fa,Tw,x3,C3,tg,rg,Sn,kw,Ew,Iw,Iv,Yte}from"./chunk-rvvy1bte.js";import{r,t,u,St}from"./chunk-rbpdk7m0.js";class Q{dependencies;constructor(n){this.dependencies=n}async resolveState(n,s){o(n);let{talkBack:a,unconfirmed:c}=await P(Wh(this.dependencies.accessibilityDetector,this.dependencies.target.device.deviceId,this.dependencies.target.adb,this.dependencies.featureFlags),n);if(o(n),c)s?.([Ca]);return a===!0}async dispatchTap(n,s,a,{signal:c,context:d}){let p={assertCurrent:()=>{o(c),d.assertCurrent()}},m=this.dependencies.talkBackDriverFactory.createDriver(this.dependencies.target.device),h={requestTraversalOrder:m.requestTraversalOrder.bind(m),requestCurrentFocus:m.requestCurrentFocus.bind(m),requestAction:m.requestAction.bind(m),requestNodeAction:m.requestNodeAction.bind(m),supportsNodeActionSelectors:m.supportsNodeActionSelectors.bind(m),requestTapCoordinates:async(y)=>{let{x:b,y:T,duration:g=10,onDispatch:v}=y;p.assertCurrent();let R=()=>{d.onDispatched?.(),v?.()},S=this.dependencies.useContextualFocusTap?await this.requestContextualTalkBackFocus({x:b,y:T},g,a,{signal:c,fence:p,onDispatch:R}):await m.requestTapCoordinates({x:b,y:T,duration:g,onDispatch:R});if(S.success)d.onTapDelivered();return o(c),{...S,totalTimeMs:0}},requestDoubleTapCoordinates:async(y,b,T)=>{p.assertCurrent();let g=await m.requestDoubleTapCoordinates(y,b,()=>{d.onDispatched?.(),T?.()});if(g.success)d.onTapDelivered(),d.onTapDelivered();return o(c),g}},f=await P(n.action==="longPress"?this.dependencies.talkBackStrategy.executeCoordinateFallback({x:s.x,y:s.y},"longPress",Tw(n,"android"),{driver:h,fenceOptions:{displayFence:p}}):this.dependencies.talkBackStrategy.executePreciseTap(s.x,s.y,h,p),c);if(d.onActivationWarnings?.(f.warnings),!f.success)throw new t(`TalkBack coordinate tap failed: ${f.error??"activation was not confirmed"}${f.focusCompleted?" Focus touch was delivered; activation failed. Do not retry automatically.":""}`);o(c)}async requestContextualTalkBackFocus(n,s,a,c){let{signal:d,fence:p,onDispatch:m}=c,h=!1;try{let f=await this.dependencies.androidClient.requestTapCoordinates({x:n.x,y:n.y,duration:s,timeoutMs:Ab(s),frameContext:a,onDispatch:()=>{h=!0},signal:d,beforeSend:p.assertCurrent});if(h&&!Fa(f.error))m();return f}catch(f){if(h)throw m(),Sn(r(f));throw u(f,"TalkBack focus tap failed before dispatch")}}}class Z{dependencies;constructor(n){this.dependencies=n}async dispatchAndroidTaps(n,s,a,c){let{transitionRevision:d}=c,p=await this.dispatchAndroidTapWithOneFreshRetry(n,s,a,c);if(!c.talkBackEnabled)await this.dispatchSecondAndroidTap(n,s,d,{...c,firstTap:p})}async dispatchAndroidTapWithOneFreshRetry(n,s,a,c){let{signal:d,transitionRevision:p,perf:m}=c,h=a.viewHierarchy?.frameContext,f=!1,y=!1,b=()=>{f=!0,c.onTapDelivered()};try{if(c.talkBackEnabled)return await this.dependencies.androidTalkBack.dispatchTap(n,s,h,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:b,onDispatched:()=>{y=!0},onActivationWarnings:c.onActivationWarnings}}),{doubleTapDelivered:!1,startedAt:this.dependencies.timer.now()};return await this.dispatchAndroidFirstTap(n,s,h,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:c.onTapDelivered}})}catch(T){o(d);let g=u(T,"Failed to dispatch Android coordinate tap");if(f||y||h===void 0||!Fa(g.message))throw g;o(d);let v=await this.dependencies.host.observeScreen.execute({freshness:this.dependencies.host.retryFreshness(n),signal:d,perf:m});this.dependencies.host.assertDisplayRevisionCurrent(p),this.dependencies.host.assertSnapshotCurrent(n,v);let R=this.dependencies.host.resolveFreshFrameRetry(n,s,a,v);if(!R)throw g;if(c.talkBackEnabled)return await this.dependencies.androidTalkBack.dispatchTap(n,R.point,R.frameContext,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:b,onDispatched:()=>{y=!0},onActivationWarnings:c.onActivationWarnings}}),{doubleTapDelivered:!1,startedAt:this.dependencies.timer.now()};return await this.dispatchAndroidFirstTap(n,R.point,R.frameContext,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:c.onTapDelivered}})}}async dispatchAndroidFirstTap(n,s,a,{signal:c,context:d}){let p=this.dependencies.timer.now();if(n.action==="doubleTap"&&await C3(this.dependencies.androidClient,{...s,frameContext:a,signal:c,assertCurrent:d.assertCurrent,onTapDelivered:d.onTapDelivered}))return{doubleTapDelivered:!0,startedAt:p};return await this.dispatchAndroidTap(s,Tw(n,"android"),a,{signal:c,context:d}),{doubleTapDelivered:!1,startedAt:p}}async dispatchSecondAndroidTap(n,s,a,c){let{signal:d}=c;if(n.action!=="doubleTap"||c.firstTap.doubleTapDelivered)return;await x3(this.dependencies.timer,c.firstTap.startedAt,{signal:d,onWarning:(p)=>c.onActivationWarnings([p])}),this.dependencies.host.assertDisplayRevisionCurrent(a),await this.dispatchAndroidTap(s,Tw(n,"android"),void 0,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(a),onTapDelivered:c.onTapDelivered}})}async dispatchAndroidTap(n,s,a,{signal:c,context:d}){let p=ite(d.onTapDelivered);await this.dependencies.androidCoordinateTap(this.dependencies.androidClient,this.dependencies.host.adb,n,{durationMs:s,options:{frameContext:a,signal:c,assertCurrent:d.assertCurrent,onTapDelivered:p}}),p(),o(c)}}import{createHash as fe}from"crypto";import{isDeepStrictEqual as rt}from"util";var nt=300000,it=128,ot=new Set(["extras","view-id","occlusionState","occludedBy","occludedByViewId"]);function V(n){if(Array.isArray(n))return n.map(V);if(!n||typeof n!=="object")return n;return Object.fromEntries(Object.entries(n).filter(([s])=>!ot.has(s)).map(([s,a])=>[s,V(a)]))}function Te(n){return Boolean(ib(n.truncationReasons).length||ib(n.viewHierarchy?.truncationReasons).length)}function ge(n){return Boolean(n.truncationReasons?.some(nb)||n.viewHierarchy?.truncationReasons?.some(nb)||n.viewHierarchy?.windows?.some((s)=>s.truncationReasons?.some(nb)))}function Se(n){return Te(n)||ge(n)&&(!n.viewHierarchy||!Qm(n.viewHierarchy))||Boolean(n.viewHierarchy?.windows?.some((s)=>ib(s.truncationReasons??void 0).length>0))}function ye(n){let s=n.rotation??n.viewHierarchy?.rotation;if(!Number.isInteger(s)||!n.viewHierarchy||Te(n))return null;let a=n.viewHierarchy;return{screenSize:{width:n.screenSize?.width,height:n.screenSize?.height},rotation:s,systemInsets:n.systemInsets,insets:n.insets,activeWindow:{appId:n.activeWindow?.appId,activityName:n.activeWindow?.activityName},screenIdentity:n.screenIdentity?{platform:n.screenIdentity.platform,source:n.screenIdentity.source,key:n.screenIdentity.key}:void 0,hierarchy:{tree:V(a.hierarchy),windows:V(a.windows),packageName:a.packageName,foregroundActivity:a.foregroundActivity,screenWidth:a.screenWidth,screenHeight:a.screenHeight,pixelWidth:a.pixelWidth,pixelHeight:a.pixelHeight,nativeScale:a.nativeScale,rotation:a.rotation,systemInsets:a.systemInsets,insets:a.insets}}}function xe(n,s){let a=ye(n),c=ye(s);return a!==null&&c!==null&&rt(a,c)}function st(n){return Number.isFinite(n.width)&&Number.isFinite(n.height)&&n.width>0&&n.height>0}function at(n){return typeof n==="number"&&Number.isFinite(n)&&n>0}function ut(n){return/^([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}):\d+(?::[0-9a-f]+)?$/i.exec(n)?.[1]?.toLowerCase()}function Ae(n){let s=[];if(!n.display?.key)s.push("display");if(!st(n.screenSize))s.push("screenSize");let a=n.rotation??n.viewHierarchy?.rotation;if(!Number.isInteger(a))s.push("rotation");if(!at(n.viewHierarchy?.nativeScale))s.push("nativeScale");if(!n.viewHierarchy?.frameContext)s.push("frameContext");if(Se(n))s.push("completeHierarchy");return s}function ct(n){let s=n.viewHierarchy?.windows?.find((c)=>c.isFocused),a=s?.bounds;return{focusedWindowPresent:s!==void 0,focusedWindowId:s?.id,focusedWindowType:s?.type,focusedWindowPackage:s?.packageName,focusedWindowBounds:a?JSON.stringify([a.left,a.top,a.right,a.bottom]):void 0}}function be(n,s){if(Ae(s).length>0)return;let{width:a,height:c}=s.screenSize;return{deviceId:n,incarnation:no(n),displayKey:s.display.key,displayRole:s.display.role,displayPosture:s.display.posture,width:a,height:c,rotation:s.rotation??s.viewHierarchy?.rotation,nativeScale:s.viewHierarchy.nativeScale,runnerEpoch:ut(s.viewHierarchy.frameContext),appId:s.activeWindow?.appId||s.viewHierarchy?.packageName,hierarchyPackage:s.viewHierarchy?.packageName,activityName:s.activeWindow?.activityName??"",windowType:s.activeWindow?.type,...ct(s)}}function dt(n,s,a){if(a==="runnerEpoch"||a==="focusedWindowPresent")return!1;if((a==="activityName"||a==="windowType")&&(!n[a]||!s[a]))return!1;if(a.startsWith("focusedWindow")&&(!n.focusedWindowPresent||!s.focusedWindowPresent))return!1;return n[a]!==s[a]}function Pe(n){if(n&&typeof n==="object"&&!Array.isArray(n)){let s=n;return[s.left,s.top,s.right,s.bottom]}return n}function q(n,s){if(Array.isArray(s)){for(let d of s)q(n,d);return}if(!s||typeof s!=="object")return;let a=s,c={...a,...we(a)};if(sO(c["resource-id"]))return;n.update("["),n.update(JSON.stringify([c.className??c.class??c.type,c.role,Pe(qt(a)),c.clickable,c.enabled,c["visible-to-user"],c.scrollable,c["resource-id"],Array.isArray(c.actions)?[...c.actions].sort():c.actions])),q(n,a.node),n.update("]")}function ve(n){let s=n.viewHierarchy,a=ge(n)?Qm(s):s,c=fe("sha256");c.update(Dr([n.systemInsets,n.insets,s.screenWidth,s.screenHeight,s.pixelWidth,s.pixelHeight,s.nativeScale,s.rotation,s.systemInsets,s.insets])),q(c,a.hierarchy);let d;if(a.windows!==void 0){let p=fe("sha256");for(let m of a.windows)p.update(JSON.stringify([m.id,m.type,m.isActive,m.isFocused,Pe(m.bounds),m.windowLayer,m.packageName])),q(p,m.hierarchy);d=p.digest("hex")}return{tree:c.digest("hex"),windows:d}}function pt(n,s){return n.tree===s.tree&&(n.windows===void 0||s.windows===void 0||n.windows===s.windows)}class Re{timer;ids;entries=new Map;constructor(n=i,s=B){this.timer=n;this.ids=s}capture(n,s){let a=be(n,s);if(!a)return{status:"unavailable",missing:Ae(s)};this.cleanup();while(this.entries.size>=it)this.entries.delete(this.entries.keys().next().value);let c={snapshotId:this.ids.next(),expiresAt:this.timer.now()+nt};return this.entries.set(c.snapshotId,{...a,...c,layout:ve(s)}),{status:"captured",reference:c}}staleReason(n,s,a){let c=this.entries.get(n);if(!c)return"Snapshot reference is unknown or evicted; re-observe.";if(this.timer.now()>=c.expiresAt)return this.entries.delete(n),"Snapshot reference expired; re-observe.";if(Se(a))return"Snapshot layout is unavailable. The hierarchy capture was incomplete; observe again, or use a selector or coordinates without a snapshotId.";let d=be(s,a);if(!d)return"Snapshot geometry or frame context is unavailable; re-observe.";if(c.runnerEpoch!==d.runnerEpoch)return"Snapshot reference is stale (runner restarted); re-observe.";for(let m of Object.keys(d))if(dt(c,d,m))return`Snapshot reference is stale (${m} changed); re-observe.`;let p=ve(a);if(!pt(c.layout,p))return"Snapshot reference is stale (tap-targeting layout changed); re-observe.";return}get size(){return this.entries.size}cleanup(){for(let[n,s]of this.entries)if(this.timer.now()>=s.expiresAt)this.entries.delete(n)}}var ip=new Re;var N=31,lt=5000;function ee(n){return`shell input stylus ${n}`}function Q5(n){let{pointer:s,platform:a,gesture:c,display:d}=n;if(s===void 0)return;if(s.toolType!=="stylus"&&s.toolType!=="eraser")return`pointer.toolType "${String(s.toolType)}" is not supported; only "stylus" or "eraser" can be injected`;if(a!=="android")return`pointer.toolType "${s.toolType}" is Android-only; omit pointer on iOS`;if(c==="doubleTap")return"stylus pointer does not support doubleTap yet; use tap or longPress";if(d!==void 0)return"stylus pointer does not support display selection yet; omit display";return}async function mt(n,s){let a=await Ut(n,lt,void 0,s);if(a===null)return`could not read the device's Android API level, so stylus input is refused (it needs API ${N} or newer)`;if(a<N)return`stylus input needs Android API ${N} or newer (this device reports API ${a}): older releases build the injected event without a stylus tool type`;return}async function ht(n,s){let a=await mt(n,s);if(a)throw new t(a)}function Ce(n,s){return Q5({pointer:s.pointer,platform:n,gesture:s.action??"tap",display:s.display})}function Ie(n,s,a="tap"){return{success:!1,x:s.x,y:s.y,action:a,error:n}}class vv extends t{}function ft(n,s){let{command:a,dispatched:c,holdMs:d,signal:p}=s;if(n instanceof Ee||n instanceof BW)return n;try{KC(a,jr(n))}catch(h){return h}if(!c)return n;let m=d===void 0?void 0:n3(n,d,p);return new vv(m??r(n),{cause:n})}async function De(n,{command:s,timeoutMs:a,holdMs:c},d){await ht(n,d.signal);let p=!1;try{await _3(n,s,{...d,timeoutMs:a,onDispatch:()=>{p=!0,d.onDispatch?.()}})}catch(m){throw ft(m,{command:s,dispatched:p,holdMs:c,signal:d.signal})}}async function _e(n,s,a,c={}){let{x:d,y:p}=s,m=a.durationMs??NT,h=a.action==="longPress";try{await De(n,h?{command:ee(`swipe ${d} ${p} ${d} ${p} ${Vo(m)}`),timeoutMs:Hr(m),holdMs:m}:{command:ee(`tap ${d} ${p}`)},c)}catch(f){throw f instanceof vv?Sn(f.message):f}}function tte(n,s,a={}){let{from:c,to:d,duration:p}=s;return De(n,{command:ee(`swipe ${c.x} ${c.y} ${d.x} ${d.y} ${Vo(p)}`),timeoutMs:Hr(p)},a)}var ke=new Map;function Y(n){let s=ke.get(n);if(!s)s=new Wn,ke.set(n,s);return s}var yt="dev.jasonpearson.automobile.ctrlproxy/.pointer.PointerInstrumentation",re=31,bt=1,Be=200,vt=15000;function e3(n){return n*2+vt}class Zc extends t{}function Tt(n){return n.points.slice(1).reduce((s,a)=>s+(a.durationMs??Be),0)}function gt(n){let s={version:bt,tool:n.features.toolType,hover:n.features.hover===!0,buttons:n.buttons??0,displayId:n.displayId??0,points:n.points.map((a,c)=>({x:a.x,y:a.y,...c===0?{}:{durationMs:a.durationMs??Be},...a.distance===void 0?{}:{distance:a.distance},...a.pressure===void 0?{}:{pressure:a.pressure},...a.tilt===void 0?{}:{tilt:a.tilt},...a.orientation===void 0?{}:{orientation:a.orientation}}))};return Buffer.from(JSON.stringify(s),"utf8").toString("base64")}function xt(n){return`shell am instrument -w -r --no-restart -e request ${gt(n)} ${yt}`}function At(n){let s=new Map;for(let d of n.split(/\r?\n/)){let p=/^INSTRUMENTATION_RESULT: ([A-Za-z]+)=(.*)$/.exec(d);if(p)s.set(p[1],p[2])}let a=s.get("success");if(a!=="true"&&a!=="false")return;let c=s.get("error");return{success:a==="true",...c?{error:c}:{},injected:Number(s.get("injected")??0),elapsedMs:Number(s.get("elapsedMs")??0)}}async function Pt(n,s){if(/Unable to find instrumentation|INSTRUMENTATION_FAILED|does not exist/i.test(n))return new Zc("The connected CtrlProxy does not include the pointer instrumentation; update CtrlProxy. No input was sent.");if(/Unknown option|--no-restart/i.test(n))return new Zc("This Android version's `am instrument` has no --no-restart, which keeps the injection from restarting CtrlProxy; hover and stylus injection need Android 12 or newer. No input was sent.");if(/Process crashed|INSTRUMENTATION_RESULT: shortMsg=/i.test(n)){let a="";try{a=(await s.executeCommand("shell settings get secure enabled_accessibility_services",{timeoutMs:5000})).stdout.includes("dev.jasonpearson.automobile.ctrlproxy")?" CtrlProxy's accessibility service is still enabled.":" CtrlProxy's accessibility service is not enabled; re-enable it before retrying."}catch(c){e.warn(`Could not read accessibility services after pointer crash: ${r(c)}`,c)}return new t("The pointer instrumentation crashed before reporting a result; the hover or stroke may have partially run. Verify state with observe before retrying."+a)}return new t("The pointer instrumentation did not report a result; the hover or stroke may have partially run. Verify state with observe before retrying.")}var wt=/could not be closed/i,Rt=5000;async function te(n,s,a,c){let d=s.points[0];try{await H(c,()=>n.executeCommand(`shell input stylus motionevent CANCEL ${Math.round(d.x)} ${Math.round(d.y)}`,{timeoutMs:Rt,...c?{signal:c}:{}}))}catch(p){e.warn(`Could not cancel ${a}: ${r(p)}`,p)}}async function Ne(n,s,a){try{return await n()}catch(c){if(!(c instanceof Zc))await te(s,a,"an abandoned pointer run");throw c}}function qV(n,s){let a=Y(s);return async(c,d)=>{o(d),await a.runExclusive(async()=>{o(d);let p=async()=>{let h=await n.executeCommand(xt(c),{timeoutMs:e3(Tt(c)),signal:d}),f=[h.stdout,h.stderr].filter(Boolean).join(`
3
- `),y=At(f);if(!y)throw await Pt(f,n);return y},m=await Ne(p,n,c);if(!m.success&&m.injected===0&&/refused/i.test(m.error??""))o(d),await te(n,c,"refused pointer input",d),o(d),m=await Ne(p,n,c);if(!m.success&&wt.test(m.error??""))await te(n,c,"an unclosed pointer");if(!m.success)throw new t(`The pointer instrumentation failed after ${m.injected} event${m.injected===1?"":"s"}: ${m.error??"unknown error"}`)})}}function Ct(n,s){let a=s.width-1,c=s.height-1,d=Math.round(n.x),p=Math.round(n.y),m=s.rotation===1?{x:a-p,y:d}:s.rotation===2?{x:a-d,y:c-p}:s.rotation===3?{x:p,y:c-d}:{x:d,y:p};return{x:oe(m.x,a),y:oe(m.y,c)}}function It(n,s){switch(s){case 1:return n+Math.PI/2;case 2:return n+Math.PI;case 3:return n-Math.PI/2;default:return n}}function oe(n,s){return Math.min(Math.max(n,0),s)}function Et(n,s){let a=Math.sin(n)**2,c=Math.sin(s)*Math.cos(s),d=Math.sqrt(Math.max(0,1-4*c*c*a)),p=c===0?a:2*a/(1+d),m=Math.sqrt(p),h=(f)=>Math.max(-90,Math.min(90,Math.round(Math.asin(Math.max(-1,Math.min(1,f)))*180/Math.PI)))||0;return{x:h(-m*Math.sin(s)),y:h(m*Math.cos(s))}}function Dt(n){let s=n.features.hover===!0,a=n.points[0],c=a.pressure??(s?0:1),d=a.distance??(s?0.5:0),m=n.points.some((b)=>b.tilt!==void 0||b.orientation!==void 0)?a.tilt??0:void 0,h=a.orientation??0,f=[{atMs:0,x:a.x,y:a.y,pressure:c,distance:d,tilt:m,orientation:h}],y=0;return n.points.slice(1).forEach((b,T)=>{let g=n.points[T],v=b.durationMs??200,R=Math.max(1,Math.ceil(v/16)),S={pressure:c,distance:d,tilt:m,orientation:h};for(let D=1;D<=R;D++){let A=D/R;c=M(S.pressure,b.pressure??S.pressure,A),d=M(S.distance,b.distance??S.distance,A),m=S.tilt===void 0?void 0:M(S.tilt,b.tilt??S.tilt,A),h=M(S.orientation,b.orientation??S.orientation,A),f.push({atMs:y+Math.floor(v*D/R),x:D===R?b.x:M(g.x,b.x,A),y:D===R?b.y:M(g.y,b.y,A),pressure:c,distance:d,tilt:m,orientation:h})}y+=v}),f}function M(n,s,a){return n+(s-n)*a}function O(n,s){return[3,n,s]}function Me(n,s){return Math.round(oe(n,1)*s)}function se(n,s,a){let c=Ct(n,s),d=!a&&n.tilt!==void 0?Et(n.tilt,It(n.orientation,s.rotation)):void 0;return[...O(0,c.x),...O(1,c.y),...a?O(25,Me(n.distance,255)):O(24,Me(n.pressure,4095)),...d?[...O(26,d.x),...O(27,d.y)]:[]]}var U=[0,0,0];function Fe(n){return n.features.toolType==="eraser"?321:320}function Ue(n,s){return[...n&32?[1,331,s]:[],...n&64?[1,332,s]:[]]}function Ot(n,s,a,c){let d=[1,Fe(c),1];return a?[...d,...se(n,s,!0),...O(24,0),...U]:[...d,1,330,1,...se(n,s,!1),...O(25,0),...Ue(c.buttons??0,1),...U]}function _t(n,s,a){let c=[1,s,0,...U];return n?c:[...Ue(a,0),1,330,0,...O(24,0),...U,...c]}function F(n,s,a){return{code:n,info:{value:0,minimum:s,maximum:a,fuzz:0,flat:0,resolution:0}}}function kt(n){return{id:1,command:"register",name:"automobile-pen",vid:6353,pid:19985,bus:"usb",configuration:[{type:100,data:[0,1,3]},{type:101,data:[320,321,330,331,332]},{type:103,data:[0,1,24,25,26,27]},{type:110,data:[1]}],abs_info:[F(0,0,n.width-1),F(1,0,n.height-1),F(24,0,4095),F(25,0,255),F(26,-90,90),F(27,-90,90)]}}var ne=(n)=>({id:1,command:"inject",events:n}),ie=(n)=>({id:1,command:"delay",duration:n});function Le(n,s){let a=n.features.hover===!0,[c,...d]=Dt(n),p=[kt(s),ie(4000),ne(Ot(c,s,a,n))],m=0;for(let h of d){if(h.atMs>m)p.push(ie(h.atMs-m)),m=h.atMs;p.push(ne([...se(h,s,a),...U]))}return p.push(ne(_t(a,Fe(n),n.buttons??0)),ie(50)),`${p.map((h)=>JSON.stringify(h)).join(`
2
+ import{i,ME,tce,we,qt,l,e}from"./chunk-r0vp315h.js";import{da,ar,yl,jT,GW,YW,YL,W3,JL,ko}from"./chunk-4vxeq0vd.js";import{B}from"./chunk-r6pvhj33.js";import{Ni,Fr,H,J,Jr,Yn,li,o,P,wb,Rb,hf,Iie,Vp,Ht,hr,Ee,Qt,Wr,$b,kO,x,E,Xs}from"./chunk-sfqe223f.js";import{DP,OP}from"./chunk-w5yypt53.js";import{m3,fte,hte,gte,yte,eg,Cw,Dw,Nv}from"./chunk-cqhw4yr6.js";import{pl,Oe}from"./chunk-e0870khr.js";import{Na,rg,zi,us,gW,BC,v3,kte}from"./chunk-vdqag3fj.js";import{zo,sz,uD,Ec,X3,Ba,$a,gg,ZT,Ua,zw,Z3,Q3,yg,vg,Tn,jw,Kw,Gw,Wv,Ire}from"./chunk-cb1ga9rd.js";import{r,t,u,Rt}from"./chunk-2b39zyxc.js";class Q{dependencies;constructor(n){this.dependencies=n}async resolveState(n,s){o(n);let{talkBack:a,unconfirmed:c}=await P(rg(this.dependencies.accessibilityDetector,this.dependencies.target.device.deviceId,this.dependencies.target.adb,this.dependencies.featureFlags),n);if(o(n),c)s?.([Na]);return a===!0}async dispatchTap(n,s,a,{signal:c,context:d}){let p={assertCurrent:()=>{o(c),d.assertCurrent()}},m=this.dependencies.talkBackDriverFactory.createDriver(this.dependencies.target.device),h={requestTraversalOrder:m.requestTraversalOrder.bind(m),requestCurrentFocus:m.requestCurrentFocus.bind(m),requestAction:m.requestAction.bind(m),requestNodeAction:m.requestNodeAction.bind(m),supportsNodeActionSelectors:m.supportsNodeActionSelectors.bind(m),requestTapCoordinates:async(y)=>{let{x:b,y:T,duration:g=10,onDispatch:v}=y;p.assertCurrent();let R=()=>{d.onDispatched?.(),v?.()},S=this.dependencies.useContextualFocusTap?await this.requestContextualTalkBackFocus({x:b,y:T},g,a,{signal:c,fence:p,onDispatch:R}):await m.requestTapCoordinates({x:b,y:T,duration:g,onDispatch:R});if(S.success)d.onTapDelivered();return o(c),{...S,totalTimeMs:0}},requestDoubleTapCoordinates:async(y,b,T)=>{p.assertCurrent();let g=await m.requestDoubleTapCoordinates(y,b,()=>{d.onDispatched?.(),T?.()});if(g.success)d.onTapDelivered(),d.onTapDelivered();return o(c),g}},f=await P(n.action==="longPress"?this.dependencies.talkBackStrategy.executeCoordinateFallback({x:s.x,y:s.y},"longPress",zw(n,"android"),{driver:h,fenceOptions:{displayFence:p}}):this.dependencies.talkBackStrategy.executePreciseTap(s.x,s.y,h,p),c);if(d.onActivationWarnings?.(f.warnings),!f.success)throw new t(`TalkBack coordinate tap failed: ${f.error??"activation was not confirmed"}${f.focusCompleted?" Focus touch was delivered; activation failed. Do not retry automatically.":""}`);o(c)}async requestContextualTalkBackFocus(n,s,a,c){let{signal:d,fence:p,onDispatch:m}=c,h=!1;try{let f=await this.dependencies.androidClient.requestTapCoordinates({x:n.x,y:n.y,duration:s,timeoutMs:$b(s),frameContext:a,onDispatch:()=>{h=!0},signal:d,beforeSend:p.assertCurrent});if(h&&!Ua(f.error))m();return f}catch(f){if(h)throw m(),Tn(r(f));throw u(f,"TalkBack focus tap failed before dispatch")}}}class Z{dependencies;constructor(n){this.dependencies=n}async dispatchAndroidTaps(n,s,a,c){let{transitionRevision:d}=c,p=await this.dispatchAndroidTapWithOneFreshRetry(n,s,a,c);if(!c.talkBackEnabled)await this.dispatchSecondAndroidTap(n,s,d,{...c,firstTap:p})}async dispatchAndroidTapWithOneFreshRetry(n,s,a,c){let{signal:d,transitionRevision:p,perf:m}=c,h=a.viewHierarchy?.frameContext,f=!1,y=!1,b=()=>{f=!0,c.onTapDelivered()};try{if(c.talkBackEnabled)return await this.dependencies.androidTalkBack.dispatchTap(n,s,h,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:b,onDispatched:()=>{y=!0},onActivationWarnings:c.onActivationWarnings}}),{doubleTapDelivered:!1,startedAt:this.dependencies.timer.now()};return await this.dispatchAndroidFirstTap(n,s,h,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:c.onTapDelivered}})}catch(T){o(d);let g=u(T,"Failed to dispatch Android coordinate tap");if(f||y||h===void 0||!Ua(g.message))throw g;o(d);let v=await this.dependencies.host.observeScreen.execute({freshness:this.dependencies.host.retryFreshness(n),signal:d,perf:m});this.dependencies.host.assertDisplayRevisionCurrent(p),this.dependencies.host.assertSnapshotCurrent(n,v);let R=this.dependencies.host.resolveFreshFrameRetry(n,s,a,v);if(!R)throw g;if(c.talkBackEnabled)return await this.dependencies.androidTalkBack.dispatchTap(n,R.point,R.frameContext,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:b,onDispatched:()=>{y=!0},onActivationWarnings:c.onActivationWarnings}}),{doubleTapDelivered:!1,startedAt:this.dependencies.timer.now()};return await this.dispatchAndroidFirstTap(n,R.point,R.frameContext,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(p),onTapDelivered:c.onTapDelivered}})}}async dispatchAndroidFirstTap(n,s,a,{signal:c,context:d}){let p=this.dependencies.timer.now();if(n.action==="doubleTap"&&await Q3(this.dependencies.androidClient,{...s,frameContext:a,signal:c,assertCurrent:d.assertCurrent,onTapDelivered:d.onTapDelivered}))return{doubleTapDelivered:!0,startedAt:p};return await this.dispatchAndroidTap(s,zw(n,"android"),a,{signal:c,context:d}),{doubleTapDelivered:!1,startedAt:p}}async dispatchSecondAndroidTap(n,s,a,c){let{signal:d}=c;if(n.action!=="doubleTap"||c.firstTap.doubleTapDelivered)return;await Z3(this.dependencies.timer,c.firstTap.startedAt,{signal:d,onWarning:(p)=>c.onActivationWarnings([p])}),this.dependencies.host.assertDisplayRevisionCurrent(a),await this.dispatchAndroidTap(s,zw(n,"android"),void 0,{signal:d,context:{assertCurrent:()=>this.dependencies.host.assertDisplayRevisionCurrent(a),onTapDelivered:c.onTapDelivered}})}async dispatchAndroidTap(n,s,a,{signal:c,context:d}){let p=gte(d.onTapDelivered);await this.dependencies.androidCoordinateTap(this.dependencies.androidClient,this.dependencies.host.adb,n,{durationMs:s,options:{frameContext:a,signal:c,assertCurrent:d.assertCurrent,onTapDelivered:p}}),p(),o(c)}}import{createHash as fe}from"crypto";import{isDeepStrictEqual as rt}from"util";var nt=300000,it=128,ot=new Set(["extras","view-id","occlusionState","occludedBy","occludedByViewId"]);function V(n){if(Array.isArray(n))return n.map(V);if(!n||typeof n!=="object")return n;return Object.fromEntries(Object.entries(n).filter(([s])=>!ot.has(s)).map(([s,a])=>[s,V(a)]))}function Te(n){return Boolean(Rb(n.truncationReasons).length||Rb(n.viewHierarchy?.truncationReasons).length)}function ge(n){return Boolean(n.truncationReasons?.some(wb)||n.viewHierarchy?.truncationReasons?.some(wb)||n.viewHierarchy?.windows?.some((s)=>s.truncationReasons?.some(wb)))}function Se(n){return Te(n)||ge(n)&&(!n.viewHierarchy||!hf(n.viewHierarchy))||Boolean(n.viewHierarchy?.windows?.some((s)=>Rb(s.truncationReasons??void 0).length>0))}function ye(n){let s=n.rotation??n.viewHierarchy?.rotation;if(!Number.isInteger(s)||!n.viewHierarchy||Te(n))return null;let a=n.viewHierarchy;return{screenSize:{width:n.screenSize?.width,height:n.screenSize?.height},rotation:s,systemInsets:n.systemInsets,insets:n.insets,activeWindow:{appId:n.activeWindow?.appId,activityName:n.activeWindow?.activityName},screenIdentity:n.screenIdentity?{platform:n.screenIdentity.platform,source:n.screenIdentity.source,key:n.screenIdentity.key}:void 0,hierarchy:{tree:V(a.hierarchy),windows:V(a.windows),packageName:a.packageName,foregroundActivity:a.foregroundActivity,screenWidth:a.screenWidth,screenHeight:a.screenHeight,pixelWidth:a.pixelWidth,pixelHeight:a.pixelHeight,nativeScale:a.nativeScale,rotation:a.rotation,systemInsets:a.systemInsets,insets:a.insets}}}function xe(n,s){let a=ye(n),c=ye(s);return a!==null&&c!==null&&rt(a,c)}function st(n){return Number.isFinite(n.width)&&Number.isFinite(n.height)&&n.width>0&&n.height>0}function at(n){return typeof n==="number"&&Number.isFinite(n)&&n>0}function ut(n){return/^([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}):\d+(?::[0-9a-f]+)?$/i.exec(n)?.[1]?.toLowerCase()}function Ae(n){let s=[];if(!n.display?.key)s.push("display");if(!st(n.screenSize))s.push("screenSize");let a=n.rotation??n.viewHierarchy?.rotation;if(!Number.isInteger(a))s.push("rotation");if(!at(n.viewHierarchy?.nativeScale))s.push("nativeScale");if(!n.viewHierarchy?.frameContext)s.push("frameContext");if(Se(n))s.push("completeHierarchy");return s}function ct(n){let s=n.viewHierarchy?.windows?.find((c)=>c.isFocused),a=s?.bounds;return{focusedWindowPresent:s!==void 0,focusedWindowId:s?.id,focusedWindowType:s?.type,focusedWindowPackage:s?.packageName,focusedWindowBounds:a?JSON.stringify([a.left,a.top,a.right,a.bottom]):void 0}}function be(n,s){if(Ae(s).length>0)return;let{width:a,height:c}=s.screenSize;return{deviceId:n,incarnation:Ni(n),displayKey:s.display.key,displayRole:s.display.role,displayPosture:s.display.posture,width:a,height:c,rotation:s.rotation??s.viewHierarchy?.rotation,nativeScale:s.viewHierarchy.nativeScale,runnerEpoch:ut(s.viewHierarchy.frameContext),appId:s.activeWindow?.appId||s.viewHierarchy?.packageName,hierarchyPackage:s.viewHierarchy?.packageName,activityName:s.activeWindow?.activityName??"",windowType:s.activeWindow?.type,...ct(s)}}function dt(n,s,a){if(a==="runnerEpoch"||a==="focusedWindowPresent")return!1;if((a==="activityName"||a==="windowType")&&(!n[a]||!s[a]))return!1;if(a.startsWith("focusedWindow")&&(!n.focusedWindowPresent||!s.focusedWindowPresent))return!1;return n[a]!==s[a]}function Pe(n){if(n&&typeof n==="object"&&!Array.isArray(n)){let s=n;return[s.left,s.top,s.right,s.bottom]}return n}function q(n,s){if(Array.isArray(s)){for(let d of s)q(n,d);return}if(!s||typeof s!=="object")return;let a=s,c={...a,...we(a)};if(kO(c["resource-id"]))return;n.update("["),n.update(JSON.stringify([c.className??c.class??c.type,c.role,Pe(qt(a)),c.clickable,c.enabled,c["visible-to-user"],c.scrollable,c["resource-id"],Array.isArray(c.actions)?[...c.actions].sort():c.actions])),q(n,a.node),n.update("]")}function ve(n){let s=n.viewHierarchy,a=ge(n)?hf(s):s,c=fe("sha256");c.update(Fr([n.systemInsets,n.insets,s.screenWidth,s.screenHeight,s.pixelWidth,s.pixelHeight,s.nativeScale,s.rotation,s.systemInsets,s.insets])),q(c,a.hierarchy);let d;if(a.windows!==void 0){let p=fe("sha256");for(let m of a.windows)p.update(JSON.stringify([m.id,m.type,m.isActive,m.isFocused,Pe(m.bounds),m.windowLayer,m.packageName])),q(p,m.hierarchy);d=p.digest("hex")}return{tree:c.digest("hex"),windows:d}}function pt(n,s){return n.tree===s.tree&&(n.windows===void 0||s.windows===void 0||n.windows===s.windows)}class Re{timer;ids;entries=new Map;constructor(n=i,s=B){this.timer=n;this.ids=s}capture(n,s){let a=be(n,s);if(!a)return{status:"unavailable",missing:Ae(s)};this.cleanup();while(this.entries.size>=it)this.entries.delete(this.entries.keys().next().value);let c={snapshotId:this.ids.next(),expiresAt:this.timer.now()+nt};return this.entries.set(c.snapshotId,{...a,...c,layout:ve(s)}),{status:"captured",reference:c}}staleReason(n,s,a){let c=this.entries.get(n);if(!c)return"Snapshot reference is unknown or evicted; re-observe.";if(this.timer.now()>=c.expiresAt)return this.entries.delete(n),"Snapshot reference expired; re-observe.";if(Se(a))return"Snapshot layout is unavailable. The hierarchy capture was incomplete; observe again, or use a selector or coordinates without a snapshotId.";let d=be(s,a);if(!d)return"Snapshot geometry or frame context is unavailable; re-observe.";if(c.runnerEpoch!==d.runnerEpoch)return"Snapshot reference is stale (runner restarted); re-observe.";for(let m of Object.keys(d))if(dt(c,d,m))return`Snapshot reference is stale (${m} changed); re-observe.`;let p=ve(a);if(!pt(c.layout,p))return"Snapshot reference is stale (tap-targeting layout changed); re-observe.";return}get size(){return this.entries.size}cleanup(){for(let[n,s]of this.entries)if(this.timer.now()>=s.expiresAt)this.entries.delete(n)}}var vp=new Re;var N=31,lt=5000;function ee(n){return`shell input stylus ${n}`}function d3(n){let{pointer:s,platform:a,gesture:c,display:d}=n;if(s===void 0)return;if(s.toolType!=="stylus"&&s.toolType!=="eraser")return`pointer.toolType "${String(s.toolType)}" is not supported; only "stylus" or "eraser" can be injected`;if(a!=="android")return`pointer.toolType "${s.toolType}" is Android-only; omit pointer on iOS`;if(c==="doubleTap")return"stylus pointer does not support doubleTap yet; use tap or longPress";if(d!==void 0)return"stylus pointer does not support display selection yet; omit display";return}async function mt(n,s){let a=await Ht(n,lt,void 0,s);if(a===null)return`could not read the device's Android API level, so stylus input is refused (it needs API ${N} or newer)`;if(a<N)return`stylus input needs Android API ${N} or newer (this device reports API ${a}): older releases build the injected event without a stylus tool type`;return}async function ht(n,s){let a=await mt(n,s);if(a)throw new t(a)}function Ce(n,s){return d3({pointer:s.pointer,platform:n,gesture:s.action??"tap",display:s.display})}function Ie(n,s,a="tap"){return{success:!1,x:s.x,y:s.y,action:a,error:n}}class Mv extends t{}function ft(n,s){let{command:a,dispatched:c,holdMs:d,signal:p}=s;if(n instanceof Ee||n instanceof sz)return n;try{uD(a,Jr(n))}catch(h){return h}if(!c)return n;let m=d===void 0?void 0:m3(n,d,p);return new Mv(m??r(n),{cause:n})}async function De(n,{command:s,timeoutMs:a,holdMs:c},d){await ht(n,d.signal);let p=!1;try{await X3(n,s,{...d,timeoutMs:a,onDispatch:()=>{p=!0,d.onDispatch?.()}})}catch(m){throw ft(m,{command:s,dispatched:p,holdMs:c,signal:d.signal})}}async function _e(n,s,a,c={}){let{x:d,y:p}=s,m=a.durationMs??ZT,h=a.action==="longPress";try{await De(n,h?{command:ee(`swipe ${d} ${p} ${d} ${p} ${zo(m)}`),timeoutMs:Wr(m),holdMs:m}:{command:ee(`tap ${d} ${p}`)},c)}catch(f){throw f instanceof Mv?Tn(f.message):f}}function mte(n,s,a={}){let{from:c,to:d,duration:p}=s;return De(n,{command:ee(`swipe ${c.x} ${c.y} ${d.x} ${d.y} ${zo(p)}`),timeoutMs:Wr(p)},a)}var ke=new Map;function Y(n){let s=ke.get(n);if(!s)s=new Yn,ke.set(n,s);return s}var yt="dev.jasonpearson.automobile.ctrlproxy/.pointer.PointerInstrumentation",re=31,bt=1,Be=200,vt=15000;function l3(n){return n*2+vt}class id extends t{}function Tt(n){return n.points.slice(1).reduce((s,a)=>s+(a.durationMs??Be),0)}function gt(n){let s={version:bt,tool:n.features.toolType,hover:n.features.hover===!0,buttons:n.buttons??0,displayId:n.displayId??0,points:n.points.map((a,c)=>({x:a.x,y:a.y,...c===0?{}:{durationMs:a.durationMs??Be},...a.distance===void 0?{}:{distance:a.distance},...a.pressure===void 0?{}:{pressure:a.pressure},...a.tilt===void 0?{}:{tilt:a.tilt},...a.orientation===void 0?{}:{orientation:a.orientation}}))};return Buffer.from(JSON.stringify(s),"utf8").toString("base64")}function St(n){return`shell am instrument -w -r --no-restart -e request ${gt(n)} ${yt}`}function xt(n){let s=new Map;for(let d of n.split(/\r?\n/)){let p=/^INSTRUMENTATION_RESULT: ([A-Za-z]+)=(.*)$/.exec(d);if(p)s.set(p[1],p[2])}let a=s.get("success");if(a!=="true"&&a!=="false")return;let c=s.get("error");return{success:a==="true",...c?{error:c}:{},injected:Number(s.get("injected")??0),elapsedMs:Number(s.get("elapsedMs")??0)}}async function At(n,s){if(/Unable to find instrumentation|INSTRUMENTATION_FAILED|does not exist/i.test(n))return new id("The connected CtrlProxy does not include the pointer instrumentation; update CtrlProxy. No input was sent.");if(/Unknown option|--no-restart/i.test(n))return new id("This Android version's `am instrument` has no --no-restart, which keeps the injection from restarting CtrlProxy; hover and stylus injection need Android 12 or newer. No input was sent.");if(/Process crashed|INSTRUMENTATION_RESULT: shortMsg=/i.test(n)){let a="";try{a=(await s.executeCommand("shell settings get secure enabled_accessibility_services",{timeoutMs:5000})).stdout.includes("dev.jasonpearson.automobile.ctrlproxy")?" CtrlProxy's accessibility service is still enabled.":" CtrlProxy's accessibility service is not enabled; re-enable it before retrying."}catch(c){e.warn(`Could not read accessibility services after pointer crash: ${r(c)}`,c)}return new t("The pointer instrumentation crashed before reporting a result; the hover or stroke may have partially run. Verify state with observe before retrying."+a)}return new t("The pointer instrumentation did not report a result; the hover or stroke may have partially run. Verify state with observe before retrying.")}var Pt=/could not be closed/i,wt=5000;async function te(n,s,a,c){let d=s.points[0];try{await H(c,()=>n.executeCommand(`shell input stylus motionevent CANCEL ${Math.round(d.x)} ${Math.round(d.y)}`,{timeoutMs:wt,...c?{signal:c}:{}}))}catch(p){e.warn(`Could not cancel ${a}: ${r(p)}`,p)}}async function Ne(n,s,a){try{return await n()}catch(c){if(!(c instanceof id))await te(s,a,"an abandoned pointer run");throw c}}function QV(n,s){let a=Y(s);return async(c,d)=>{o(d),await a.runExclusive(async()=>{o(d);let p=async()=>{let h=await n.executeCommand(St(c),{timeoutMs:l3(Tt(c)),signal:d}),f=[h.stdout,h.stderr].filter(Boolean).join(`
3
+ `),y=xt(f);if(!y)throw await At(f,n);return y},m=await Ne(p,n,c);if(!m.success&&m.injected===0&&/refused/i.test(m.error??""))o(d),await te(n,c,"refused pointer input",d),o(d),m=await Ne(p,n,c);if(!m.success&&Pt.test(m.error??""))await te(n,c,"an unclosed pointer");if(!m.success)throw new t(`The pointer instrumentation failed after ${m.injected} event${m.injected===1?"":"s"}: ${m.error??"unknown error"}`)})}}function Ct(n,s){let a=s.width-1,c=s.height-1,d=Math.round(n.x),p=Math.round(n.y),m=s.rotation===1?{x:a-p,y:d}:s.rotation===2?{x:a-d,y:c-p}:s.rotation===3?{x:p,y:c-d}:{x:d,y:p};return{x:oe(m.x,a),y:oe(m.y,c)}}function It(n,s){switch(s){case 1:return n+Math.PI/2;case 2:return n+Math.PI;case 3:return n-Math.PI/2;default:return n}}function oe(n,s){return Math.min(Math.max(n,0),s)}function Et(n,s){let a=Math.sin(n)**2,c=Math.sin(s)*Math.cos(s),d=Math.sqrt(Math.max(0,1-4*c*c*a)),p=c===0?a:2*a/(1+d),m=Math.sqrt(p),h=(f)=>Math.max(-90,Math.min(90,Math.round(Math.asin(Math.max(-1,Math.min(1,f)))*180/Math.PI)))||0;return{x:h(-m*Math.sin(s)),y:h(m*Math.cos(s))}}function Dt(n){let s=n.features.hover===!0,a=n.points[0],c=a.pressure??(s?0:1),d=a.distance??(s?0.5:0),m=n.points.some((b)=>b.tilt!==void 0||b.orientation!==void 0)?a.tilt??0:void 0,h=a.orientation??0,f=[{atMs:0,x:a.x,y:a.y,pressure:c,distance:d,tilt:m,orientation:h}],y=0;return n.points.slice(1).forEach((b,T)=>{let g=n.points[T],v=b.durationMs??200,R=Math.max(1,Math.ceil(v/16)),S={pressure:c,distance:d,tilt:m,orientation:h};for(let D=1;D<=R;D++){let A=D/R;c=M(S.pressure,b.pressure??S.pressure,A),d=M(S.distance,b.distance??S.distance,A),m=S.tilt===void 0?void 0:M(S.tilt,b.tilt??S.tilt,A),h=M(S.orientation,b.orientation??S.orientation,A),f.push({atMs:y+Math.floor(v*D/R),x:D===R?b.x:M(g.x,b.x,A),y:D===R?b.y:M(g.y,b.y,A),pressure:c,distance:d,tilt:m,orientation:h})}y+=v}),f}function M(n,s,a){return n+(s-n)*a}function O(n,s){return[3,n,s]}function Me(n,s){return Math.round(oe(n,1)*s)}function se(n,s,a){let c=Ct(n,s),d=!a&&n.tilt!==void 0?Et(n.tilt,It(n.orientation,s.rotation)):void 0;return[...O(0,c.x),...O(1,c.y),...a?O(25,Me(n.distance,255)):O(24,Me(n.pressure,4095)),...d?[...O(26,d.x),...O(27,d.y)]:[]]}var U=[0,0,0];function Fe(n){return n.features.toolType==="eraser"?321:320}function Ue(n,s){return[...n&32?[1,331,s]:[],...n&64?[1,332,s]:[]]}function Ot(n,s,a,c){let d=[1,Fe(c),1];return a?[...d,...se(n,s,!0),...O(24,0),...U]:[...d,1,330,1,...se(n,s,!1),...O(25,0),...Ue(c.buttons??0,1),...U]}function _t(n,s,a){let c=[1,s,0,...U];return n?c:[...Ue(a,0),1,330,0,...O(24,0),...U,...c]}function F(n,s,a){return{code:n,info:{value:0,minimum:s,maximum:a,fuzz:0,flat:0,resolution:0}}}function kt(n){return{id:1,command:"register",name:"automobile-pen",vid:6353,pid:19985,bus:"usb",configuration:[{type:100,data:[0,1,3]},{type:101,data:[320,321,330,331,332]},{type:103,data:[0,1,24,25,26,27]},{type:110,data:[1]}],abs_info:[F(0,0,n.width-1),F(1,0,n.height-1),F(24,0,4095),F(25,0,255),F(26,-90,90),F(27,-90,90)]}}var ne=(n)=>({id:1,command:"inject",events:n}),ie=(n)=>({id:1,command:"delay",duration:n});function Le(n,s){let a=n.features.hover===!0,[c,...d]=Dt(n),p=[kt(s),ie(4000),ne(Ot(c,s,a,n))],m=0;for(let h of d){if(h.atMs>m)p.push(ie(h.atMs-m)),m=h.atMs;p.push(ne([...se(h,s,a),...U]))}return p.push(ne(_t(a,Fe(n),n.buttons??0)),ie(50)),`${p.map((h)=>JSON.stringify(h)).join(`
4
4
  `)}
5
- `}var t3=4050;function $e(n){return t3+n.slice(1).reduce((s,a)=>s+(a.durationMs??200),0)}var Ge=5000,Nt=1e4,Bt=1e5,X="automobile-uinput-exit=",We=97;async function Mt(n,s){let{stdout:a}=await n.executeCommand(bw(0),{timeoutMs:Ge,noRetry:!0,signal:s}),c=vw(a),d=c?bv(c):void 0;if(!d)throw Error(`Could not parse the display size from wm size output: ${a.trim()}`);let p=await al(n,{timeoutMs:Ge,signal:s});if(p===null)throw Error("WindowManager did not report the display rotation");return{...d,rotation:p}}async function Ft(n,s,a,c){let d=Buffer.from(s,"utf8").toString("base64"),p=await n.execute(["shell",`s=$(echo ${d} | base64 -d) || { echo ${X}${We}; exit 0; }; printf '%s\\n' "$s" | uinput - 2>&1; echo ${X}$?`],{timeoutMs:a,noRetry:!0,signal:c}),m=`${p.stdout}
6
- ${p.stderr}`,h=new RegExp(`${X}(\\d+)`).exec(m);return{exitCode:h?Number(h[1]):null,stderr:m.replace(new RegExp(`${X}\\d+`),"").trim()}}function Lt(n){let s=n.stderr||`exit ${n.exitCode??"unknown"}`;if(n.exitCode===We)return new Zc("The device could not decode the uinput script (base64 -d failed). No input was sent.");if(n.exitCode===127||/not found/i.test(n.stderr))return new Zc(`This device has no uinput tool, so the uinput route cannot inject a stylus: ${s}. No input was sent.`);if(/permission denied|eacces/i.test(n.stderr))return new Zc(`/dev/uinput is not writable; run adb root on an emulator or userdebug build: ${s}. No input was sent.`);return new t(`The uinput pen failed and may have played part of the stroke or hover: ${s}. Verify state with observe before retrying.`)}function VV(n,s,a={readGeometry:(c)=>Mt(n,c),runScript:(c,d,p)=>Ft(n,c,d,p)}){let c=Y(s);return async(d,p)=>{if(o(p),(d.displayId??0)!==0)throw new Zc(`display ${d.displayId} is not supported; the uinput route injects on the default display. No input was sent.`);await c.runExclusive(async()=>{o(p);let m=await a.readGeometry(p).catch((y)=>{throw p?.aborted?y:new Zc(`Could not read the display geometry for the uinput pen: ${r(y)}. No input was sent.`)}),h=Le(d,m);if(Buffer.byteLength(h,"utf8")*1.3333333333333333>Bt)throw new Zc("The stroke is too long for one uinput script; split it into shorter gestures. No input was sent.");o(p);let f=await a.runScript(h,$e(d.points)+Nt,p).catch((y)=>{throw p?.aborted?y:new t(`The uinput pen run failed and may have played part of the stroke or hover: ${r(y)}. Verify state with observe before retrying.`,{cause:y})});if(f.exitCode!==0)throw Lt(f)})}}var k={supported:!0};function C(n,s){return s?{supported:!1,reason:n,missingCapability:s}:{supported:!1,reason:n}}class _{dispatch;constructor(n){this.dispatch=n}inject(n,s){return this.dispatch(n,s)}}class ae extends _{route="adb-input-source";supports(n,s){if(s.platform!=="android"||n.toolType!=="stylus")return C("adb input stylus injects a stylus on Android only");if(n.hover||n.variablePressure||n.extendedAxes||n.path)return C("adb input stylus injects a constant-pressure tap or straight swipe; it cannot hover, vary pressure, tilt, press buttons or draw a path");if(s.apiLevel===void 0)return C("the device's Android API level could not be read");return s.apiLevel>=N?k:C(`adb input stylus needs Android API ${N} or newer (this device reports API ${s.apiLevel})`)}}function ze(n){return n.toolType==="finger"&&n.hover!==!0&&n.variablePressure!==!0&&n.extendedAxes!==!0&&n.path!==!0}function L(n){let s=[n.toolType];if(n.hover)s.push("hover");if(n.variablePressure)s.push("variable pressure");if(n.extendedAxes)s.push("tilt, orientation or buttons");if(n.path)s.push("path");return s.join(" ")}function je(n){if(n.hover)return $t(n);if((n.variablePressure||n.extendedAxes||n.path)&&n.toolType!=="stylus"&&n.toolType!=="eraser")return`${n.toolType} input has no variable pressure, tilt, buttons or stroke; only a stylus or eraser does`;if(n.toolType==="mouse")return"mouse input is supported for hover only";return}function $t(n){if(n.toolType==="finger")return"a finger does not hover; hover comes from a stylus or a mouse";if(n.variablePressure)return"hover has no contact, so it has no pressure";if(n.extendedAxes||n.path)return"tilt, orientation, buttons and strokes describe a stylus in contact; a hover carries only a position and distance";return}class ue extends _{route="ctrlproxy-a11y";supports(n,s){if(s.platform!=="android")return C("accessibility gestures are an Android route");return ze(n)?k:C(`accessibility dispatchGesture only produces a finger touch, not ${L(n)}`)}}class ce extends _{route="instrumentation";supports(n,s){if(s.platform!=="android")return C("instrumentation injection is an Android route");if(n.toolType==="finger")return C("finger touches use the accessibility route");if(n.toolType==="eraser")return C("the instrumentation runner does not inject an eraser");let a=n.hover?mP:pP;if(s.capabilities.has(a))return k;let c=s.apiLevel!==void 0&&s.apiLevel<re?`: this device runs Android API ${s.apiLevel} and the route needs Android 12 (API ${re})`:"";return C(`the connected runner does not advertise ${a}${c}`,a)}}class de extends _{route="uinput";supports(n,s){if(s.platform!=="android")return C("uinput injection is an Android route");if(n.toolType!=="stylus"&&n.toolType!=="eraser")return C("the uinput route injects a stylus or eraser only");if(s.rootShell!==!0)return C("uinput injection needs a root adb shell (run adb root on an emulator or userdebug build)");return k}}function WV(n){return[new ue(n.a11y),new ae(n.adbInputSource),new ce(n.instrumentation),new de(n.uinput)]}function r3(n,s,a){let c=je(n);if(c)return{selected:null,missingCapabilities:[],refusal:`${L(n)} is not a valid pointer request: ${c}.`};let d=[],p=new Set;for(let f of a){let y=f.supports(n,s);if(y.supported)return{selected:f};if(d.push(`${f.route}: ${y.reason}`),y.missingCapability)p.add(y.missingCapability)}let m=[...p],h=m.length>0?` Use a device whose runner advertises ${m.join(" and ")}.`:"";return{selected:null,missingCapabilities:m,refusal:`${L(n)} input cannot be injected on this device, and a finger touch is never substituted. ${d.join("; ")}.${h}`}}function Ve(n,s,a){let c=r3(n,s,a);if(c.selected===null)throw new t(c.refusal);return c.selected}function He(n){return new Set([pP,mP].filter((s)=>n(s)))}var Gt=5000,Wt=5000;function zt(n,s){return s==="eraser"||!n.has(pP)||!n.has(mP)}async function jt(n,s){try{let{stdout:a}=await n.executeCommand("shell id -u",{timeoutMs:Wt,noRetry:!0,signal:s});return a.trim()==="0"}catch(a){if(s?.aborted)throw a;return e.warn(`[pointer] could not read the adb shell uid: ${r(a)}`,a),!1}}async function zV(n,s,a,c){let d=E.getExistingInstance(n.deviceId),p=new Set;try{for(let h of[mP,pP])if(d&&await d.supportsCommand(h))p.add(h)}catch(h){if(a?.aborted)throw h;e.warn(`[pointer] could not read the runner's capabilities: ${r(h)}`,h)}return{platform:"android",apiLevel:await Ut(s,Gt,void 0,a).catch((h)=>{if(a?.aborted)throw h;return e.warn(`[pointer] could not read the Android API level: ${r(h)}`,h),null})??void 0,capabilities:He((h)=>p.has(h)),...zt(p,c)?{rootShell:await jt(s,a)}:{}}}var Vt=40;function TC(n,s,a={}){let c=s.map((p)=>{let m=p.pressure??n.pressure,h=p.tilt??n.tilt,f=p.orientation??n.orientation;return{x:p.x,y:p.y,...p.durationMs===void 0?{}:{durationMs:p.durationMs},...m===void 0?{}:{pressure:m},...h===void 0?{}:{tilt:h},...f===void 0?{}:{orientation:f}}}),d=wae(n.buttons);return{features:{toolType:n.toolType,...c.some((p)=>p.pressure!==void 0&&p.pressure!==1)?{variablePressure:!0}:{},...d!==0||c.some((p)=>p.tilt!==void 0||p.orientation!==void 0)?{extendedAxes:!0}:{},...a.path?{path:!0}:{}},points:c,buttons:d}}function Ye(n,s){return[n,{...n,durationMs:s??Vt}]}async function kC(n,s,a,c={}){let d=await(c.readEnvironment??((h)=>zV(n,s,h,a.features.toolType)))(c.signal),p=c.injectors??WV({a11y:qe,adbInputSource:qe,instrumentation:qV(s,n.deviceId),uinput:VV(s,n.deviceId)}),m=Ve(a.features,d,p);c.assertCurrent?.(),c.onDispatch?.();try{await m.inject(a,c.signal)}catch(h){if(h instanceof Zc||c.signal?.aborted)throw h;throw new vv(r(h),{cause:h})}}async function qe(){throw new t("This route cannot inject a stylus with pressure, tilt or buttons.")}class G extends t{}function pe(n,s){return n===1?s*(1-Number.EPSILON):n*s}function W(n,s,a){let c=s+pe(n,a-s);return c>=a?Math.max(s,a-Math.max(Math.abs(a),a-s)*Number.EPSILON):c}var z=["left","top","right","bottom"];function w(n){throw new t(`tapAt image ${n}. Observe again and pass metadata from the same image.`)}function le(n){return!!n&&[n.width,n.height].every((s)=>Number.isFinite(s)&&s>0)}function Xe(n){return le(n)&&Number.isInteger(n.width)&&Number.isInteger(n.height)}function me(n){return!!n&&z.every((s)=>Number.isFinite(n[s]))&&n.right>n.left&&n.bottom>n.top}function Ht(n,s){let a="crop"in n?n.crop:n.screenshot,c="crop"in n?n.rotation:n.screenshot.rotation;if(c!==void 0&&(!Number.isInteger(c)||c<0||c>3))w("rotation must be 0, 1, 2, or 3");if(a.screenshotOrientation==="display")return 0;if(a.screenshotOrientation!=="native")w("requires screenshotOrientation (display or native)");if(c===void 0)w("with native screenshotOrientation requires observe.rotation");if(s==="android"&&c!==0)w("Android requires display-aligned orientation");return c}function Ke(n,s){if(![n.x,n.y].every((a)=>Number.isFinite(a)&&a>0)||Math.abs(n.x-n.y)>xT)w("has missing or inconsistent pixelsPerNativeUnit / aspect ratio");if(s==="android"&&(n.x!==1||n.y!==1))w("Android pixels require scale 1")}function Yt(n){let{screenSize:s,clippedBounds:a,requestedBounds:c}=n;if(!me(a)||!me(c))w("requires finite nonempty crop bounds");let d={left:Math.max(0,c.left),top:Math.max(0,c.top),right:Math.min(s.width,c.right),bottom:Math.min(s.height,c.bottom)};if(z.some((p)=>a[p]!==d[p])||n.clipped!==z.some((p)=>a[p]!==c[p]))w("has inconsistent clippedBounds / requestedBounds")}function Xt(n,s){let{screenSize:a,imageSize:c,pixelsPerNativeUnit:d,rasterBounds:p}=n;if(!me(p))w("requires finite nonempty rasterBounds");let m=EW(a,s),h=ML(OL(n.clippedBounds,a,s),d,{width:m.width*d.x,height:m.height*d.y}),f=p.right-p.left,y=p.bottom-p.top,b=n.screenshotOrientation==="display"&&(s===1||s===3);return!z.some((T)=>!Number.isInteger(p[T])||Math.abs(h[T]-p[T])>0.0000001)&&c.width===(b?y:f)&&c.height===(b?f:y)}function Kt(n,s,a){let c=n.crop,d=[a];if(s==="ios"&&c.screenshotOrientation==="display"&&n.rotation!==void 0&&(n.rotation===2||(n.rotation===1||n.rotation===3)&&c.screenSize.width>c.screenSize.height))d.push(n.rotation);let p=d.filter((m)=>Xt(c,m));if(p.length===0)w("has inconsistent rasterBounds, imageSize, scale, or clippedBounds");return p}function Jt(n,s,a){let c=n.crop;if(c.unit!==(s==="android"?"pixels":"points"))w("crop unit does not match the platform");if(!Xe(c.imageSize))w("requires positive integer crop imageSize");if(!c.pixelsPerNativeUnit)w("requires pixelsPerNativeUnit");if(Ke(c.pixelsPerNativeUnit,s),c.scaleProvenance!=="raster-dimensions"&&c.scaleProvenance!=="native-scale-confirmed")w("requires scaleProvenance");return Yt(c),Kt(n,s,a)}function Qt(n,s,a){let{nativeScale:c,imageSize:d}=n.screenshot;if(c!==void 0&&(!Number.isFinite(c)||c<=0))w("requires positive finite nativeScale provenance");if(d===void 0)return;if(!Xe(d))w("requires positive integer imageSize");Ke({x:d.width/s.width,y:d.height/s.height},a)}function er(n,s){if(n.unit!=="normalized"&&n.unit!=="pixels")w("unit must be normalized or pixels");let a=n.unit==="normalized"?{width:1,height:1}:s;if(!a)w("pixels requires imageSize with the real file dimensions");let c=n.unit==="normalized";for(let[d,p]of[[n.x,a.width],[n.y,a.height]])if(!Number.isFinite(d)||d<0||(c?d>p:d>=p))w(`${n.unit} coordinates must be in [0, ${a.width}${c?"]":")"} x [0, ${a.height}${c?"]":")"}`)}function Je(n,s){return[n.x,n.y].every(Number.isFinite)&&n.x>=0&&n.y>=0&&n.x<s.width&&n.y<s.height}function tr(n,s){if(n.x===s.right)n.x=W(1,s.left,s.right);if(n.y===s.bottom)n.y=W(1,s.top,s.bottom)}function rr(n,s,a){let{crop:c}=s,{pixelsPerNativeUnit:d,rasterBounds:p,screenSize:m}=c,h=a.map((b)=>({bounds:E3({left:p.left/d.x,top:p.top/d.y,right:p.right/d.x,bottom:p.bottom/d.y},m,b),scale:b===1||b===3?{x:d.y,y:d.x}:d})),f=h[0];if(h.some((b)=>z.some((T)=>Math.abs(b.bounds[T]-f.bounds[T])>0.0000001)||b.scale.x!==f.scale.x||b.scale.y!==f.scale.y))w("crop pixel padding is ambiguous between source orientations");let y={x:(f.bounds.left*f.scale.x+n.x)/f.scale.x,y:(f.bounds.top*f.scale.y+n.y)/f.scale.y};if(!Je(y,m))w("pixels resolve outside native screen bounds");return y}function nr(n,s,a,c){let{source:d}=n;if("crop"in d&&d.crop.screenshotOrientation==="display")return rr(n,d,c);let p=EW(s,a),m="crop"in d?d.crop.pixelsPerNativeUnit:{x:d.screenshot.imageSize.width/p.width,y:d.screenshot.imageSize.height/p.height},h="crop"in d?d.crop.rasterBounds:{left:0,top:0},f=kW({x:(h.left+n.x)/m.x,y:(h.top+n.y)/m.y},s,a),y="crop"in d?d.crop.imageSize:d.screenshot.imageSize,b=E3({left:h.left/m.x,top:h.top/m.y,right:(h.left+y.width)/m.x,bottom:(h.top+y.height)/m.y},s,a);if(tr(f,b),!Je(f,s))w("pixels resolve outside native screen bounds");return f}function Qe(n,s,a){let c=n.source,d="crop"in c?c.crop:c.screenshot,{screenSize:p,imageSize:m}=d;if(!le(p)||!le(a))w("requires positive finite screenSize");if(p.width!==a.width||p.height!==a.height)w("source screenSize changed; observe again");let h=Ht(c,s),f=[];if("crop"in c)f=Jt(c,s,h);else Qt(c,EW(p,h),s);if(er(n,m),n.unit==="pixels")return nr(n,p,h,f);let y="crop"in c?c.crop.clippedBounds:{left:0,top:0,right:p.width,bottom:p.height},b=kW(n,{width:1,height:1},h);return{x:W(b.x,y.left,y.right),y:W(b.y,y.top,y.bottom)}}function ir(n){let{durationMs:s}=n,a=n.action??"tap";if(a!=="tap"&&a!=="longPress"&&a!=="doubleTap")return"tapAt action is unsupported";if(s!==void 0&&(a!=="longPress"||!Number.isInteger(s)||s<Na||s>eg))return`tapAt durationMs requires longPress and must be ${Na}\u2013${eg} ms`;return}function I(n){return n.image??{x:n.x,y:n.y}}function et(n,s){let a=I(n);return s==="android"&&!n.image?{x:Math.round(a.x),y:Math.round(a.y)}:a}function or(n,s){return n.x!==void 0||n.y!==void 0||n.coordinateSpace!==void 0?`${s} image is mutually exclusive with x, y, and coordinateSpace`:void 0}function ar(n,s){if(n.image!==void 0)return or(n,s);let{x:a,y:c}=n,d=n.coordinateSpace??"absolute";if(d!=="absolute"&&d!=="normalized"&&d!=="percent")return`${s} coordinateSpace is unsupported`;if(!Number.isFinite(a)||!Number.isFinite(c))return`${s} requires finite x and y coordinates`;let p=d==="normalized"?1:d==="percent"?100:void 0;if(p!==void 0&&!ur(a,c,p))return`${s} ${d} coordinates must be between 0 and ${p}`;return}function ur(n,s,a){return n>=0&&n<=a&&s>=0&&s<=a}function Ze(n,s,a){let c=a==="normalized"?1:a==="percent"?100:void 0;if(c===void 0)return n;return pe(n/c,s)}function cr(n){if(!n)return!1;return Number.isFinite(n.width)&&Number.isFinite(n.height)&&n.width>0&&n.height>0}function dr(n,s){return n.x<0||n.x>=s.width||n.y<0||n.y>=s.height}function pr(n,s){let a=n.image?.source;return a&&"crop"in a?{width:a.crop.rasterBounds.right,height:a.crop.rasterBounds.bottom}:s}function lr(n,s,a){if(!n||!("screenshot"in n.source))return n;let c=n.source.screenshot;if(c.screenSize.width!==s.screenSize.width||c.screenSize.height!==s.screenSize.height)return n;return{...n,source:{screenshot:{...c,screenSize:a}}}}function mr(n,s,a,c){if(a==="android"&&c==="tapAt")ute(s,n.androidXr===!0);let d=a==="android"&&c==="tapAt"&&n.pointSpace!=="native"?nW(s.backStack,n.androidXr??!1):void 0,p=d?c3(s):s.screenSize,m=d?lr(n.image,s,p):n.image,h=d&&m&&"crop"in m.source?s.screenSize:p;return{xr:d,screenSize:p,image:m,imageScreenSize:h}}function Qc(n,s,a,c="tapAt"){let{x:d,y:p}=I(n),m=ar(n,c);if(m)return{x:d,y:p,error:m};let h=n.coordinateSpace??"absolute",{xr:f,screenSize:y,image:b,imageScreenSize:T}=mr(n,s,a,c);if(!cr(y))return{x:d,y:p,error:`${c} requires a positive screenSize from a fresh observation`};let g=b?Qe(b,a==="ios"?"ios":"android",T):{x:Ze(d,y.width,h),y:Ze(p,y.height,h)},{x:v,y:R}=g;if(dr({x:v,y:R},y))return{x:d,y:p,error:`${c} coordinates (${d}, ${p}) are outside screen bounds [0, ${y.width}) x [0, ${y.height})`};let S=pr(n,y),D=a==="android"?Math.min(Math.round(v),Math.ceil(S.width)-1):v,A=a==="android"?Math.min(Math.round(R),Math.ceil(S.height)-1):R;if(f){let j=xC(s,!0),K=mte({x:D,y:A},f.panel,y);return{...K,screenshotPoint:{x:D,y:A},xrPanel:{packageName:f.panel.packageName,taskId:f.panel.id,displayX:K.x,displayY:K.y},warning:j}}return{x:D,y:A}}function hr(n,s,a){let c=n.action??"tap",d=c==="longPress"?"long press":c==="doubleTap"?"double tap":"tap";return Ip(s.viewHierarchy,n.layer,[a],d)}function he(n,s,a){yr(n,s,a);let c=ir(n);if(c)return{x:I(n).x,y:I(n).y,error:c};let d=Qc(n,s,a);if("error"in d)return d;let p=hr(n,s,d);if(p)return{...d,error:p};if(n.planContext)vr(n.planContext,s,d.screenshotPoint??d,a);return d}function yr(n,s,a){let c=n.planContext?.geometry;if(!c)return;let d=s.rotation??s.viewHierarchy?.rotation,m=[["platform",c.platform===a],["dimensions",c.deviceWidth===s.screenSize.width&&c.deviceHeight===s.screenSize.height],["orientation",Number.isInteger(d)&&c.orientation===d],["point",br(n,c,a)]].find(([,h])=>!h)?.[0];if(m)throw new G(`tapAt replay ${m} mismatch: recorded ${JSON.stringify(c)}, current ${a} ${s.screenSize?.width}x${s.screenSize?.height} orientation ${d}. Replay on compatible geometry or record this step again.`)}function br(n,s,a){if(n.image||(n.coordinateSpace??"absolute")!=="absolute")return!1;if(n.x!==s.x||n.y!==s.y)return!1;return a!=="android"||Number.isInteger(s.x)&&Number.isInteger(s.y)}function vr(n,s,a,c){let d=s.rotation??s.viewHierarchy?.rotation;if((c==="android"||c==="ios")&&Number.isInteger(d)&&d!==void 0&&d>=0&&d<=3)n.recordedGeometry={platform:c,deviceWidth:s.screenSize.width,deviceHeight:s.screenSize.height,orientation:d,x:a.x,y:a.y}}function Tr(n,s,a){let c=n.talkBackDriverFactory??a;return{featureFlags:n.featureFlags??sr.getInstance(),accessibilityDetector:n.accessibilityDetector??ni,talkBackDriverFactory:c,talkBackStrategy:n.talkBackStrategy??new Iv({timer:s,driverFactory:c}),useContextualFocusTap:n.talkBackDriverFactory===void 0}}var tt=1000;function gr(n,{detector:s,stateClient:a,featureFlags:c,timer:d}){return()=>{let p=new AbortController;return l(()=>s.isVoiceOverEnabled(n.deviceId,a(),{featureFlags:c,timeoutMs:tt,signal:p.signal}),{timer:d,timeoutMs:tt,label:"tapAt VoiceOver probe",onTimeout:()=>p.abort()})}}class EC extends Oe{androidClient;iosDoubleTap;iosClient;iosCoordinateTap;invalidateIosCache;isIosVoiceOverOn;lastRenderedObservation;stylusRoutes;snapshotReferences;androidTalkBack;androidDispatcher;xrDetector;androidXr;constructor(n,s=null,a={}){super(n,{adb:s,timer:a.timer,displayFence:a});cs(n.platform,"tapAt"),this.androidClient=a.androidClient??Ws(n,this.adbFactory);let c=()=>x.getInstance(n);this.iosClient=a.iosClient??c(),this.iosDoubleTap=a.dispatchIosDoubleTap??Iw,this.iosCoordinateTap=a.dispatchIosCoordinateTap??Ew,this.invalidateIosCache=a.invalidateIosCache??(()=>x.getExistingInstance(this.device.deviceId)?.invalidateCache()),this.lastRenderedObservation=a.lastRenderedObservation,this.stylusRoutes=a.stylus??{},this.snapshotReferences=a.snapshotReferences??ip,this.xrDetector=a.xrDetector;let d=Tr(a,this.timer,new qh(this.adbFactory));this.isIosVoiceOverOn=gr(n,{detector:a.iosVoiceOverDetector??Ao,stateClient:()=>a.iosVoiceOverStateClient??c(),featureFlags:d.featureFlags,timer:this.timer}),this.androidTalkBack=new Q({target:this,androidClient:this.androidClient,...d});let p=this;this.androidDispatcher=new Z({host:{get adb(){return p.adb},get observeScreen(){return p.observeScreen},assertDisplayRevisionCurrent:(m)=>this.assertDisplayRevisionCurrent(m),assertSnapshotCurrent:(m,h)=>this.assertSnapshotCurrent(m,h),resolveFreshFrameRetry:(m,h,f,y)=>this.resolveFreshFrameRetry(m,h,f,y),retryFreshness:(m)=>this.retryFreshness(m)},androidClient:this.androidClient,androidCoordinateTap:a.dispatchAndroidCoordinateTap??kw,androidTalkBack:this.androidTalkBack,timer:this.timer})}async executeOnDisplay(n,s,a){let{onTapDelivered:c,signal:d,onDispatchCompleted:p,onActivationWarnings:m}=a,h=n.action??"tap",{observation:f,displayId:y,followUpDisplay:b,assertCurrent:T}=await Wi(this.device,s,this.observeScreen,{adb:this.adb,lastRenderedObservation:this.lastRenderedObservation,signal:d,transitions:this.displayTransitionReader}),g=this.staleSnapshotReason(n,f);if(g)return{success:!1,x:I(n).x,y:I(n).y,action:h,error:g};let v=await this.resolveWithXr(n,f,d);if("error"in v)return{success:!1,x:v.x,y:v.y,action:h,error:v.error};return this.observedInteraction(async()=>{if(T(),this.device.platform==="android"&&await this.androidTalkBack.resolveState(d,m)){let S=rg(y);if(S)throw S;await this.dispatchDisplayTalkBackTapWithOneFreshRetry(n,v,f,{signal:d,assertCurrent:T,followUpDisplay:b,onTapDelivered:()=>c(!0),onActivationWarnings:m})}else await this.dispatchGesture(n,v,f,{signal:d,displayId:y,assertCurrent:T,onTapDelivered:c,onWarning:(S)=>m?.([S])});return p?.(),{success:!0,x:v.x,y:v.y,action:h,...v.xrPanel?{xrPanel:v.xrPanel}:{},...v.warning?{warning:v.warning}:{}}},{changeExpected:!1,display:b,previousObservation:f,signal:d})}async execute(n,s,a,c){cs(this.device.platform,"tapAt");let{progress:d,signal:p,planContext:m}=Yte(s,a,c),h=Ce(this.device.platform,n);if(h)return Ie(h,I(n),n.action);return this.executeTap(n,d,p,m)}async dispatchStylusTapAt(n,s,a,c){let d={signal:c,assertCurrent:()=>this.assertDisplayRevisionCurrent(a)};if(!vE(n.pointer)){await _e(this.adb,s,n,d);return}let p=n.action==="longPress"?n.durationMs??NT:void 0;try{await kC(this.device,this.adb,TC(n.pointer,Ye(s,p)),{...d,...this.stylusRoutes})}catch(m){throw m instanceof vv?Sn(m.message):m}}async executeTap(n,s,a,c){n={...n,planContext:c};let d=n.action??"tap",p=J();p.serial("tapAt");let m,h,f={tapsDelivered:0,talkBack:!1,displayCompleted:!1},y=new Set,b=rte(y),T=(v=!1)=>{f.talkBack||=v,f.tapsDelivered++},g=this.captureTransitionRevision();try{if(o(a),n.display!==void 0)return{...await this.executeOnDisplay(n,n.display,{onTapDelivered:T,signal:a,onDispatchCompleted:()=>{f.displayCompleted=!0},onActivationWarnings:b}),...y.size?{warnings:[...y]}:{}};if(this.hasStaleCallerRevision(this.displayTransitionReader.revision(this.device.deviceId)))return Zt({success:!1,x:I(n).x,y:I(n).y,action:d},this.staleDisplay(g.observedGeneration));let v=null,R=await this.observedInteraction(async()=>{let S=await this.observeScreen.execute({freshness:"cached-ok",signal:a,perf:p});if(v=S,this.currentActionRevision()!==g.revision)return Zt({success:!1,x:I(n).x,y:I(n).y,action:d},this.staleDisplay(g.observedGeneration));let D=this.staleSnapshotReason(n,S);if(D)return{success:!1,x:I(n).x,y:I(n).y,action:d,error:D};let A=await this.resolveWithXr(n,S,a);if("error"in A)return{success:!1,x:A.x,y:A.y,action:d,error:A.error};switch(m=A,this.assertDisplayRevisionCurrent(g),o(a),this.device.platform){case"android":{if(n.pointer){await this.dispatchStylusTapAt(n,A,g,a),T();break}let j=await this.androidTalkBack.resolveState(a,b);f.talkBack=j,await this.androidDispatcher.dispatchAndroidTaps(n,A,S,{transitionRevision:g,perf:p,signal:a,onTapDelivered:T,talkBackEnabled:j,onActivationWarnings:b});break}case"ios":h=await this.dispatchIosTapsWithOneFreshRetry(n,A,S,{transitionRevision:g,onTapDelivered:T,signal:a});break;default:throw St(this.device.platform,"tap at coordinates")}return{success:!0,x:A.x,y:A.y,action:d,...A.xrPanel?{xrPanel:A.xrPanel}:{},...A.warning?{warning:A.warning}:{}}},{changeExpected:!1,progress:s,perf:p,signal:a,skipPreviousObserve:!0,observationTimestampProvider:()=>h,predictionContext:{toolName:"tapAt",toolArgs:{...n,action:d,platform:this.device.platform}}});return this.annotateDeviceLock(R,v),{...R,...y.size?{warnings:[...y]}:{}}}catch(v){if(v instanceof G)throw v;return this.rethrowObservationAbort(v,a,f.displayCompleted),this.createDispatchFailure(v,n,m,f)}finally{p.end()}}captureTransitionRevision(){return{revision:this.currentActionRevision(),observedGeneration:this.renderedDisplayGeneration(this.device.deviceId)??this.displayTransitionReader.identityRevision(this.device.deviceId)}}createDispatchFailure(n,s,a,c){let d=s.action??"tap",{tapsDelivered:p,talkBack:m}=c;e.warn(`tapAt dispatch failed: ${r(n)}`,n);let h=a??et(s,this.device.platform),f=Zt({success:!1,x:h.x,y:h.y,error:`Failed to tap at coordinates: ${r(n)}`,action:d},n);if(m&&d!=="longPress"){if(n instanceof fr&&p===3)f.error+=" A TalkBack focus touch and an activation double tap were delivered."}else f.error+=n instanceof fr?` ${p} ${p===1?"tap was":"taps were"} delivered.`:nte(d,p);return f}async dispatchIosTapsWithOneFreshRetry(n,s,a,c){let{transitionRevision:d,signal:p}=c,m=a.viewHierarchy?.frameContext;try{return await this.dispatchIosTaps(n,s,m,c)}catch(h){o(p);let f=u(h,"Failed to dispatch iOS coordinate tap");if(m===void 0||!Fa(f.message))throw f;let y=await this.observeScreen.execute({freshness:"fresh",signal:p});this.assertDisplayRevisionCurrent(d),this.assertSnapshotCurrent(n,y);let b=this.resolveFreshFrameRetry(n,s,a,y);if(!b||!il(a,y,!0))throw f;return await this.dispatchIosTaps(n,b.point,b.frameContext,c)}}async dispatchIosTaps(n,s,a,c){let{transitionRevision:d,onTapDelivered:p,signal:m}=c;this.assertDisplayRevisionCurrent(d),await this.dispatchIosCoordinateTap(n.action,s,{durationMs:Tw(n,"ios"),frameContext:a,signal:m});try{if(p(),n.action==="doubleTap")p();return o(m),this.timer.now()}finally{this.invalidateIosCacheSafely()}}async dispatchIosCoordinateTap(n,s,a){let{durationMs:c,frameContext:d,signal:p}=a,m=n==="doubleTap"?this.iosDoubleTap:this.iosCoordinateTap;await ote(()=>m(this.iosClient,s,{durationMs:c,frameContext:d,options:{signal:p}}),this.isIosVoiceOverOn)}invalidateIosCacheSafely(){try{this.invalidateIosCache()}catch(n){e.warn(`tapAt iOS cache invalidation failed: ${r(n)}`,n)}}async dispatchDisplayTalkBackTapWithOneFreshRetry(n,s,a,c){let{signal:d,assertCurrent:p}=c,m=a.viewHierarchy?.frameContext,h=!1,f=!1,y={assertCurrent:p,onTapDelivered:()=>{h=!0,c.onTapDelivered()},onDispatched:()=>{f=!0},onActivationWarnings:c.onActivationWarnings};try{await this.androidTalkBack.dispatchTap(n,s,m,{signal:d,context:y})}catch(b){o(d);let T=u(b,"Failed to dispatch Android coordinate tap");if(h||f||m===void 0||!Fa(T.message))throw T;let g=await this.observeScreen.execute({display:c.followUpDisplay,freshness:this.retryFreshness(n),signal:d});p(),this.assertSnapshotCurrent(n,g);let v=this.resolveFreshFrameRetry(n,s,a,g);if(g.display.key!==a.display.key||!v)throw T;await this.androidTalkBack.dispatchTap(n,v.point,v.frameContext,{signal:d,context:y})}}async resolveWithXr(n,s,a){if(this.device.platform==="android")this.androidXr=await ra({device:this.device,adb:this.adb,backStack:s.backStack,signal:a},this.xrDetector);return he({...n,androidXr:this.androidXr},s,this.device.platform)}resolveFreshFrameRetry(n,s,a,c){let d=he({...n,androidXr:this.androidXr},c,this.device.platform),p=c.viewHierarchy?.frameContext;if("error"in d||d.x!==s.x||d.y!==s.y||!p||this.device.platform!=="ios"&&p===a.viewHierarchy?.frameContext)return;if(!n.snapshotId&&!xe(a,c))throw new t("Stale frame context: screen layout changed since the last observation. Observe again and recompute coordinates, or pass a fresh snapshotId.");return{point:d,frameContext:p}}assertDisplayRevisionCurrent(n){if(this.currentActionRevision()!==n.revision)throw this.staleDisplay(n.observedGeneration)}currentActionRevision(){return this.device.platform==="ios"?this.displayTransitionReader.identityRevision(this.device.deviceId):this.displayTransitionReader.revision(this.device.deviceId)}staleSnapshotReason(n,s){return n.snapshotId?this.snapshotReferences.staleReason(n.snapshotId,this.device.deviceId,s):void 0}assertSnapshotCurrent(n,s){let a=this.staleSnapshotReason(n,s);if(a)throw new t(a)}retryFreshness(n){return n.snapshotId?"fresh":"cached-ok"}hasStaleCallerRevision(n){let s=this.renderedDisplayRevision(this.device.deviceId);if(s===void 0)return!1;return this.device.platform==="ios"?!this.displayTransitionReader.sameIdentitySince(this.device.deviceId,s):s!==n}async dispatchAndroidDisplayGesture(n,s,a,c){let{displayId:d,signal:p}=c;if(await Ma(this.androidClient,d)){o(p),c.assertCurrent();let m=!1,h=()=>{m=!0},f=await this.androidClient.requestTapCoordinates({x:n.x,y:n.y,duration:s,timeoutMs:Ab(s),onDispatch:h,signal:p,displayId:d===0?void 0:d,beforeSend:c.assertCurrent});if(f.success)c.onTapDelivered();if(o(p),f.success)return;if(m)throw Sn(f.error);if(Fa(f.error))throw new t(f.error??"Stale frame context");e.warn(`[TapAtCoordinate] dispatchGesture tap failed (${f.error}), falling back to ADB input`)}o(p),c.assertCurrent(),await wc(this.adb,a,d,{signal:p,assertCurrent:c.assertCurrent,timeoutMs:s>=Na?Hr(s):void 0}),c.onTapDelivered(),o(p)}async dispatchGesture(n,s,a,c){let{signal:d,displayId:p}=c,m=n.action??"tap",h=Tw(n,this.device.platform),f=async()=>{if(o(d),c.assertCurrent(),this.device.platform==="android"){let y=m==="longPress"?`swipe ${s.x} ${s.y} ${s.x} ${s.y} ${h}`:`tap ${s.x} ${s.y}`;await this.dispatchAndroidDisplayGesture(s,h,y,c)}else if(this.device.platform==="ios"){if(await this.dispatchIosCoordinateTap(m,s,{durationMs:h,frameContext:a.viewHierarchy?.frameContext,signal:d}),c.onTapDelivered(),m==="doubleTap")c.onTapDelivered()}else throw St(this.device.platform,"tapAt gesture")};if(this.device.platform==="android"&&m==="doubleTap"){await tg({client:await Ma(this.androidClient,p)?this.androidClient:void 0,point:s,displayId:p===0?void 0:p,timer:this.timer,signal:d,assertCurrent:c.assertCurrent,onTapDelivered:c.onTapDelivered,onWarning:c.onWarning,tap:()=>f()});return}if(await f(),this.device.platform==="ios"){try{o(d)}finally{this.invalidateIosCacheSafely()}return}}}
7
- export{ip,Q5,vv,tte,e3,Zc,qV,t3,VV,WV,r3,zV,TC,kC,Qc,EC};
5
+ `}var u3=4050;function $e(n){return u3+n.slice(1).reduce((s,a)=>s+(a.durationMs??200),0)}var Ge=5000,Nt=1e4,Bt=1e5,X="automobile-uinput-exit=",We=97;async function Mt(n,s){let{stdout:a}=await n.executeCommand(Dw(0),{timeoutMs:Ge,noRetry:!0,signal:s}),c=Cw(a),d=c?Nv(c):void 0;if(!d)throw Error(`Could not parse the display size from wm size output: ${a.trim()}`);let p=await yl(n,{timeoutMs:Ge,signal:s});if(p===null)throw Error("WindowManager did not report the display rotation");return{...d,rotation:p}}async function Ft(n,s,a,c){let d=Buffer.from(s,"utf8").toString("base64"),p=await n.execute(["shell",`s=$(echo ${d} | base64 -d) || { echo ${X}${We}; exit 0; }; printf '%s\\n' "$s" | uinput - 2>&1; echo ${X}$?`],{timeoutMs:a,noRetry:!0,signal:c}),m=`${p.stdout}
6
+ ${p.stderr}`,h=new RegExp(`${X}(\\d+)`).exec(m);return{exitCode:h?Number(h[1]):null,stderr:m.replace(new RegExp(`${X}\\d+`),"").trim()}}function Ut(n){let s=n.stderr||`exit ${n.exitCode??"unknown"}`;if(n.exitCode===We)return new id("The device could not decode the uinput script (base64 -d failed). No input was sent.");if(n.exitCode===127||/not found/i.test(n.stderr))return new id(`This device has no uinput tool, so the uinput route cannot inject a stylus: ${s}. No input was sent.`);if(/permission denied|eacces/i.test(n.stderr))return new id(`/dev/uinput is not writable; run adb root on an emulator or userdebug build: ${s}. No input was sent.`);return new t(`The uinput pen failed and may have played part of the stroke or hover: ${s}. Verify state with observe before retrying.`)}function eW(n,s,a={readGeometry:(c)=>Mt(n,c),runScript:(c,d,p)=>Ft(n,c,d,p)}){let c=Y(s);return async(d,p)=>{if(o(p),(d.displayId??0)!==0)throw new id(`display ${d.displayId} is not supported; the uinput route injects on the default display. No input was sent.`);await c.runExclusive(async()=>{o(p);let m=await a.readGeometry(p).catch((y)=>{throw p?.aborted?y:new id(`Could not read the display geometry for the uinput pen: ${r(y)}. No input was sent.`)}),h=Le(d,m);if(Buffer.byteLength(h,"utf8")*1.3333333333333333>Bt)throw new id("The stroke is too long for one uinput script; split it into shorter gestures. No input was sent.");o(p);let f=await a.runScript(h,$e(d.points)+Nt,p).catch((y)=>{throw p?.aborted?y:new t(`The uinput pen run failed and may have played part of the stroke or hover: ${r(y)}. Verify state with observe before retrying.`,{cause:y})});if(f.exitCode!==0)throw Ut(f)})}}var k={supported:!0};function C(n,s){return s?{supported:!1,reason:n,missingCapability:s}:{supported:!1,reason:n}}class _{dispatch;constructor(n){this.dispatch=n}inject(n,s){return this.dispatch(n,s)}}class ae extends _{route="adb-input-source";supports(n,s){if(s.platform!=="android"||n.toolType!=="stylus")return C("adb input stylus injects a stylus on Android only");if(n.hover||n.variablePressure||n.extendedAxes||n.path)return C("adb input stylus injects a constant-pressure tap or straight swipe; it cannot hover, vary pressure, tilt, press buttons or draw a path");if(s.apiLevel===void 0)return C("the device's Android API level could not be read");return s.apiLevel>=N?k:C(`adb input stylus needs Android API ${N} or newer (this device reports API ${s.apiLevel})`)}}function ze(n){return n.toolType==="finger"&&n.hover!==!0&&n.variablePressure!==!0&&n.extendedAxes!==!0&&n.path!==!0}function L(n){let s=[n.toolType];if(n.hover)s.push("hover");if(n.variablePressure)s.push("variable pressure");if(n.extendedAxes)s.push("tilt, orientation or buttons");if(n.path)s.push("path");return s.join(" ")}function je(n){if(n.hover)return Lt(n);if((n.variablePressure||n.extendedAxes||n.path)&&n.toolType!=="stylus"&&n.toolType!=="eraser")return`${n.toolType} input has no variable pressure, tilt, buttons or stroke; only a stylus or eraser does`;if(n.toolType==="mouse")return"mouse input is supported for hover only";return}function Lt(n){if(n.toolType==="finger")return"a finger does not hover; hover comes from a stylus or a mouse";if(n.variablePressure)return"hover has no contact, so it has no pressure";if(n.extendedAxes||n.path)return"tilt, orientation, buttons and strokes describe a stylus in contact; a hover carries only a position and distance";return}class ue extends _{route="ctrlproxy-a11y";supports(n,s){if(s.platform!=="android")return C("accessibility gestures are an Android route");return ze(n)?k:C(`accessibility dispatchGesture only produces a finger touch, not ${L(n)}`)}}class ce extends _{route="instrumentation";supports(n,s){if(s.platform!=="android")return C("instrumentation injection is an Android route");if(n.toolType==="finger")return C("finger touches use the accessibility route");if(n.toolType==="eraser")return C("the instrumentation runner does not inject an eraser");let a=n.hover?OP:DP;if(s.capabilities.has(a))return k;let c=s.apiLevel!==void 0&&s.apiLevel<re?`: this device runs Android API ${s.apiLevel} and the route needs Android 12 (API ${re})`:"";return C(`the connected runner does not advertise ${a}${c}`,a)}}class de extends _{route="uinput";supports(n,s){if(s.platform!=="android")return C("uinput injection is an Android route");if(n.toolType!=="stylus"&&n.toolType!=="eraser")return C("the uinput route injects a stylus or eraser only");if(s.rootShell!==!0)return C("uinput injection needs a root adb shell (run adb root on an emulator or userdebug build)");return k}}function tW(n){return[new ue(n.a11y),new ae(n.adbInputSource),new ce(n.instrumentation),new de(n.uinput)]}function p3(n,s,a){let c=je(n);if(c)return{selected:null,missingCapabilities:[],refusal:`${L(n)} is not a valid pointer request: ${c}.`};let d=[],p=new Set;for(let f of a){let y=f.supports(n,s);if(y.supported)return{selected:f};if(d.push(`${f.route}: ${y.reason}`),y.missingCapability)p.add(y.missingCapability)}let m=[...p],h=m.length>0?` Use a device whose runner advertises ${m.join(" and ")}.`:"";return{selected:null,missingCapabilities:m,refusal:`${L(n)} input cannot be injected on this device, and a finger touch is never substituted. ${d.join("; ")}.${h}`}}function Ve(n,s,a){let c=p3(n,s,a);if(c.selected===null)throw new t(c.refusal);return c.selected}function He(n){return new Set([DP,OP].filter((s)=>n(s)))}var $t=5000,Gt=5000;function Wt(n,s){return s==="eraser"||!n.has(DP)||!n.has(OP)}async function zt(n,s){try{let{stdout:a}=await n.executeCommand("shell id -u",{timeoutMs:Gt,noRetry:!0,signal:s});return a.trim()==="0"}catch(a){if(s?.aborted)throw a;return e.warn(`[pointer] could not read the adb shell uid: ${r(a)}`,a),!1}}async function rW(n,s,a,c){let d=E.getExistingInstance(n.deviceId),p=new Set;try{for(let h of[OP,DP])if(d&&await d.supportsCommand(h))p.add(h)}catch(h){if(a?.aborted)throw h;e.warn(`[pointer] could not read the runner's capabilities: ${r(h)}`,h)}return{platform:"android",apiLevel:await Ht(s,$t,void 0,a).catch((h)=>{if(a?.aborted)throw h;return e.warn(`[pointer] could not read the Android API level: ${r(h)}`,h),null})??void 0,capabilities:He((h)=>p.has(h)),...Wt(p,c)?{rootShell:await zt(s,a)}:{}}}var jt=40;function OC(n,s,a={}){let c=s.map((p)=>{let m=p.pressure??n.pressure,h=p.tilt??n.tilt,f=p.orientation??n.orientation;return{x:p.x,y:p.y,...p.durationMs===void 0?{}:{durationMs:p.durationMs},...m===void 0?{}:{pressure:m},...h===void 0?{}:{tilt:h},...f===void 0?{}:{orientation:f}}}),d=tce(n.buttons);return{features:{toolType:n.toolType,...c.some((p)=>p.pressure!==void 0&&p.pressure!==1)?{variablePressure:!0}:{},...d!==0||c.some((p)=>p.tilt!==void 0||p.orientation!==void 0)?{extendedAxes:!0}:{},...a.path?{path:!0}:{}},points:c,buttons:d}}function Ye(n,s){return[n,{...n,durationMs:s??jt}]}async function MC(n,s,a,c={}){let d=await(c.readEnvironment??((h)=>rW(n,s,h,a.features.toolType)))(c.signal),p=c.injectors??tW({a11y:qe,adbInputSource:qe,instrumentation:QV(s,n.deviceId),uinput:eW(s,n.deviceId)}),m=Ve(a.features,d,p);c.assertCurrent?.(),c.onDispatch?.();try{await m.inject(a,c.signal)}catch(h){if(h instanceof id||c.signal?.aborted)throw h;throw new Mv(r(h),{cause:h})}}async function qe(){throw new t("This route cannot inject a stylus with pressure, tilt or buttons.")}class G extends t{}function pe(n,s){return n===1?s*(1-Number.EPSILON):n*s}function W(n,s,a){let c=s+pe(n,a-s);return c>=a?Math.max(s,a-Math.max(Math.abs(a),a-s)*Number.EPSILON):c}var z=["left","top","right","bottom"];function w(n){throw new t(`tapAt image ${n}. Observe again and pass metadata from the same image.`)}function le(n){return!!n&&[n.width,n.height].every((s)=>Number.isFinite(s)&&s>0)}function Xe(n){return le(n)&&Number.isInteger(n.width)&&Number.isInteger(n.height)}function me(n){return!!n&&z.every((s)=>Number.isFinite(n[s]))&&n.right>n.left&&n.bottom>n.top}function Vt(n,s){let a="crop"in n?n.crop:n.screenshot,c="crop"in n?n.rotation:n.screenshot.rotation;if(c!==void 0&&(!Number.isInteger(c)||c<0||c>3))w("rotation must be 0, 1, 2, or 3");if(a.screenshotOrientation==="display")return 0;if(a.screenshotOrientation!=="native")w("requires screenshotOrientation (display or native)");if(c===void 0)w("with native screenshotOrientation requires observe.rotation");if(s==="android"&&c!==0)w("Android requires display-aligned orientation");return c}function Ke(n,s){if(![n.x,n.y].every((a)=>Number.isFinite(a)&&a>0)||Math.abs(n.x-n.y)>jT)w("has missing or inconsistent pixelsPerNativeUnit / aspect ratio");if(s==="android"&&(n.x!==1||n.y!==1))w("Android pixels require scale 1")}function Yt(n){let{screenSize:s,clippedBounds:a,requestedBounds:c}=n;if(!me(a)||!me(c))w("requires finite nonempty crop bounds");let d={left:Math.max(0,c.left),top:Math.max(0,c.top),right:Math.min(s.width,c.right),bottom:Math.min(s.height,c.bottom)};if(z.some((p)=>a[p]!==d[p])||n.clipped!==z.some((p)=>a[p]!==c[p]))w("has inconsistent clippedBounds / requestedBounds")}function Xt(n,s){let{screenSize:a,imageSize:c,pixelsPerNativeUnit:d,rasterBounds:p}=n;if(!me(p))w("requires finite nonempty rasterBounds");let m=YW(a,s),h=JL(YL(n.clippedBounds,a,s),d,{width:m.width*d.x,height:m.height*d.y}),f=p.right-p.left,y=p.bottom-p.top,b=n.screenshotOrientation==="display"&&(s===1||s===3);return!z.some((T)=>!Number.isInteger(p[T])||Math.abs(h[T]-p[T])>0.0000001)&&c.width===(b?y:f)&&c.height===(b?f:y)}function Kt(n,s,a){let c=n.crop,d=[a];if(s==="ios"&&c.screenshotOrientation==="display"&&n.rotation!==void 0&&(n.rotation===2||(n.rotation===1||n.rotation===3)&&c.screenSize.width>c.screenSize.height))d.push(n.rotation);let p=d.filter((m)=>Xt(c,m));if(p.length===0)w("has inconsistent rasterBounds, imageSize, scale, or clippedBounds");return p}function Jt(n,s,a){let c=n.crop;if(c.unit!==(s==="android"?"pixels":"points"))w("crop unit does not match the platform");if(!Xe(c.imageSize))w("requires positive integer crop imageSize");if(!c.pixelsPerNativeUnit)w("requires pixelsPerNativeUnit");if(Ke(c.pixelsPerNativeUnit,s),c.scaleProvenance!=="raster-dimensions"&&c.scaleProvenance!=="native-scale-confirmed")w("requires scaleProvenance");return Yt(c),Kt(n,s,a)}function Zt(n,s,a){let{nativeScale:c,imageSize:d}=n.screenshot;if(c!==void 0&&(!Number.isFinite(c)||c<=0))w("requires positive finite nativeScale provenance");if(d===void 0)return;if(!Xe(d))w("requires positive integer imageSize");Ke({x:d.width/s.width,y:d.height/s.height},a)}function er(n,s){if(n.unit!=="normalized"&&n.unit!=="pixels")w("unit must be normalized or pixels");let a=n.unit==="normalized"?{width:1,height:1}:s;if(!a)w("pixels requires imageSize with the real file dimensions");let c=n.unit==="normalized";for(let[d,p]of[[n.x,a.width],[n.y,a.height]])if(!Number.isFinite(d)||d<0||(c?d>p:d>=p))w(`${n.unit} coordinates must be in [0, ${a.width}${c?"]":")"} x [0, ${a.height}${c?"]":")"}`)}function Je(n,s){return[n.x,n.y].every(Number.isFinite)&&n.x>=0&&n.y>=0&&n.x<s.width&&n.y<s.height}function tr(n,s){if(n.x===s.right)n.x=W(1,s.left,s.right);if(n.y===s.bottom)n.y=W(1,s.top,s.bottom)}function rr(n,s,a){let{crop:c}=s,{pixelsPerNativeUnit:d,rasterBounds:p,screenSize:m}=c,h=a.map((b)=>({bounds:W3({left:p.left/d.x,top:p.top/d.y,right:p.right/d.x,bottom:p.bottom/d.y},m,b),scale:b===1||b===3?{x:d.y,y:d.x}:d})),f=h[0];if(h.some((b)=>z.some((T)=>Math.abs(b.bounds[T]-f.bounds[T])>0.0000001)||b.scale.x!==f.scale.x||b.scale.y!==f.scale.y))w("crop pixel padding is ambiguous between source orientations");let y={x:(f.bounds.left*f.scale.x+n.x)/f.scale.x,y:(f.bounds.top*f.scale.y+n.y)/f.scale.y};if(!Je(y,m))w("pixels resolve outside native screen bounds");return y}function nr(n,s,a,c){let{source:d}=n;if("crop"in d&&d.crop.screenshotOrientation==="display")return rr(n,d,c);let p=YW(s,a),m="crop"in d?d.crop.pixelsPerNativeUnit:{x:d.screenshot.imageSize.width/p.width,y:d.screenshot.imageSize.height/p.height},h="crop"in d?d.crop.rasterBounds:{left:0,top:0},f=GW({x:(h.left+n.x)/m.x,y:(h.top+n.y)/m.y},s,a),y="crop"in d?d.crop.imageSize:d.screenshot.imageSize,b=W3({left:h.left/m.x,top:h.top/m.y,right:(h.left+y.width)/m.x,bottom:(h.top+y.height)/m.y},s,a);if(tr(f,b),!Je(f,s))w("pixels resolve outside native screen bounds");return f}function Qe(n,s,a){let c=n.source,d="crop"in c?c.crop:c.screenshot,{screenSize:p,imageSize:m}=d;if(!le(p)||!le(a))w("requires positive finite screenSize");if(p.width!==a.width||p.height!==a.height)w("source screenSize changed; observe again");let h=Vt(c,s),f=[];if("crop"in c)f=Jt(c,s,h);else Zt(c,YW(p,h),s);if(er(n,m),n.unit==="pixels")return nr(n,p,h,f);let y="crop"in c?c.crop.clippedBounds:{left:0,top:0,right:p.width,bottom:p.height},b=GW(n,{width:1,height:1},h);return{x:W(b.x,y.left,y.right),y:W(b.y,y.top,y.bottom)}}function ir(n){let{durationMs:s}=n,a=n.action??"tap";if(a!=="tap"&&a!=="longPress"&&a!=="doubleTap")return"tapAt action is unsupported";if(s!==void 0&&(a!=="longPress"||!Number.isInteger(s)||s<$a||s>gg))return`tapAt durationMs requires longPress and must be ${$a}\u2013${gg} ms`;return}function I(n){return n.image??{x:n.x,y:n.y}}function et(n,s){let a=I(n);return s==="android"&&!n.image?{x:Math.round(a.x),y:Math.round(a.y)}:a}function or(n,s){return n.x!==void 0||n.y!==void 0||n.coordinateSpace!==void 0?`${s} image is mutually exclusive with x, y, and coordinateSpace`:void 0}function sr(n,s){if(n.image!==void 0)return or(n,s);let{x:a,y:c}=n,d=n.coordinateSpace??"absolute";if(d!=="absolute"&&d!=="normalized"&&d!=="percent")return`${s} coordinateSpace is unsupported`;if(!Number.isFinite(a)||!Number.isFinite(c))return`${s} requires finite x and y coordinates`;let p=d==="normalized"?1:d==="percent"?100:void 0;if(p!==void 0&&!ur(a,c,p))return`${s} ${d} coordinates must be between 0 and ${p}`;return}function ur(n,s,a){return n>=0&&n<=a&&s>=0&&s<=a}function Ze(n,s,a){let c=a==="normalized"?1:a==="percent"?100:void 0;if(c===void 0)return n;return pe(n/c,s)}function cr(n){if(!n)return!1;return Number.isFinite(n.width)&&Number.isFinite(n.height)&&n.width>0&&n.height>0}function dr(n,s){return n.x<0||n.x>=s.width||n.y<0||n.y>=s.height}function pr(n,s){let a=n.image?.source;return a&&"crop"in a?{width:a.crop.rasterBounds.right,height:a.crop.rasterBounds.bottom}:s}function lr(n,s,a){if(!n||!("screenshot"in n.source))return n;let c=n.source.screenshot;if(c.screenSize.width!==s.screenSize.width||c.screenSize.height!==s.screenSize.height)return n;return{...n,source:{screenshot:{...c,screenSize:a}}}}function mr(n,s,a,c){if(a==="android"&&c==="tapAt")Iie(s,n.androidXr===!0);let d=a==="android"&&c==="tapAt"&&n.pointSpace!=="native"?gW(s.backStack,n.androidXr??!1):void 0,p=d?v3(s):s.screenSize,m=d?lr(n.image,s,p):n.image,h=d&&m&&"crop"in m.source?s.screenSize:p;return{xr:d,screenSize:p,image:m,imageScreenSize:h}}function od(n,s,a,c="tapAt"){let{x:d,y:p}=I(n),m=sr(n,c);if(m)return{x:d,y:p,error:m};let h=n.coordinateSpace??"absolute",{xr:f,screenSize:y,image:b,imageScreenSize:T}=mr(n,s,a,c);if(!cr(y))return{x:d,y:p,error:`${c} requires a positive screenSize from a fresh observation`};let g=b?Qe(b,a==="ios"?"ios":"android",T):{x:Ze(d,y.width,h),y:Ze(p,y.height,h)},{x:v,y:R}=g;if(dr({x:v,y:R},y))return{x:d,y:p,error:`${c} coordinates (${d}, ${p}) are outside screen bounds [0, ${y.width}) x [0, ${y.height})`};let S=pr(n,y),D=a==="android"?Math.min(Math.round(v),Math.ceil(S.width)-1):v,A=a==="android"?Math.min(Math.round(R),Math.ceil(S.height)-1):R;if(f){let j=BC(s,!0),K=kte({x:D,y:A},f.panel,y);return{...K,screenshotPoint:{x:D,y:A},xrPanel:{packageName:f.panel.packageName,taskId:f.panel.id,displayX:K.x,displayY:K.y},warning:j}}return{x:D,y:A}}function fr(n,s,a){let c=n.action??"tap",d=c==="longPress"?"long press":c==="doubleTap"?"double tap":"tap";return Vp(s.viewHierarchy,n.layer,[a],d)}function he(n,s,a){yr(n,s,a);let c=ir(n);if(c)return{x:I(n).x,y:I(n).y,error:c};let d=od(n,s,a);if("error"in d)return d;let p=fr(n,s,d);if(p)return{...d,error:p};if(n.planContext)vr(n.planContext,s,d.screenshotPoint??d,a);return d}function yr(n,s,a){let c=n.planContext?.geometry;if(!c)return;let d=s.rotation??s.viewHierarchy?.rotation,m=[["platform",c.platform===a],["dimensions",c.deviceWidth===s.screenSize.width&&c.deviceHeight===s.screenSize.height],["orientation",Number.isInteger(d)&&c.orientation===d],["point",br(n,c,a)]].find(([,h])=>!h)?.[0];if(m)throw new G(`tapAt replay ${m} mismatch: recorded ${JSON.stringify(c)}, current ${a} ${s.screenSize?.width}x${s.screenSize?.height} orientation ${d}. Replay on compatible geometry or record this step again.`)}function br(n,s,a){if(n.image||(n.coordinateSpace??"absolute")!=="absolute")return!1;if(n.x!==s.x||n.y!==s.y)return!1;return a!=="android"||Number.isInteger(s.x)&&Number.isInteger(s.y)}function vr(n,s,a,c){let d=s.rotation??s.viewHierarchy?.rotation;if((c==="android"||c==="ios")&&Number.isInteger(d)&&d!==void 0&&d>=0&&d<=3)n.recordedGeometry={platform:c,deviceWidth:s.screenSize.width,deviceHeight:s.screenSize.height,orientation:d,x:a.x,y:a.y}}function Tr(n,s,a){let c=n.talkBackDriverFactory??a;return{featureFlags:n.featureFlags??ar.getInstance(),accessibilityDetector:n.accessibilityDetector??li,talkBackDriverFactory:c,talkBackStrategy:n.talkBackStrategy??new Wv({timer:s,driverFactory:c}),useContextualFocusTap:n.talkBackDriverFactory===void 0}}var tt=1000;function gr(n,{detector:s,stateClient:a,featureFlags:c,timer:d}){return()=>{let p=new AbortController;return l(()=>s.isVoiceOverEnabled(n.deviceId,a(),{featureFlags:c,timeoutMs:tt,signal:p.signal}),{timer:d,timeoutMs:tt,label:"tapAt VoiceOver probe",onTimeout:()=>p.abort()})}}class NC extends Oe{androidClient;iosDoubleTap;iosClient;iosCoordinateTap;invalidateIosCache;isIosVoiceOverOn;lastRenderedObservation;stylusRoutes;snapshotReferences;androidTalkBack;androidDispatcher;xrDetector;androidXr;constructor(n,s=null,a={}){super(n,{adb:s,timer:a.timer,displayFence:a});us(n.platform,"tapAt"),this.androidClient=a.androidClient??Xs(n,this.adbFactory);let c=()=>x.getInstance(n);this.iosClient=a.iosClient??c(),this.iosDoubleTap=a.dispatchIosDoubleTap??Gw,this.iosCoordinateTap=a.dispatchIosCoordinateTap??Kw,this.invalidateIosCache=a.invalidateIosCache??(()=>x.getExistingInstance(this.device.deviceId)?.invalidateCache()),this.lastRenderedObservation=a.lastRenderedObservation,this.stylusRoutes=a.stylus??{},this.snapshotReferences=a.snapshotReferences??vp,this.xrDetector=a.xrDetector;let d=Tr(a,this.timer,new eg(this.adbFactory));this.isIosVoiceOverOn=gr(n,{detector:a.iosVoiceOverDetector??ko,stateClient:()=>a.iosVoiceOverStateClient??c(),featureFlags:d.featureFlags,timer:this.timer}),this.androidTalkBack=new Q({target:this,androidClient:this.androidClient,...d});let p=this;this.androidDispatcher=new Z({host:{get adb(){return p.adb},get observeScreen(){return p.observeScreen},assertDisplayRevisionCurrent:(m)=>this.assertDisplayRevisionCurrent(m),assertSnapshotCurrent:(m,h)=>this.assertSnapshotCurrent(m,h),resolveFreshFrameRetry:(m,h,f,y)=>this.resolveFreshFrameRetry(m,h,f,y),retryFreshness:(m)=>this.retryFreshness(m)},androidClient:this.androidClient,androidCoordinateTap:a.dispatchAndroidCoordinateTap??jw,androidTalkBack:this.androidTalkBack,timer:this.timer})}async executeOnDisplay(n,s,a){let{onTapDelivered:c,signal:d,onDispatchCompleted:p,onActivationWarnings:m}=a,h=n.action??"tap",{observation:f,displayId:y,followUpDisplay:b,assertCurrent:T}=await zi(this.device,s,this.observeScreen,{adb:this.adb,lastRenderedObservation:this.lastRenderedObservation,signal:d,transitions:this.displayTransitionReader}),g=this.staleSnapshotReason(n,f);if(g)return{success:!1,x:I(n).x,y:I(n).y,action:h,error:g};let v=await this.resolveWithXr(n,f,d);if("error"in v)return{success:!1,x:v.x,y:v.y,action:h,error:v.error};return this.observedInteraction(async()=>{if(T(),this.device.platform==="android"&&await this.androidTalkBack.resolveState(d,m)){let S=vg(y);if(S)throw S;await this.dispatchDisplayTalkBackTapWithOneFreshRetry(n,v,f,{signal:d,assertCurrent:T,followUpDisplay:b,onTapDelivered:()=>c(!0),onActivationWarnings:m})}else await this.dispatchGesture(n,v,f,{signal:d,displayId:y,assertCurrent:T,onTapDelivered:c,onWarning:(S)=>m?.([S])});return p?.(),{success:!0,x:v.x,y:v.y,action:h,...v.xrPanel?{xrPanel:v.xrPanel}:{},...v.warning?{warning:v.warning}:{}}},{changeExpected:!1,display:b,previousObservation:f,signal:d})}async execute(n,s,a,c){us(this.device.platform,"tapAt");let{progress:d,signal:p,planContext:m}=Ire(s,a,c),h=Ce(this.device.platform,n);if(h)return Ie(h,I(n),n.action);return this.executeTap(n,d,p,m)}async dispatchStylusTapAt(n,s,a,c){let d={signal:c,assertCurrent:()=>this.assertDisplayRevisionCurrent(a)};if(!ME(n.pointer)){await _e(this.adb,s,n,d);return}let p=n.action==="longPress"?n.durationMs??ZT:void 0;try{await MC(this.device,this.adb,OC(n.pointer,Ye(s,p)),{...d,...this.stylusRoutes})}catch(m){throw m instanceof Mv?Tn(m.message):m}}async executeTap(n,s,a,c){n={...n,planContext:c};let d=n.action??"tap",p=J();p.serial("tapAt");let m,h,f={tapsDelivered:0,talkBack:!1,displayCompleted:!1},y=new Set,b=fte(y),T=(v=!1)=>{f.talkBack||=v,f.tapsDelivered++},g=this.captureTransitionRevision();try{if(o(a),n.display!==void 0)return{...await this.executeOnDisplay(n,n.display,{onTapDelivered:T,signal:a,onDispatchCompleted:()=>{f.displayCompleted=!0},onActivationWarnings:b}),...y.size?{warnings:[...y]}:{}};if(this.hasStaleCallerRevision(this.displayTransitionReader.revision(this.device.deviceId)))return Qt({success:!1,x:I(n).x,y:I(n).y,action:d},this.staleDisplay(g.observedGeneration));let v=null,R=await this.observedInteraction(async()=>{let S=await this.observeScreen.execute({freshness:"cached-ok",signal:a,perf:p});if(v=S,this.currentActionRevision()!==g.revision)return Qt({success:!1,x:I(n).x,y:I(n).y,action:d},this.staleDisplay(g.observedGeneration));let D=this.staleSnapshotReason(n,S);if(D)return{success:!1,x:I(n).x,y:I(n).y,action:d,error:D};let A=await this.resolveWithXr(n,S,a);if("error"in A)return{success:!1,x:A.x,y:A.y,action:d,error:A.error};switch(m=A,this.assertDisplayRevisionCurrent(g),o(a),this.device.platform){case"android":{if(n.pointer){await this.dispatchStylusTapAt(n,A,g,a),T();break}let j=await this.androidTalkBack.resolveState(a,b);f.talkBack=j,await this.androidDispatcher.dispatchAndroidTaps(n,A,S,{transitionRevision:g,perf:p,signal:a,onTapDelivered:T,talkBackEnabled:j,onActivationWarnings:b});break}case"ios":h=await this.dispatchIosTapsWithOneFreshRetry(n,A,S,{transitionRevision:g,onTapDelivered:T,signal:a});break;default:throw Rt(this.device.platform,"tap at coordinates")}return{success:!0,x:A.x,y:A.y,action:d,...A.xrPanel?{xrPanel:A.xrPanel}:{},...A.warning?{warning:A.warning}:{}}},{changeExpected:!1,progress:s,perf:p,signal:a,skipPreviousObserve:!0,observationTimestampProvider:()=>h,predictionContext:{toolName:"tapAt",toolArgs:{...n,action:d,platform:this.device.platform}}});return this.annotateDeviceLock(R,v),{...R,...y.size?{warnings:[...y]}:{}}}catch(v){if(v instanceof G)throw v;return this.rethrowObservationAbort(v,a,f.displayCompleted),this.createDispatchFailure(v,n,m,f)}finally{p.end()}}captureTransitionRevision(){return{revision:this.currentActionRevision(),observedGeneration:this.renderedDisplayGeneration(this.device.deviceId)??this.displayTransitionReader.identityRevision(this.device.deviceId)}}createDispatchFailure(n,s,a,c){let d=s.action??"tap",{tapsDelivered:p,talkBack:m}=c;e.warn(`tapAt dispatch failed: ${r(n)}`,n);let h=a??et(s,this.device.platform),f=Qt({success:!1,x:h.x,y:h.y,error:`Failed to tap at coordinates: ${r(n)}`,action:d},n);if(m&&d!=="longPress"){if(n instanceof hr&&p===3)f.error+=" A TalkBack focus touch and an activation double tap were delivered."}else f.error+=n instanceof hr?` ${p} ${p===1?"tap was":"taps were"} delivered.`:hte(d,p);return f}async dispatchIosTapsWithOneFreshRetry(n,s,a,c){let{transitionRevision:d,signal:p}=c,m=a.viewHierarchy?.frameContext;try{return await this.dispatchIosTaps(n,s,m,c)}catch(h){o(p);let f=u(h,"Failed to dispatch iOS coordinate tap");if(m===void 0||!Ua(f.message))throw f;let y=await this.observeScreen.execute({freshness:"fresh",signal:p});this.assertDisplayRevisionCurrent(d),this.assertSnapshotCurrent(n,y);let b=this.resolveFreshFrameRetry(n,s,a,y);if(!b||!pl(a,y,!0))throw f;return await this.dispatchIosTaps(n,b.point,b.frameContext,c)}}async dispatchIosTaps(n,s,a,c){let{transitionRevision:d,onTapDelivered:p,signal:m}=c;this.assertDisplayRevisionCurrent(d),await this.dispatchIosCoordinateTap(n.action,s,{durationMs:zw(n,"ios"),frameContext:a,signal:m});try{if(p(),n.action==="doubleTap")p();return o(m),this.timer.now()}finally{this.invalidateIosCacheSafely()}}async dispatchIosCoordinateTap(n,s,a){let{durationMs:c,frameContext:d,signal:p}=a,m=n==="doubleTap"?this.iosDoubleTap:this.iosCoordinateTap;await yte(()=>m(this.iosClient,s,{durationMs:c,frameContext:d,options:{signal:p}}),this.isIosVoiceOverOn)}invalidateIosCacheSafely(){try{this.invalidateIosCache()}catch(n){e.warn(`tapAt iOS cache invalidation failed: ${r(n)}`,n)}}async dispatchDisplayTalkBackTapWithOneFreshRetry(n,s,a,c){let{signal:d,assertCurrent:p}=c,m=a.viewHierarchy?.frameContext,h=!1,f=!1,y={assertCurrent:p,onTapDelivered:()=>{h=!0,c.onTapDelivered()},onDispatched:()=>{f=!0},onActivationWarnings:c.onActivationWarnings};try{await this.androidTalkBack.dispatchTap(n,s,m,{signal:d,context:y})}catch(b){o(d);let T=u(b,"Failed to dispatch Android coordinate tap");if(h||f||m===void 0||!Ua(T.message))throw T;let g=await this.observeScreen.execute({display:c.followUpDisplay,freshness:this.retryFreshness(n),signal:d});p(),this.assertSnapshotCurrent(n,g);let v=this.resolveFreshFrameRetry(n,s,a,g);if(g.display.key!==a.display.key||!v)throw T;await this.androidTalkBack.dispatchTap(n,v.point,v.frameContext,{signal:d,context:y})}}async resolveWithXr(n,s,a){if(this.device.platform==="android")this.androidXr=await da({device:this.device,adb:this.adb,backStack:s.backStack,signal:a},this.xrDetector);return he({...n,androidXr:this.androidXr},s,this.device.platform)}resolveFreshFrameRetry(n,s,a,c){let d=he({...n,androidXr:this.androidXr},c,this.device.platform),p=c.viewHierarchy?.frameContext;if("error"in d||d.x!==s.x||d.y!==s.y||!p||this.device.platform!=="ios"&&p===a.viewHierarchy?.frameContext)return;if(!n.snapshotId&&!xe(a,c))throw new t("Stale frame context: screen layout changed since the last observation. Observe again and recompute coordinates, or pass a fresh snapshotId.");return{point:d,frameContext:p}}assertDisplayRevisionCurrent(n){if(this.currentActionRevision()!==n.revision)throw this.staleDisplay(n.observedGeneration)}currentActionRevision(){return this.device.platform==="ios"?this.displayTransitionReader.identityRevision(this.device.deviceId):this.displayTransitionReader.revision(this.device.deviceId)}staleSnapshotReason(n,s){return n.snapshotId?this.snapshotReferences.staleReason(n.snapshotId,this.device.deviceId,s):void 0}assertSnapshotCurrent(n,s){let a=this.staleSnapshotReason(n,s);if(a)throw new t(a)}retryFreshness(n){return n.snapshotId?"fresh":"cached-ok"}hasStaleCallerRevision(n){let s=this.renderedDisplayRevision(this.device.deviceId);if(s===void 0)return!1;return this.device.platform==="ios"?!this.displayTransitionReader.sameIdentitySince(this.device.deviceId,s):s!==n}async dispatchAndroidDisplayGesture(n,s,a,c){let{displayId:d,signal:p}=c;if(await Ba(this.androidClient,d)){o(p),c.assertCurrent();let m=!1,h=()=>{m=!0},f=await this.androidClient.requestTapCoordinates({x:n.x,y:n.y,duration:s,timeoutMs:$b(s),onDispatch:h,signal:p,displayId:d===0?void 0:d,beforeSend:c.assertCurrent});if(f.success)c.onTapDelivered();if(o(p),f.success)return;if(m)throw Tn(f.error);if(Ua(f.error))throw new t(f.error??"Stale frame context");e.warn(`[TapAtCoordinate] dispatchGesture tap failed (${f.error}), falling back to ADB input`)}o(p),c.assertCurrent(),await Ec(this.adb,a,d,{signal:p,assertCurrent:c.assertCurrent,timeoutMs:s>=$a?Wr(s):void 0}),c.onTapDelivered(),o(p)}async dispatchGesture(n,s,a,c){let{signal:d,displayId:p}=c,m=n.action??"tap",h=zw(n,this.device.platform),f=async()=>{if(o(d),c.assertCurrent(),this.device.platform==="android"){let y=m==="longPress"?`swipe ${s.x} ${s.y} ${s.x} ${s.y} ${h}`:`tap ${s.x} ${s.y}`;await this.dispatchAndroidDisplayGesture(s,h,y,c)}else if(this.device.platform==="ios"){if(await this.dispatchIosCoordinateTap(m,s,{durationMs:h,frameContext:a.viewHierarchy?.frameContext,signal:d}),c.onTapDelivered(),m==="doubleTap")c.onTapDelivered()}else throw Rt(this.device.platform,"tapAt gesture")};if(this.device.platform==="android"&&m==="doubleTap"){await yg({client:await Ba(this.androidClient,p)?this.androidClient:void 0,point:s,displayId:p===0?void 0:p,timer:this.timer,signal:d,assertCurrent:c.assertCurrent,onTapDelivered:c.onTapDelivered,onWarning:c.onWarning,tap:()=>f()});return}if(await f(),this.device.platform==="ios"){try{o(d)}finally{this.invalidateIosCacheSafely()}return}}}
7
+ export{vp,d3,Mv,mte,l3,id,QV,u3,eW,tW,p3,rW,OC,MC,od,NC};
8
8
 
9
- //# debugId=1A3720A0C6D91EE164756E2164756E21
9
+ //# debugId=69A3A34FFA18F6AB64756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{LU}from"./chunk-hegfz0ae.js";import"./chunk-r6pvhj33.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{LU as DefaultDatabaseInitializer};
3
+
4
+ //# debugId=8B8383039EE610C364756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{fee,hee,m5}from"./chunk-e98dqnc9.js";import{PassThrough as u}from"stream";var i=Symbol("swallowsErrorsAfterClose"),a=class{_readBuffer;_started=!1;_closed=!1;constructor(e=m5.stdin,r=m5.stdout,s){this._stdin=e,this._stdout=r,this._readBuffer=new fee({maxBufferSize:s?.maxBufferSize})}onclose;onerror;onmessage;_ondata=(e)=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(r){this.onerror?.(r),this.close().catch(()=>{})}};_onerror=(e)=>{this.onerror?.(e)};_onstdouterror=(e)=>{if(this._closed)return;this.onerror?.(e),this.close().catch(()=>{})};_onstdinclose=()=>{this.close().catch(()=>{})};async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0;for(let e of this._stdout.listeners("error"))if(e[i])this._stdout.off("error",e);if(this._stdin.readableEnded||this._stdin.destroyed)setImmediate(this._onstdinclose);this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror),this._stdin.on("end",this._onstdinclose),this._stdin.on("close",this._onstdinclose),this._stdout.on("error",this._onstdouterror)}processReadBuffer(){while(!0)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._closed)return;if(this._closed=!0,this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.off("end",this._onstdinclose),this._stdin.off("close",this._onstdinclose),this._onstdouterror[i]=!0,this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(e){if(this._closed)return Promise.reject(Error("StdioServerTransport is closed"));return new Promise((r,s)=>{let d=hee(e),t=!1,o=(l)=>{if(t)return;t=!0,this._stdout.off("error",o),this._stdout.off("drain",n),s(l)},n=()=>{if(t)return;t=!0,this._stdout.off("error",o),this._stdout.off("drain",n),r()};if(this._stdout.once("error",o),this._stdout.write(d)){if(t)return;t=!0,this._stdout.off("error",o),r()}else if(!t)this._stdout.once("drain",n)})}};class c extends a{source;feed;constructor(e,r,s){super(r,s);this.source=e;this.feed=r}forwardSourceError=(e)=>{this.onerror?.(e)};async start(){await super.start(),this.source.on("error",this.forwardSourceError),this.source.pipe(this.feed,{end:!1})}async close(){this.source.off("error",this.forwardSourceError),this.source.unpipe(this.feed),await super.close()}}function z(e=process.stdin,r=process.stdout){return new c(e,new u,r)}export{z as createStdioServerTransport};
2
+ import{Iee,_ee,I5}from"./chunk-6hrj3jt6.js";import{PassThrough as u}from"stream";var i=Symbol("swallowsErrorsAfterClose"),a=class{_readBuffer;_started=!1;_closed=!1;constructor(e=I5.stdin,r=I5.stdout,s){this._stdin=e,this._stdout=r,this._readBuffer=new Iee({maxBufferSize:s?.maxBufferSize})}onclose;onerror;onmessage;_ondata=(e)=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(r){this.onerror?.(r),this.close().catch(()=>{})}};_onerror=(e)=>{this.onerror?.(e)};_onstdouterror=(e)=>{if(this._closed)return;this.onerror?.(e),this.close().catch(()=>{})};_onstdinclose=()=>{this.close().catch(()=>{})};async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0;for(let e of this._stdout.listeners("error"))if(e[i])this._stdout.off("error",e);if(this._stdin.readableEnded||this._stdin.destroyed)setImmediate(this._onstdinclose);this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror),this._stdin.on("end",this._onstdinclose),this._stdin.on("close",this._onstdinclose),this._stdout.on("error",this._onstdouterror)}processReadBuffer(){while(!0)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._closed)return;if(this._closed=!0,this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.off("end",this._onstdinclose),this._stdin.off("close",this._onstdinclose),this._onstdouterror[i]=!0,this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(e){if(this._closed)return Promise.reject(Error("StdioServerTransport is closed"));return new Promise((r,s)=>{let d=_ee(e),t=!1,o=(l)=>{if(t)return;t=!0,this._stdout.off("error",o),this._stdout.off("drain",n),s(l)},n=()=>{if(t)return;t=!0,this._stdout.off("error",o),this._stdout.off("drain",n),r()};if(this._stdout.once("error",o),this._stdout.write(d)){if(t)return;t=!0,this._stdout.off("error",o),r()}else if(!t)this._stdout.once("drain",n)})}};class c extends a{source;feed;constructor(e,r,s){super(r,s);this.source=e;this.feed=r}forwardSourceError=(e)=>{this.onerror?.(e)};async start(){await super.start(),this.source.on("error",this.forwardSourceError),this.source.pipe(this.feed,{end:!1})}async close(){this.source.off("error",this.forwardSourceError),this.source.unpipe(this.feed),await super.close()}}function z(e=process.stdin,r=process.stdout){return new c(e,new u,r)}export{z as createStdioServerTransport};
3
3
 
4
- //# debugId=5C330F4A3EB7DCD164756E2164756E21
4
+ //# debugId=4FD15D55CA8C296364756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import"./chunk-58wzr3mt.js";import"./chunk-z637nqg8.js";import"./chunk-4hw3665t.js";import{GK}from"./chunk-6bznss4t.js";import{t}from"./chunk-rbpdk7m0.js";import{createHash as l}from"crypto";import s from"path";function m(e){let r=e._meta??{},{frame:n,revision:o,variants:i,rendererVersion:p}=r;if(typeof n!=="string"||typeof o!=="number"||!Array.isArray(i)||typeof p!=="string"||typeof e.text!=="string")throw new t(`The prototype web page for ${e.uri} came back without its HTML or metadata; nothing was written.`);return{frame:n,revision:o,variants:i.map(String),rendererVersion:p}}var b=(e)=>l("sha256").update(e).digest("hex");function w(e,r,n){return`${GK(e.variant??e.id)}-${r.frame}-r${r.revision}-${n.slice(0,12)}.html`}async function g(e,r,n){let o=e.outputPath;if(o===void 0)return s.join(r.defaultDir(),n);if(!s.isAbsolute(o))throw new t(`outputPath "${o}" is not absolute: give an absolute file or directory path, or omit outputPath to write under ${r.defaultDir()}.`);let i=await r.kind(o);if(i==="directory"||/[\\/]$/.test(o))return s.join(o,n);if(i==="other")throw new t(`outputPath "${o}" exists and is not a regular file or directory; choose another outputPath.`);if(s.extname(o).toLowerCase()!==".html")throw new t(`outputPath "${o}" is neither an .html file nor a directory: end a file path in .html, or end a directory path in "${s.sep}" (or name an existing directory) to write ${n} there.`);return o}function f(e){return new t(`${e} already exists with different content; pass overwrite: true to replace it, or choose another outputPath. Nothing was written.`)}var P=new Set(["EACCES","EPERM","EROFS","ENOENT","ENOTDIR","EISDIR"]);function x(e,r){let n=e?.code;if(n==="EEXIST")return f(r);let o=n!==void 0&&P.has(n)?` (${n})`:"",i=e instanceof Error?`: ${e.message}`:"";return new t(`Cannot write the prototype web page to ${r}${o}${i}. Choose a writable outputPath, or omit it to write under the AutoMobile data directory.`)}async function E(e,r,n,o){if(await e.kind(r)==="file"&&!o){let i=await e.read(r);if(Buffer.from(i).equals(Buffer.from(n)))return;throw f(r)}try{await e.write(r,n,{exclusive:!o})}catch(i){throw x(i,r)}}async function I(e,r){let{id:n,frame:o,revision:i,variant:p,mcpSessionId:h}=e,d=await r.readWeb({id:n,frame:o,revision:i,variant:p,mcpSessionId:h}),a=m(d),u=Buffer.from(d.text,"utf8"),y=b(u),c=await g(e,r.files,w(e,a,y));return await E(r.files,c,u,e.overwrite===!0),{path:c,sha256:y,bytes:u.length,frame:a.frame,revision:a.revision,variants:a.variants,rendererVersion:a.rendererVersion}}export{I as exportPrototypeWeb};
2
+ import"./chunk-5wk1t46v.js";import"./chunk-r0vp315h.js";import"./chunk-w5yypt53.js";import{hG}from"./chunk-ntfrqrqn.js";import{t}from"./chunk-2b39zyxc.js";import{createHash as l}from"crypto";import s from"path";function m(e){let r=e._meta??{},{frame:n,revision:o,variants:i,rendererVersion:p}=r;if(typeof n!=="string"||typeof o!=="number"||!Array.isArray(i)||typeof p!=="string"||typeof e.text!=="string")throw new t(`The prototype web page for ${e.uri} came back without its HTML or metadata; nothing was written.`);return{frame:n,revision:o,variants:i.map(String),rendererVersion:p}}var b=(e)=>l("sha256").update(e).digest("hex");function w(e,r,n){return`${hG(e.variant??e.id)}-${r.frame}-r${r.revision}-${n.slice(0,12)}.html`}async function g(e,r,n){let o=e.outputPath;if(o===void 0)return s.join(r.defaultDir(),n);if(!s.isAbsolute(o))throw new t(`outputPath "${o}" is not absolute: give an absolute file or directory path, or omit outputPath to write under ${r.defaultDir()}.`);let i=await r.kind(o);if(i==="directory"||/[\\/]$/.test(o))return s.join(o,n);if(i==="other")throw new t(`outputPath "${o}" exists and is not a regular file or directory; choose another outputPath.`);if(s.extname(o).toLowerCase()!==".html")throw new t(`outputPath "${o}" is neither an .html file nor a directory: end a file path in .html, or end a directory path in "${s.sep}" (or name an existing directory) to write ${n} there.`);return o}function f(e){return new t(`${e} already exists with different content; pass overwrite: true to replace it, or choose another outputPath. Nothing was written.`)}var P=new Set(["EACCES","EPERM","EROFS","ENOENT","ENOTDIR","EISDIR"]);function x(e,r){let n=e?.code;if(n==="EEXIST")return f(r);let o=n!==void 0&&P.has(n)?` (${n})`:"",i=e instanceof Error?`: ${e.message}`:"";return new t(`Cannot write the prototype web page to ${r}${o}${i}. Choose a writable outputPath, or omit it to write under the AutoMobile data directory.`)}async function E(e,r,n,o){if(await e.kind(r)==="file"&&!o){let i=await e.read(r);if(Buffer.from(i).equals(Buffer.from(n)))return;throw f(r)}try{await e.write(r,n,{exclusive:!o})}catch(i){throw x(i,r)}}async function I(e,r){let{id:n,frame:o,revision:i,variant:p,mcpSessionId:h}=e,d=await r.readWeb({id:n,frame:o,revision:i,variant:p,mcpSessionId:h}),a=m(d),u=Buffer.from(d.text,"utf8"),y=b(u),c=await g(e,r.files,w(e,a,y));return await E(r.files,c,u,e.overwrite===!0),{path:c,sha256:y,bytes:u.length,frame:a.frame,revision:a.revision,variants:a.variants,rendererVersion:a.rendererVersion}}export{I as exportPrototypeWeb};
3
3
 
4
- //# debugId=23C894C0998E1DF164756E2164756E21
4
+ //# debugId=757E29C742DC1A9464756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{kj,pce,Fc,ZY,QY}from"./chunk-sfqe223f.js";import"./chunk-r6pvhj33.js";import"./chunk-aewdveet.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{pce as getLastStartupTimingMs,Fc as getPerformanceMonitor,kj as setLastTtiMs,ZY as startPerformanceMonitor,QY as stopPerformanceMonitor};
3
+
4
+ //# debugId=6B9E3A23648B1DD164756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{zK,jK,KK}from"./chunk-ddqhj4eg.js";import"./chunk-wxdjeb4k.js";import"./chunk-96r3bpg7.js";import"./chunk-g3af2qbk.js";import"./chunk-sqdrxjw5.js";import"./chunk-4vxeq0vd.js";import"./chunk-69pmjdf2.js";import"./chunk-sfqe223f.js";import"./chunk-r6pvhj33.js";import"./chunk-w5yypt53.js";import"./chunk-aewdveet.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{zK as getVideoRecordingSocketPath,jK as startVideoRecordingSocketServer,KK as stopVideoRecordingSocketServer};
3
+
4
+ //# debugId=0DCE3CCEDCA129F364756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{i,lM,we,Ea,e}from"./chunk-r0vp315h.js";import{me,U,o,ya,Rr,N,hf,va,lt,Nt,mn,rt,Dl,fe,ts,Zn,Ee,Wr,zr,x}from"./chunk-sfqe223f.js";import{FC}from"./chunk-cqhw4yr6.js";import{$W,rz,nz,YT,oz}from"./chunk-4vxeq0vd.js";import{Eu,zo,uD,Kn}from"./chunk-cb1ga9rd.js";import{r,t,u,Rt}from"./chunk-2b39zyxc.js";var Qc=5000,UF=2500,dl=30000,hu=1770000;var HF=800,N5=500;async function Ev(n,s,c,{timeoutMs:a=HF,context:l="while TalkBack is on",platform:d="android"}={}){let p=s.now()+Math.max(0,a);while(s.now()<p){o(c);let m=await n(p-s.now());if(o(c),m&&s.now()<=p)return m;let h=p-s.now();if(h>0)await s.sleep(Math.min(N5,h))}throw o(c),new t(d==="ios"?`Unable to retrieve a fresh tap hierarchy: iOS runner failed to produce a view hierarchy ${l}. Observe again.`:`Unable to retrieve a fresh tap hierarchy: hierarchy unavailable from the accessibility service ${l}. Observe again and check that the accessibility service is running.`)}async function qF(n){let{adb:s,x:c,y:a,durationMs:l,signal:d,assertCurrent:p,logTag:m}=n;o(d);let h=zo(l),f=Wr(l),b=async(y)=>{p?.();let w=await s.executeCommand(y,{timeoutMs:f,signal:d});uD(y,w)};try{try{await b(`shell input touchscreen swipe ${c} ${a} ${c} ${a} ${h}`)}catch(y){if(e.warn(`[${m}] touch input swipe failed: ${r(y)}`,y),FC(y,l,d),y instanceof Ee)throw y;o(d),await b(`shell input swipe ${c} ${a} ${c} ${a} ${h}`)}}catch(y){if(e.warn(`[${m}] Android long press failed: ${r(y)}`,y),FC(y,l,d),y instanceof Ee)throw y;throw u(y,"Android long press failed")}}function CV(n,s=""){return`Element with exact text '${n}'${s} is no longer present; re-observe and pick it again.`}function hp(n,s){return n.x>=s.left&&n.x<s.right&&n.y>=s.top&&n.y<s.bottom}function Wee(n){return!!n&&n.left<n.right&&n.top<n.bottom}function ed(n,s){let c=rt(s);return(c&&n.find((a)=>a.source===c))??n.find((a)=>a.element&&a.bounds&&Nt(a.bounds,s.bounds)&&a.nativeId===s["resource-id"]&&a.nodeKey===s["view-id"])}function DV(n,s,c){let a=c==="ios"?zr(s):void 0,l=rt(n);return a&&(!l||a.nodes.some((d)=>d.source===l))?a.hierarchy:s}function zee(n){return n===void 0?"touch":"none"}class wo extends t{reason;constructor(n,s){super(n);this.reason=s}}function VF(n){return E(n)}function V(n,s){return E(n,T(n)).approvedClickNodes.has(s)}function k(n){let s=new Set(["button","icon","view","id","com","android","systemui"]);return new Set(n.toLowerCase().split(/[^a-z0-9]+/).filter((c)=>c.length>1&&!s.has(c)))}function P(n,s,c){let a=lt(n)??n,{approvedClickNodes:l}=E(a,T(a)),d=k(c.split("/").pop()??c),p=new fe().project(a).filter((m)=>m.source!==s&&l.has(m.source)).map((m)=>m.properties.text||m.properties["content-desc"]||"").filter((m)=>m!==""&&[...k(m)].some((h)=>d.has(h)));return[...new Set(p)]}function E(n,s=new Set){let c={hiddenNodes:new Set,approvedClickNodes:new Set,nodeClickTargets:s},a=hf(n),l=O(n,c),d=a&&a!==n?O(a,c):void 0,{hiddenNodes:p,approvedClickNodes:m}=c;if(p.size===0)return{hierarchy:n,hiddenNodes:p,approvedClickNodes:m};if(d)va(l,d);return{hierarchy:l,hiddenNodes:p,approvedClickNodes:m}}function F(n,s){let c=we(n);return c["visible-to-user"]===!1&&(s||typeof c["resource-id"]==="string"&&c["resource-id"].startsWith("com.android.systemui"))}function O(n,{hiddenNodes:s,approvedClickNodes:c,nodeClickTargets:a}){let l=s.size,d=new Set(n.windows?.filter((f)=>f.packageName?.startsWith("com.android.systemui")).map((f)=>f.id));function p(f,b=!1){if(Array.isArray(f))return f.flatMap((S)=>p(S,b));let y=we(f),w=b||typeof y.windowId==="number"&&d.has(y.windowId),g=Ea(f).flatMap((S)=>p(S,w)),C=F(f,w);if(C&&!a.has(f))return s.add(f),g;let v=Ea(f),A=g.length===v.length&&g.every((S,_)=>S===v[_])?f:{...f,node:g};if(C)c.add(f),c.add(A);return[A]}let m=n.hierarchy.node?p(n.hierarchy.node):[],h=n.windows?.map((f)=>({...f,hierarchy:f.hierarchy?{node:p(f.hierarchy,f.packageName?.startsWith("com.android.systemui"))}:void 0}));if(s.size===l)return{...n};return{...n,hierarchy:{...n.hierarchy,node:{node:m}},windows:h}}function T(n){let s=lt(n)??null;if(!Eu(s))return new Set;let c=new fe().project(s);return new Set(c.filter((a)=>{if(a.properties["visible-to-user"]!==!1||!a.bounds||a.properties["hierarchy-source"]==="uiautomator"||!Rr(a.properties.actions,"click"))return!1;let l=Kn(a.properties);if(!l)return!1;let d=c.filter((p)=>Dl(p.properties,l));return new Set(d.map((p)=>p.source)).size===1&&!!d[0]?.bounds&&mn(d[0].bounds,a.bounds,0)}).map((a)=>a.source))}function X(n,s,c){let a=s.selection.matchedElement??s.selection.element,l=a&&rt(a);if(!l||!c.has(l))return;let d=n.text??n.textAny?.join(" | ")??n.elementId??n.testTag;return new wo(`Target '${d}' is hidden XR system chrome (visible-to-user false, systemui). Use observe to find the visible control or tapAt with screen coordinates from the screenshot.`,"no-visible-tap-area")}function D(n,s){let a=(n.selection.matchedElement??n.selection.element)?.["visible-to-user"]===!1?s():void 0;if(a)return{...n,selection:{...n.selection,element:null,matchedElement:void 0},visibilityError:a};return n.selection.element||n.selection.matchedElement?n:{...n,visibilityError:s()}}function jee(n,s,c){let a=E(s,n.action==="tap"?T(s):void 0);if(a.hiddenNodes.size===0)return c(n,s);let l={...n,selectionStrategy:"first",index:void 0},d=()=>X(n,c(l,s),a.hiddenNodes);try{return D(c(n,a.hierarchy),d)}catch(p){if(!(p instanceof t))throw p;let m=c(l,a.hierarchy);if(m.selection.element||m.selection.matchedElement)throw p;let h=d();if(!h)throw p;return{selection:{element:null,indexInMatches:-1,totalMatches:0,strategy:n.selectionStrategy??"first"},containerFound:!0,visibilityError:h}}}function Fm(){return new t("The element's bounds are in an XR panel coordinate space and are not tappable screen coordinates. A safe accessibility node click is unavailable. Observe again and select an actionable node or use keyboard focus keys.")}function I(n){return new t(`The accessibility node click was sent to CtrlProxy but its result was not confirmed (${n}), and the screen did not visibly change. The click may still have landed. Do not retry automatically: observe the screen first.`)}function B(n){return n.dispatched===!0&&n.acknowledged===!1}function W(n,s){if(s===void 0||!n.success)return;if(n.effect?.screenChanged===!0){n.warnings=[...n.warnings??[],`CtrlProxy did not confirm the accessibility node click (${s}), but the screen changed after it (${n.effect.basis}), so the click is reported as landed.`];return}n.success=!1,n.error=I(s).message,delete n.warnings}function Kee(n){return{onUnconfirmedClick:(s)=>{n.xrClick={...n.xrClick,unconfirmed:s}},onHiddenChromeClick:(s)=>{n.xrClick={...n.xrClick,hiddenChrome:s}}}}function Gee(n,s){W(n,s?.unconfirmed),L(n,s?.hiddenChrome)}function q(n){let s=n.alternatives.length?`Select the labeled control instead: ${n.alternatives.map((c)=>`tapOn {text: "${c}"}`).join(" or ")}, or observe and use tapAt with screen coordinates from the screenshot.`:"Observe the screen and use tapAt with screen coordinates from the screenshot.";return new t(`Target '${n.label}' is hidden XR system chrome (visible-to-user false, systemui): its accessibility node accepted the click but the screen did not change, so the control was not activated. ${s}`)}function L(n,s){if(!s||!n.success||n.effect?.screenChanged!==!1)return;n.success=!1,n.error=q(s).message,delete n.warnings}function j(n,s){let c=n.class??n.className,l=Boolean(n.text||n["content-desc"])?void 0:s,d={...n.checkable===!0||n.checkable==="true"?{checkable:!0}:{},className:typeof c==="string"?H(c):void 0,text:H(n.text),contentDesc:H(n["content-desc"]),labelText:H(l?.text),labelContentDesc:H(l?.["content-desc"])};return Object.values(d).some((p)=>p!==void 0)?d:void 0}function H(n){return n||void 0}function z(n,s,c,a){let l=lt(c.resolvedHierarchy)??null;if(n!=="tap"||s["hierarchy-source"]==="uiautomator"||!s.bounds||!Eu(l))throw Fm();let d=new fe().project({...l,windows:ya(l.hierarchy,l.windows)}),p=K(d,s,c,{hierarchy:l,resolveContainer:a}),m=(h,f)=>{let b=Kn(h);if(!b){let w=d.filter((C)=>C.bounds&&mn(C.bounds,h.bounds,0)&&Rr(C.properties.actions,"click"));if(new Set(w.map((C)=>C.source)).size!==1||!R(d,w[0],p))return;let g=j(w[0].properties,f??w[0].hoistedLabelSources?.[0]?.properties);if(!g)return;return{expectedBounds:h.bounds,identityHints:g}}let y=d.filter((w)=>Dl(w.properties,b));return new Set(y.map((w)=>w.source)).size===1&&y[0]?.bounds&&mn(y[0].bounds,h.bounds,0)?{selector:b,expectedBounds:h.bounds}:void 0};if(Rr(s.actions,"click")){let h=m(s);if(h)return{...h,...h.selector&&s["visible-to-user"]===!1&&Y(d,s,l)?{allowInvisible:!0,hiddenChrome:G(d,s,l)}:{}};throw Fm()}return Q(s,d,m,p)}function Y(n,s,c){let a=ed(n,s);return a!==void 0&&V(c,a.source)}function G(n,s,c){let a=s["resource-id"]??"",l=ed(n,s);return{label:a||s["content-desc"]||s.text||"",alternatives:l?P(c,l.source,a):[]}}function K(n,s,c,{hierarchy:a,resolveContainer:l}){let d=c.container!==void 0,p=d?l?.(a):void 0,m=p?ed(n,p):void 0,h=m?n.indexOf(m):-1,f=ed(n,s),b=m&&f&&R(n,m,{scoped:!0,containerIndex:n.indexOf(f)}),y={scoped:d&&!b,containerIndex:h};if(y.scoped&&(!f||!R(n,f,y)))throw Fm();return y}function R(n,s,c){if(!c.scoped)return!0;for(let a=s.parentIndex;a!==void 0;a=n[a].parentIndex)if(a===c.containerIndex)return!0;return!1}function J(n,s,c){let a=[];for(let d=s.parentIndex;d!==void 0;d=n[d].parentIndex)a.push(d);if(!c.scoped)return a;let l=a.indexOf(c.containerIndex);if(l<0)throw Fm();return a.slice(0,l)}function Q(n,s,c,a){let l=Kn(n),d=s.filter((p)=>p.bounds&&mn(p.bounds,n.bounds,0)&&p.properties.text===n.text&&!Rr(p.properties.actions,"click")&&(n["view-id"]?p.properties["view-id"]===n["view-id"]:l&&Dl(p.properties,l)));if(new Set(d.map((p)=>p.source)).size!==1)throw Fm();for(let p of J(s,d[0],a)){let m=s[p],h=m.bounds;if(!h||h.left>n.bounds.left||h.top>n.bounds.top||h.right<n.bounds.right||h.bottom<n.bounds.bottom||!Rr(m.properties.actions,"click"))continue;let f=c({...m.properties,bounds:h},{...d[0].properties,bounds:n.bounds});if(f)return f}throw Fm()}async function WF(n,{action:s,element:c,signal:a,options:l,resolveContainer:d}){o(a);let{selector:p,hiddenChrome:m,...h}=z(s,c,l??{},l&&d&&((b)=>d(b,l))),f=await Z(n,{target:{selector:p,...h},signal:a,displayFence:l?.displayFence});if(ee(f,l),f.success&&m)l?.onHiddenChromeClick?.(m)}async function Z(n,{target:{selector:s,...c},signal:a,displayFence:l}){try{if(!await n().supportsNodeActionSelectors(void 0,a,!0))throw Fm();o(a),l?.assertCurrent();let d=await n().requestNodeAction("click",s,{signal:a,...c});return o(a),d}catch(d){if(o(a),d instanceof Ee||d instanceof t&&d.message.includes("Update CtrlProxy"))throw d;throw new t(Fm().message,{cause:d})}}function ee(n,s){if(n.success){s?.onTalkBackActivation?.();return}if(B(n)){let c=n.error||"no reply from CtrlProxy";if(e.warn(`[XrNodeClick] Click was dispatched but not confirmed: ${c}`),s?.onUnconfirmedClick){s.onUnconfirmedClick(c);return}throw I(c)}throw Fm()}var re=300,vC=1500,zF=100;async function jF(n,s,c,{preTapHash:a,signal:l}){l=me(l),o(l),await n.sleep(re),o(l);let d;try{d=await s(vC)}catch(m){if(l?.aborted||m instanceof Error&&m.name==="AbortError"||m instanceof Ee||m instanceof Zn)throw m;return e.warn(`[androidGhostTapRetry] Post-tap hierarchy unreadable: ${r(m)}`,m),{status:"unavailable"}}if(o(l),!d||!a)return{status:"unavailable"};let p=c(d);if(!p)return{status:"unavailable"};if(p!==a)return{status:"changed"};return{status:"unchanged",hierarchy:d}}async function M(n,s,c,a){let d=(a?.timer??i).now()+s,p=await n.requestHierarchySync(new U,N.isRawElementSearchEnabled(),c,{timeoutMs:s}),m=p?n.convertToViewHierarchyResult(p.hierarchy):null;if(!m)return null;if(lM(m)&&a)return $W(m,a,d,c);return m}function KF(n,s){if(!n)return!0;let c=s?.hierarchy;return Boolean(c&&typeof c==="object"&&"error"in c&&c.error)}async function GF(n,s){let{device:c}=n,{signal:a,screenSize:l}=s,d=Math.max(0,s.timeoutMs),p=n.timer.now()+d;switch(c.platform){case"android":{let m=await M(n.androidService,d,a,{adb:n.adb,timer:n.timer});return m?n.prepareForResponse(m,l):null}case"ios":{let m=x.getInstance(c),h=s.forceCapture?await m.requestHierarchySyncForTapRevalidation(void 0,!1,a,d):await m.requestHierarchySync(void 0,!1,a,{timeoutMs:d});if(!h?.hierarchy)return null;let f=n.viewHierarchy.normalizeIosHierarchy(m.convertToViewHierarchyResult(h.hierarchy)),b=h[ts];if(b==="device"||b==="client-cache")Object.assign(f,{[ts]:b});let y=n.prepareForResponse(f,l);return await nz(y,n.sdkBridge??rz(c,n.timer),a,Math.max(0,p-n.timer.now())),await oz(y,n.sdkWeb??YT(c,n.timer),a,Math.max(0,p-n.timer.now())),y}default:throw Rt(c.platform,n.actionLabel)}}async function YF(n){let{timer:s,signal:c}=n,a=n.startTime+n.durationMs,l=n.maxRequests??Number.POSITIVE_INFINITY,d=0,p=n.startTime;while(s.now()<a&&d<l){if(o(c),n.pacing==="sleepFirst")await s.sleep(n.intervalMs);else{let h=Math.min(p,a)-s.now();if(h>0)await s.sleep(h),o(c)}if(s.now()>=a)break;p=s.now()+n.intervalMs;let m=await n.fetch(Math.max(0,a-s.now()));if(d+=1,!m)continue;if(n.discardLateResult&&s.now()>=a)break;if(n.accept(m))break}return{requestCount:d}}
3
+ export{Qc,UF,dl,hu,HF,N5,Ev,qF,CV,hp,Wee,ed,DV,zee,wo,VF,jee,Fm,Kee,Gee,WF,vC,zF,jF,KF,GF,YF};
4
+
5
+ //# debugId=1237CA4205B0C10764756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{h,I}from"./chunk-5wk1t46v.js";import{ei}from"./chunk-r6pvhj33.js";var r=2,O=10,l=900000,_=[h.DEVICE_RECOVERY_ON_LOSS.name,h.DEVICE_RECOVERY_ON_LOSS.legacyName,h.ANDROID_REBOOT_ON_DEATH.name,h.ANDROID_REBOOT_ON_DEATH.legacyName];function i(e,n){for(let t of n)if(e[t]!==void 0)return e[t];return}function M5(e){let n=[],t=i(e,_),c=!1;if(t!==void 0){if(t==="1")c=!0;else if(t!=="0")n.push(`Invalid AUTOMOBILE_DEVICE_RECOVERY_ON_LOSS value ${JSON.stringify(t)}; using 0.`)}let o=i(e,[h.DEVICE_RECOVERY_MAX_ATTEMPTS.name,h.DEVICE_RECOVERY_MAX_ATTEMPTS.legacyName]),s=r;if(o!==void 0)if(/^[1-9]\d*$/.test(o)){let a=Number(o);if(a<=O)s=a;else n.push(`Invalid AUTOMOBILE_DEVICE_RECOVERY_MAX_ATTEMPTS value ${JSON.stringify(o)}; using ${r}.`)}else n.push(`Invalid AUTOMOBILE_DEVICE_RECOVERY_MAX_ATTEMPTS value ${JSON.stringify(o)}; using ${r}.`);return{policy:{onLoss:c,maxAttempts:s},warnings:n}}function Lee(){return M5(process.env).policy}function Bee(e=process.env){let n=i(e,[h.DEVICE_RECOVERY_WINDOW_MS.name,h.DEVICE_RECOVERY_WINDOW_MS.legacyName]);if(n!==void 0&&/^[1-9]\d*$/.test(n))return Number(n);return l}function LF(e=process.env){return i(e,_)!=="0"}var E=I(h.DEVICE_POOL_MATCHING),u=["LATEST","RANDOM","MINIMUM"],Yh=E&&u.includes(E)?E:"LATEST";function $ee(e=process.env){return I(h.DEVICE_POOL_AUTOLOCK,e)==="1"}function Uee(){return ei(h.DEVICE_POOL_TIMEOUT.name,h.DEVICE_POOL_TIMEOUT.legacyName,{fallback:60})*1000}
3
+ export{M5,Lee,Bee,LF,Yh,$ee,Uee};
4
+
5
+ //# debugId=99A7854B024A654A64756E2164756E21
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{i,e}from"./chunk-z637nqg8.js";import{bt,oo,me,$a,o,P,_g,wi,K,Ss,ve,Al,Ee,Hr,Ab,kb,E}from"./chunk-r5bxavdx.js";import{r,t}from"./chunk-rbpdk7m0.js";function Q(n){return n?.startsWith("Element not found with ")===!0}function Y(n,a){return n&&!Q(a)}async function MT(n){if(Y(n.advertised,n.error))return!0;if(!n.advertised||!n.needsNodeSelector)return!1;return!await z(n.selected,n.readHierarchy)}async function z(n,a){let s=await q(a);return Qh(s)&&V(n,s)}async function O(n,a,s){let c;try{c=await a()}catch(d){if(d instanceof Ee)throw d;return e.warn(`[TalkBack] Cannot verify resource-id uniqueness: ${r(d)}`,d),`Unable to verify uniqueness of resource-id "${n}"; using coordinate fallback.`}if(!Qh(c))return`Unable to verify uniqueness of resource-id "${n}" in an incomplete hierarchy; using coordinate fallback.`;let l=new ve().project(c).filter((d)=>Ss(d.nativeId,n));J(l,s);let u=new Set(l.map((d)=>d.source)).size;if(u!==1)return u>1?`Selected resource-id "${n}" is shared by ${u} elements; using coordinate fallback.`:`Resource-id "${n}" is absent from the current hierarchy; using coordinate fallback.`;return}function J(n,a){if(!a)return;if(!n.some((c)=>["text","content-desc"].every((u)=>!a[u]||c.properties[u]===a[u])&&(!a.bounds||c.bounds!==void 0&&wi(c.bounds,a.bounds,0))))throw new t("Selected element moved or is gone from the current hierarchy. Observe again before tapping.")}async function F(n,a,s={}){if(ee(n,s))return{element:n,hierarchy:null};let c=s.hierarchy??await q(a);if(!Qh(c)&&!L(s))return{element:n,hierarchy:c};if(!c||c.hierarchy.error)throw new t("Cannot confirm the selected element because the accessibility hierarchy is unavailable. Observe again and check that the accessibility service is running.");return Z(n,c,s)}function Z(n,a,s){let c=V(n,a);if((!s.hierarchy||!c)&&s.reResolve){let l=te(s.reResolve,a);if(!l)throw new t("Selected element moved or is gone; the original selector no longer resolves. Observe again before tapping.");if(!_(n,l))throw new t("Selected element moved; the original selector now resolves to a different element. Observe again before tapping.");if(!l.bounds)throw new t("Selected element moved and has no current bounds. Observe again before tapping.");return s.onResolvedElement?.(l),{element:l,hierarchy:a}}if(!c)throw new t("Selected element moved or is gone from the current hierarchy. Observe again before tapping.");return{element:n,hierarchy:a}}function _(n,a){return["text","content-desc","resource-id","test-tag","unique-id","collection-row-index","collection-column-index"].every((s)=>n[s]===void 0||n[s]===a[s])}function Qh(n){return!!n&&!n.hierarchy.error&&!n.ctrlProxyIncomplete&&!n.truncationReasons?.length&&!n.windows?.some((a)=>a.truncationReasons?.length)}async function q(n){try{return await n()}catch(a){if(a instanceof Ee)throw a;return e.warn(`[TalkBack] Cannot confirm selected target: ${r(a)}`,a),null}}function V(n,a){return new ve().project(a).some((s)=>_(n,s.properties)&&(!n.bounds||!!s.bounds&&wi(s.bounds,n.bounds,0)))}function L(n){return!!(n.hierarchy||n.reResolve)}function ee(n,a){return!L(a)&&(!n["resource-id"]||!!n["test-tag"]||!!n["unique-id"])}function te(n,a){try{return n(a)}catch(s){if(s instanceof Ee)throw s;throw new t("Selected element moved or is gone; the original selector cannot resolve unambiguously in the newer hierarchy. Observe again before tapping.",{cause:s})}}function Vo(n){return n>0?Math.max(1,Math.round(n)):Math.round(n)}function re(n,a){return`shell input touchscreen${a===void 0?"":` -d ${a}`} ${n}`}class BW extends t{}function KC(n,a){let s=[a.stdout,a.stderr].filter(Boolean).join(`
3
- `);if(/(?:^|\r?\n)(?:Unknown command:|Error:|Usage: input\b)/.test(s))throw new BW(`Android command failed: ${n}: ${s.trim()}`)}async function wc(n,a,s,c={}){let{signal:l,assertCurrent:u,timeoutMs:d,onDispatch:p}=c;await _3(n,re(a,s),{signal:l,assertCurrent:u,timeoutMs:d,onDispatch:p})}async function _3(n,a,s={}){let{signal:c,assertCurrent:l,timeoutMs:u,onDispatch:d}=s;if(!l)d?.();let p=l?await n.execute(["shell",a.slice(6)],{signal:c,timeoutMs:u,beforeDispatch:async()=>{l(),d?.()}}):await n.executeCommand(a,{timeoutMs:u,signal:c});KC(a,p)}async function Ma(n,a){return a===void 0||a===0||await n.supportsCommand?.("gesture_display_id_v1")===!0}var Na=500,eg=1e4,Bm=60000,NT=1000,H=200;function Fa(n){return typeof n==="string"&&n.toLowerCase().includes("stale frame context")}var ne=10,oe=50;function Tw(n,a){if(n.action==="longPress")return n.durationMs??1000;return a==="android"?ne:oe}var ie=300,ae=250;function se(n){return`The two taps started ${n} ms apart, too close to or beyond Android's ${ie} ms double-tap timeout, so the app may not register a double tap. Update CtrlProxy so the double tap is sent as one device-timed gesture.`}async function x3(n,a,s){let c=H-(n.now()-a);if(c>0)await P(n.sleep(c),s.signal);o(s.signal);let l=n.now()-a;if(l>ae){let u=se(l);e.warn(`[doubleTap] ${u}`),s.onWarning?.(u)}}async function C3(n,a){let{signal:s}=a,c=n;if(typeof c.requestDoubleTapCoordinates!=="function")return!1;o(s);let l=!1,u=await c.requestDoubleTapCoordinates(a.x,a.y,()=>{l=!0},{frameContext:a.frameContext,displayId:a.displayId,signal:s,beforeSend:a.assertCurrent});if(u.success)a.onTapDelivered?.(),a.onTapDelivered?.();if(o(s),u.success)return!0;return ce(u,{dispatched:l,frameContext:a.frameContext})}function ce(n,a){let{error:s}=n;if(a.frameContext!==void 0&&Fa(s))throw new t(s??"Stale frame context; observe a fresh frame before retrying");if(a.dispatched){if(n.acknowledged===!0)throw new t(`Double tap was rejected by CtrlProxy: ${s??"unknown error"}`);throw new t(`Double tap outcome is indeterminate: the gesture was dispatched but no result was confirmed (${s??"unknown error"}). Do not retry automatically.`)}return e.debug(`[doubleTap] single-gesture double tap not used (${s??"unknown error"}); sending two taps`),!1}async function tg(n){let{timer:a,signal:s}=n;if(n.client&&await C3(n.client,{...n.point,frameContext:n.frameContext,displayId:n.displayId,signal:s,assertCurrent:n.assertCurrent,onTapDelivered:n.onTapDelivered}))return;let c=a.now();await n.tap(!1),await x3(a,c,{signal:s,onWarning:n.onWarning}),n.assertCurrent?.(),await n.tap(!0)}function rg(n,a="coordinate activation"){if(n===void 0||n===0)return;return new t(`TalkBack ${a} cannot target display ${n}; no gesture was dispatched.`)}class GC extends t{}function jte(n){return!(n instanceof GC)}function Sn(n){return new GC(`Tap outcome is indeterminate: the request was dispatched but no result was confirmed (${n??"unknown error"}). Do not retry automatically.`)}async function kw(n,a,s,{durationMs:c,options:l={}}){let{x:u,y:d}=s,{frameContext:p,signal:m,assertCurrent:f,onTapDelivered:g}=l;o(m);let b=!1,y=()=>{b=!0},h=Ab(c),v=await n.requestTapCoordinates({x:u,y:d,duration:c,timeoutMs:h,frameContext:p,onDispatch:y,signal:m,beforeSend:f});if(v.success)g?.();if(o(m),v.success)return;if(p!==void 0&&Fa(v.error))throw new t(v.error??"Stale frame context; observe a fresh frame before retrying");if(b)throw Sn(v.error);e.warn(`[TapOnElement] dispatchGesture tap failed (${v.error}), falling back to ADB input`),await wc(a,c>=Na?`swipe ${u} ${d} ${u} ${d} ${Vo(c)}`:`tap ${u} ${d}`,void 0,{signal:m,assertCurrent:f,timeoutMs:c>=Na?Hr(c):void 0}),g?.(),o(m)}async function Ew(n,a,{durationMs:s,frameContext:c,options:l={}}){return U(n,a,{durationMs:s,frameContext:c,options:l})}async function Iw(n,a,{durationMs:s=50,frameContext:c,options:l={}}={}){return U(n,a,{durationMs:s,frameContext:c,options:{...l,failureLabel:"double tap",doubleTap:!0}})}async function U(n,a,{durationMs:s,frameContext:c,options:l}){let{x:u,y:d}=a,{failureLabel:p="tap",signal:m,doubleTap:f=!1}=l;if(f)o(m,!0);let g=l.timeoutMs??Ab(s),b=!1,y=()=>{b=!0},h;try{h=f?await n.requestDoubleTapCoordinates(u,d,g,{frameContext:c,signal:m,onDispatch:y}):await n.requestTapCoordinates({x:u,y:d,duration:s,timeoutMs:g,frameContext:c,signal:m,onDispatch:y})}catch(v){if(le(v,b,m))throw e.warn(`[coordinateTapDispatch] iOS ${p} transport failed`,v),Sn(r(v));throw v}if(h.success)return;if(ue(h,b))throw e.warn(`[coordinateTapDispatch] iOS ${p} at (${u}, ${d}) unconfirmed after ${g}ms: ${h.error??"no error"}; the runner may stay busy until its XCUITest gesture returns`),Sn(h.error);throw new t(`CtrlProxy iOS ${p} failed: ${h.error}`)}function le(n,a,s){return a&&!(n instanceof t)&&n!==s?.reason}function ue(n,a){if(Al(n))return!0;return(n.dispatched??a)&&n.acknowledged!==!0&&!Fa(n.error)}function de(n,a,s){if(n.success||n.focusCompleted)s.onDispatched();if(!n.success)return;if(a==="doubleTap")s.onDispatched();for(let c of n.warnings??[])s.onWarning?.(c)}function pe(n,a){let{target:s,signal:c,talkBack:l}=a,u={assertCurrent:()=>{o(c),s.assertCurrent()}};return async({x:d,y:p})=>{u.assertCurrent();let m=n.action,f=m==="longPress"?n.duration??800:50,g=m==="tap"?await l.strategy.executePreciseTap(d,p,l.driver,u):await l.strategy.executeCoordinateFallback({x:d,y:p},m,f,{driver:l.driver,fenceOptions:{displayFence:u}});if(de(g,m,a),o(c),!g.success)throw new t(`TalkBack coordinate tap failed: ${g.error??"activation was not confirmed"}${g.focusCompleted?" Focus touch was delivered; activation failed. Do not retry automatically.":""}`)}}async function WL(n,a,s,c){let{target:l,signal:u,timer:d=i}=c,p=c.talkBack?rg(l.displayId):void 0;if(p)throw p;if(c.talkBack)return pe(s,{...c,talkBack:c.talkBack});let m=await Ma(n,l.displayId),f=async({x:g,y:b},y)=>{o(u),l.assertCurrent();let h=s.action==="longPress"?s.duration??800:10;if(m){let v=!1,k=()=>{v=!0},w=await n.requestTapCoordinates({x:g,y:b,duration:h,timeoutMs:Ab(h),onDispatch:k,signal:u,displayId:l.displayId===0?void 0:l.displayId,beforeSend:l.assertCurrent});if(w.success)y();if(o(u),w.success)return;if(v)throw Sn(w.error);if(Fa(w.error))throw new t(w.error??"Stale frame context");e.warn(`[androidDisplayTapDispatch] dispatchGesture tap failed (${w.error}), falling back to ADB input`)}await wc(a,s.action==="longPress"?`swipe ${g} ${b} ${g} ${b} ${Vo(h)}`:`tap ${g} ${b}`,l.displayId,{signal:u,assertCurrent:l.assertCurrent,timeoutMs:s.action==="longPress"?Hr(h):void 0}),y(),o(u)};return async(g)=>{let b=0,y=()=>{b++,c.onDispatched()};try{if(s.action==="doubleTap")await tg({client:m?n:void 0,point:g,displayId:l.displayId===0?void 0:l.displayId,timer:d,signal:u,assertCurrent:l.assertCurrent,onTapDelivered:y,onWarning:c.onWarning,tap:()=>f(g,y)});else await f(g,y)}catch(h){if(s.action==="doubleTap"&&b===1)throw Sn(`${r(h)}. Double tap partially applied: one tap was delivered; the second tap was not confirmed`);throw h}}}function C(n){return typeof n==="string"&&n.length>0?n:void 0}function j(n){return typeof n==="number"&&Number.isInteger(n)?n:void 0}function yi(n){let a={resourceId:C(n["resource-id"]),testTag:C(n["test-tag"]),uniqueId:C(n["unique-id"])},s=j(n["collection-row-index"]),c=j(n["collection-column-index"]),l=a.resourceId!==void 0||a.testTag!==void 0||a.uniqueId!==void 0;if(l&&s!==void 0&&c!==void 0)a.collectionRow=s,a.collectionColumn=c;return l?a:void 0}function ca(n){return n.testTag!==void 0||n.uniqueId!==void 0||n.collectionRow!==void 0||n.collectionColumn!==void 0}function G(n,a){let{testTag:s,resourceId:c}=n;if(s===void 0||n.uniqueId!==void 0||n.collectionRow!==void 0||n.collectionColumn!==void 0)return;let l=a.filter((u)=>u["test-tag"]===s&&(c===void 0||u["resource-id"]===c)).length;return l>1?`test tag "${s}" is shared by ${l} elements, so it does not identify the target`:void 0}async function ng(n,a,s){if(ca(n))return await a.supportsNodeActionSelectors()?void 0:"Runner does not support stable node selectors";return O(n.resourceId,()=>a.getAccessibilityHierarchy?.()??Promise.resolve(null),s)}class D{textMatcher;constructor(n=new kb){this.textMatcher=n}findTargetIndex(n,a,s={}){return this.resolveTargetCandidate(n,a,s)?.index??null}findCurrentFocusIndex(n,a){if(!n||a.length===0)return null;let s=a.indexOf(n);if(s>=0)return s;let c=this.getResourceId(n);if(c)return this.findIndexByValue(a,n,(p)=>this.getResourceId(p),{value:c});let l=this.getTestTag(n);if(l)return this.findIndexByValue(a,n,(p)=>this.getTestTag(p),{value:l});let u=this.getContentDesc(n);if(u)return this.findIndexByValue(a,n,(p)=>this.getContentDesc(p),{value:u,caseInsensitive:!0});let d=this.getText(n);if(d)return this.findIndexByValue(a,n,(p)=>this.getText(p),{value:d,caseInsensitive:!0});if(n.bounds){let p=n.bounds,m=a.findIndex((f)=>f.bounds&&f.bounds.left===p.left&&f.bounds.top===p.top&&f.bounds.right===p.right&&f.bounds.bottom===p.bottom);return m===-1?null:m}return null}matchesSelector(n,a,s={}){let c=this.getResourceId(n),l=this.getContentDesc(n),u=this.getTestTag(n),d=this.getText(n);if(a.resourceId&&a.resourceId!==c)return!1;if(a.testTag&&a.testTag!==u)return!1;if(a.text){let p=this.createTextMatcher(a.text,s);if(!(p(d)||p(l)))return!1}if(a.contentDesc){if(!this.createTextMatcher(a.contentDesc,s)(l))return!1}return!0}matchesFocusedTarget(n,a,s){let c=this.resolveTargetCandidate(a,s);if(!c)return!1;let l={partialMatch:c.partialMatch};if(!this.matchesSelector(n,s,l))return!1;if(c.matchCount===1)return!0;return n===c.element||c.element.bounds!==void 0&&this.boundsMatch(n,c.element.bounds)}createTextMatcher(n,a){let s=a.partialMatch??!1,c=a.caseSensitive??!1;return this.textMatcher.createTextMatcher(n,s,c)}findMatches(n,a,s){return n.flatMap((c,l)=>this.matchesSelector(c,a,s)?[{element:c,index:l}]:[])}resolveTargetCandidate(n,a,s={}){let c=this.findMatches(n,a,{...s,partialMatch:!1}),l=c.length===0&&s.partialMatch!==!1,u=l?this.findMatches(n,a,{...s,partialMatch:!0}):c;if(u.length===0)return null;return{...this.selectTargetCandidate(u,a),matchCount:u.length,partialMatch:l}}selectTargetCandidate(n,a){if(n.length===1)return n[0];if(!a.bounds)return this.firstVisibleOrFirst(n);return n.find(({element:c})=>this.boundsMatch(c,a.bounds))??this.nearestBoundsMatch(n,a.bounds)}firstVisibleOrFirst(n){return n.find(({element:a})=>this.isVisible(a))??n[0]}nearestBoundsMatch(n,a){let s,c=Number.POSITIVE_INFINITY;for(let l of n){if(!l.element.bounds)continue;let u=this.boundsDistance(l.element.bounds,a);if(u<c)s=l,c=u}return s??this.firstVisibleOrFirst(n)}findIndexByValue(n,a,s,{value:c,caseInsensitive:l=!1}){let u=l?c.toLowerCase():c,d=n.flatMap((m,f)=>{let g=s(m);if(!g)return[];return(l?g.toLowerCase():g)===u?[{element:m,index:f}]:[]});if(d.length===1)return d[0].index;let p=a.bounds;if(!p)return null;return d.find(({element:m})=>this.boundsMatch(m,p))?.index??null}getResourceId(n){let a=n["resource-id"]??n.resourceId;return typeof a==="string"&&a.length>0?a:void 0}getContentDesc(n){let a=n["content-desc"]??n.contentDesc;return typeof a==="string"&&a.length>0?a:void 0}getTestTag(n){let a=n["test-tag"]??n.testTag;return typeof a==="string"&&a.length>0?a:void 0}getText(n){return typeof n.text==="string"&&n.text.length>0?n.text:void 0}isVisible(n){if(!n.bounds)return!1;let a=n.bounds.right-n.bounds.left,s=n.bounds.bottom-n.bounds.top;return a>0&&s>0}boundsMatch(n,a){if(!n.bounds)return!1;return n.bounds.left===a.left&&n.bounds.top===a.top&&n.bounds.right===a.right&&n.bounds.bottom===a.bottom}boundsDistance(n,a){let s=(n.left+n.right)/2,c=(n.top+n.bottom)/2,l=(a.left+a.right)/2,u=(a.top+a.bottom)/2;return(s-l)**2+(c-u)**2}}class x{detectPlatform(n){if(!n)return e.warn("[DeviceDetection] Empty device ID provided, defaulting to Android"),"android";let a=/^emulator-\d+$/;if($a(n))return e.info(`[DeviceDetection] Detected iOS device: ${n}`),"ios";if(a.test(n))return e.info(`[DeviceDetection] Detected Android emulator: ${n}`),"android";return e.info(`[DeviceDetection] Device ID pattern suggests Android device: ${n}`),"android"}isiOSDevice(n){return this.detectPlatform(n)==="ios"}isAndroidDevice(n){return this.detectPlatform(n)==="android"}static detectPlatform=(n)=>new x().detectPlatform(n);static isiOSDevice=(n)=>new x().isiOSDevice(n);static isAndroidDevice=(n)=>new x().isAndroidDevice(n)}class S extends Error{}class T extends t{}class I{accessibilityService;constructor(n){this.accessibilityService=n}async getAccessibilityHierarchy(){return this.accessibilityService.getAccessibilityHierarchy(void 0,{skipWaitForFresh:!1,disableAllFiltering:!0})}async requestTraversalOrder(){return this.accessibilityService.requestTraversalOrder()}async requestCurrentFocus(){return this.accessibilityService.requestCurrentFocus()}async requestAction(n,a,s){return this.accessibilityService.requestAction(n,a,void 0,{signal:s})}async requestNodeAction(n,a,s){return this.accessibilityService.requestNodeAction(n,a,{signal:s})}async supportsNodeActionSelectors(){return this.accessibilityService.supportsNodeActionSelectors()}}class B{createDriver(n){return new I(E.getInstance(n))}}var fe="Request time budget exhausted during focus navigation.";function M(n,a){if(n instanceof S||bt(n)||a<=0)return n;let s=r(n);return new S(`${s.endsWith(".")?s:`${s}.`} Focus navigation partially applied: ${a} accessibility-focus request${a===1?"":"s"} already moved the TalkBack cursor and the target was not activated. Observe before retrying; do not retry automatically.`,{cause:n})}function R(n,a,s){try{o(n)}catch(l){throw M(l,s)}let c=oo()?.getDeadlineMs?.();if(c!==void 0&&a.now()>=c)throw M(Error(fe),s)}function ge(n){let a=n.bounds;return[n["resource-id"]??"",n["content-desc"]??"",n.text??"",a?`${a.left},${a.top},${a.right},${a.bottom}`:""].join("|")}function W(n){return n.map(ge).sort().join(`
4
- `)}class N{static DEFAULT_FOCUS_SETTLE_MS=100;static FOCUS_READBACK_BOUND_MS=500;matcher;timer;driverFactory;deviceResolver;constructor(n={}){this.matcher=n.matcher??new D,this.timer=n.timer??i,this.driverFactory=n.driverFactory??new B,this.deviceResolver=n.deviceResolver??this.resolveDevice}async navigateToElement(n,a,s={}){let c=me(s.signal),l={focusRequests:0};try{return await this.runNavigation(n,a,{...s,signal:c,onFocusRequested:()=>{l.focusRequests+=1,s.onFocusRequested?.()}},l)}catch(u){throw c?.aborted?M(u,l.focusRequests):u}}async runNavigation(n,a,s,c){let{signal:l}=s,u=this.deviceResolver(n);if(u.platform!=="android")throw new t("TalkBack focus navigation is only supported on Android devices.");let d=this.driverFactory.createDriver(u);R(l,this.timer,c.focusRequests);let p=await this.verifyNavigationState(d,a,!1,l);if(s.onFocusObserved?.(p.currentFocus,p.orderedElements),p.reachedTarget)return!0;let m=p.targetIndex===null?void 0:p.orderedElements[p.targetIndex];if(!m)throw new T(`Target not found in the accessibility traversal (${this.describeSelector(a)}). Use observe to inspect elements and the diagnostics returned by tapOn/waitFor failures.`+this.describeTraversalTruncation(p));await this.requestFocus(d,m,p.orderedElements,{options:s,progress:c});let f=await this.readCursorAfterFocusRequest(d,a,s,c.focusRequests);if(s.onFocusObserved?.(f.currentFocus,f.orderedElements),f.reachedTarget)return!0;throw this.unreachedTargetError(p,f,a)}async readCursorAfterFocusRequest(n,a,s,c){let{signal:l}=s,u=Math.max(0,s.focusSettleMs??N.DEFAULT_FOCUS_SETTLE_MS),d=u>0?Math.max(1,Math.ceil(N.FOCUS_READBACK_BOUND_MS/u)):1,p;for(let m=1;;m+=1){if(u>0)await P(this.timer.sleep(u),l);if(R(l,this.timer,c),p=await this.verifyNavigationState(n,a,!0,l),p.reachedTarget||m>=d)return p}}async requestFocus(n,a,s,{options:c,progress:l}){let{signal:u}=c,d=yi(a);if(!d)throw new T("The target has no resource-id, test tag or unique id, so the TalkBack cursor cannot be moved onto it without a touch gesture.");let p=G(d,s)??await ng(d,n,a);if(p)throw new T(`The TalkBack cursor cannot be moved onto the target: ${p}.`);R(u,this.timer,l.focusRequests),c.displayFence?.assertCurrent(),c.onFocusRequested?.();let m=await P(ca(d)?n.requestNodeAction("focus",d,u):n.requestAction("focus",d.resourceId,u),u);if(!m.success)throw new t(`Could not move the TalkBack cursor onto the target: ${m.error??"ACTION_ACCESSIBILITY_FOCUS failed"}. No tap was sent.`)}unreachedTargetError(n,a,s){let c=this.describeSelector(s);if(W(n.orderedElements)!==W(a.orderedElements))return new t(`The screen changed while moving the TalkBack cursor onto the target (${c}), and the cursor is not on it. No tap was sent. Observe the new screen and resolve the target again.`);let l=a.currentFocus?this.describeFocus(a.currentFocus):"no element has accessibility focus";return new t(`The TalkBack cursor did not move onto the target (${c}) after the focus request; ${l}. No tap was sent. Observe before retrying.`)}resolveDevice(n){let a=x.detectPlatform(n);return{name:n,deviceId:n,platform:a}}async verifyNavigationState(n,a,s,c){let l=await P(n.requestTraversalOrder(),c);if(l.error){let f=`Failed to get traversal order: ${l.error}`;throw s?new t(`${f}. The focus request may have moved the cursor; no tap was sent.`):new T(f)}let u=l.elements??[],d=this.matcher.findTargetIndex(u,a),p=null;if(l.focusedIndex!==null&&l.focusedIndex!==void 0)p=u[l.focusedIndex]??null;if(!p){let f=await P(n.requestCurrentFocus(),c);if(f.error)e.warn(`[FocusNavigation] Failed to get current focus: ${f.error}`);else p=f.focusedElement??null}let m=p?this.matcher.matchesFocusedTarget(p,u,a):!1;return{orderedElements:u,currentFocus:p,targetIndex:d,reachedTarget:m,truncationReasons:l.truncationReasons}}describeTraversalTruncation(n){return n.truncationReasons?.includes("max_children")?" the accessibility traversal was truncated (max_children); the target may be beyond the cap.":""}describeFocus(n){let a=n.text||n["content-desc"]||n["resource-id"];return a?`focus is on "${a}"`:"focus is on another element"}describeSelector(n){let a=[];if(n.resourceId)a.push(`resourceId="${n.resourceId}"`);if(n.text)a.push(`text="${n.text}"`);if(n.contentDesc)a.push(`contentDesc="${n.contentDesc}"`);if(n.testTag)a.push(`testTag="${n.testTag}"`);return a.length>0?a.join(", "):"unknown selector"}}var he=500,$W="TalkBack activation is unconfirmed: the coordinate gesture completed, but the element may only have received accessibility focus. Observe the result before retrying.";function be(n,a){return Array.isArray(n.actions)&&n.actions.includes(a)}class Iv{matcher;executor;timer;constructor(n={}){this.matcher=n.matcher??new D,this.executor=n.executor??new N({matcher:this.matcher,timer:n.timer,driverFactory:n.driverFactory}),this.timer=n.timer??i}async executeTap(n,a,s,{fence:c,signal:l}={}){let u={reachable:!1,traversalOrder:[],focusTrapDetected:!1},d=a?.["resource-id"],p=a.text,m=a["content-desc"];if(!d&&!p&&!m)return{success:!1,method:"focus-navigation",error:"Element has no resource-id, text, or content-desc for navigation",screenReaderNavigation:u};let f=this.createFocusSelector({resourceId:d,elementText:p,elementContentDesc:m,bounds:a.bounds}),g=me(l),b=0,y=[];try{if(!await this.executor.navigateToElement(n,f,{displayFence:c,signal:g,onFocusObserved:(w,X)=>{y=[...X],this.appendTraversalFocus(u,w)},onFocusRequested:()=>{b+=1}}))throw new t("Focus navigation did not reach target element")}catch(k){if(k instanceof T)return e.warn(`[TalkBackTapStrategy] Focus navigation unavailable: ${k.message}`,k),{success:!1,method:"focus-navigation",error:k.message,screenReaderNavigation:u};throw k}u.reachable=!0,e.info("[TalkBackTapStrategy] Focus navigation successful, activating element");let h=()=>R(g,this.timer,b);return h(),{...await this.activateElement(a,s,{fence:c,orderedElements:y,assertLive:h}),screenReaderNavigation:u}}createFocusSelector({resourceId:n,elementText:a,elementContentDesc:s,bounds:c}){return{...n?{resourceId:n}:{},...a?{text:a}:{},...s?{contentDesc:s}:{},bounds:c}}appendTraversalFocus(n,a){if(!a)return;let s=n.traversalOrder.at(-1);if(!s||this.focusSignature(s)!==this.focusSignature(a))n.traversalOrder.push(a)}focusSignature(n){let a=n.bounds;return[n["resource-id"]??"",n["content-desc"]??"",n.text??"",a?`${a.left},${a.top},${a.right},${a.bottom}`:""].join("|")}async executeDirectActivation(n,a,s={}){let c=await F(n,()=>a.getAccessibilityHierarchy?.()??Promise.resolve(null),s),l=c.element!==n?{element:c.element}:{};n=c.element;let u={supportsNodeActionSelectors:()=>a.supportsNodeActionSelectors(),getAccessibilityHierarchy:async()=>c.hierarchy},d=yi(n);if(!d)return{success:!1,...l,method:"accessibility-action",error:"Element has no stable selector for direct accessibility activation"};let p=await ng(d,u,n);if(p)return{success:!1,...l,method:"accessibility-action",error:p};let m=ca(d)?await a.requestNodeAction("click",d):await a.requestAction("click",d.resourceId);if(m.success)return e.info("[TalkBackTapStrategy] Direct activation via ACTION_CLICK succeeded"),{success:!0,...l,method:"accessibility-action"};if(m.dispatched&&m.acknowledged!==!0)throw Sn(m.error);return{success:!1,...l,method:"accessibility-action",error:m.error??"ACTION_CLICK failed"}}async executeCoordinateFallback(n,a,s,{driver:c,fenceOptions:l={}}){let{x:u,y:d}=n,p=l.displayFence,m=a==="longPress"?s:50;if(a==="doubleTap"){p?.assertCurrent();let g=await this.dispatchDriverTap(c,u,d,{durationMs:m,doubleTap:!0});if(!g.success)return{success:!1,method:"coordinate-fallback",error:`Double tap failed: ${g.error}`,unsupportedCapability:g.unsupportedCapability,completedTaps:0};return{success:!0,method:"coordinate-fallback",completedTaps:2,warnings:[$W]}}p?.assertCurrent();let f=await this.dispatchDriverTap(c,u,d,{durationMs:m});if(!f.success)return{success:!1,method:"coordinate-fallback",error:f.error};if(a==="tap")return{success:!1,method:"coordinate-fallback",error:"A single coordinate touch only moves TalkBack focus and does not activate the element"};return{success:!0,method:"coordinate-fallback"}}async executePreciseTap(n,a,s,c){c?.assertCurrent();let l=await this.dispatchDriverTap(s,n,a,{durationMs:50});if(!l.success)return{success:!1,method:"coordinate-fallback",error:`Focus tap failed: ${l.error}`,focusCompleted:!1,completedTaps:0};return await this.timer.sleep(he),{...await this.executeCoordinateFallback({x:n,y:a},"doubleTap",50,{driver:s,fenceOptions:{displayFence:c}}),focusCompleted:!0}}async executeLongPress(n,a,s,{driver:c,fenceOptions:l={}}){let{x:u,y:d}=n,p=l.displayFence,m=await F(s,()=>c.getAccessibilityHierarchy?.()??Promise.resolve(null),l);if(m.element!==s){let y=m.element.bounds;u=Math.round((y.left+y.right)/2),d=Math.round((y.top+y.bottom)/2)}let f=m.element!==s?{element:m.element}:{};s=m.element;let g={supportsNodeActionSelectors:()=>c.supportsNodeActionSelectors(),getAccessibilityHierarchy:async()=>m.hierarchy},b=yi(s);if(b){let y=await ng(b,g,s);if(y)return e.info(`[TalkBackTapStrategy] ${y}`),{...await this.executeCoordinateFallback({x:u,y:d},"longPress",a,{driver:c,fenceOptions:{displayFence:p}}),...f};let h=ca(b)?await c.requestNodeAction("long_click",b):await c.requestAction("long_click",b.resourceId);if(h.success)return e.info("[TalkBackTapStrategy] Long press via ACTION_LONG_CLICK succeeded"),{success:!0,...f,method:"accessibility-action"};if(h.dispatched&&h.acknowledged!==!0)throw Sn(h.error);if(await MT({advertised:be(s,"long_click"),error:h.error,needsNodeSelector:ca(b),selected:s,readHierarchy:()=>c.getAccessibilityHierarchy?.()??Promise.resolve(null)}))return{success:!1,...f,method:"accessibility-action",error:h.error??"ACTION_LONG_CLICK failed",semanticActionFailure:!0};e.warn(`[TalkBackTapStrategy] ACTION_LONG_CLICK failed (${h.error}), falling back to coordinate gesture`)}return{...await this.executeCoordinateFallback({x:u,y:d},"longPress",a,{driver:c,fenceOptions:{displayFence:p}}),...f}}async activateElement(n,a,{fence:s={assertCurrent:()=>{}},orderedElements:c,assertLive:l}){let u=n["resource-id"],d=await this.resolveActivationCenter(n,a,c),p=50;if(l(),!d){if(u){e.warn("[TalkBackTapStrategy] Activation target has no bounds; using ACTION_CLICK fallback");let f=await this.executeDirectActivation(n,a);if(f.success)return{success:!0,method:"accessibility-action"};return{success:!1,method:"focus-navigation",error:`Activation failed: target has no bounds and ACTION_CLICK failed (${f.error??"unknown"})`}}return{success:!1,method:"focus-navigation",error:"Activation failed: target has no bounds and no resource-id for ACTION_CLICK"}}s.assertCurrent();let m=await this.dispatchDriverTap(a,d.x,d.y,{durationMs:50,doubleTap:!0});if(!m.success){if(l(),u){if(e.warn("[TalkBackTapStrategy] Double-tap activation failed, trying ACTION_CLICK fallback"),!(await this.executeDirectActivation(n,a)).success)return{success:!1,method:"focus-navigation",error:"Activation failed: double-tap and ACTION_CLICK both failed",unsupportedCapability:m.unsupportedCapability};return{success:!0,method:"accessibility-action"}}return{success:!1,method:"focus-navigation",error:"Activation failed: double-tap failed",unsupportedCapability:m.unsupportedCapability}}return e.info("[TalkBackTapStrategy] Element activation gesture sent via focus navigation"),{success:!0,method:"focus-navigation",warnings:[$W]}}async dispatchDriverTap(n,a,s,{durationMs:c,doubleTap:l=!1}){let u=!1,d;try{let p=()=>{u=!0};d=l?await n.requestDoubleTapCoordinates(a,s,p):await n.requestTapCoordinates({x:a,y:s,duration:c,onDispatch:p})}catch(p){if(u)throw Sn(r(p));if(p instanceof Ee||p instanceof t)throw p;return e.warn(`[TalkBackTapStrategy] Coordinate tap failed before dispatch: ${r(p)}`,p),{success:!1,totalTimeMs:0,error:r(p)}}if(!d.success&&u)throw Sn(d.error);return d}getElementCenter(n){if(!n.bounds)return null;return{x:Math.round((n.bounds.left+n.bounds.right)/2),y:Math.round((n.bounds.top+n.bounds.bottom)/2)}}async resolveActivationCenter(n,a,s){try{let c=await a.requestCurrentFocus(),l=c.focusedElement;if(l?.bounds&&!c.error){let u=this.createFocusSelector({resourceId:C(n["resource-id"]),elementText:C(n.text),elementContentDesc:C(n["content-desc"]),bounds:n.bounds}),d=await this.activationTraversal(a,s,u);if(this.matcher.matchesFocusedTarget(l,d,u))return this.getElementCenter(l);throw new t("TalkBack focus no longer matches the selected activation target.")}}catch(c){if(c instanceof t)throw c;e.debug(`[TalkBackTapStrategy] Could not read current focus for activation: ${c}`)}return this.getElementCenter(n)}async activationTraversal(n,a,s){let c;try{c=await n.requestTraversalOrder()}catch(d){if(d instanceof Ee)throw d;e.warn(`[TalkBackTapStrategy] Could not refresh activation traversal: ${r(d)}`,d)}if(!c?.error&&c?.elements?.length)return c.elements;let l=a.filter((d)=>this.matcher.matchesSelector(d,s));if((l.length?l:a.filter((d)=>this.matcher.matchesSelector(d,s,{partialMatch:!0}))).length===1)return a;throw new t("Cannot verify the selected TalkBack activation target: fresh traversal is unavailable or empty.")}}function Kte(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,perf:a,signal:s}}function Gte(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a,deadlineMs:s?.requestDeadlineMs}}function Yte(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a,planContext:s}}function zL(n){return n===void 0?void 0:{requestDeadlineMs:n}}function ye(n){return typeof n==="object"&&n!==null&&"aborted"in n}function ig(n){if(n===void 0||ye(n))return{signal:n};return n}function Wo(n,a){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a}}var A=(n)=>n===!0||n==="true";function La(n){return A(n.focused)||A(n.isFocused)||A(n["has-keyboard-focus"])||A(n["accessibility-focused"])||A(n.accessibilityFocused)}class YC{parser;constructor(n=new K){this.parser=n}findFocusedTextInput(n){let a=[this.parser.extractRootNodes(n),...this.parser.extractWindowRootGroups(n,"topmost-first")];for(let s of a){let c=this.findInRoots(s);if(c)return c}return null}findInRoots(n){for(let a of n){let s=null;if(this.parser.traverseNode(a,(c)=>{if(s)return;let l=this.parser.extractNodeProperties(c),u=l.class||l.className;if(A(l.focused)&&u&&_g.some((d)=>u.includes(d)))s=this.parser.parseNodeBounds(c)}),s)return s}return null}}
5
- export{MT,Qh,Vo,BW,KC,wc,_3,Ma,Na,eg,Bm,NT,Fa,Tw,x3,C3,tg,rg,GC,jte,Sn,kw,Ew,Iw,WL,yi,ca,ng,$W,Iv,Kte,Gte,Yte,zL,ig,Wo,La,YC};
2
+ import{i,e}from"./chunk-r0vp315h.js";import{St,so,me,Va,o,P,jg,mn,K,ws,fe,Ml,Ee,Wr,$b,Hb,E}from"./chunk-sfqe223f.js";import{r,t}from"./chunk-2b39zyxc.js";function Q(n){return n?.startsWith("Element not found with ")===!0}function Y(n,a){return n&&!Q(a)}async function XT(n){if(Y(n.advertised,n.error))return!0;if(!n.advertised||!n.needsNodeSelector)return!1;return!await z(n.selected,n.readHierarchy)}async function z(n,a){let s=await q(a);return Eu(s)&&V(n,s)}async function O(n,a,s){let c;try{c=await a()}catch(d){if(d instanceof Ee)throw d;return e.warn(`[TalkBack] Cannot verify resource-id uniqueness: ${r(d)}`,d),`Unable to verify uniqueness of resource-id "${n}"; using coordinate fallback.`}if(!Eu(c))return`Unable to verify uniqueness of resource-id "${n}" in an incomplete hierarchy; using coordinate fallback.`;let l=new fe().project(c).filter((d)=>ws(d.nativeId,n));J(l,s);let u=new Set(l.map((d)=>d.source)).size;if(u!==1)return u>1?`Selected resource-id "${n}" is shared by ${u} elements; using coordinate fallback.`:`Resource-id "${n}" is absent from the current hierarchy; using coordinate fallback.`;return}function J(n,a){if(!a)return;if(!n.some((c)=>["text","content-desc"].every((u)=>!a[u]||c.properties[u]===a[u])&&(!a.bounds||c.bounds!==void 0&&mn(c.bounds,a.bounds,0))))throw new t("Selected element moved or is gone from the current hierarchy. Observe again before tapping.")}async function F(n,a,s={}){if(ee(n,s))return{element:n,hierarchy:null};let c=s.hierarchy??await q(a);if(!Eu(c)&&!L(s))return{element:n,hierarchy:c};if(!c||c.hierarchy.error)throw new t("Cannot confirm the selected element because the accessibility hierarchy is unavailable. Observe again and check that the accessibility service is running.");return Z(n,c,s)}function Z(n,a,s){let c=V(n,a);if((!s.hierarchy||!c)&&s.reResolve){let l=te(s.reResolve,a);if(!l)throw new t("Selected element moved or is gone; the original selector no longer resolves. Observe again before tapping.");if(!_(n,l))throw new t("Selected element moved; the original selector now resolves to a different element. Observe again before tapping.");if(!l.bounds)throw new t("Selected element moved and has no current bounds. Observe again before tapping.");return s.onResolvedElement?.(l),{element:l,hierarchy:a}}if(!c)throw new t("Selected element moved or is gone from the current hierarchy. Observe again before tapping.");return{element:n,hierarchy:a}}function _(n,a){return["text","content-desc","resource-id","test-tag","unique-id","collection-row-index","collection-column-index"].every((s)=>n[s]===void 0||n[s]===a[s])}function Eu(n){return!!n&&!n.hierarchy.error&&!n.ctrlProxyIncomplete&&!n.truncationReasons?.length&&!n.windows?.some((a)=>a.truncationReasons?.length)}async function q(n){try{return await n()}catch(a){if(a instanceof Ee)throw a;return e.warn(`[TalkBack] Cannot confirm selected target: ${r(a)}`,a),null}}function V(n,a){return new fe().project(a).some((s)=>_(n,s.properties)&&(!n.bounds||!!s.bounds&&mn(s.bounds,n.bounds,0)))}function L(n){return!!(n.hierarchy||n.reResolve)}function ee(n,a){return!L(a)&&(!n["resource-id"]||!!n["test-tag"]||!!n["unique-id"])}function te(n,a){try{return n(a)}catch(s){if(s instanceof Ee)throw s;throw new t("Selected element moved or is gone; the original selector cannot resolve unambiguously in the newer hierarchy. Observe again before tapping.",{cause:s})}}function zo(n){return n>0?Math.max(1,Math.round(n)):Math.round(n)}function re(n,a){return`shell input touchscreen${a===void 0?"":` -d ${a}`} ${n}`}class sz extends t{}function uD(n,a){let s=[a.stdout,a.stderr].filter(Boolean).join(`
3
+ `);if(/(?:^|\r?\n)(?:Unknown command:|Error:|Usage: input\b)/.test(s))throw new sz(`Android command failed: ${n}: ${s.trim()}`)}async function Ec(n,a,s,c={}){let{signal:l,assertCurrent:u,timeoutMs:d,onDispatch:p}=c;await X3(n,re(a,s),{signal:l,assertCurrent:u,timeoutMs:d,onDispatch:p})}async function X3(n,a,s={}){let{signal:c,assertCurrent:l,timeoutMs:u,onDispatch:d}=s;if(!l)d?.();let p=l?await n.execute(["shell",a.slice(6)],{signal:c,timeoutMs:u,beforeDispatch:async()=>{l(),d?.()}}):await n.executeCommand(a,{timeoutMs:u,signal:c});uD(a,p)}async function Ba(n,a){return a===void 0||a===0||await n.supportsCommand?.("gesture_display_id_v1")===!0}var $a=500,gg=1e4,tf=60000,ZT=1000,H=200;function Ua(n){return typeof n==="string"&&n.toLowerCase().includes("stale frame context")}var ne=10,oe=50;function zw(n,a){if(n.action==="longPress")return n.durationMs??1000;return a==="android"?ne:oe}var ie=300,ae=250;function se(n){return`The two taps started ${n} ms apart, too close to or beyond Android's ${ie} ms double-tap timeout, so the app may not register a double tap. Update CtrlProxy so the double tap is sent as one device-timed gesture.`}async function Z3(n,a,s){let c=H-(n.now()-a);if(c>0)await P(n.sleep(c),s.signal);o(s.signal);let l=n.now()-a;if(l>ae){let u=se(l);e.warn(`[doubleTap] ${u}`),s.onWarning?.(u)}}async function Q3(n,a){let{signal:s}=a,c=n;if(typeof c.requestDoubleTapCoordinates!=="function")return!1;o(s);let l=!1,u=await c.requestDoubleTapCoordinates(a.x,a.y,()=>{l=!0},{frameContext:a.frameContext,displayId:a.displayId,signal:s,beforeSend:a.assertCurrent});if(u.success)a.onTapDelivered?.(),a.onTapDelivered?.();if(o(s),u.success)return!0;return ce(u,{dispatched:l,frameContext:a.frameContext})}function ce(n,a){let{error:s}=n;if(a.frameContext!==void 0&&Ua(s))throw new t(s??"Stale frame context; observe a fresh frame before retrying");if(a.dispatched){if(n.acknowledged===!0)throw new t(`Double tap was rejected by CtrlProxy: ${s??"unknown error"}`);throw new t(`Double tap outcome is indeterminate: the gesture was dispatched but no result was confirmed (${s??"unknown error"}). Do not retry automatically.`)}return e.debug(`[doubleTap] single-gesture double tap not used (${s??"unknown error"}); sending two taps`),!1}async function yg(n){let{timer:a,signal:s}=n;if(n.client&&await Q3(n.client,{...n.point,frameContext:n.frameContext,displayId:n.displayId,signal:s,assertCurrent:n.assertCurrent,onTapDelivered:n.onTapDelivered}))return;let c=a.now();await n.tap(!1),await Z3(a,c,{signal:s,onWarning:n.onWarning}),n.assertCurrent?.(),await n.tap(!0)}function vg(n,a="coordinate activation"){if(n===void 0||n===0)return;return new t(`TalkBack ${a} cannot target display ${n}; no gesture was dispatched.`)}class pD extends t{}function Tre(n){return!(n instanceof pD)}function Tn(n){return new pD(`Tap outcome is indeterminate: the request was dispatched but no result was confirmed (${n??"unknown error"}). Do not retry automatically.`)}async function jw(n,a,s,{durationMs:c,options:l={}}){let{x:u,y:d}=s,{frameContext:p,signal:m,assertCurrent:f,onTapDelivered:g}=l;o(m);let b=!1,y=()=>{b=!0},h=$b(c),v=await n.requestTapCoordinates({x:u,y:d,duration:c,timeoutMs:h,frameContext:p,onDispatch:y,signal:m,beforeSend:f});if(v.success)g?.();if(o(m),v.success)return;if(p!==void 0&&Ua(v.error))throw new t(v.error??"Stale frame context; observe a fresh frame before retrying");if(b)throw Tn(v.error);e.warn(`[TapOnElement] dispatchGesture tap failed (${v.error}), falling back to ADB input`),await Ec(a,c>=$a?`swipe ${u} ${d} ${u} ${d} ${zo(c)}`:`tap ${u} ${d}`,void 0,{signal:m,assertCurrent:f,timeoutMs:c>=$a?Wr(c):void 0}),g?.(),o(m)}async function Kw(n,a,{durationMs:s,frameContext:c,options:l={}}){return U(n,a,{durationMs:s,frameContext:c,options:l})}async function Gw(n,a,{durationMs:s=50,frameContext:c,options:l={}}={}){return U(n,a,{durationMs:s,frameContext:c,options:{...l,failureLabel:"double tap",doubleTap:!0}})}async function U(n,a,{durationMs:s,frameContext:c,options:l}){let{x:u,y:d}=a,{failureLabel:p="tap",signal:m,doubleTap:f=!1}=l;if(f)o(m,!0);let g=l.timeoutMs??$b(s),b=!1,y=()=>{b=!0},h;try{h=f?await n.requestDoubleTapCoordinates(u,d,g,{frameContext:c,signal:m,onDispatch:y}):await n.requestTapCoordinates({x:u,y:d,duration:s,timeoutMs:g,frameContext:c,signal:m,onDispatch:y})}catch(v){if(le(v,b,m))throw e.warn(`[coordinateTapDispatch] iOS ${p} transport failed`,v),Tn(r(v));throw v}if(h.success)return;if(ue(h,b))throw e.warn(`[coordinateTapDispatch] iOS ${p} at (${u}, ${d}) unconfirmed after ${g}ms: ${h.error??"no error"}; the runner may stay busy until its XCUITest gesture returns`),Tn(h.error);throw new t(`CtrlProxy iOS ${p} failed: ${h.error}`)}function le(n,a,s){return a&&!(n instanceof t)&&n!==s?.reason}function ue(n,a){if(Ml(n))return!0;return(n.dispatched??a)&&n.acknowledged!==!0&&!Ua(n.error)}function de(n,a,s){if(n.success||n.focusCompleted)s.onDispatched();if(!n.success)return;if(a==="doubleTap")s.onDispatched();for(let c of n.warnings??[])s.onWarning?.(c)}function pe(n,a){let{target:s,signal:c,talkBack:l}=a,u={assertCurrent:()=>{o(c),s.assertCurrent()}};return async({x:d,y:p})=>{u.assertCurrent();let m=n.action,f=m==="longPress"?n.duration??800:50,g=m==="tap"?await l.strategy.executePreciseTap(d,p,l.driver,u):await l.strategy.executeCoordinateFallback({x:d,y:p},m,f,{driver:l.driver,fenceOptions:{displayFence:u}});if(de(g,m,a),o(c),!g.success)throw new t(`TalkBack coordinate tap failed: ${g.error??"activation was not confirmed"}${g.focusCompleted?" Focus touch was delivered; activation failed. Do not retry automatically.":""}`)}}async function cB(n,a,s,c){let{target:l,signal:u,timer:d=i}=c,p=c.talkBack?vg(l.displayId):void 0;if(p)throw p;if(c.talkBack)return pe(s,{...c,talkBack:c.talkBack});let m=await Ba(n,l.displayId),f=async({x:g,y:b},y)=>{o(u),l.assertCurrent();let h=s.action==="longPress"?s.duration??800:10;if(m){let v=!1,k=()=>{v=!0},w=await n.requestTapCoordinates({x:g,y:b,duration:h,timeoutMs:$b(h),onDispatch:k,signal:u,displayId:l.displayId===0?void 0:l.displayId,beforeSend:l.assertCurrent});if(w.success)y();if(o(u),w.success)return;if(v)throw Tn(w.error);if(Ua(w.error))throw new t(w.error??"Stale frame context");e.warn(`[androidDisplayTapDispatch] dispatchGesture tap failed (${w.error}), falling back to ADB input`)}await Ec(a,s.action==="longPress"?`swipe ${g} ${b} ${g} ${b} ${zo(h)}`:`tap ${g} ${b}`,l.displayId,{signal:u,assertCurrent:l.assertCurrent,timeoutMs:s.action==="longPress"?Wr(h):void 0}),y(),o(u)};return async(g)=>{let b=0,y=()=>{b++,c.onDispatched()};try{if(s.action==="doubleTap")await yg({client:m?n:void 0,point:g,displayId:l.displayId===0?void 0:l.displayId,timer:d,signal:u,assertCurrent:l.assertCurrent,onTapDelivered:y,onWarning:c.onWarning,tap:()=>f(g,y)});else await f(g,y)}catch(h){if(s.action==="doubleTap"&&b===1)throw Tn(`${r(h)}. Double tap partially applied: one tap was delivered; the second tap was not confirmed`);throw h}}}function C(n){return typeof n==="string"&&n.length>0?n:void 0}function j(n){return typeof n==="number"&&Number.isInteger(n)?n:void 0}function Kn(n){let a={resourceId:C(n["resource-id"]),testTag:C(n["test-tag"]),uniqueId:C(n["unique-id"])},s=j(n["collection-row-index"]),c=j(n["collection-column-index"]),l=a.resourceId!==void 0||a.testTag!==void 0||a.uniqueId!==void 0;if(l&&s!==void 0&&c!==void 0)a.collectionRow=s,a.collectionColumn=c;return l?a:void 0}function fa(n){return n.testTag!==void 0||n.uniqueId!==void 0||n.collectionRow!==void 0||n.collectionColumn!==void 0}function G(n,a){let{testTag:s,resourceId:c}=n;if(s===void 0||n.uniqueId!==void 0||n.collectionRow!==void 0||n.collectionColumn!==void 0)return;let l=a.filter((u)=>u["test-tag"]===s&&(c===void 0||u["resource-id"]===c)).length;return l>1?`test tag "${s}" is shared by ${l} elements, so it does not identify the target`:void 0}async function bg(n,a,s){if(fa(n))return await a.supportsNodeActionSelectors()?void 0:"Runner does not support stable node selectors";return O(n.resourceId,()=>a.getAccessibilityHierarchy?.()??Promise.resolve(null),s)}class D{textMatcher;constructor(n=new Hb){this.textMatcher=n}findTargetIndex(n,a,s={}){return this.resolveTargetCandidate(n,a,s)?.index??null}findCurrentFocusIndex(n,a){if(!n||a.length===0)return null;let s=a.indexOf(n);if(s>=0)return s;let c=this.getResourceId(n);if(c)return this.findIndexByValue(a,n,(p)=>this.getResourceId(p),{value:c});let l=this.getTestTag(n);if(l)return this.findIndexByValue(a,n,(p)=>this.getTestTag(p),{value:l});let u=this.getContentDesc(n);if(u)return this.findIndexByValue(a,n,(p)=>this.getContentDesc(p),{value:u,caseInsensitive:!0});let d=this.getText(n);if(d)return this.findIndexByValue(a,n,(p)=>this.getText(p),{value:d,caseInsensitive:!0});if(n.bounds){let p=n.bounds,m=a.findIndex((f)=>f.bounds&&f.bounds.left===p.left&&f.bounds.top===p.top&&f.bounds.right===p.right&&f.bounds.bottom===p.bottom);return m===-1?null:m}return null}matchesSelector(n,a,s={}){let c=this.getResourceId(n),l=this.getContentDesc(n),u=this.getTestTag(n),d=this.getText(n);if(a.resourceId&&a.resourceId!==c)return!1;if(a.testTag&&a.testTag!==u)return!1;if(a.text){let p=this.createTextMatcher(a.text,s);if(!(p(d)||p(l)))return!1}if(a.contentDesc){if(!this.createTextMatcher(a.contentDesc,s)(l))return!1}return!0}matchesFocusedTarget(n,a,s){let c=this.resolveTargetCandidate(a,s);if(!c)return!1;let l={partialMatch:c.partialMatch};if(!this.matchesSelector(n,s,l))return!1;if(c.matchCount===1)return!0;return n===c.element||c.element.bounds!==void 0&&this.boundsMatch(n,c.element.bounds)}createTextMatcher(n,a){let s=a.partialMatch??!1,c=a.caseSensitive??!1;return this.textMatcher.createTextMatcher(n,s,c)}findMatches(n,a,s){return n.flatMap((c,l)=>this.matchesSelector(c,a,s)?[{element:c,index:l}]:[])}resolveTargetCandidate(n,a,s={}){let c=this.findMatches(n,a,{...s,partialMatch:!1}),l=c.length===0&&s.partialMatch!==!1,u=l?this.findMatches(n,a,{...s,partialMatch:!0}):c;if(u.length===0)return null;return{...this.selectTargetCandidate(u,a),matchCount:u.length,partialMatch:l}}selectTargetCandidate(n,a){if(n.length===1)return n[0];if(!a.bounds)return this.firstVisibleOrFirst(n);return n.find(({element:c})=>this.boundsMatch(c,a.bounds))??this.nearestBoundsMatch(n,a.bounds)}firstVisibleOrFirst(n){return n.find(({element:a})=>this.isVisible(a))??n[0]}nearestBoundsMatch(n,a){let s,c=Number.POSITIVE_INFINITY;for(let l of n){if(!l.element.bounds)continue;let u=this.boundsDistance(l.element.bounds,a);if(u<c)s=l,c=u}return s??this.firstVisibleOrFirst(n)}findIndexByValue(n,a,s,{value:c,caseInsensitive:l=!1}){let u=l?c.toLowerCase():c,d=n.flatMap((m,f)=>{let g=s(m);if(!g)return[];return(l?g.toLowerCase():g)===u?[{element:m,index:f}]:[]});if(d.length===1)return d[0].index;let p=a.bounds;if(!p)return null;return d.find(({element:m})=>this.boundsMatch(m,p))?.index??null}getResourceId(n){let a=n["resource-id"]??n.resourceId;return typeof a==="string"&&a.length>0?a:void 0}getContentDesc(n){let a=n["content-desc"]??n.contentDesc;return typeof a==="string"&&a.length>0?a:void 0}getTestTag(n){let a=n["test-tag"]??n.testTag;return typeof a==="string"&&a.length>0?a:void 0}getText(n){return typeof n.text==="string"&&n.text.length>0?n.text:void 0}isVisible(n){if(!n.bounds)return!1;let a=n.bounds.right-n.bounds.left,s=n.bounds.bottom-n.bounds.top;return a>0&&s>0}boundsMatch(n,a){if(!n.bounds)return!1;return n.bounds.left===a.left&&n.bounds.top===a.top&&n.bounds.right===a.right&&n.bounds.bottom===a.bottom}boundsDistance(n,a){let s=(n.left+n.right)/2,c=(n.top+n.bottom)/2,l=(a.left+a.right)/2,u=(a.top+a.bottom)/2;return(s-l)**2+(c-u)**2}}class x{detectPlatform(n){if(!n)return e.warn("[DeviceDetection] Empty device ID provided, defaulting to Android"),"android";let a=/^emulator-\d+$/;if(Va(n))return e.info(`[DeviceDetection] Detected iOS device: ${n}`),"ios";if(a.test(n))return e.info(`[DeviceDetection] Detected Android emulator: ${n}`),"android";return e.info(`[DeviceDetection] Device ID pattern suggests Android device: ${n}`),"android"}isiOSDevice(n){return this.detectPlatform(n)==="ios"}isAndroidDevice(n){return this.detectPlatform(n)==="android"}static detectPlatform=(n)=>new x().detectPlatform(n);static isiOSDevice=(n)=>new x().isiOSDevice(n);static isAndroidDevice=(n)=>new x().isAndroidDevice(n)}class S extends Error{}class T extends t{}class I{accessibilityService;constructor(n){this.accessibilityService=n}async getAccessibilityHierarchy(){return this.accessibilityService.getAccessibilityHierarchy(void 0,{skipWaitForFresh:!1,disableAllFiltering:!0})}async requestTraversalOrder(){return this.accessibilityService.requestTraversalOrder()}async requestCurrentFocus(){return this.accessibilityService.requestCurrentFocus()}async requestAction(n,a,s){return this.accessibilityService.requestAction(n,a,void 0,{signal:s})}async requestNodeAction(n,a,s){return this.accessibilityService.requestNodeAction(n,a,{signal:s})}async supportsNodeActionSelectors(){return this.accessibilityService.supportsNodeActionSelectors()}}class B{createDriver(n){return new I(E.getInstance(n))}}var ge="Request time budget exhausted during focus navigation.";function M(n,a){if(n instanceof S||St(n)||a<=0)return n;let s=r(n);return new S(`${s.endsWith(".")?s:`${s}.`} Focus navigation partially applied: ${a} accessibility-focus request${a===1?"":"s"} already moved the TalkBack cursor and the target was not activated. Observe before retrying; do not retry automatically.`,{cause:n})}function R(n,a,s){try{o(n)}catch(l){throw M(l,s)}let c=so()?.getDeadlineMs?.();if(c!==void 0&&a.now()>=c)throw M(Error(ge),s)}function he(n){let a=n.bounds;return[n["resource-id"]??"",n["content-desc"]??"",n.text??"",a?`${a.left},${a.top},${a.right},${a.bottom}`:""].join("|")}function W(n){return n.map(he).sort().join(`
4
+ `)}class N{static DEFAULT_FOCUS_SETTLE_MS=100;static FOCUS_READBACK_BOUND_MS=500;matcher;timer;driverFactory;deviceResolver;constructor(n={}){this.matcher=n.matcher??new D,this.timer=n.timer??i,this.driverFactory=n.driverFactory??new B,this.deviceResolver=n.deviceResolver??this.resolveDevice}async navigateToElement(n,a,s={}){let c=me(s.signal),l={focusRequests:0};try{return await this.runNavigation(n,a,{...s,signal:c,onFocusRequested:()=>{l.focusRequests+=1,s.onFocusRequested?.()}},l)}catch(u){throw c?.aborted?M(u,l.focusRequests):u}}async runNavigation(n,a,s,c){let{signal:l}=s,u=this.deviceResolver(n);if(u.platform!=="android")throw new t("TalkBack focus navigation is only supported on Android devices.");let d=this.driverFactory.createDriver(u);R(l,this.timer,c.focusRequests);let p=await this.verifyNavigationState(d,a,!1,l);if(s.onFocusObserved?.(p.currentFocus,p.orderedElements),p.reachedTarget)return!0;let m=p.targetIndex===null?void 0:p.orderedElements[p.targetIndex];if(!m)throw new T(`Target not found in the accessibility traversal (${this.describeSelector(a)}). Use observe to inspect elements and the diagnostics returned by tapOn/waitFor failures.`+this.describeTraversalTruncation(p));await this.requestFocus(d,m,p.orderedElements,{options:s,progress:c});let f=await this.readCursorAfterFocusRequest(d,a,s,c.focusRequests);if(s.onFocusObserved?.(f.currentFocus,f.orderedElements),f.reachedTarget)return!0;throw this.unreachedTargetError(p,f,a)}async readCursorAfterFocusRequest(n,a,s,c){let{signal:l}=s,u=Math.max(0,s.focusSettleMs??N.DEFAULT_FOCUS_SETTLE_MS),d=u>0?Math.max(1,Math.ceil(N.FOCUS_READBACK_BOUND_MS/u)):1,p;for(let m=1;;m+=1){if(u>0)await P(this.timer.sleep(u),l);if(R(l,this.timer,c),p=await this.verifyNavigationState(n,a,!0,l),p.reachedTarget||m>=d)return p}}async requestFocus(n,a,s,{options:c,progress:l}){let{signal:u}=c,d=Kn(a);if(!d)throw new T("The target has no resource-id, test tag or unique id, so the TalkBack cursor cannot be moved onto it without a touch gesture.");let p=G(d,s)??await bg(d,n,a);if(p)throw new T(`The TalkBack cursor cannot be moved onto the target: ${p}.`);R(u,this.timer,l.focusRequests),c.displayFence?.assertCurrent(),c.onFocusRequested?.();let m=await P(fa(d)?n.requestNodeAction("focus",d,u):n.requestAction("focus",d.resourceId,u),u);if(!m.success)throw new t(`Could not move the TalkBack cursor onto the target: ${m.error??"ACTION_ACCESSIBILITY_FOCUS failed"}. No tap was sent.`)}unreachedTargetError(n,a,s){let c=this.describeSelector(s);if(W(n.orderedElements)!==W(a.orderedElements))return new t(`The screen changed while moving the TalkBack cursor onto the target (${c}), and the cursor is not on it. No tap was sent. Observe the new screen and resolve the target again.`);let l=a.currentFocus?this.describeFocus(a.currentFocus):"no element has accessibility focus";return new t(`The TalkBack cursor did not move onto the target (${c}) after the focus request; ${l}. No tap was sent. Observe before retrying.`)}resolveDevice(n){let a=x.detectPlatform(n);return{name:n,deviceId:n,platform:a}}async verifyNavigationState(n,a,s,c){let l=await P(n.requestTraversalOrder(),c);if(l.error){let f=`Failed to get traversal order: ${l.error}`;throw s?new t(`${f}. The focus request may have moved the cursor; no tap was sent.`):new T(f)}let u=l.elements??[],d=this.matcher.findTargetIndex(u,a),p=null;if(l.focusedIndex!==null&&l.focusedIndex!==void 0)p=u[l.focusedIndex]??null;if(!p){let f=await P(n.requestCurrentFocus(),c);if(f.error)e.warn(`[FocusNavigation] Failed to get current focus: ${f.error}`);else p=f.focusedElement??null}let m=p?this.matcher.matchesFocusedTarget(p,u,a):!1;return{orderedElements:u,currentFocus:p,targetIndex:d,reachedTarget:m,truncationReasons:l.truncationReasons}}describeTraversalTruncation(n){return n.truncationReasons?.includes("max_children")?" the accessibility traversal was truncated (max_children); the target may be beyond the cap.":""}describeFocus(n){let a=n.text||n["content-desc"]||n["resource-id"];return a?`focus is on "${a}"`:"focus is on another element"}describeSelector(n){let a=[];if(n.resourceId)a.push(`resourceId="${n.resourceId}"`);if(n.text)a.push(`text="${n.text}"`);if(n.contentDesc)a.push(`contentDesc="${n.contentDesc}"`);if(n.testTag)a.push(`testTag="${n.testTag}"`);return a.length>0?a.join(", "):"unknown selector"}}var be=500,az="TalkBack activation is unconfirmed: the coordinate gesture completed, but the element may only have received accessibility focus. Observe the result before retrying.";function ye(n,a){return Array.isArray(n.actions)&&n.actions.includes(a)}class Wv{matcher;executor;timer;constructor(n={}){this.matcher=n.matcher??new D,this.executor=n.executor??new N({matcher:this.matcher,timer:n.timer,driverFactory:n.driverFactory}),this.timer=n.timer??i}async executeTap(n,a,s,{fence:c,signal:l}={}){let u={reachable:!1,traversalOrder:[],focusTrapDetected:!1},d=a?.["resource-id"],p=a.text,m=a["content-desc"];if(!d&&!p&&!m)return{success:!1,method:"focus-navigation",error:"Element has no resource-id, text, or content-desc for navigation",screenReaderNavigation:u};let f=this.createFocusSelector({resourceId:d,elementText:p,elementContentDesc:m,bounds:a.bounds}),g=me(l),b=0,y=[];try{if(!await this.executor.navigateToElement(n,f,{displayFence:c,signal:g,onFocusObserved:(w,X)=>{y=[...X],this.appendTraversalFocus(u,w)},onFocusRequested:()=>{b+=1}}))throw new t("Focus navigation did not reach target element")}catch(k){if(k instanceof T)return e.warn(`[TalkBackTapStrategy] Focus navigation unavailable: ${k.message}`,k),{success:!1,method:"focus-navigation",error:k.message,screenReaderNavigation:u};throw k}u.reachable=!0,e.info("[TalkBackTapStrategy] Focus navigation successful, activating element");let h=()=>R(g,this.timer,b);return h(),{...await this.activateElement(a,s,{fence:c,orderedElements:y,assertLive:h}),screenReaderNavigation:u}}createFocusSelector({resourceId:n,elementText:a,elementContentDesc:s,bounds:c}){return{...n?{resourceId:n}:{},...a?{text:a}:{},...s?{contentDesc:s}:{},bounds:c}}appendTraversalFocus(n,a){if(!a)return;let s=n.traversalOrder.at(-1);if(!s||this.focusSignature(s)!==this.focusSignature(a))n.traversalOrder.push(a)}focusSignature(n){let a=n.bounds;return[n["resource-id"]??"",n["content-desc"]??"",n.text??"",a?`${a.left},${a.top},${a.right},${a.bottom}`:""].join("|")}async executeDirectActivation(n,a,s={}){let c=await F(n,()=>a.getAccessibilityHierarchy?.()??Promise.resolve(null),s),l=c.element!==n?{element:c.element}:{};n=c.element;let u={supportsNodeActionSelectors:()=>a.supportsNodeActionSelectors(),getAccessibilityHierarchy:async()=>c.hierarchy},d=Kn(n);if(!d)return{success:!1,...l,method:"accessibility-action",error:"Element has no stable selector for direct accessibility activation"};let p=await bg(d,u,n);if(p)return{success:!1,...l,method:"accessibility-action",error:p};let m=fa(d)?await a.requestNodeAction("click",d):await a.requestAction("click",d.resourceId);if(m.success)return e.info("[TalkBackTapStrategy] Direct activation via ACTION_CLICK succeeded"),{success:!0,...l,method:"accessibility-action"};if(m.dispatched&&m.acknowledged!==!0)throw Tn(m.error);return{success:!1,...l,method:"accessibility-action",error:m.error??"ACTION_CLICK failed"}}async executeCoordinateFallback(n,a,s,{driver:c,fenceOptions:l={}}){let{x:u,y:d}=n,p=l.displayFence,m=a==="longPress"?s:50;if(a==="doubleTap"){p?.assertCurrent();let g=await this.dispatchDriverTap(c,u,d,{durationMs:m,doubleTap:!0});if(!g.success)return{success:!1,method:"coordinate-fallback",error:`Double tap failed: ${g.error}`,unsupportedCapability:g.unsupportedCapability,completedTaps:0};return{success:!0,method:"coordinate-fallback",completedTaps:2,warnings:[az]}}p?.assertCurrent();let f=await this.dispatchDriverTap(c,u,d,{durationMs:m});if(!f.success)return{success:!1,method:"coordinate-fallback",error:f.error};if(a==="tap")return{success:!1,method:"coordinate-fallback",error:"A single coordinate touch only moves TalkBack focus and does not activate the element"};return{success:!0,method:"coordinate-fallback"}}async executePreciseTap(n,a,s,c){c?.assertCurrent();let l=await this.dispatchDriverTap(s,n,a,{durationMs:50});if(!l.success)return{success:!1,method:"coordinate-fallback",error:`Focus tap failed: ${l.error}`,focusCompleted:!1,completedTaps:0};return await this.timer.sleep(be),{...await this.executeCoordinateFallback({x:n,y:a},"doubleTap",50,{driver:s,fenceOptions:{displayFence:c}}),focusCompleted:!0}}async executeLongPress(n,a,s,{driver:c,fenceOptions:l={}}){let{x:u,y:d}=n,p=l.displayFence,m=await F(s,()=>c.getAccessibilityHierarchy?.()??Promise.resolve(null),l);if(m.element!==s){let y=m.element.bounds;u=Math.round((y.left+y.right)/2),d=Math.round((y.top+y.bottom)/2)}let f=m.element!==s?{element:m.element}:{};s=m.element;let g={supportsNodeActionSelectors:()=>c.supportsNodeActionSelectors(),getAccessibilityHierarchy:async()=>m.hierarchy},b=Kn(s);if(b){let y=await bg(b,g,s);if(y)return e.info(`[TalkBackTapStrategy] ${y}`),{...await this.executeCoordinateFallback({x:u,y:d},"longPress",a,{driver:c,fenceOptions:{displayFence:p}}),...f};let h=fa(b)?await c.requestNodeAction("long_click",b):await c.requestAction("long_click",b.resourceId);if(h.success)return e.info("[TalkBackTapStrategy] Long press via ACTION_LONG_CLICK succeeded"),{success:!0,...f,method:"accessibility-action"};if(h.dispatched&&h.acknowledged!==!0)throw Tn(h.error);if(await XT({advertised:ye(s,"long_click"),error:h.error,needsNodeSelector:fa(b),selected:s,readHierarchy:()=>c.getAccessibilityHierarchy?.()??Promise.resolve(null)}))return{success:!1,...f,method:"accessibility-action",error:h.error??"ACTION_LONG_CLICK failed",semanticActionFailure:!0};e.warn(`[TalkBackTapStrategy] ACTION_LONG_CLICK failed (${h.error}), falling back to coordinate gesture`)}return{...await this.executeCoordinateFallback({x:u,y:d},"longPress",a,{driver:c,fenceOptions:{displayFence:p}}),...f}}async activateElement(n,a,{fence:s={assertCurrent:()=>{}},orderedElements:c,assertLive:l}){let u=n["resource-id"],d=await this.resolveActivationCenter(n,a,c),p=50;if(l(),!d){if(u){e.warn("[TalkBackTapStrategy] Activation target has no bounds; using ACTION_CLICK fallback");let f=await this.executeDirectActivation(n,a);if(f.success)return{success:!0,method:"accessibility-action"};return{success:!1,method:"focus-navigation",error:`Activation failed: target has no bounds and ACTION_CLICK failed (${f.error??"unknown"})`}}return{success:!1,method:"focus-navigation",error:"Activation failed: target has no bounds and no resource-id for ACTION_CLICK"}}s.assertCurrent();let m=await this.dispatchDriverTap(a,d.x,d.y,{durationMs:50,doubleTap:!0});if(!m.success){if(l(),u){if(e.warn("[TalkBackTapStrategy] Double-tap activation failed, trying ACTION_CLICK fallback"),!(await this.executeDirectActivation(n,a)).success)return{success:!1,method:"focus-navigation",error:"Activation failed: double-tap and ACTION_CLICK both failed",unsupportedCapability:m.unsupportedCapability};return{success:!0,method:"accessibility-action"}}return{success:!1,method:"focus-navigation",error:"Activation failed: double-tap failed",unsupportedCapability:m.unsupportedCapability}}return e.info("[TalkBackTapStrategy] Element activation gesture sent via focus navigation"),{success:!0,method:"focus-navigation",warnings:[az]}}async dispatchDriverTap(n,a,s,{durationMs:c,doubleTap:l=!1}){let u=!1,d;try{let p=()=>{u=!0};d=l?await n.requestDoubleTapCoordinates(a,s,p):await n.requestTapCoordinates({x:a,y:s,duration:c,onDispatch:p})}catch(p){if(u)throw Tn(r(p));if(p instanceof Ee||p instanceof t)throw p;return e.warn(`[TalkBackTapStrategy] Coordinate tap failed before dispatch: ${r(p)}`,p),{success:!1,totalTimeMs:0,error:r(p)}}if(!d.success&&u)throw Tn(d.error);return d}getElementCenter(n){if(!n.bounds)return null;return{x:Math.round((n.bounds.left+n.bounds.right)/2),y:Math.round((n.bounds.top+n.bounds.bottom)/2)}}async resolveActivationCenter(n,a,s){try{let c=await a.requestCurrentFocus(),l=c.focusedElement;if(l?.bounds&&!c.error){let u=this.createFocusSelector({resourceId:C(n["resource-id"]),elementText:C(n.text),elementContentDesc:C(n["content-desc"]),bounds:n.bounds}),d=await this.activationTraversal(a,s,u);if(this.matcher.matchesFocusedTarget(l,d,u))return this.getElementCenter(l);throw new t("TalkBack focus no longer matches the selected activation target.")}}catch(c){if(c instanceof t)throw c;e.debug(`[TalkBackTapStrategy] Could not read current focus for activation: ${c}`)}return this.getElementCenter(n)}async activationTraversal(n,a,s){let c;try{c=await n.requestTraversalOrder()}catch(d){if(d instanceof Ee)throw d;e.warn(`[TalkBackTapStrategy] Could not refresh activation traversal: ${r(d)}`,d)}if(!c?.error&&c?.elements?.length)return c.elements;let l=a.filter((d)=>this.matcher.matchesSelector(d,s));if((l.length?l:a.filter((d)=>this.matcher.matchesSelector(d,s,{partialMatch:!0}))).length===1)return a;throw new t("Cannot verify the selected TalkBack activation target: fresh traversal is unavailable or empty.")}}function kre(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,perf:a,signal:s}}function Ere(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a,deadlineMs:s?.requestDeadlineMs}}function Ire(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a,planContext:s}}function dB(n){return n===void 0?void 0:{requestDeadlineMs:n}}function ve(n){return typeof n==="object"&&n!==null&&"aborted"in n}function Sg(n){if(n===void 0||ve(n))return{signal:n};return n}function jo(n,a){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a}}var A=(n)=>n===!0||n==="true";function Ha(n){return A(n.focused)||A(n.isFocused)||A(n["has-keyboard-focus"])||A(n["accessibility-focused"])||A(n.accessibilityFocused)}class mD{parser;constructor(n=new K){this.parser=n}findFocusedTextInput(n){let a=[this.parser.extractRootNodes(n),...this.parser.extractWindowRootGroups(n,"topmost-first")];for(let s of a){let c=this.findInRoots(s);if(c)return c}return null}findInRoots(n){for(let a of n){let s=null;if(this.parser.traverseNode(a,(c)=>{if(s)return;let l=this.parser.extractNodeProperties(c),u=l.class||l.className;if(A(l.focused)&&u&&jg.some((d)=>u.includes(d)))s=this.parser.parseNodeBounds(c)}),s)return s}return null}}
5
+ export{XT,Eu,zo,sz,uD,Ec,X3,Ba,$a,gg,tf,ZT,Ua,zw,Z3,Q3,yg,vg,pD,Tre,Tn,jw,Kw,Gw,cB,Kn,fa,bg,az,Wv,kre,Ere,Ire,dB,Sg,jo,Ha,mD};
6
6
 
7
- //# debugId=CA49E5AC96D9324364756E2164756E21
7
+ //# debugId=E81B5E6E457E2C9864756E2164756E21