@tapflowio/relay 0.20.0 → 0.21.0

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 (120) hide show
  1. package/dist/RelayServer.d.ts +31 -0
  2. package/dist/RelayServer.d.ts.map +1 -1
  3. package/dist/RelayServer.js +159 -22
  4. package/dist/RelayServer.js.map +1 -1
  5. package/dist/api/auth.d.ts +2 -2
  6. package/dist/api/auth.d.ts.map +1 -1
  7. package/dist/api/auth.js +22 -33
  8. package/dist/api/auth.js.map +1 -1
  9. package/dist/lib/adminAccount.d.ts +24 -0
  10. package/dist/lib/adminAccount.d.ts.map +1 -0
  11. package/dist/lib/adminAccount.js +61 -0
  12. package/dist/lib/adminAccount.js.map +1 -0
  13. package/dist/lib/adminBootstrap.d.ts +48 -0
  14. package/dist/lib/adminBootstrap.d.ts.map +1 -0
  15. package/dist/lib/adminBootstrap.js +68 -0
  16. package/dist/lib/adminBootstrap.js.map +1 -0
  17. package/dist/lib/buildTickets.d.ts +50 -0
  18. package/dist/lib/buildTickets.d.ts.map +1 -0
  19. package/dist/lib/buildTickets.js +47 -0
  20. package/dist/lib/buildTickets.js.map +1 -0
  21. package/dist/lib/config.d.ts +4 -4
  22. package/dist/lib/loadEnvFile.d.ts +1 -1
  23. package/dist/lib/loadEnvFile.d.ts.map +1 -1
  24. package/dist/lib/loadEnvFile.js +11 -1
  25. package/dist/lib/loadEnvFile.js.map +1 -1
  26. package/dist/server.js +22 -0
  27. package/dist/server.js.map +1 -1
  28. package/package.json +6 -6
  29. package/public/assets/{AppCenter-Dg4dscW-.js → AppCenter-BkSQFKRv.js} +5 -5
  30. package/public/assets/AppCenter-BkSQFKRv.js.br +0 -0
  31. package/public/assets/AppCenter-BkSQFKRv.js.gz +0 -0
  32. package/public/assets/{Default-Dxi8aZ1t.js → Default-D1inA8sU.js} +1 -1
  33. package/public/assets/Default-D1inA8sU.js.br +0 -0
  34. package/public/assets/Default-D1inA8sU.js.gz +0 -0
  35. package/public/assets/{Invite-0EwoClX6.js → Invite-ChaVEWvP.js} +1 -1
  36. package/public/assets/Invite-ChaVEWvP.js.br +0 -0
  37. package/public/assets/Invite-ChaVEWvP.js.gz +0 -0
  38. package/public/assets/MacResources-CLChFyJW.js +1 -0
  39. package/public/assets/MacResources-CLChFyJW.js.br +0 -0
  40. package/public/assets/MacResources-CLChFyJW.js.gz +0 -0
  41. package/public/assets/NotFound-BoDDivK5.js.gz +0 -0
  42. package/public/assets/QASession-DICynZa0.js +140 -0
  43. package/public/assets/QASession-DICynZa0.js.br +0 -0
  44. package/public/assets/QASession-DICynZa0.js.gz +0 -0
  45. package/public/assets/{ResetPassword-CXU2bRry.js → ResetPassword-Ut9BFums.js} +1 -1
  46. package/public/assets/ResetPassword-Ut9BFums.js.br +0 -0
  47. package/public/assets/ResetPassword-Ut9BFums.js.gz +0 -0
  48. package/public/assets/{Setup-XXChRxeL.js → Setup-CoHwaxo7.js} +1 -1
  49. package/public/assets/Setup-CoHwaxo7.js.br +0 -0
  50. package/public/assets/Setup-CoHwaxo7.js.gz +0 -0
  51. package/public/assets/{Team-D0bXpmEY.js → Team-DaVY1DGm.js} +2 -2
  52. package/public/assets/Team-DaVY1DGm.js.br +0 -0
  53. package/public/assets/Team-DaVY1DGm.js.gz +0 -0
  54. package/public/assets/Tokens-_KZJ7AZ9.js +1 -0
  55. package/public/assets/Tokens-_KZJ7AZ9.js.br +0 -0
  56. package/public/assets/Tokens-_KZJ7AZ9.js.gz +0 -0
  57. package/public/assets/{alert-dialog-CgatMXjB.js → alert-dialog-Cc_pQpe6.js} +1 -1
  58. package/public/assets/alert-dialog-Cc_pQpe6.js.br +0 -0
  59. package/public/assets/alert-dialog-Cc_pQpe6.js.gz +0 -0
  60. package/public/assets/{badge-B6Nf3A0Y.js → badge-CikXk90N.js} +1 -1
  61. package/public/assets/badge-CikXk90N.js.br +0 -0
  62. package/public/assets/badge-CikXk90N.js.gz +0 -0
  63. package/public/assets/{build-format-BFC8gLoh.js → build-format-DsApFPHy.js} +3 -3
  64. package/public/assets/build-format-DsApFPHy.js.br +0 -0
  65. package/public/assets/build-format-DsApFPHy.js.gz +0 -0
  66. package/public/assets/{dialog-DK9a3b4z.js → dialog-B4Wg7TCg.js} +3 -3
  67. package/public/assets/dialog-B4Wg7TCg.js.br +0 -0
  68. package/public/assets/dialog-B4Wg7TCg.js.gz +0 -0
  69. package/public/assets/index-CBfjqtE-.js +198 -0
  70. package/public/assets/index-CBfjqtE-.js.br +0 -0
  71. package/public/assets/index-CBfjqtE-.js.gz +0 -0
  72. package/public/assets/index-ClHUQm-F.css.gz +0 -0
  73. package/public/assets/{pencil-BeLNLEKe.js → pencil-DMswV31e.js} +2 -2
  74. package/public/assets/pencil-DMswV31e.js.br +0 -0
  75. package/public/assets/pencil-DMswV31e.js.gz +0 -0
  76. package/public/assets/{table-DW57-o1p.js → table-dbLmBL_w.js} +1 -1
  77. package/public/assets/table-dbLmBL_w.js.br +0 -0
  78. package/public/assets/table-dbLmBL_w.js.gz +0 -0
  79. package/public/assets/{tabs-Xlttuqxh.js → tabs-pPYCRfmT.js} +1 -1
  80. package/public/assets/tabs-pPYCRfmT.js.br +0 -0
  81. package/public/assets/tabs-pPYCRfmT.js.gz +0 -0
  82. package/public/assets/tinyh264.worker-DiJ50Hai.js.gz +0 -0
  83. package/public/assets/{trash-2-CGxISX8x.js → trash-VgeHmI8N.js} +4 -4
  84. package/public/assets/trash-VgeHmI8N.js.br +0 -0
  85. package/public/assets/trash-VgeHmI8N.js.gz +0 -0
  86. package/public/assets/vendor-charts-DyX5CBcf.js.gz +0 -0
  87. package/public/assets/vendor-react-AJpf4YZ0.js.gz +0 -0
  88. package/public/assets/vendor-router-BFibuab1.js +12 -0
  89. package/public/assets/vendor-router-BFibuab1.js.br +0 -0
  90. package/public/assets/vendor-router-BFibuab1.js.gz +0 -0
  91. package/public/favicon.svg.gz +0 -0
  92. package/public/index.html +2 -2
  93. package/public/index.html.br +0 -0
  94. package/public/index.html.gz +0 -0
  95. package/public/logo-dark.svg.gz +0 -0
  96. package/public/logo.svg.gz +0 -0
  97. package/public/assets/AppCenter-Dg4dscW-.js.br +0 -0
  98. package/public/assets/Default-Dxi8aZ1t.js.br +0 -0
  99. package/public/assets/Invite-0EwoClX6.js.br +0 -0
  100. package/public/assets/MacResources-Dy1M3EqK.js +0 -1
  101. package/public/assets/MacResources-Dy1M3EqK.js.br +0 -0
  102. package/public/assets/QASession-DqMj8JL1.js +0 -140
  103. package/public/assets/QASession-DqMj8JL1.js.br +0 -0
  104. package/public/assets/ResetPassword-CXU2bRry.js.br +0 -0
  105. package/public/assets/Setup-XXChRxeL.js.br +0 -0
  106. package/public/assets/Team-D0bXpmEY.js.br +0 -0
  107. package/public/assets/Tokens-D0YNHS5e.js +0 -1
  108. package/public/assets/Tokens-D0YNHS5e.js.br +0 -0
  109. package/public/assets/alert-dialog-CgatMXjB.js.br +0 -0
  110. package/public/assets/badge-B6Nf3A0Y.js.br +0 -0
  111. package/public/assets/build-format-BFC8gLoh.js.br +0 -0
  112. package/public/assets/dialog-DK9a3b4z.js.br +0 -0
  113. package/public/assets/index-9vdYIm7s.js +0 -210
  114. package/public/assets/index-9vdYIm7s.js.br +0 -0
  115. package/public/assets/pencil-BeLNLEKe.js.br +0 -0
  116. package/public/assets/table-DW57-o1p.js.br +0 -0
  117. package/public/assets/tabs-Xlttuqxh.js.br +0 -0
  118. package/public/assets/trash-2-CGxISX8x.js.br +0 -0
  119. package/public/assets/vendor-router-ChFy8CZ1.js +0 -12
  120. package/public/assets/vendor-router-ChFy8CZ1.js.br +0 -0
@@ -0,0 +1,140 @@
1
+ import{i as s,j as n}from"./vendor-react-AJpf4YZ0.js";import{W as ne,J as te,y as Vt,T as Ce,z as Te,B as ie,x as Ee,S as Cn,a4 as Ne,r as mr,s as Mt,K as Ke,a9 as tt,t as nt,O as Tn,a8 as ht,af as gr,ab as xr,U as br,w as yr,f as vr,ag as wr,aa as Sr,a7 as Rr,L as kr}from"./index-CBfjqtE-.js";import{f as jr,a as Cr,P as En,c as ln,S as Tr,b as Er}from"./build-format-DsApFPHy.js";import{u as Nn,n as X,T as Nr,b as Ar,c as un,a as dn}from"./tabs-pPYCRfmT.js";import{c as An,b as _r}from"./vendor-router-BFibuab1.js";import{A as Pr,c as Dr,f as Lr,g as Ir,d as Mr,e as Ur,b as $r,a as Br}from"./alert-dialog-Cc_pQpe6.js";import{D as _n,a as Pn,d as Fr,e as Dn,b as Or,c as Hr,k as zr,S as Wr,i as Vr,j as qr,g as Xr,h as fn}from"./dialog-B4Wg7TCg.js";import{B as Kr}from"./badge-CikXk90N.js";/**
2
+ * @license lucide-react v1.41.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Yr=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Gr=ne("arrow-left",Yr);/**
7
+ * @license lucide-react v1.41.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Jr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Qr=ne("arrow-up",Jr);/**
12
+ * @license lucide-react v1.41.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Zr=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],es=ne("camera",Zr);/**
17
+ * @license lucide-react v1.41.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ts=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],ns=ne("download",ts);/**
22
+ * @license lucide-react v1.41.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const rs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],ss=ne("film",rs);/**
27
+ * @license lucide-react v1.41.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const os=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Ln=ne("house",os);/**
32
+ * @license lucide-react v1.41.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const as=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],is=ne("image-plus",as);/**
37
+ * @license lucide-react v1.41.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const cs=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],ls=ne("keyboard",cs);/**
42
+ * @license lucide-react v1.41.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const us=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],In=ne("link-2",us);/**
47
+ * @license lucide-react v1.41.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const ds=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yt=ne("loader-circle",ds);/**
52
+ * @license lucide-react v1.41.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const fs=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],hs=ne("message-square",fs);/**
57
+ * @license lucide-react v1.41.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const ps=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ms=ne("power",ps);/**
62
+ * @license lucide-react v1.41.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const gs=[["path",{d:"M13.414 13.414a2 2 0 1 1-2.828-2.828",key:"srl686"}],["path",{d:"M16.247 7.761a6 6 0 0 1 1.744 4.572",key:"1h86sp"}],["path",{d:"M19.075 4.933a10 10 0 0 1 2.234 10.72",key:"1n13k4"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}]],xs=ne("radio-off",gs);/**
67
+ * @license lucide-react v1.41.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const bs=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Ot=ne("radio",bs);/**
72
+ * @license lucide-react v1.41.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const ys=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],vs=ne("refresh-cw",ys);/**
77
+ * @license lucide-react v1.41.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const ws=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Ss=ne("rotate-cw",ws);/**
82
+ * @license lucide-react v1.41.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const Rs=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]],ks=ne("scan-line",Rs);/**
87
+ * @license lucide-react v1.41.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const js=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Cs=ne("square",js);/**
92
+ * @license lucide-react v1.41.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const Ts=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Es=ne("video",Ts);/**
97
+ * @license lucide-react v1.41.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const Ns=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],As=ne("volume-1",Ns);/**
102
+ * @license lucide-react v1.41.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const _s=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Ps=ne("volume-2",_s);function Ds(e){const[t,r]=s.useState(null);return s.useEffect(()=>{e&&jr(e).then(r)},[e]),{build:t}}function Ls(e){const[t,r]=s.useState([]),[o,i]=s.useState(null),[a,c]=s.useState(null),[u,d]=s.useState(""),[h,p]=s.useState(!1),[g,x]=s.useState(""),f=s.useCallback(k=>{k.type==="agents:listed"&&r(k.sessions),k.type==="session:joined"&&(p(!1),x("Connected")),k.type==="error"&&(p(!1),x(`Error: ${k.message}`))},[]),{send:b,connected:v}=Nn(f);s.useEffect(()=>{if(!v)return;b({type:"agents:list"});const k=setInterval(()=>b({type:"agents:list"}),5e3);return()=>clearInterval(k)},[v,b]);const T=s.useRef({sessionId:a,deviceId:u});s.useEffect(()=>{T.current={sessionId:a,deviceId:u}},[a,u]),s.useEffect(()=>()=>{const{sessionId:k,deviceId:B}=T.current;k&&B&&b({type:"device:shutdown",sessionId:k,payload:{deviceId:B}})},[b]);const j=t.filter(k=>k.devices.some(B=>B.platform===e)),L=s.useCallback(k=>{d(k.id),p(!0),x("Booting…"),c(k.sessionId)},[]),C=s.useCallback(()=>d(""),[]),N=s.useCallback(()=>{const{sessionId:k,deviceId:B}=T.current;k&&B&&b({type:"device:shutdown",sessionId:k,payload:{deviceId:B}}),c(null),p(!1),x("")},[b]),E=s.useCallback(()=>{const{sessionId:k,deviceId:B}=T.current;k&&B&&b({type:"device:shutdown",sessionId:k,payload:{deviceId:B}}),c(null),i(null),p(!1),x(""),b({type:"agents:list"})},[b]),M=s.useCallback(()=>{c(null),i(null),p(!1),x(""),b({type:"agents:list"})},[b]);return{sessions:t,selectedAgent:o,setSelectedAgent:i,activeSessionId:a,deviceId:u,booting:h,status:g,send:b,connected:v,agentGroups:j,startDevice:L,resetDevice:C,handleBack:N,handleBackToMacs:E,handleSessionEnded:M}}function Is(e,t){const[r,o]=s.useState(""),[i,a]=s.useState(""),[c,u]=s.useState("app-only"),[d,h]=s.useState("app-only"),p=(e==null?void 0:e.capabilities.includes("full-reset"))??!1,g=s.useCallback(()=>{h(p?c:"app-only"),u("app-only")},[c,p]),x=(e==null?void 0:e.devices.filter(v=>v.platform===t))??[],f=[...new Set(x.map(v=>v.osVersion).filter(Boolean))].sort((v,T)=>{const j=N=>N.replace(/^[^\d]*/,"").split(".").map(Number),[L,C]=[j(v),j(T)];for(let N=0;N<Math.max(L.length,C.length);N++){const E=(C[N]??0)-(L[N]??0);if(E!==0)return E}return 0}),b=(r?x.filter(v=>v.osVersion===r):x).filter(v=>!i||v.name.toLowerCase().includes(i.toLowerCase()));return{filteredDevices:x,osVersions:f,osVersion:r,setOsVersion:o,deviceSearch:i,setDeviceSearch:a,versionedDevices:b,resetMode:c,setResetMode:u,appliedResetMode:d,consumeResetMode:g,fullResetSupported:p}}function Ms(){const[e]=An(),t=e.get("perf")==="1",[r,o]=s.useState(t);return s.useEffect(()=>{if(!t){o(!1);return}o(!0);const i=a=>{a.ctrlKey&&a.shiftKey&&a.key==="P"&&o(c=>!c)};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),{perfMode:t,visible:r}}function Mn(e){const t=e.rolloverOffset.x-e.buttonW/2,r=e.anchor==="top"?e.rolloverOffset.y:e.normalOffset.y-e.buttonH/2;return{left:t,top:r,right:t+e.buttonW,bottom:r+e.buttonH}}function Us(e,t,r){const o=Math.max(r.left-e,0,e-r.right),i=Math.max(r.top-t,0,t-r.bottom);return Math.hypot(o,i)}function $s(e,t,r,o){let i=null,a=1/0;for(const c of r){const u=Us(e,t,Mn(c));u<a&&(a=u,i=c.name)}return a<=o?i:null}const Bs=["video/mp4;codecs=avc1","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Un({sessionId:e,buildId:t,onRecordingUploaded:r}){const[o,i]=s.useState("idle"),a=s.useRef(null),c=s.useRef(r);s.useEffect(()=>{c.current=r},[r]);const u=s.useRef(!1),d=s.useRef(null),h=s.useRef([]),p=s.useRef(""),g=s.useRef(0),x=s.useRef(null),f=s.useCallback(function T(){var j;u.current&&((j=x.current)==null||j.call(x),g.current=requestAnimationFrame(T))},[]),b=s.useCallback(T=>{const j=a.current;if(!j)return;const L=j.getContext("2d");L&&(L.fillStyle="#000",L.fillRect(0,0,j.width,j.height));const C=Bs.find(E=>MediaRecorder.isTypeSupported(E))??"";if(!C)return;p.current=C,h.current=[];const N=new MediaRecorder(j.captureStream(30),{mimeType:C});N.ondataavailable=E=>{E.data.size>0&&h.current.push(E.data)},d.current=N,N.start(1e3),x.current=T,u.current=!0,g.current=requestAnimationFrame(f),i("recording")},[f]),v=s.useCallback(async()=>{var E;i("uploading"),u.current=!1,cancelAnimationFrame(g.current);const T=d.current;if(!T){i("idle");return}await new Promise(M=>{const k=setTimeout(M,5e3);T.onstop=()=>{clearTimeout(k),M()};try{T.stop()}catch{clearTimeout(k),M()}}),d.current=null;const j=p.current,L=j.includes("mp4")?".mp4":".webm",C=new Blob(h.current,{type:j});h.current=[];const N=new FormData;N.append("file",C,`tapflow-${Date.now()}${L}`);try{const M=new URLSearchParams({sessionId:e});t&&M.set("buildId",String(t));const k=await fetch(`/api/v1/recordings/upload?${M}`,{method:"POST",credentials:"include",body:N}),B=await k.json();if(k.ok&&B.url){const G=document.createElement("a");G.href=B.url,G.download="",G.click(),(E=c.current)==null||E.call(c),i("done"),setTimeout(()=>i("idle"),2e3)}else i("idle")}catch{i("idle")}},[e,t]);return s.useEffect(()=>{if(o!=="recording")return;const T=()=>{document.visibilityState==="hidden"&&v()};return document.addEventListener("visibilitychange",T),()=>{var j;document.removeEventListener("visibilitychange",T),u.current&&(u.current=!1,cancelAnimationFrame(g.current),(j=d.current)==null||j.stop(),d.current=null)}},[o,v]),{recordState:o,recordCanvasRef:a,startClientRecording:b,stopClientRecording:v}}function $n(){const e=s.useRef(0),[t,r]=s.useState(0);return s.useEffect(()=>{const o=setInterval(()=>{r(e.current),e.current=0},1e3);return()=>clearInterval(o)},[]),{fps:t,frameCount:e}}function ft({className:e,...t}){return n.jsx("kbd",{"data-slot":"kbd",className:te("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}function qt({className:e,...t}){return n.jsx("kbd",{"data-slot":"kbd-group",className:te("inline-flex items-center gap-1",e),...t})}function St({label:e,keys:t}){return n.jsxs("span",{className:"flex items-center gap-3",children:[e,n.jsx(qt,{children:t.map(r=>n.jsx(ft,{children:r},r))})]})}const hn="text-muted-foreground hover:text-muted-foreground",pn="text-destructive hover:text-destructive";function Fs(e){switch(e){case"awaiting-app":return" Launch an app through tapflow so it is told too.";case"not-armed":return" Restart the device so tapflow can set it up.";case"state-unconfirmed":return" tapflow could not confirm the change — try again.";case"unsupported-device":return" The device did not change when tapflow asked — try again, or use another device.";case"filter-unavailable":return" This Mac is not set up to take devices off the network — see the network control guide.";case"enforcement-lost":return" It went back on the network on its own.";case"hooks-not-installed":return" tapflow cannot tell this app it is off the network.";default:return" tapflow cannot change it right now."}}function Os({position:e,steerable:t,reason:r}){const o=r==="awaiting-app",i=!t&&r==="state-unconfirmed"?" animate-pulse":"",a=t?"":Fs(r);switch(e){case"offline":return{Icon:xs,className:(t||o?"text-amber-500 hover:text-amber-500":pn)+i,status:`Device is offline.${a}`};case"online":return{Icon:Ot,className:(t||o?"":pn)+i,status:`Device is on the network.${a}`};case"waiting":return{Icon:Ot,className:`${hn} animate-pulse`,status:"Checking the network state."};case"unknown":return{Icon:Ot,className:hn,status:"No network state has been reported."}}}function Hs({position:e,steerable:t,reason:r}){const o=e==="offline"?"Bring device online":e==="online"?"Take device offline":"Toggle device network",i=e==="online"||e==="offline",a=r==="state-unconfirmed"||r==="unsupported-device";return t||!i||r==="awaiting-app"?o:a?`Retry: ${o.toLowerCase()}`:`${o} — unavailable`}function Bn({joined:e,onScreenshot:t,onRecordToggle:r,recordState:o,onRotate:i,onDeepLink:a,navigationSlot:c,deviceSlot:u,launchSlot:d,network:h,reboot:p}){const g=s.useId(),x=s.useId(),f=s.useId(),[b,v]=s.useState(!1);return e?n.jsxs(Vt,{delayDuration:400,children:[n.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-2xl border bg-background/90 backdrop-blur-sm px-1.5 py-2.5 shrink-0 mt-3",children:[n.jsxs("div",{role:"group","aria-label":"Navigation",className:"flex flex-col items-center gap-0.5",children:[d,c,n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Open a deeplink",onClick:a,children:n.jsx(In,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsx(St,{label:"Deeplink",keys:["⌘","K"]})})]})]}),n.jsx("div",{role:"separator","aria-orientation":"horizontal",className:"w-4 h-px bg-border my-1"}),n.jsxs("div",{role:"group","aria-label":"Device",className:"flex flex-col items-center gap-0.5",children:[u,n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Rotate the device",onClick:i,children:n.jsx(Ss,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsx(St,{label:"Rotate",keys:["⌘","⇧","O"]})})]}),p&&(()=>{const T=p.pending?"Restarting the device":"Restart the device";return n.jsxs(n.Fragment,{children:[n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{ref:p.buttonRef,variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":T,"aria-busy":p.pending,"aria-disabled":p.pending,"aria-describedby":x,onClick:()=>{p.pending||v(!0)},children:p.pending?n.jsx(yt,{className:"h-4 w-4 animate-spin"}):n.jsx(vs,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:T})]}),n.jsx("span",{id:x,role:"status",className:"sr-only",children:p.pending?"Restarting the device.":""})]})})()]}),n.jsx("div",{role:"separator","aria-orientation":"horizontal",className:"w-4 h-px bg-border my-1"}),n.jsxs("div",{role:"group","aria-label":"Capture",className:"flex flex-col items-center gap-0.5",children:[n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Take a screenshot",onClick:t,children:n.jsx(es,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsx(St,{label:"Screenshot",keys:["⌘","S"]})})]}),n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:te("h-8 w-8 aria-disabled:opacity-50",o==="recording"&&"text-red-500 hover:text-red-500"),"aria-label":o==="recording"?"Stop recording":o==="uploading"?"Processing the recording":o==="done"?"Recording saved":"Start recording","aria-busy":o==="uploading","aria-disabled":o==="uploading"||o==="done","aria-describedby":f,onClick:()=>{(o==="idle"||o==="recording")&&r()},children:o==="uploading"?n.jsx(yt,{className:"h-4 w-4 animate-spin"}):o==="recording"?n.jsx(Cs,{className:"h-4 w-4 fill-current"}):n.jsx(Es,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:o==="idle"?n.jsx(St,{label:"Start recording",keys:["⌘","⇧","Y"]}):o==="recording"?n.jsx(St,{label:"Stop recording",keys:["⌘","⇧","Y"]}):o==="done"?"Recording saved":"Processing the recording"})]}),n.jsx("span",{id:f,role:"status",className:"sr-only",children:o==="recording"?"Recording.":o==="uploading"?"Processing the recording.":o==="done"?"Recording saved.":""})]}),h&&n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"separator","aria-orientation":"horizontal",className:"w-4 h-px bg-border my-1"}),n.jsx("div",{role:"group","aria-label":"Environment",className:"flex flex-col items-center gap-0.5",children:h&&(()=>{const{Icon:T,className:j,status:L}=Os(h),C=Hs(h),N=h.position==="waiting"||h.position==="unknown"||!h.steerable;return n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:te("h-8 w-8",j),"aria-label":C,"aria-busy":h.pending,"aria-disabled":h.pending,"aria-describedby":g,onClick:()=>{h.pending||h.onToggle()},children:h.pending?n.jsx(yt,{className:"h-4 w-4 animate-spin"}):n.jsx(T,{className:"h-4 w-4"})})}),n.jsx("span",{id:g,role:"status",className:"sr-only",children:h.pending?"Changing the network state.":L}),n.jsx(Ee,{side:"left",children:N?`${C} — ${L}`:C})]})})()})]})]}),p&&n.jsx(Pr,{open:b,onOpenChange:v,children:n.jsxs(Dr,{children:[n.jsxs(Lr,{children:[n.jsx(Ir,{children:"Restart this device?"}),n.jsx(Mr,{children:"Anything open on the device closes, and whatever you had set up on screen is gone. Installed apps and their data stay. The device takes a moment to come back."})]}),n.jsxs(Ur,{children:[n.jsx($r,{children:"Cancel"}),n.jsx(Br,{onClick:()=>{v(!1),p.onReboot()},children:"Restart"})]})]})})]}):null}const zs=3e3,Ws=8e3;function Fn({sessionId:e,send:t,supported:r,deviceReady:o,handlerRef:i,onError:a}){const[c,u]=s.useState("waiting"),[d,h]=s.useState(!0),[p,g]=s.useState(void 0),x=s.useRef(void 0),[f,b]=s.useState(!1),v=s.useRef(null),T=s.useRef(new Set),j=s.useRef(a);s.useEffect(()=>{j.current=a},[a]);const L=s.useRef(o);s.useEffect(()=>{L.current=o},[o]);const C=s.useRef(o);s.useEffect(()=>{u("waiting"),h(!0),g(void 0),x.current=void 0,b(!1),v.current=null,C.current=L.current,T.current.clear()},[e]),s.useEffect(()=>{var k;if(o){C.current=!0,u("waiting");return}u(C.current?"unknown":"waiting"),h(!0),g(void 0),x.current=void 0,v.current&&((k=j.current)==null||k.call(j,"The device became unavailable before it answered. Its network state is unchanged as far as tapflow can tell."),T.current.add(v.current)),b(!1),v.current=null},[o]),s.useEffect(()=>{if(r)return i.current=k=>{var G,z;if(k.type==="network:error"){k.requestId===v.current&&(v.current=null,b(!1),(G=j.current)==null||G.call(j,k.message));return}if(k.type!=="network:state"||!L.current||k.requestId!==void 0&&T.current.has(k.requestId))return;const B=k.payload.available?void 0:k.payload.reason;u(k.payload.offline?"offline":"online"),h(k.payload.available),g(B),B==="enforcement-lost"&&x.current!=="enforcement-lost"&&((z=j.current)==null||z.call(j,"The device went back on the network before you took it off. Anything checked while it was offline needs checking again.")),x.current=B,k.requestId!==void 0&&k.requestId===v.current&&(v.current=null,b(!1))},()=>{i.current=void 0}},[i,r]),s.useEffect(()=>{if(!r||!o||c!=="waiting")return;const k=setTimeout(()=>u(B=>B==="waiting"?"unknown":B),zs);return()=>clearTimeout(k)},[r,o,c]);const N=s.useCallback(()=>{if(!r||f)return;const k=X();v.current=k,b(!0),t({type:"network:set",sessionId:e,requestId:k,payload:{offline:c!=="offline"}})},[c,f,t,e,r]),[E,M]=s.useState(null);return s.useEffect(()=>{M(f?v.current:null)},[f]),s.useEffect(()=>{if(E===null)return;const k=setTimeout(()=>{var B;v.current===E&&(v.current=null,b(!1),(B=j.current)==null||B.call(j,"The device did not answer. Its network state is unchanged as far as tapflow can tell."))},Ws);return()=>clearTimeout(k)},[E]),{position:c,steerable:d,reason:p,pending:f,toggle:N}}class Xt{constructor(t){this.bytes=t,this.bitPos=0}get position(){return this.bitPos}bit(){const t=this.bitPos>>3,r=7-(this.bitPos&7);return this.bitPos++,t>=this.bytes.length?0:this.bytes[t]>>r&1}bits(t){let r=0;for(let o=0;o<t;o++)r=r<<1|this.bit();return r>>>0}flag(){return this.bit()===1}ue(){let t=0;for(;this.bit()===0&&t<32;)t++;return t===0?0:(1<<t)-1+this.bits(t)}se(){const t=this.ue();return t&1?Math.ceil(t/2):-Math.ceil(t/2)}}class Vs{constructor(){this.bitsArr=[]}bit(t){this.bitsArr.push(t&1)}ue(t){const r=t+1,o=Math.floor(Math.log2(r));for(let i=0;i<o;i++)this.bit(0);for(let i=o;i>=0;i--)this.bit(r>>i&1)}toBytes(){const t=[];for(let r=0;r<this.bitsArr.length;r+=8){let o=0;for(let i=0;i<8;i++)o=o<<1|(this.bitsArr[r+i]??0);t.push(o)}return new Uint8Array(t)}}function On(e){const t=[];let r=0;for(let o=1;o<e.length;o++){const i=e[o];if(r>=2&&i===3){r=0;continue}t.push(i),r=i===0?r+1:0}return new Uint8Array(t)}function qs(e){const t=[];let r=0;for(const o of e)r>=2&&o<=3&&(t.push(3),r=0),t.push(o),r=o===0?r+1:0;return new Uint8Array(t)}const Xs=new Set([100,110,122,244,44,83,86,118,128,138,139,134,135]);function mn(e){const t=e.ue()+1;e.bits(4),e.bits(4);for(let r=0;r<t;r++)e.ue(),e.ue(),e.flag();e.bits(5),e.bits(5),e.bits(5),e.bits(5)}function Hn(e){const t=e.bits(8);e.bits(8);const r=e.bits(8);if(e.ue(),Xs.has(t)){const g=e.ue();if(g===3&&e.flag(),e.ue(),e.ue(),e.flag(),e.flag()){const x=g!==3?8:12;for(let f=0;f<x;f++)if(e.flag()){const b=f<6?16:64;let v=8,T=8;for(let j=0;j<b;j++)T!==0&&(T=(v+e.se()+256)%256),v=T===0?v:T}}}e.ue();const o=e.ue();if(o===0)e.ue();else if(o===1){e.flag(),e.se(),e.se();const g=e.ue();for(let x=0;x<g;x++)e.se()}const i=e.ue();e.flag(),e.ue(),e.ue(),e.flag()||e.flag(),e.flag(),e.flag()&&(e.ue(),e.ue(),e.ue(),e.ue());const a={profileIdc:t,levelIdc:r,numRefFrames:i,bitstreamRestriction:!1,maxNumReorderFrames:null,maxDecFrameBuffering:null};if(!e.flag())return{...a,vuiPresent:!1,restrictionFlagPos:-1};e.flag()&&e.bits(8)===255&&(e.bits(16),e.bits(16)),e.flag()&&e.flag(),e.flag()&&(e.bits(3),e.flag(),e.flag()&&(e.bits(8),e.bits(8),e.bits(8))),e.flag()&&(e.ue(),e.ue()),e.flag()&&(e.bits(32),e.bits(32),e.flag());const u=e.flag();u&&mn(e);const d=e.flag();d&&mn(e),(u||d)&&e.flag(),e.flag();const h=e.position;return e.flag()?(e.flag(),e.ue(),e.ue(),e.ue(),e.ue(),{...a,vuiPresent:!0,bitstreamRestriction:!0,maxNumReorderFrames:e.ue(),maxDecFrameBuffering:e.ue(),restrictionFlagPos:h}):{...a,vuiPresent:!0,restrictionFlagPos:h}}function Ks(e){const t=Hn(new Xt(On(e)));return{profileIdc:t.profileIdc,levelIdc:t.levelIdc,vuiPresent:t.vuiPresent,bitstreamRestriction:t.bitstreamRestriction,maxNumReorderFrames:t.maxNumReorderFrames,maxDecFrameBuffering:t.maxDecFrameBuffering}}function Ys(e){const t=On(e),r=Hn(new Xt(t));if(!r.vuiPresent||r.restrictionFlagPos<0||r.bitstreamRestriction)return null;const o=new Vs,i=new Xt(t);for(let a=0;a<r.restrictionFlagPos;a++)o.bit(i.bit());return o.bit(1),o.bit(1),o.ue(0),o.ue(0),o.ue(0),o.ue(0),o.ue(0),o.ue(r.numRefFrames),o.bit(1),Uint8Array.from([e[0],...qs(o.toBytes())])}function Gs(e){const t=[],r=e.length;let o=-1,i=0;for(;i+2<r;){const a=i+3<r&&e[i]===0&&e[i+1]===0&&e[i+2]===0&&e[i+3]===1,c=e[i]===0&&e[i+1]===0&&e[i+2]===1;a||c?(o>=0&&t.push(e.subarray(o,i)),i+=a?4:3,o=i):i++}return o>=0&&t.push(e.subarray(o,r)),t}class Js{constructor(t){this.onFrame=t,this.decoder=null,this.sps=null,this.pps=null,this.frameCount=0,this.submitAt=new Map,this.spsLogged=!1}setDecodeSampler(t){this.decodeSampler=t}decode(t){const r=[];let o=!1;for(const h of Gs(new Uint8Array(t))){const p=h[0]&31;if(p===7){const g=!this.sps||h.length!==this.sps.length||h.some((x,f)=>x!==this.sps[f]);this.sps=h,g&&this.decoder&&(this.decoder.close(),this.decoder=null)}else p===8?this.pps=h:p>=1&&p<=5&&(p===5&&(o=!0),r.push(h))}if(o&&this.sps&&this.pps&&!this.decoder&&this.initDecoder(this.sps,this.pps),!this.decoder||r.length===0)return;let i=0;for(const h of r)i+=4+h.length;const a=new Uint8Array(i),c=new DataView(a.buffer);let u=0;for(const h of r)c.setUint32(u,h.length,!1),u+=4,a.set(h,u),u+=h.length;const d=Math.round(this.frameCount++*(1e6/30));if(this.decodeSampler&&(this.submitAt.set(d,performance.now()),this.submitAt.size>120)){const h=this.submitAt.keys().next().value;h!==void 0&&this.submitAt.delete(h)}try{this.decoder.decode(new EncodedVideoChunk({type:o?"key":"delta",timestamp:d,data:a}))}catch{}}sampleDecode(t){var o;if(!this.decodeSampler)return;const r=this.submitAt.get(t.timestamp);r!==void 0&&(this.submitAt.delete(t.timestamp),this.decodeSampler({decodeMs:performance.now()-r,queueSize:((o=this.decoder)==null?void 0:o.decodeQueueSize)??0}))}close(){var t;(t=this.decoder)==null||t.close(),this.decoder=null}logSpsVui(t){if(!(this.spsLogged||!this.decodeSampler)){this.spsLogged=!0;try{console.log("[sps-vui]",JSON.stringify(Ks(t)))}catch(r){console.warn("[sps-vui] parse failed",r)}}}initDecoder(t,r){this.logSpsVui(t);const o=Ys(t)??t,i=o[0]===0?o.subarray(4):o,a=`avc1.${i[1].toString(16).padStart(2,"0")}${i[2].toString(16).padStart(2,"0")}${i[3].toString(16).padStart(2,"0")}`,c=this.buildAVCC(o,r);this.decoder=new VideoDecoder({output:u=>{this.sampleDecode(u),this.onFrame(u)},error:u=>console.error("[WebCodecsCore]",u)}),this.decoder.configure({codec:a,description:c,optimizeForLatency:!0})}buildAVCC(t,r){const o=t[0]===0?t.subarray(4):t,i=r[0]===0?r.subarray(4):r,a=new Uint8Array(8+o.length+1+2+i.length);let c=0;return a[c++]=1,a[c++]=o[1],a[c++]=o[2],a[c++]=o[3],a[c++]=255,a[c++]=225,a[c++]=o.length>>8&255,a[c++]=o.length&255,a.set(o,c),c+=o.length,a[c++]=1,a[c++]=i.length>>8&255,a[c++]=i.length&255,a.set(i,c),a}}const Qs=`#version 300 es
107
+ in vec2 a_pos;
108
+ out vec2 v_uv;
109
+ void main() {
110
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
111
+ gl_Position = vec4(a_pos, 0.0, 1.0);
112
+ }`,Zs=`#version 300 es
113
+ precision mediump float;
114
+ in vec2 v_uv;
115
+ uniform sampler2D u_tex;
116
+ out vec4 out_color;
117
+ void main() {
118
+ out_color = texture(u_tex, v_uv);
119
+ }`;function eo(e){const t=e.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!t)return null;const r=(p,g)=>{const x=t.createShader(p);return t.shaderSource(x,g),t.compileShader(x),x},o=t.createProgram(),i=r(t.VERTEX_SHADER,Qs),a=r(t.FRAGMENT_SHADER,Zs);t.attachShader(o,i),t.attachShader(o,a),t.linkProgram(o),t.deleteShader(i),t.deleteShader(a),t.useProgram(o);const c=t.createVertexArray();t.bindVertexArray(c);const u=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,u),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const d=t.getAttribLocation(o,"a_pos");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),t.bindVertexArray(null);const h=t.createTexture();return t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.uniform1i(t.getUniformLocation(o,"u_tex"),0),{gl:t,program:o,tex:h,vao:c}}class to{constructor(t){this.canvas=t,this.state=null}init(){return this.state=eo(this.canvas),this.state!==null}drawFrame(t){const r=this.state;if(!r)return t.close(),null;const o=t.displayWidth,i=t.displayHeight;try{return(this.canvas.width!==o||this.canvas.height!==i)&&(this.canvas.width=o,this.canvas.height=i,r.gl.viewport(0,0,o,i)),r.gl.activeTexture(r.gl.TEXTURE0),r.gl.bindTexture(r.gl.TEXTURE_2D,r.tex),r.gl.texImage2D(r.gl.TEXTURE_2D,0,r.gl.RGBA,r.gl.RGBA,r.gl.UNSIGNED_BYTE,t),r.gl.bindVertexArray(r.vao),r.gl.drawArrays(r.gl.TRIANGLES,0,6),r.gl.bindVertexArray(null),r.gl.bindTexture(r.gl.TEXTURE_2D,null),{width:o,height:i}}finally{t.close()}}dispose(){const t=this.state;t&&(t.gl.deleteTexture(t.tex),t.gl.deleteVertexArray(t.vao),t.gl.deleteProgram(t.program),this.state=null)}}function no(e){const t=new to(e);return t.init(),t}class ro{constructor(t=no){this._size=null,this.canvas=document.createElement("canvas"),this.renderer=t(this.canvas),this.core=new Js(r=>this.render(r))}get surface(){return this.canvas}get size(){return this._size}onResize(t){this.resizeCb=t}onDecodedFrame(t){this.decodedCb=t,this.core.setDecodeSampler(r=>{this.lastSample=r})}decode(t){this.core.decode(t)}close(){this.core.close(),this.renderer.dispose()}render(t){var o,i;const r=this.renderer.drawFrame(t);r&&((o=this.decodedCb)==null||o.call(this,performance.now(),this.lastSample),this.lastSample=void 0,(!this._size||this._size.width!==r.width||this._size.height!==r.height)&&(this._size=r,(i=this.resizeCb)==null||i.call(this,r)))}}const so=`#version 300 es
120
+ in vec2 a_pos;
121
+ out vec2 v_uv;
122
+ void main() {
123
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
124
+ gl_Position = vec4(a_pos, 0.0, 1.0);
125
+ }`,oo=`#version 300 es
126
+ precision mediump float;
127
+ in vec2 v_uv;
128
+ uniform sampler2D u_texY;
129
+ uniform sampler2D u_texU;
130
+ uniform sampler2D u_texV;
131
+ out vec4 out_color;
132
+ void main() {
133
+ float Y = (texture(u_texY, v_uv).r - 0.0627451) * 1.1643836; // (y-16/255)*255/219
134
+ float U = (texture(u_texU, v_uv).r - 0.5019608) * 1.1383929; // (u-128/255)*255/224
135
+ float V = (texture(u_texV, v_uv).r - 0.5019608) * 1.1383929;
136
+ float r = Y + 1.5748 * V;
137
+ float g = Y - 0.1873 * U - 0.4681 * V;
138
+ float b = Y + 1.8556 * U;
139
+ out_color = vec4(r, g, b, 1.0);
140
+ }`;function Ht(e,t,r,o){const i=e.createTexture();return e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(e.getUniformLocation(o,r),t),i}function ao(e){const t=e.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!t)return null;const r=(x,f)=>{const b=t.createShader(x);return t.shaderSource(b,f),t.compileShader(b),b},o=t.createProgram(),i=r(t.VERTEX_SHADER,so),a=r(t.FRAGMENT_SHADER,oo);t.attachShader(o,i),t.attachShader(o,a),t.linkProgram(o),t.deleteShader(i),t.deleteShader(a),t.useProgram(o);const c=t.createVertexArray();t.bindVertexArray(c);const u=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,u),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const d=t.getAttribLocation(o,"a_pos");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),t.bindVertexArray(null),t.pixelStorei(t.UNPACK_ALIGNMENT,1);const h=Ht(t,0,"u_texY",o),p=Ht(t,1,"u_texU",o),g=Ht(t,2,"u_texV",o);return{gl:t,program:o,texY:h,texU:p,texV:g,vao:c}}class io{constructor(t){this.canvas=t,this.state=null}init(){return this.state=ao(this.canvas),this.state!==null}drawI420(t,r,o){const i=this.state;if(!i)return null;const{gl:a}=i,c=r+1>>1,u=o+1>>1,d=r*o,h=c*u,p=t.subarray(0,d),g=t.subarray(d,d+h),x=t.subarray(d+h,d+2*h);(this.canvas.width!==r||this.canvas.height!==o)&&(this.canvas.width=r,this.canvas.height=o,a.viewport(0,0,r,o));const f=(b,v,T,j,L)=>{a.activeTexture(a.TEXTURE0+b),a.bindTexture(a.TEXTURE_2D,v),a.texImage2D(a.TEXTURE_2D,0,a.R8,T,j,0,a.RED,a.UNSIGNED_BYTE,L)};return f(0,i.texY,r,o,p),f(1,i.texU,c,u,g),f(2,i.texV,c,u,x),a.bindVertexArray(i.vao),a.drawArrays(a.TRIANGLES,0,6),a.bindVertexArray(null),{width:r,height:o}}dispose(){const t=this.state;t&&(t.gl.deleteTexture(t.texY),t.gl.deleteTexture(t.texU),t.gl.deleteTexture(t.texV),t.gl.deleteVertexArray(t.vao),t.gl.deleteProgram(t.program),this.state=null)}}const co=0;function lo(e){const t=new io(e);return t.init(),t}function uo(){return new Worker(new URL("/assets/tinyh264.worker-DiJ50Hai.js",import.meta.url),{type:"module"})}class fo{constructor(t=lo,r=uo){this.ready=!1,this.pending=[],this._size=null,this.canvas=document.createElement("canvas"),this.renderer=t(this.canvas),this.worker=r(),this.worker.onmessage=o=>this.onMessage(o.data)}get surface(){return this.canvas}get size(){return this._size}onResize(t){this.resizeCb=t}onDecodedFrame(t){this.decodedCb=t}decode(t){if(!this.ready){this.pending.push(t);return}this.post(t)}close(){this.worker.terminate(),this.renderer.dispose()}post(t){this.worker.postMessage({type:"decode",data:t,offset:0,length:t.byteLength,renderStateId:co},[t])}onMessage(t){var o,i;if(t.type==="decoderReady"){this.ready=!0;for(const a of this.pending)this.post(a);this.pending.length=0;return}const r=this.renderer.drawI420(new Uint8Array(t.data),t.width,t.height);r&&((o=this.decodedCb)==null||o.call(this,performance.now()),(!this._size||this._size.width!==r.width||this._size.height!==r.height)&&(this._size=r,(i=this.resizeCb)==null||i.call(this,r)))}}function Jt(){const e=typeof window<"u";let t=!1;try{t=!!document.createElement("canvas").getContext("webgl2")}catch{t=!1}return{secureContext:e&&window.isSecureContext===!0,webCodecs:e&&"VideoDecoder"in window,webgl2:t,wasm:typeof WebAssembly<"u"&&typeof Worker<"u"}}function ho(e=Jt()){return e.secureContext&&e.webCodecs&&e.webgl2?new ro:e.wasm&&e.webgl2?new fo:null}function po(e=Jt()){return e.secureContext&&e.webCodecs&&e.webgl2||e.wasm&&e.webgl2}function mo(e=Jt()){return e.secureContext&&e.webCodecs&&e.webgl2?"high":e.wasm&&e.webgl2?"standard":"unsupported"}const go="https://www.tapflow.dev/reference/configuration#https-secure-context";function xo({open:e,onOpenChange:t}){return n.jsx(_n,{open:e,onOpenChange:t,children:n.jsxs(Pn,{className:"sm:max-w-[440px]",children:[n.jsxs(Fr,{children:[n.jsx(Dn,{children:"Streaming in Standard mode"}),n.jsxs(Or,{className:"space-y-3 pt-1",children:[n.jsx("span",{className:"block",children:"This screen is running in Standard mode. For a faster, smoother picture, switch to Smooth."}),n.jsx("span",{className:"block",children:"Smooth needs the relay served over HTTPS. If you didn't set up tapflow, ask whoever did."})]})]}),n.jsxs(Hr,{children:[n.jsx(ie,{variant:"outline",onClick:()=>window.open(go,"_blank","noopener,noreferrer"),children:"How to enable"}),n.jsx(ie,{onClick:()=>t(!1),children:"Got it"})]})]})})}const gn="tapflow.perfModeNoticeDismissed";function bo(e,t){return e==="standard"&&!t}const yo={high:"Smooth",standard:"Standard",unsupported:null};function vo(e){const{connected:t,joined:r,bootError:o,deviceReady:i,installing:a,installError:c,agentAway:u,decoderUnsupported:d}=e;return t?r?u?"The agent went away — waiting for it to come back…":o?`Boot failed: ${o.length>40?o.slice(0,40)+"…":o}`:i?a?"Installing app…":c?`Install failed: ${c}`:d?"Streaming is not supported in this environment.":null:"Starting device…":"Joining session…":"Connecting…"}function Qt(e){const{joined:t,fps:r,keyboardActive:o}=e,i=vo(e),a=r>15,c=a?"#10b981":"#94a3b8",u=a?"Active":"Idle",d=s.useMemo(()=>mo(),[]),h=yo[d],[p,g]=s.useState(!1);s.useEffect(()=>{let f=!1;try{f=localStorage.getItem(gn)==="1"}catch{}bo(d,f)&&g(!0)},[d]);const x=f=>{if(g(f),!f)try{localStorage.setItem(gn,"1")}catch{}};return n.jsxs("div",{className:"w-[300px] shrink-0 mt-3 rounded-xl border bg-background px-4 py-4 flex flex-col gap-3",children:[n.jsxs("div",{className:te("flex items-center",o?"text-emerald-500":"text-muted-foreground"),style:{gap:6},children:[n.jsx(ks,{className:"h-3.5 w-3.5 shrink-0"}),n.jsx("span",{className:"text-[12px] font-medium",children:"Focus"})]}),t&&n.jsxs("div",{className:"flex items-center gap-[12px]",children:[n.jsxs("div",{className:"flex items-center gap-[4px]",children:[n.jsx("span",{className:"h-2 w-2 rounded-full shrink-0 mr-1",style:{background:c}}),n.jsx("span",{className:"text-[12px] font-mono text-foreground/75",children:r}),n.jsx("span",{className:"text-[12px] text-muted-foreground",children:"fps"}),n.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"·"}),n.jsx("span",{className:te("text-[11px]",a?"text-emerald-500":"text-muted-foreground/60"),children:u})]}),h&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{orientation:"vertical",className:"h-3"}),d==="standard"?n.jsx("button",{type:"button",onClick:()=>g(!0),className:"text-[11px] text-foreground/70 hover:text-foreground underline-offset-2 hover:underline",children:h}):n.jsx("span",{className:"text-[11px] text-muted-foreground",children:h})]})]}),n.jsx("div",{role:"status",className:i?void 0:"sr-only",children:i&&n.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed break-words",children:i})}),n.jsx(xo,{open:p,onOpenChange:x})]})}function zn({open:e,onOpenChange:t,openUrl:r}){const[o,i]=s.useState(""),a=s.useRef(null);s.useEffect(()=>{e?setTimeout(()=>{var u;return(u=a.current)==null?void 0:u.focus()},0):i("")},[e]);const c=()=>{o.trim()&&(r(o.trim()),t(!1))};return n.jsx(_n,{open:e,onOpenChange:t,children:n.jsxs(Pn,{className:"w-[500px] max-w-[500px] h-[52px] !rounded-[18px] p-[10px] border border-border bg-background shadow-lg overflow-hidden [&>button]:hidden","aria-describedby":void 0,children:[n.jsx(Dn,{className:"sr-only",children:"Open Deeplink"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"flex-1 h-[32px] flex items-center gap-2 pl-[4px] pb-[1px]",children:[n.jsx(Cr,{className:"h-4 w-4 text-muted-foreground shrink-0","aria-hidden":"true"}),n.jsx("input",{ref:a,"aria-label":"Deeplink URL",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground min-w-0",placeholder:"myapp://home...",value:o,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()}})]}),n.jsx(ie,{size:"sm",disabled:!o.trim(),onClick:c,className:"shrink-0 rounded-xl h-8 px-4",children:"Open"})]})]})})}function wo(e,t,r,o,i,a){const{x:c,y:u,width:d,height:h}=i;let p,g;if(a){const x=(e.x-t.left)/t.width;p=(1-(e.y-t.top)/t.height)*r,g=x*o}else p=(e.x-t.left)*(r/t.width),g=(e.y-t.top)*(o/t.height);return p<c||p>c+d||g<u||g>u+h?null:{x:(p-c)/d,y:(g-u)/h}}function So(e,t,r){const o=(e.x-t.left)/t.width,i=(e.y-t.top)/t.height;return o<0||o>1||i<0||i>1?null:r?{x:i,y:1-o}:{x:o,y:i}}function Wn(e){return{f0:{x:1-e.x,y:1-e.y},f1:e}}function Ro(e,t){return e>0?Math.min(1,t/e):1}const Kt=22,xn=[84,70,70,69],ko=1,jo=0,It=1,Vn=2,Co=1,To=2,Eo=4;function No(e){if(e.byteLength<Kt)return null;const t=new DataView(e);for(let i=0;i<xn.length;i++)if(t.getUint8(i)!==xn[i])return null;if(t.getUint8(4)!==ko)return null;const r=t.getUint8(5),o=r&Eo?Vn:r&Co?It:jo;return{capturedAt:Number(t.getBigUint64(6)),relayedAt:Number(t.getBigUint64(14)),codec:o,keyframe:o===It&&(r&To)!==0}}function qn(e){const{binaryFrameHandlerRef:t,perfHookRef:r,frameCount:o}=e,i=s.useRef(e);s.useLayoutEffect(()=>{i.current=e},[e]),s.useEffect(()=>{let a=null,c=!1,u=!1,d;const h=()=>{if(a)return a;if(c)return null;const p=ho();return p?(a=p,p.onResize(g=>i.current.onResize(g)),d=i.current.onDecoderReady(p),p):(c=!0,i.current.onUnsupported(),console.warn("[decoder] none available — set up HTTPS or use a supported browser"),null)};return t.current=(p,g)=>{const x=i.current.onJpegFrame;if(x&&(g==null?void 0:g.codec)!==It){x(p,g);return}const f=h();if(f){if(!u){if(!(g!=null&&g.keyframe))return;u=!0}f.decode(p),o.current+=1}},()=>{t.current=void 0,typeof d=="function"&&d(),a==null||a.close(),a==null||a.surface.remove(),a=null}},[t,r,o])}const Ao=3e3+5*300,_o=Ao+500,_t=8;function Po(){var e;return window.isSecureContext&&typeof ClipboardItem<"u"&&!!((e=navigator.clipboard)!=null&&e.write)}class Rt extends Error{}function Do(e){const t=e.then(r=>new Blob([r],{type:"text/plain"}));return navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}function Zt(e){return!(e.metaKey||e.ctrlKey)||e.altKey?!1:e.code==="KeyV"?!0:!e.shiftKey&&(e.code==="KeyC"||e.code==="KeyX")}const Lo=1024*1024,Io=e=>new TextEncoder().encode(e).length,Mo=e=>{var t;return!!((t=e.payload)!=null&&t.unsupported)},Uo=e=>{var t,r;return((t=e.payload)==null?void 0:t.sentinelParked)===!1||((r=e.payload)==null?void 0:r.unsupported)===!0};function $o(){const e=window.getSelection();return!!e&&!e.isCollapsed&&e.toString().length>0}function bn(){const e=document.activeElement;return!!e&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)}function Xn({sessionId:e,send:t,active:r,supported:o,handlerRef:i,sendChord:a,onError:c}){const u=s.useRef(new Map),d=s.useRef(null),h=s.useRef(c);s.useLayoutEffect(()=>{h.current=c});const p=s.useCallback(x=>{var f;d.current!==x&&(d.current=x,(f=h.current)==null||f.call(h,x))},[]);s.useEffect(()=>(i.current=x=>{if(!x.requestId)return;const f=u.current.get(x.requestId);f&&(u.current.delete(x.requestId),f(x))},()=>{i.current=void 0}),[i]);const g=s.useCallback((...[x,f])=>{const b=X();return new Promise(v=>{const T=setTimeout(()=>{u.current.delete(b),v(null)},_o);u.current.set(b,j=>{clearTimeout(T),v(j)}),t({type:x,sessionId:e,requestId:b,payload:f})})},[t,e]);s.useEffect(()=>{if(!r||!o)return;const x=async b=>{if(b.code==="KeyV"||!Zt(b))return;const v=b.code==="KeyX";if(bn()||$o()||(b.preventDefault(),b.repeat))return;if(!Po()){a(v?"KeyX":"KeyC",_t),p("Copied on the device. Serving the dashboard over HTTPS also brings it to your clipboard.");return}let T,j;const L=new Promise((M,k)=>{T=M,j=k});L.catch(()=>{});const C=Do(L).catch(M=>{M instanceof Rt||p(M instanceof Error&&M.name==="NotAllowedError"?"Your browser blocked the clipboard write":"Could not write to your clipboard")}),N=await g("clipboard:read",{press:v?"cut":"copy"});if(!N){j(new Rt("timeout")),p("The device is taking too long — try again");return}if(N.type==="clipboard:error"){j(new Rt(N.message||"read failed")),p(N.message||"Clipboard read failed"),Uo(N)&&a(v?"KeyX":"KeyC",_t);return}if(N.type!=="clipboard:data"){j(new Rt("unexpected reply")),p("Clipboard read failed");return}const{text:E}=N.payload;if(d.current=null,!E){j(new Rt("empty"));return}T(E),await C},f=b=>{var T;if(bn())return;const v=((T=b.clipboardData)==null?void 0:T.getData("text"))??"";if(b.preventDefault(),!v){a("KeyV",_t);return}if(Io(v)>Lo){p("That text is too large to send to the device");return}g("clipboard:write",{text:v,pasteAfter:!0}).then(j=>{if(!j){p("The device is taking too long — try again");return}if(j.type==="clipboard:write-done"){d.current=null;return}if(j.type!=="clipboard:error"){p("Clipboard write failed");return}p(j.message||"Clipboard write failed"),Mo(j)&&a("KeyV",_t)})};return document.addEventListener("keydown",x),document.addEventListener("paste",f),()=>{document.removeEventListener("keydown",x),document.removeEventListener("paste",f)}},[r,o,g,a,p])}const ze=13,ut=8,yn=16,Bo=.02,Fo=100;function Oo({sessionId:e,buildId:t,send:r,openUrl:o,launchApp:i,connected:a,joined:c,deviceReady:u,installing:d,installed:h,installError:p,bootError:g,launching:x,chrome:f,binaryFrameHandlerRef:b,clipboardHandlerRef:v,clipboardSupported:T,networkHandlerRef:j,networkSupported:L,onRecordingUploaded:C,swKeyboardVisible:N,swKeyboardPending:E,onKbdToggle:M,rebootPending:k,onReboot:B,restartButtonRef:G,perfHookRef:z}){const F=s.useRef(null),Q=s.useRef(null),ue=s.useRef(null),{fps:Ie,frameCount:Fe}=$n(),be=s.useRef(0),{recordState:ye,recordCanvasRef:Z,startClientRecording:Ae,stopClientRecording:Oe}=Un({sessionId:e,buildId:t,onRecordingUploaded:C}),He=s.useRef(0),[Me,Ue]=s.useState(!1),[U,q]=s.useState(!1),[K,Se]=s.useState(!1),[J,Re]=s.useState(!1),[de,ee]=s.useState(!1),[We,rt]=s.useState(null),[Ve,fe]=s.useState(null),[ve,ke]=s.useState(!1),[Y,he]=s.useState(null),$e=s.useRef(Y);s.useEffect(()=>{$e.current=Y},[Y]);const ge=s.useRef(null),oe=s.useRef(null),re=s.useRef(!1),ae=s.useRef(!1),_e=s.useRef(0),Pe=s.useRef(null),je=s.useRef(null),we=s.useRef("idle"),w=s.useRef(null),H=s.useRef(null),ce=s.useRef(null);s.useEffect(()=>{ce.current=f},[f]),s.useEffect(()=>{const l=new Image;l.onload=()=>{H.current=l},l.src=`data:image/png;base64,${f.framePng}`},[f.framePng]),qn({binaryFrameHandlerRef:b,perfHookRef:z,frameCount:Fe,onUnsupported:()=>Se(!0),onResize:l=>{const y=F.current;if(y&&(y.width!==l.width||y.height!==l.height)&&(y.width=l.width,y.height=l.height,!ce.current)){const m=Z.current;m&&(m.width=l.width,m.height=l.height)}q(!0)},onDecoderReady:l=>{var S;const y=l.surface,m=F.current;y.style.position="absolute",m&&(y.style.left=m.style.left,y.style.top=m.style.top,y.style.width=m.style.width,y.style.height=m.style.height,y.style.borderRadius=m.style.borderRadius),y.style.objectFit="fill",y.style.zIndex="3",y.style.pointerEvents="none",(S=Q.current)==null||S.appendChild(y);let A=null;const P=()=>{const I=F.current,$=I==null?void 0:I.getContext("2d");if(I&&$&&l.size)try{$.drawImage(l.surface,0,0,I.width,I.height)}catch{}A=requestAnimationFrame(P)};return A=requestAnimationFrame(P),()=>{A!==null&&cancelAnimationFrame(A)}},onJpegFrame:l=>{const y=performance.now();be.current&&y-be.current,be.current=y;const m=He.current;createImageBitmap(new Blob([l],{type:"image/jpeg"})).then(A=>{if(performance.now()-y,He.current!==m){A.close();return}const P=F.current,S=P==null?void 0:P.getContext("2d");if(!P||!S){A.close();return}if((P.width!==A.width||P.height!==A.height)&&(P.width=A.width,P.height=A.height,!ce.current)){const $=Z.current;$&&($.width=A.width,$.height=A.height)}const I=performance.now();S.drawImage(A,0,0),performance.now()-I,A.close(),q(!0),Fe.current+=1}).catch(()=>{})}}),s.useEffect(()=>{const l=Z.current,y=Q.current;l&&y&&(l.width=y.clientWidth,l.height=y.clientHeight)},[f,Z]);const pe=s.useCallback(()=>{const l=Z.current,y=F.current;if(!l||!y)return;const m=l.getContext("2d");if(!m)return;const A=ce.current;if(m.clearRect(0,0,l.width,l.height),A){H.current&&m.drawImage(H.current,0,0,l.width,l.height);const I=Math.round(A.screenCornerRadius/2*(l.height/(A.compositeHeight/2)));m.save(),m.beginPath(),I>0?m.roundRect(y.offsetLeft,y.offsetTop,y.clientWidth,y.clientHeight,I):m.rect(y.offsetLeft,y.offsetTop,y.clientWidth,y.clientHeight),m.clip(),m.drawImage(y,y.offsetLeft,y.offsetTop,y.clientWidth,y.clientHeight),m.restore()}else m.drawImage(y,0,0,l.width,l.height);const P=$e.current;if(P)for(const I of[P.f0,P.f1]){const $=A?y.offsetLeft+I.x*y.clientWidth:I.x*l.width,le=A?y.offsetTop+I.y*y.clientHeight:I.y*l.height;re.current?(m.beginPath(),m.arc($,le,ut,0,Math.PI*2),m.fillStyle="rgba(255,255,255,0.92)",m.fill(),m.strokeStyle="rgba(0,0,0,0.2)",m.lineWidth=1,m.stroke()):(m.beginPath(),m.arc($,le,ze,0,Math.PI*2),m.strokeStyle="rgba(0,0,0,0.3)",m.lineWidth=3,m.stroke(),m.beginPath(),m.arc($,le,ze,0,Math.PI*2),m.strokeStyle="rgba(255,255,255,0.65)",m.lineWidth=1.5,m.stroke())}const S=je.current;if(S){const I=we.current,$=w.current;if(m.save(),I==="down")m.beginPath(),m.arc(S.x,S.y,ut,0,Math.PI*2),m.fillStyle="rgba(255,255,255,0.92)",m.fill(),m.strokeStyle="rgba(0,0,0,0.2)",m.lineWidth=1,m.stroke();else if(I==="release"&&$){const le=Math.min((performance.now()-$.startTime)/350,1);m.beginPath(),m.arc(S.x,S.y,ut+26*le,0,Math.PI*2),m.strokeStyle=`rgba(255,255,255,${(1-le)*.55})`,m.lineWidth=1.5,m.stroke(),le>=1&&(we.current="idle",w.current=null)}else m.beginPath(),m.arc(S.x,S.y,ze,0,Math.PI*2),m.strokeStyle="rgba(0,0,0,0.3)",m.lineWidth=3,m.stroke(),m.beginPath(),m.arc(S.x,S.y,ze,0,Math.PI*2),m.strokeStyle="rgba(255,255,255,0.65)",m.lineWidth=1.5,m.stroke();m.restore()}},[Z]),V=s.useCallback(()=>{const l=F.current;if(!l)return;const y=document.createElement("canvas"),m=y.getContext("2d");m&&(y.width=l.width,y.height=l.height,m.drawImage(l,0,0),y.toBlob(A=>{if(!A)return;const P=URL.createObjectURL(A),S=document.createElement("a");S.href=P,S.download=`tapflow-${Date.now()}.png`,S.click(),URL.revokeObjectURL(P)},"image/png"))},[]),me=s.useCallback(()=>{if(ye==="idle"){const l=Z.current;if(!l)return;const y=Q.current;if(y&&y.clientWidth>0)l.width=y.clientWidth,l.height=y.clientHeight;else{const m=F.current;if(m&&m.width>0)l.width=m.width,l.height=m.height;else return}Ae(pe)}else ye==="recording"&&Oe()},[ye,Ae,Oe,pe,Z]),qe=s.useCallback(()=>{r({type:"input:rotate",sessionId:e}),Re(l=>!l)},[r,e]),Nt=s.useRef(J);s.useEffect(()=>{Nt.current=J},[J]),s.useEffect(()=>()=>{Nt.current&&r({type:"input:rotate",sessionId:e})},[]);const Ut=s.useCallback((l,y)=>{r({type:"input:key",sessionId:e,requestId:X(),payload:{code:l,modifiers:y}})},[r,e]);Xn({sessionId:e,send:r,active:de,supported:T,handlerRef:v,sendChord:Ut,onError:l=>Ne.error(l)});const st=Fn({sessionId:e,send:r,supported:L,deviceReady:u,handlerRef:j,onError:l=>Ne.error(l)});s.useEffect(()=>{const l=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),y=S=>{if(S.code==="AltLeft"||S.code==="AltRight"){ae.current=!0;return}if(S.metaKey){const $=document.activeElement;if(!$||$.tagName!=="INPUT"&&$.tagName!=="TEXTAREA"){if(!S.shiftKey&&S.code==="KeyK"){S.preventDefault(),Ue(!0);return}if(!S.shiftKey&&S.code==="KeyS"){S.preventDefault(),V();return}if(S.shiftKey&&S.code==="KeyY"){S.preventDefault(),me();return}if(S.shiftKey&&S.code==="KeyO"){S.preventDefault(),qe();return}if(S.shiftKey&&S.code==="KeyU"){S.preventDefault(),r({type:"input:button",sessionId:e,requestId:X(),payload:{name:"home"}});return}if(S.shiftKey&&S.code==="KeyK"){S.preventDefault(),E||M();return}}}if(!de||l.has(S.code)||T&&Zt(S))return;S.preventDefault();const I=(S.shiftKey?2:0)|(S.ctrlKey?1:0)|(S.metaKey?8:0);r({type:"input:key",sessionId:e,requestId:X(),payload:{code:S.code,modifiers:I}})},m=()=>{re.current&&(re.current=!1,ke(!1),r({type:"input:pinch:end",sessionId:e,requestId:X()})),ae.current=!1,he(null)},A=S=>{(S.code==="AltLeft"||S.code==="AltRight")&&m()},P=()=>{ae.current&&m()};return window.addEventListener("keydown",y),window.addEventListener("keyup",A),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",A),window.removeEventListener("blur",P)}},[de,T,r,e,V,me,qe,M,E]),s.useEffect(()=>{if(!de)return;const l=y=>{const m=Q.current??F.current;m&&!m.contains(y.target)&&ee(!1)};return document.addEventListener("pointerdown",l),()=>document.removeEventListener("pointerdown",l)},[de]);const Xe=s.useCallback(l=>{const y=(J?ue.current:null)??Q.current;if(!y)return null;const m=y.getBoundingClientRect(),A=f.compositeWidth/2,P=f.compositeHeight/2,S=f.screenRect.x/2,I=f.screenRect.y/2,$=f.screenRect.width/2,le=f.screenRect.height/2;return wo({x:l.clientX,y:l.clientY},m,A,P,{x:S,y:I,width:$,height:le},J)},[f,J]),ot=s.useCallback(l=>{const y=Xe(l);return y?Wn(y):null},[Xe]),xe=s.useCallback(l=>{const y=J?ue.current:Q.current;if(!y)return null;const m=y.getBoundingClientRect();let A,P;if(J){const I=m.height-(l.clientY-m.top),$=l.clientX-m.left;A=I*(f.compositeWidth/m.height),P=$*(f.compositeHeight/m.width)}else A=(l.clientX-m.left)*(f.compositeWidth/m.width),P=(l.clientY-m.top)*(f.compositeHeight/m.height);const S=f.screenRect;return A>=S.x&&A<=S.x+S.width&&P>=S.y&&P<=S.y+S.height?null:$s(A,P,f.buttons,Fo)},[f,J]),Ge=s.useCallback(l=>{const y=F.current,m=Z.current;return y&&y.clientWidth>0?{x:y.offsetLeft+l.x*y.clientWidth,y:y.offsetTop+l.y*y.clientHeight}:{x:l.x*((m==null?void 0:m.width)??1),y:l.y*((m==null?void 0:m.height)??1)}},[Z]),Je=s.useCallback(l=>{if(ee(!0),ae.current){const S=ot(l);if(!S)return;re.current=!0,ke(!0),l.target.setPointerCapture(l.pointerId),he(S),r({type:"input:pinch:start",sessionId:e,payload:S});return}const y=xe(l);if(y){ge.current=y,rt(y),l.target.setPointerCapture(l.pointerId),r({type:"input:button",sessionId:e,requestId:X(),payload:{name:y,phase:"down"}});return}const m=Xe(l);if(!m)return;oe.current=m,l.target.setPointerCapture(l.pointerId),je.current=Ge(m),we.current="down",w.current=null;const A=l.currentTarget.getBoundingClientRect(),P=Pe.current;P&&(P.style.display="block",P.style.left=`${l.clientX-A.left}px`,P.style.top=`${l.clientY-A.top}px`,P.style.width=`${ut*2}px`,P.style.height=`${ut*2}px`,P.style.background="rgba(255,255,255,0.92)",P.style.border="1.5px solid rgba(0,0,0,0.2)",P.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"),r({type:"input:touch:start",sessionId:e,payload:m})},[xe,Xe,ot,Ge,r,e]),at=s.useCallback(l=>{if(l.buttons===0){if(fe(xe(l)),ae.current){he(ot(l)),je.current=null;const I=Pe.current;I&&(I.style.display="none")}else{he(null);const I=Xe(l);je.current=I?Ge(I):null,we.current!=="down"&&(we.current="idle");const $=Pe.current;if($)if(I){const le=l.currentTarget.getBoundingClientRect();$.style.display="block",$.style.left=`${l.clientX-le.left}px`,$.style.top=`${l.clientY-le.top}px`,$.style.width=`${ze*2}px`,$.style.height=`${ze*2}px`,$.style.background="transparent",$.style.border="1.5px solid rgba(255,255,255,0.6)",$.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"}else $.style.display="none"}return}if(re.current){const I=ot(l);if(!I)return;const $=performance.now();if($-_e.current<yn)return;_e.current=$,he(I),r({type:"input:pinch:move",sessionId:e,payload:I});return}if(ge.current||!oe.current)return;const y=Xe(l);if(!y)return;const m=y.x-oe.current.x,A=y.y-oe.current.y;if(Math.sqrt(m*m+A*A)<Bo)return;const P=performance.now();if(P-_e.current<yn)return;_e.current=P,je.current=Ge(y);const S=Pe.current;if(S&&S.style.display!=="none"){const I=l.currentTarget.getBoundingClientRect();S.style.left=`${l.clientX-I.left}px`,S.style.top=`${l.clientY-I.top}px`}r({type:"input:touch:move",sessionId:e,payload:y})},[xe,Xe,ot,Ge,r,e]),$t=s.useCallback(()=>{if(re.current){re.current=!1,ke(!1),he(null),r({type:"input:pinch:end",sessionId:e,requestId:X()});return}if(oe.current=null,ge.current){r({type:"input:button",sessionId:e,requestId:X(),payload:{name:ge.current,phase:"up"}}),ge.current=null,setTimeout(()=>rt(null),100);return}we.current="release",w.current={startTime:performance.now()};const l=Pe.current;l&&(l.style.width=`${ze*2}px`,l.style.height=`${ze*2}px`,l.style.background="transparent",l.style.border="1.5px solid rgba(255,255,255,0.6)",l.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),r({type:"input:touch:end",sessionId:e,requestId:X()})},[r,e]),Qe=s.useCallback(()=>{if(re.current){re.current=!1,ke(!1),he(null),r({type:"input:pinch:end",sessionId:e,requestId:X()});return}if(oe.current=null,ge.current){r({type:"input:button",sessionId:e,requestId:X(),payload:{name:ge.current,phase:"up"}}),ge.current=null,rt(null);return}we.current="release",w.current={startTime:performance.now()},r({type:"input:touch:end",sessionId:e,requestId:X()})},[r,e]),Bt=s.useCallback(()=>{fe(null),he(null),je.current=null;const l=Pe.current;l&&(l.style.display="none")},[]),Ft=f.compositeWidth/2,vt=f.compositeHeight/2,wt=Ro(vt,750),it=Math.round(Ft*wt),ct=Math.round(vt*wt),lt=f.screenRect.x/f.compositeWidth*100,mt=f.screenRect.y/f.compositeHeight*100,gt=f.screenRect.width/f.compositeWidth*100,xt=f.screenRect.height/f.compositeHeight*100,R=Math.round(f.screenCornerRadius/2*wt),D=n.jsx(n.Fragment,{children:n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Home",onClick:()=>r({type:"input:button",sessionId:e,requestId:X(),payload:{name:"home"}}),children:n.jsx(Ln,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsxs("span",{className:"flex items-center gap-3",children:["Home ",n.jsxs(qt,{children:[n.jsx(ft,{children:"⌘"}),n.jsx(ft,{children:"⇧"}),n.jsx(ft,{children:"U"})]})]})})]})}),W=s.useId(),_=n.jsxs(n.Fragment,{children:[n.jsx("span",{id:W,role:"status",className:"sr-only",children:E?"Changing the software keyboard.":N?"The software keyboard is up.":"The software keyboard is down."}),n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":E?"Software keyboard — changing it":"Software keyboard","aria-pressed":N,"aria-busy":E,"aria-disabled":E,"aria-describedby":W,onClick:()=>{E||M()},"data-active":N,children:E?n.jsx(yt,{className:"h-4 w-4 animate-spin"}):n.jsx(ls,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:E?n.jsx("span",{children:"Software keyboard — changing it"}):n.jsxs("span",{className:"flex items-center gap-3",children:["Software keyboard ",n.jsxs(qt,{children:[n.jsx(ft,{children:"⌘"}),n.jsx(ft,{children:"⇧"}),n.jsx(ft,{children:"K"})]})]})})]})]}),se=h&&t?n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:x,"aria-label":"Launch app",onClick:i,children:x?n.jsx(yt,{className:"h-4 w-4 animate-spin"}):n.jsx(En,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:x?"Launching…":"Launch app"})]}):null;return n.jsxs("div",{role:"region","aria-label":"Device screen",className:"flex items-start justify-center gap-16",children:[n.jsx("canvas",{ref:Z,style:{display:"none"}}),n.jsx(zn,{open:Me,onOpenChange:Ue,openUrl:o}),n.jsx(Bn,{joined:c,onDeepLink:()=>Ue(!0),onScreenshot:V,onRecordToggle:me,recordState:ye,onRotate:qe,navigationSlot:D,deviceSlot:_,launchSlot:se,network:L?{position:st.position,steerable:st.steerable,reason:st.reason,pending:st.pending,onToggle:st.toggle}:void 0,reboot:{pending:k,onReboot:B,buttonRef:G}}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsxs("div",{ref:ue,style:{width:J?ct:it,height:J?it:ct,position:"relative",flexShrink:0},children:[n.jsxs("div",{ref:Q,className:`relative ${Ve?"cursor-pointer":"cursor-default"}`,style:{width:it,height:ct,...J?{position:"absolute",top:(it-ct)/2,left:(ct-it)/2,transform:"rotate(-90deg)",transformOrigin:"center center"}:{}},onPointerDown:Je,onPointerMove:at,onPointerUp:$t,onPointerCancel:Qe,onPointerLeave:Bt,children:[n.jsx("img",{src:`data:image/png;base64,${f.framePng}`,style:{position:"absolute",top:0,left:0,zIndex:2,width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),n.jsx("canvas",{ref:F,style:{position:"absolute",zIndex:3,left:`${lt}%`,top:`${mt}%`,width:`${gt}%`,height:`${xt}%`,borderRadius:R>0?`${R}px`:void 0,backgroundColor:"#010101",cursor:"none",visibility:U?"visible":"hidden"}}),!U&&n.jsx("div",{className:"absolute animate-pulse bg-zinc-700",style:{zIndex:3,left:`${lt}%`,top:`${mt}%`,width:`${gt}%`,height:`${xt}%`,borderRadius:R>0?`${R}px`:void 0}}),Y&&(()=>{const l=lt/100,y=mt/100,m=gt/100,A=xt/100,P=(S,I)=>({left:`${(l+S*m)*100}%`,top:`${(y+I*A)*100}%`});return n.jsx(n.Fragment,{children:[Y.f0,Y.f1].map((S,I)=>n.jsx("div",{style:{position:"absolute",zIndex:10,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease",...ve?{width:ut*2,height:ut*2,background:"rgba(255,255,255,0.92)",border:"1.5px solid rgba(0,0,0,0.2)",boxShadow:"0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"}:{width:ze*2,height:ze*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"},...P(S.x,S.y)}},I))})})(),c&&Ie===0&&n.jsx("div",{style:{position:"absolute",zIndex:8,left:`${lt}%`,top:`${mt}%`,width:`${gt}%`,height:`${xt}%`,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:n.jsx("span",{style:{color:"white",fontSize:"0.875rem"},children:"Waiting for first frame..."})}),f.buttons.map(l=>{const y=We===l.name,m=Ve===l.name,A=l.anchor==="top",P=Mn(l),S=P.top/f.compositeHeight*100,I=l.buttonH/f.compositeHeight*100,$=l.buttonW/f.compositeWidth*100,le=l.buttonW/2,De=P.left/f.compositeWidth*100,Be=(2*l.rolloverOffset.x-l.normalOffset.x-le)/f.compositeWidth*100,Ze=l.rolloverOffset.x/f.compositeWidth*100,At=S,bt=A?(2*l.rolloverOffset.y-l.normalOffset.y)/f.compositeHeight*100:0,pr=l.onTop?4:1;return n.jsxs(s.Fragment,{children:[l.buttonPng&&n.jsx("img",{src:`data:image/png;base64,${l.buttonPng}`,style:{position:"absolute",zIndex:pr,top:`${A&&m?bt:S}%`,left:`${A?De:m?Be:De}%`,width:`${$}%`,height:`${I}%`,transition:A?"top 0.15s ease":"left 0.15s ease",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),y&&l.pressedPng&&l.pressedRect&&n.jsx("img",{src:`data:image/png;base64,${l.pressedPng}`,style:{position:"absolute",zIndex:l.onTop?3:1,left:`${A?De:m?Be:De}%`,top:`${A&&m?bt:S}%`,width:`${l.pressedRect.width/f.compositeWidth*100}%`,height:`${l.pressedRect.height/f.compositeHeight*100}%`,pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),m&&n.jsx("div",{className:"bg-foreground/85 text-background text-[11px] px-[7px] py-1.5 rounded-lg whitespace-nowrap pointer-events-none",style:{position:"absolute",zIndex:5,left:`${Ze}%`,top:`${At}%`,transform:"translate(-50%, calc(-100% - 8px))"},children:l.accessibilityTitle})]},l.name)})]}),n.jsx("div",{ref:Pe,style:{display:"none",position:"absolute",zIndex:20,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease, box-shadow 0.1s ease"}})]}),n.jsx(Qt,{joined:c,fps:Ie,connected:a,deviceReady:u,bootError:g,installing:d,installError:p,decoderUnsupported:K,keyboardActive:de})]})]})}const dt=13,kt=8,vn=16,Ho=.02,zt=720;function zo({sessionId:e,buildId:t,send:r,openUrl:o,launchApp:i,connected:a,joined:c,deviceReady:u,installing:d,installed:h,installError:p,bootError:g,launching:x,androidButtons:f,binaryFrameHandlerRef:b,clipboardHandlerRef:v,clipboardSupported:T,networkHandlerRef:j,networkSupported:L,onRecordingUploaded:C,rebootPending:N,onReboot:E,restartButtonRef:M,screenWidth:k,screenHeight:B,cornerRadius:G,perfHookRef:z}){const F=s.useRef(null),Q=s.useRef(null),ue=s.useRef(null),{fps:Ie,frameCount:Fe}=$n(),{recordState:be,recordCanvasRef:ye,startClientRecording:Z,stopClientRecording:Ae}=Un({sessionId:e,buildId:t,onRecordingUploaded:C}),[Oe,He]=s.useState(!1),[Me,Ue]=s.useState(!1),[U,q]=s.useState(!1),K=s.useRef(null),[Se,J]=s.useState(null),[Re,de]=s.useState(!1),[ee,We]=s.useState(!1),[rt,Ve]=s.useState(!1),[fe,ve]=s.useState(null),ke=s.useRef(fe);s.useEffect(()=>{ke.current=fe},[fe]);const Y=s.useRef(!1),he=s.useRef(!1),$e=s.useRef(null),ge=s.useRef(0),oe=s.useRef(null),re=s.useRef(null),ae=s.useRef("idle"),_e=s.useRef(null);qn({binaryFrameHandlerRef:b,perfHookRef:z,frameCount:Fe,onUnsupported:()=>q(!0),onResize:R=>{Ue(!0);const D=K.current;(!D||D.width!==R.width||D.height!==R.height)&&(K.current=R,J(R))},onDecoderReady:R=>{var W;ue.current=R;const D=R.surface;D.style.display="block",D.style.width="100%",D.style.height="100%",D.style.objectFit="fill",(W=F.current)==null||W.appendChild(D)}});const Pe=s.useCallback(()=>{var le;const R=ye.current,D=(le=ue.current)==null?void 0:le.surface,W=K.current;if(!R||!D||!W)return;const _=R.getContext("2d");if(!_)return;const se=W.width,l=W.height,y=R.width>R.height!=se>l;_.save(),y&&(_.translate(R.width,0),_.rotate(Math.PI/2)),_.drawImage(D,0,0,se,l);const m=Math.max(se,l),A=m>zt?m/zt:1,P=dt*A,S=kt*A,I=ke.current;if(I)for(const De of[I.f0,I.f1]){const Be=De.x*se,Ze=De.y*l;Y.current?(_.beginPath(),_.arc(Be,Ze,S,0,Math.PI*2),_.fillStyle="rgba(255,255,255,0.92)",_.fill(),_.strokeStyle="rgba(0,0,0,0.2)",_.lineWidth=A,_.stroke()):(_.beginPath(),_.arc(Be,Ze,P,0,Math.PI*2),_.strokeStyle="rgba(0,0,0,0.3)",_.lineWidth=3*A,_.stroke(),_.beginPath(),_.arc(Be,Ze,P,0,Math.PI*2),_.strokeStyle="rgba(255,255,255,0.65)",_.lineWidth=1.5*A,_.stroke())}const $=re.current;if($){const De=$.x*se,Be=$.y*l,Ze=ae.current,At=_e.current;if(Ze==="down")_.beginPath(),_.arc(De,Be,S,0,Math.PI*2),_.fillStyle="rgba(255,255,255,0.92)",_.fill(),_.strokeStyle="rgba(0,0,0,0.2)",_.lineWidth=A,_.stroke();else if(Ze==="release"&&At){const bt=Math.min((performance.now()-At.startTime)/350,1);_.beginPath(),_.arc(De,Be,S+26*A*bt,0,Math.PI*2),_.strokeStyle=`rgba(255,255,255,${(1-bt)*.55})`,_.lineWidth=1.5*A,_.stroke(),bt>=1&&(ae.current="idle",_e.current=null)}else _.beginPath(),_.arc(De,Be,P,0,Math.PI*2),_.strokeStyle="rgba(0,0,0,0.3)",_.lineWidth=3*A,_.stroke(),_.beginPath(),_.arc(De,Be,P,0,Math.PI*2),_.strokeStyle="rgba(255,255,255,0.65)",_.lineWidth=1.5*A,_.stroke()}_.restore()},[ye]),je=s.useCallback(()=>{var se;const R=(se=ue.current)==null?void 0:se.surface,D=K.current;if(!R||!D)return;const W=document.createElement("canvas"),_=W.getContext("2d");_&&(W.width=D.width,W.height=D.height,_.drawImage(R,0,0,D.width,D.height),W.toBlob(l=>{if(!l)return;const y=URL.createObjectURL(l),m=document.createElement("a");m.href=y,m.download=`tapflow-${Date.now()}.png`,m.click(),URL.revokeObjectURL(y)},"image/png"))},[]),we=s.useCallback(()=>{if(be==="idle"){const R=ye.current;if(!R)return;const D=K.current;if(!D)return;const W=V.current;R.width=W?D.height:D.width,R.height=W?D.width:D.height,Z(Pe)}else be==="recording"&&Ae()},[be,Z,Ae,Pe,ye]),w=s.useCallback(()=>{r({type:"input:rotate",sessionId:e}),de(R=>!R)},[r,e]),H=s.useRef(Re);s.useEffect(()=>{H.current=Re},[Re]),s.useEffect(()=>()=>{H.current&&r({type:"input:rotate",sessionId:e})},[]);const ce=s.useCallback((R,D)=>{r({type:"input:key",sessionId:e,requestId:X(),payload:{code:R,modifiers:D}})},[r,e]);Xn({sessionId:e,send:r,active:ee,supported:T,handlerRef:v,sendChord:ce,onError:R=>Ne.error(R)});const pe=Fn({sessionId:e,send:r,supported:L,deviceReady:u,handlerRef:j,onError:R=>Ne.error(R)});s.useEffect(()=>{const R=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),D=l=>{if(l.code==="AltLeft"||l.code==="AltRight"){he.current=!0;return}if(l.metaKey){const m=document.activeElement;if(!m||m.tagName!=="INPUT"&&m.tagName!=="TEXTAREA"){if(!l.shiftKey&&l.code==="KeyK"){l.preventDefault(),He(!0);return}if(!l.shiftKey&&l.code==="KeyS"){l.preventDefault(),je();return}if(l.shiftKey&&l.code==="KeyY"){l.preventDefault(),we();return}if(l.shiftKey&&l.code==="KeyO"){l.preventDefault(),w();return}}}if(!ee||R.has(l.code)||T&&Zt(l))return;l.preventDefault();const y=(l.shiftKey?2:0)|(l.ctrlKey?1:0)|(l.metaKey?8:0);r({type:"input:key",sessionId:e,requestId:X(),payload:{code:l.code,modifiers:y}})},W=()=>{Y.current&&(Y.current=!1,Ve(!1),r({type:"input:pinch:end",sessionId:e,requestId:X()})),he.current=!1,ve(null)},_=l=>{(l.code==="AltLeft"||l.code==="AltRight")&&W()},se=()=>{he.current&&W()};return window.addEventListener("keydown",D),window.addEventListener("keyup",_),window.addEventListener("blur",se),()=>{window.removeEventListener("keydown",D),window.removeEventListener("keyup",_),window.removeEventListener("blur",se)}},[ee,T,r,e,je,we,w]),s.useEffect(()=>{if(!ee)return;const R=D=>{const W=Q.current??F.current;W&&!W.contains(D.target)&&We(!1)};return document.addEventListener("pointerdown",R),()=>document.removeEventListener("pointerdown",R)},[ee]);const V=s.useRef(!1),me=s.useCallback(R=>{const D=F.current;if(!D)return null;const W=D.getBoundingClientRect();return So({x:R.clientX,y:R.clientY},W,V.current)},[]),qe=s.useCallback(R=>{const D=me(R);return D?Wn(D):null},[me]),Nt=s.useCallback(R=>{if(he.current){const se=qe(R);if(!se)return;Y.current=!0,Ve(!0),R.target.setPointerCapture(R.pointerId);const l=oe.current;l&&(l.style.display="none"),ve(se),r({type:"input:pinch:start",sessionId:e,payload:se});return}const D=me(R);if(!D)return;We(!0),$e.current=D,R.target.setPointerCapture(R.pointerId);const W=R.currentTarget.getBoundingClientRect();re.current=D,ae.current="down",_e.current=null;const _=oe.current;_&&(_.style.display="block",_.style.left=`${R.clientX-W.left}px`,_.style.top=`${R.clientY-W.top}px`,_.style.width=`${kt*2}px`,_.style.height=`${kt*2}px`,_.style.background="rgba(255,255,255,0.92)",_.style.border="1.5px solid rgba(0,0,0,0.2)",_.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"),r({type:"input:touch:start",sessionId:e,payload:D})},[me,qe,r,e]),Ut=s.useCallback(R=>{if(R.buttons===0){if(he.current){ve(qe(R)),re.current=null;const S=oe.current;S&&(S.style.display="none");return}const m=me(R),A=R.currentTarget.getBoundingClientRect(),P=oe.current;m?(re.current=m,ae.current!=="down"&&(ae.current="idle"),P&&(P.style.display="block",P.style.left=`${R.clientX-A.left}px`,P.style.top=`${R.clientY-A.top}px`,P.style.width=`${dt*2}px`,P.style.height=`${dt*2}px`,P.style.background="transparent",P.style.border="1.5px solid rgba(255,255,255,0.6)",P.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)")):(re.current=null,P&&(P.style.display="none"));return}if(Y.current){const m=qe(R);if(!m)return;const A=performance.now();if(A-ge.current<vn)return;ge.current=A,ve(m),r({type:"input:pinch:move",sessionId:e,payload:m});return}if(!$e.current)return;const D=me(R);if(!D)return;const W=D.x-$e.current.x,_=D.y-$e.current.y;if(Math.sqrt(W*W+_*_)<Ho)return;const se=performance.now();if(se-ge.current<vn)return;ge.current=se;const l=R.currentTarget.getBoundingClientRect();re.current=D;const y=oe.current;y&&y.style.display!=="none"&&(y.style.left=`${R.clientX-l.left}px`,y.style.top=`${R.clientY-l.top}px`),r({type:"input:touch:move",sessionId:e,payload:D})},[me,qe,r,e]),st=s.useCallback(()=>{if(Y.current){Y.current=!1,Ve(!1),ve(null),r({type:"input:pinch:end",sessionId:e,requestId:X()});return}$e.current=null,ae.current="release",_e.current={startTime:performance.now()};const R=oe.current;R&&(R.style.width=`${dt*2}px`,R.style.height=`${dt*2}px`,R.style.background="transparent",R.style.border="1.5px solid rgba(255,255,255,0.6)",R.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),r({type:"input:touch:end",sessionId:e,requestId:X()})},[r,e]),Xe=s.useCallback(()=>{if(Y.current){Y.current=!1,Ve(!1),ve(null),r({type:"input:pinch:end",sessionId:e,requestId:X()});return}$e.current=null,ae.current="release",_e.current={startTime:performance.now()},r({type:"input:touch:end",sessionId:e,requestId:X()})},[r,e]),ot=s.useCallback(()=>{ve(null),re.current=null;const R=oe.current;R&&(R.style.display="none")},[]),xe=Se??(k&&B?{width:k,height:B}:null),Ge=xe?Math.min(1,zt/Math.max(xe.width,xe.height)):.3,Je=xe?Math.round(xe.width*Ge):324,at=xe?Math.round(xe.height*Ge):720,$t=xe?xe.width>xe.height:!1,Qe=Re&&!$t;s.useLayoutEffect(()=>{V.current=Qe},[Qe]);const Bt=Qe?at:Je,Ft=Qe?Je:at,vt=G!=null?Math.round(G*Je):22,cn=Qe?{position:"absolute",width:Je,height:at,top:(Je-at)/2,left:(at-Je)/2,transform:"rotate(90deg)",transformOrigin:"center center",visibility:Me?"visible":"hidden",cursor:"none"}:{visibility:Me?"visible":"hidden",cursor:"none"},wt=["home","back","recent_apps"],it=["volume_up","volume_down","power"],ct=R=>R==="back"?n.jsx(Gr,{className:"h-4 w-4"}):R==="recent_apps"?n.jsx(mr,{className:"h-4 w-4"}):R==="volume_up"?n.jsx(Ps,{className:"h-4 w-4"}):R==="volume_down"?n.jsx(As,{className:"h-4 w-4"}):R==="power"?n.jsx(ms,{className:"h-4 w-4"}):n.jsx(Ln,{className:"h-4 w-4"}),lt=R=>n.jsx(n.Fragment,{children:R.map(D=>f==null?void 0:f.find(W=>W.name===D)).filter(D=>D!==void 0).map(D=>n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":D.accessibilityTitle,onClick:()=>r({type:"input:button",sessionId:e,requestId:X(),payload:{name:D.name}}),children:ct(D.name)})}),n.jsx(Ee,{side:"left",children:D.accessibilityTitle})]},D.name))}),mt=lt(wt),gt=lt(it),xt=h&&t?n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:x||d,"aria-label":"Launch app",onClick:i,children:x?n.jsx(yt,{className:"h-4 w-4 animate-spin"}):n.jsx(En,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:x?"Launching…":d?"Installing…":"Launch app"})]}):null;return n.jsxs("div",{role:"region","aria-label":"Device screen",className:"flex items-start justify-center gap-16",children:[n.jsx("canvas",{ref:ye,style:{display:"none"}}),n.jsx(zn,{open:Oe,onOpenChange:He,openUrl:o}),n.jsx(Bn,{joined:c,onDeepLink:()=>He(!0),onScreenshot:je,onRecordToggle:we,recordState:be,onRotate:w,navigationSlot:mt,deviceSlot:gt,launchSlot:xt,network:L?{position:pe.position,steerable:pe.steerable,reason:pe.reason,pending:pe.pending,onToggle:pe.toggle}:void 0,reboot:{pending:N,onReboot:E,buttonRef:M}}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsx("div",{style:{background:"#1c1c1e",borderRadius:`${vt+12}px`,padding:"12px",flexShrink:0,boxShadow:"0 8px 32px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06)"},children:n.jsx("div",{ref:Q,className:"relative",style:{width:Bt,height:Ft,backgroundColor:"#010101",borderRadius:`${vt}px`,overflow:"hidden"},children:!U&&n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:F,className:Qe?void 0:"block w-full h-full",style:cn,onPointerDown:Nt,onPointerMove:Ut,onPointerUp:st,onPointerCancel:Xe,onPointerLeave:ot}),!Me&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-zinc-700"}),!Me&&u&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:n.jsx("span",{style:{color:"rgba(255,255,255,0.6)",fontSize:"0.875rem"},children:"Waiting for stream…"})}),n.jsx("div",{ref:oe,style:{display:"none",position:"absolute",zIndex:20,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease, box-shadow 0.1s ease"}}),fe&&n.jsx(n.Fragment,{children:[fe.f0,fe.f1].map((R,D)=>n.jsx("div",{style:{position:"absolute",zIndex:10,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease",left:`${R.x*100}%`,top:`${R.y*100}%`,...rt?{width:kt*2,height:kt*2,background:"rgba(255,255,255,0.92)",border:"1.5px solid rgba(0,0,0,0.2)",boxShadow:"0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"}:{width:dt*2,height:dt*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"}}},D))})]})})}),n.jsx(Qt,{joined:c,fps:Ie,connected:a,deviceReady:u,bootError:g,installing:d,installError:p,decoderUnsupported:U,keyboardActive:ee})]})]})}function Wo(e,t){const r=new DataView(e),o=Math.floor(e.byteLength/2),i=Math.floor(o/t),a=[];for(let c=0;c<t;c++)a.push(new Float32Array(i));for(let c=0;c<i;c++)for(let u=0;u<t;u++){const d=r.getInt16((c*t+u)*2,!0);a[u][c]=d/32768}return a}const Vo=44100,Wt=2,wn=.06,qo=.3;function Xo(){const e=s.useRef(null),t=s.useRef(0),r=s.useCallback(()=>{if(e.current)return e.current;const i=window.AudioContext??window.webkitAudioContext;return i?(e.current=new i,e.current):null},[]),o=s.useCallback(i=>{var x;const a=r();if(!a)return;a.state==="suspended"&&a.resume();const c=Wo(i,Wt),u=((x=c[0])==null?void 0:x.length)??0;if(u===0)return;const d=a.createBuffer(Wt,u,Vo);for(let f=0;f<Wt;f++)d.getChannelData(f).set(c[f]);const h=a.createBufferSource();h.buffer=d,h.connect(a.destination);const p=a.currentTime;let g=t.current;(g<p+.005||g>p+qo+wn)&&(g=p+wn),h.start(g),t.current=g+d.duration},[r]);return s.useEffect(()=>()=>{var i;(i=e.current)==null||i.close(),e.current=null},[]),{pushFrame:o}}const Ko=2e4;function Yo({sessionId:e,deviceId:t,deviceReady:r,send:o,handlerRef:i,onShutdownComplete:a,onError:c}){const[u,d]=s.useState(!1),h=s.useRef(null),p=s.useRef(a),g=s.useRef(c);s.useEffect(()=>{p.current=a},[a]),s.useEffect(()=>{g.current=c},[c]),s.useEffect(()=>{d(!1),h.current=null},[e]),s.useEffect(()=>{r||(d(!1),h.current=null)},[r]),s.useEffect(()=>(i.current=v=>{if(v.requestId===h.current){if(h.current=null,d(!1),v.type==="device:shutdown-error"){g.current(`The device was not restarted. ${v.message}`);return}p.current()}},()=>{i.current=void 0}),[i]);const[x,f]=s.useState(null);s.useEffect(()=>{f(u?h.current:null)},[u]),s.useEffect(()=>{if(x===null)return;const v=setTimeout(()=>{h.current===x&&(d(!1),g.current("The device has not answered the restart yet. If its answer arrives tapflow will finish restarting it; if nothing changes, press Restart again."))},Ko);return()=>clearTimeout(v)},[x]);const b=s.useCallback(()=>{if(u)return;const v=X();h.current=v,d(!0),o({type:"device:shutdown",sessionId:e,requestId:v,payload:{deviceId:t}})},[u,o,e,t]);return{pending:u,reboot:b}}const Sn={"channel-unavailable":{title:"Input is not reaching this device",action:"Rejoin the session to continue."},"not-booted":{title:"The device is not running",action:"Start it again to continue testing."},"dispatch-failed":{title:"The device rejected that input",action:"Try once more. If it keeps failing, restart the device."},unsupported:{title:"That input is not supported on this device",action:"Everything else still works — this one has no equivalent here."},malformed:{title:"tapflow sent a malformed input",action:"This is a bug in tapflow — please report it with what you were doing."},"channel-starting":null,"no-gesture":null,"not-session-owner":{title:"This session is no longer yours",action:"Go back and open the device again — another tester may have taken it. Nothing you just did reached the device."}};function Go(e){const t=e!==void 0&&Object.hasOwn(Sn,e)?e:"channel-unavailable";return{key:t,notice:Sn[t]}}function Jo({sessionId:e,deviceId:t,buildId:r,resetMode:o,onRecordingUploaded:i,onSessionEnded:a}){const c=s.useRef(()=>{}),u=s.useRef(!1),d=s.useRef({pending:0,appInstalled:!1});Ms();const h=s.useRef(null),p=s.useRef(null),g=s.useRef([]);s.useRef({onFrameBegin:()=>{var w;return(w=h.current)==null?void 0:w.onFrameBegin()},onFrameEnd:w=>{var pe,V;const H=g.current.shift()??null,ce=H?{...w,capturedAt:H.capturedAt,relayedAt:H.relayedAt}:w;(pe=h.current)==null||pe.onFrameEnd(ce),(V=p.current)==null||V.call(p,ce)}});const[x,f]=s.useState(!1),[b,v]=s.useState(!1),[T,j]=s.useState(!1),[L,C]=s.useState(null),[N,E]=s.useState(!1),[M,k]=s.useState(!1),[B,G]=s.useState(null),[z,F]=s.useState(null),[Q,ue]=s.useState(!1),[Ie,Fe]=s.useState([]),be=s.useRef(new Set),ye=s.useRef(null),Z=s.useRef(new Set),Ae=s.useRef(new Set),Oe=s.useRef(new Set),[He,Me]=s.useState(!1),Ue=8e3,[U,q]=s.useState(!1),K=s.useRef(null);s.useEffect(()=>()=>{K.current&&clearTimeout(K.current)},[]);const Se=s.useRef(void 0),J=s.useRef(void 0),Re=s.useRef(void 0),de=s.useRef(void 0),ee=s.useCallback(w=>{const H=X();be.current.add(H),ye.current=H,c.current({type:"device:boot",sessionId:e,requestId:H,payload:{deviceId:t,resetMode:w,acceptH264:po(),secureContext:window.isSecureContext}})},[e,t]),{pushFrame:We}=Xo(),rt=s.useCallback(w=>{var H,ce,pe;if(!("sessionId"in w&&w.sessionId!==e)){if(w.type==="session:joined"){d.current={pending:0,appInstalled:!1},f(!0),v(!1),Fe(w.capabilities??[]);const V=u.current?"app-only":o;u.current=!0,be.current.clear(),ee(V)}if(w.type==="session:agent-away"){v(!0),C(null),j(!1);return}if(w.type==="session:terminated"){a==null||a(w.reason);return}if(w.type==="session:rebound"){j(!1),C(null),E(!1),G(null),F(null),ue(!1),q(!1),K.current&&clearTimeout(K.current),Me(!1),g.current=[],Fe(w.capabilities);const V=b;v(!1),d.current={pending:d.current.pending+1,appInstalled:d.current.pending>0?d.current.appInstalled:M},u.current=!0,ee("app-only"),V||Ne.info("The agent restarted — reconnecting to the device.");return}if(w.type==="device:boot-error"){if(w.requestId!==void 0&&w.requestId!==ye.current||b)return;d.current={pending:0,appInstalled:!1},F(w.message)}if(w.type==="input:error"){if(b)return;const{key:V,notice:me}=Go(w.reason);w.reason!==void 0&&w.reason!==V&&console.debug(`[tapflow] unrecognised input:error reason "${w.reason}", treated as ${V}`),me?Ne.error(me.title,{id:`input:${e}:${V}`,description:w.message?`${me.action} (${w.message})`:me.action,duration:6e3}):console.debug(`[tapflow] input refused, shown nowhere: ${V}${w.message?` — ${w.message}`:""}`)}if(w.type==="device:booting"&&(j(!1),E(!1),k(!1),G(null),F(null),Ae.current.clear(),Oe.current.clear(),C(null)),w.type==="device:ready"){if(j(!0),w.requestId!==void 0&&!be.current.delete(w.requestId))return;if(d.current.pending>0){const{appInstalled:V}=d.current;if(d.current={pending:d.current.pending-1,appInstalled:V},V){k(!0);return}}if(r){E(!0);const V=X();Ae.current.add(V),c.current({type:"app:install",sessionId:e,requestId:V,buildId:r})}}if(w.type==="app:install-done"||w.type==="app:install-error"){if(!Ae.current.delete(w.requestId))return;E(!1),w.type==="app:install-done"?k(!0):G(w.message)}if(w.type==="app:launch-done"||w.type==="app:launch-error"){if(!Oe.current.delete(w.requestId))return;ue(!1)}if(w.type==="session:chrome"&&C(w.payload),w.type==="keyboard:toggled"){const{visible:V}=w.payload;Me(V),q(!1),K.current&&clearTimeout(K.current)}if(w.type==="network:state"||w.type==="network:error"){(H=Re.current)==null||H.call(Re,w);return}if(w.type==="device:shutdown-done"||w.type==="device:shutdown-error"){(ce=de.current)==null||ce.call(de,w);return}if((w.type==="clipboard:data"||w.type==="clipboard:write-done"||w.type==="clipboard:error")&&((pe=J.current)==null||pe.call(J,w)),w.type==="open-url:done"||w.type==="open-url:error"){if(!Z.current.delete(w.requestId))return;w.type==="open-url:done"?Ne.success("Deeplink opened"):Ne.error(w.message)}if(w.type==="error")switch(w.reason){case"session-not-found":a==null||a("agent-disconnected");return;case"session-busy":a==null||a("busy-elsewhere");return;case"agent-resources-exhausted":a==null||a("mac-overloaded");return}}},[e,r,a,o,M,b,ee]),Ve=s.useCallback(w=>{var V;const H=No(w);if(H&&H.codec===Vn){We(w.slice(Kt));return}H&&H.codec===It||g.current.push(H);const ce=H?w.slice(Kt):w,pe=H?{codec:H.codec,keyframe:H.keyframe,capturedAt:H.capturedAt,relayedAt:H.relayedAt}:void 0;(V=Se.current)==null||V.call(Se,ce,pe)},[We]),{send:fe,connected:ve}=Nn(rt,Ve);s.useLayoutEffect(()=>{c.current=fe}),s.useEffect(()=>{ve&&fe({type:"session:start",sessionId:e})},[ve,fe,e]);const ke=L!==null&&"framePng"in L?L:null,Y=L!==null&&!("framePng"in L)?L:null,he=()=>{q(!0),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{q(!1),Ne.error("The device did not answer. The software keyboard is where it was, as far as tapflow can tell.")},Ue),fe({type:"input:keyboard:toggle",sessionId:e})},$e=s.useCallback(w=>{const H=X();Z.current.add(H),c.current({type:"open-url",sessionId:e,requestId:H,payload:{url:w}})},[e]),ge=s.useCallback(()=>{if(r===void 0)return;const w=X();Oe.current.add(w),ue(!0),c.current({type:"app:launch",sessionId:e,requestId:w,buildId:r})},[e,r]),oe=s.useRef(null),re=s.useRef(!1),ae=s.useRef(!1),{pending:_e,reboot:Pe}=Yo({sessionId:e,deviceId:t,deviceReady:T,send:fe,handlerRef:de,onShutdownComplete:s.useCallback(()=>{ae.current=!0,ee("app-only")},[ee]),onError:s.useCallback(w=>{Ne.error(w)},[])});s.useEffect(()=>{var ce;const w=!!(ke??Y),H=!re.current&&w;re.current=w,!(!H||!ae.current)&&(ae.current=!1,document.activeElement===document.body&&((ce=oe.current)==null||ce.focus()))},[ke,Y]),s.useEffect(()=>{(z||b)&&(ae.current=!1)},[z,b]);const je={sessionId:e,buildId:r,send:fe,openUrl:$e,launchApp:ge,connected:ve,joined:x,deviceReady:T,installing:N,installed:M,installError:B,bootError:z,launching:Q,binaryFrameHandlerRef:Se,clipboardHandlerRef:J,clipboardSupported:Ie.includes("clipboard"),networkHandlerRef:Re,networkSupported:Ie.includes("network-control"),onRecordingUploaded:i,swKeyboardVisible:He,swKeyboardPending:U,onKbdToggle:he,rebootPending:_e,onReboot:Pe,restartButtonRef:oe};if(!ke&&!Y)return n.jsxs("div",{role:"region","aria-label":"Device screen",className:"flex items-start justify-center gap-16",children:[n.jsx("div",{"aria-hidden":"true",className:"flex flex-col items-center gap-0.5 rounded-2xl border bg-background/90 px-1.5 py-2.5 shrink-0 mt-3 opacity-40",children:Array.from({length:5}).map((w,H)=>n.jsx("div",{className:"h-8 w-8 rounded-md bg-muted animate-pulse"},H))}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsx("div",{"aria-hidden":"true",style:{background:"#1c1c1e",borderRadius:"34px",padding:"12px",flexShrink:0},children:n.jsx("div",{className:"animate-pulse bg-zinc-700",style:{width:324,height:720,borderRadius:"22px"}})}),n.jsx(Qt,{joined:x,fps:0,connected:ve,deviceReady:T,bootError:z,installing:N,installError:B,decoderUnsupported:!1,keyboardActive:!1,agentAway:b})]})]});const we=void 0;return n.jsxs(n.Fragment,{children:[ke&&n.jsx(Oo,{...je,chrome:ke,perfHookRef:we}),Y&&n.jsx(zo,{...je,androidButtons:Y.buttons,screenWidth:Y.screenWidth,screenHeight:Y.screenHeight,cornerRadius:Y.cornerRadius,perfHookRef:we}),!1]})}const Kn=s.forwardRef(({className:e,...t},r)=>n.jsx("textarea",{className:te("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));Kn.displayName="Textarea";var Qo=Object.defineProperty,O=(e,t)=>Qo(e,"name",{value:t,configurable:!0});function Yn(e,t){return s.useReducer((r,o)=>t[r][o]??r,e)}O(Yn,"useStateMachine");var Gn="ScrollArea",[Jn,qa]=Tn(Gn),[Zo,Le]=Jn(Gn),ea=s.forwardRef(O(function(t,r){const{__scopeScrollArea:o,type:i="hover",dir:a,scrollHideDelay:c=600,...u}=t,[d,h]=s.useState(null),[p,g]=s.useState(null),[x,f]=s.useState(null),[b,v]=s.useState(null),[T,j]=s.useState(null),[L,C]=s.useState(0),[N,E]=s.useState(0),[M,k]=s.useState(!1),[B,G]=s.useState(!1),z=tt(r,h),F=xr(a);return n.jsx(Zo,{scope:o,type:i,dir:F,scrollHideDelay:c,scrollArea:d,viewport:p,onViewportChange:g,content:x,onContentChange:f,scrollbarX:b,onScrollbarXChange:v,scrollbarXEnabled:M,onScrollbarXEnabledChange:k,scrollbarY:T,onScrollbarYChange:j,scrollbarYEnabled:B,onScrollbarYEnabledChange:G,onCornerWidthChange:C,onCornerHeightChange:E,children:n.jsx(nt.div,{dir:F,...u,ref:z,style:{position:"relative","--radix-scroll-area-corner-width":L+"px","--radix-scroll-area-corner-height":N+"px",...t.style}})})},"ScrollArea")),ta="ScrollAreaViewport",na=s.forwardRef(O(function(t,r){const{__scopeScrollArea:o,children:i,nonce:a,...c}=t,u=Le(ta,o),d=s.useRef(null),h=tt(r,d,u.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx(ra,{nonce:a}),n.jsx(nt.div,{"data-radix-scroll-area-viewport":"",...c,ref:h,style:{overflowX:u.scrollbarXEnabled?"scroll":"hidden",overflowY:u.scrollbarYEnabled?"scroll":"hidden",...t.style},children:n.jsx("div",{ref:u.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})},"ScrollAreaViewport")),ra=s.memo(O(function({nonce:t}){return n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:t})},"ScrollAreaViewportStyle"),(e,t)=>e.nonce===t.nonce),Ye="ScrollAreaScrollbar",Qn=s.forwardRef(O(function(t,r){const{forceMount:o,...i}=t,a=Le(Ye,t.__scopeScrollArea),{onScrollbarXEnabledChange:c,onScrollbarYEnabledChange:u}=a,d=t.orientation==="horizontal";return s.useEffect(()=>(d?c(!0):u(!0),()=>{d?c(!1):u(!1)}),[d,c,u]),a.type==="hover"?n.jsx(sa,{...i,ref:r,forceMount:o}):a.type==="scroll"?n.jsx(oa,{...i,ref:r,forceMount:o}):a.type==="auto"?n.jsx(Zn,{...i,ref:r,forceMount:o}):a.type==="always"?n.jsx(en,{...i,ref:r,"data-state":"visible"}):null},"ScrollAreaScrollbar")),sa=s.forwardRef(O(function(t,r){const{forceMount:o,...i}=t,a=Le(Ye,t.__scopeScrollArea),[c,u]=s.useState(!1);return s.useEffect(()=>{const d=a.scrollArea;let h=0;if(d){const p=O(()=>{window.clearTimeout(h),u(!0)},"handlePointerEnter"),g=O(()=>{h=window.setTimeout(()=>u(!1),a.scrollHideDelay)},"handlePointerLeave");return d.addEventListener("pointerenter",p),d.addEventListener("pointerleave",g),()=>{window.clearTimeout(h),d.removeEventListener("pointerenter",p),d.removeEventListener("pointerleave",g)}}},[a.scrollArea,a.scrollHideDelay]),n.jsx(Mt,{present:o||c,children:n.jsx(Zn,{"data-state":c?"visible":"hidden",...i,ref:r})})},"ScrollAreaScrollbarHover")),oa=s.forwardRef(O(function(t,r){const{forceMount:o,...i}=t,a=Le(Ye,t.__scopeScrollArea),c=t.orientation==="horizontal",u=Et(()=>h("SCROLL_END"),100),[d,h]=Yn("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return s.useEffect(()=>{if(d==="idle"){const p=window.setTimeout(()=>h("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(p)}},[d,a.scrollHideDelay,h]),s.useEffect(()=>{const p=a.viewport,g=c?"scrollLeft":"scrollTop";if(p){let x=p[g];const f=O(()=>{const b=p[g];x!==b&&(h("SCROLL"),u()),x=b},"handleScroll");return p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,c,h,u]),n.jsx(Mt,{present:o||d!=="hidden",children:n.jsx(en,{"data-state":d==="hidden"?"hidden":"visible",...i,ref:r,onPointerEnter:Ke(t.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:Ke(t.onPointerLeave,()=>h("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Zn=s.forwardRef(O(function(t,r){const o=Le(Ye,t.__scopeScrollArea),{forceMount:i,...a}=t,[c,u]=s.useState(!1),d=t.orientation==="horizontal",h=Et(()=>{if(o.viewport){const p=o.viewport.offsetWidth<o.viewport.scrollWidth,g=o.viewport.offsetHeight<o.viewport.scrollHeight;u(d?p:g)}},10);return pt(o.viewport,h),pt(o.content,h),n.jsx(Mt,{present:i||c,children:n.jsx(en,{"data-state":c?"visible":"hidden",...a,ref:r})})},"ScrollAreaScrollbarAuto")),en=s.forwardRef(O(function(t,r){const{orientation:o="vertical",...i}=t,a=Le(Ye,t.__scopeScrollArea),c=s.useRef(null),u=s.useRef(0),[d,h]=s.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),p=tn(d.viewport,d.content),g={...i,sizes:d,onSizesChange:h,hasThumb:p>0&&p<1,onThumbChange:O(f=>c.current=f,"onThumbChange"),onThumbPointerUp:O(()=>u.current=0,"onThumbPointerUp"),onThumbPointerDown:O(f=>u.current=f,"onThumbPointerDown")};function x(f,b){return rr(f,u.current,d,b)}return O(x,"getScrollPosition"),o==="horizontal"?n.jsx(aa,{...g,ref:r,onThumbPositionChange:()=>{if(a.viewport&&c.current){const f=a.viewport.scrollLeft,b=Gt(f,d,a.dir);c.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:f=>{a.viewport&&(a.viewport.scrollLeft=f)},onDragScroll:f=>{a.viewport&&(a.viewport.scrollLeft=x(f,a.dir))}}):o==="vertical"?n.jsx(ia,{...g,ref:r,onThumbPositionChange:()=>{if(a.viewport&&c.current){const f=a.viewport.scrollTop,b=Gt(f,d);c.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:f=>{a.viewport&&(a.viewport.scrollTop=f)},onDragScroll:f=>{a.viewport&&(a.viewport.scrollTop=x(f))}}):null},"ScrollAreaScrollbarVisible")),aa=s.forwardRef(O(function(t,r){const{sizes:o,onSizesChange:i,...a}=t,c=Le(Ye,t.__scopeScrollArea),[u,d]=s.useState(),h=s.useRef(null),p=tt(r,h,c.onScrollbarXChange);return s.useEffect(()=>{h.current&&d(getComputedStyle(h.current))},[h]),n.jsx(tr,{"data-orientation":"horizontal",...a,ref:p,sizes:o,style:{bottom:0,left:c.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:c.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Tt(o)+"px",...t.style},onThumbPointerDown:g=>t.onThumbPointerDown(g.x),onDragScroll:g=>t.onDragScroll(g.x),onWheelScroll:(g,x)=>{if(c.viewport){const f=c.viewport.scrollLeft+g.deltaX;t.onWheelScroll(f),rn(f,x)&&g.preventDefault()}},onResize:()=>{h.current&&c.viewport&&u&&i({content:c.viewport.scrollWidth,viewport:c.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Ct(u.paddingLeft),paddingEnd:Ct(u.paddingRight)}})}})},"ScrollAreaScrollbarX")),ia=s.forwardRef(O(function(t,r){const{sizes:o,onSizesChange:i,...a}=t,c=Le(Ye,t.__scopeScrollArea),[u,d]=s.useState(),h=s.useRef(null),p=tt(r,h,c.onScrollbarYChange);return s.useEffect(()=>{h.current&&d(getComputedStyle(h.current))},[h]),n.jsx(tr,{"data-orientation":"vertical",...a,ref:p,sizes:o,style:{top:0,right:c.dir==="ltr"?0:void 0,left:c.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Tt(o)+"px",...t.style},onThumbPointerDown:g=>t.onThumbPointerDown(g.y),onDragScroll:g=>t.onDragScroll(g.y),onWheelScroll:(g,x)=>{if(c.viewport){const f=c.viewport.scrollTop+g.deltaY;t.onWheelScroll(f),rn(f,x)&&g.preventDefault()}},onResize:()=>{h.current&&c.viewport&&u&&i({content:c.viewport.scrollHeight,viewport:c.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Ct(u.paddingTop),paddingEnd:Ct(u.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[ca,er]=Jn(Ye),tr=s.forwardRef(O(function(t,r){const{__scopeScrollArea:o,sizes:i,hasThumb:a,onThumbChange:c,onThumbPointerUp:u,onThumbPointerDown:d,onThumbPositionChange:h,onDragScroll:p,onWheelScroll:g,onResize:x,...f}=t,b=Le(Ye,o),[v,T]=s.useState(null),j=tt(r,T),L=s.useRef(null),C=s.useRef(""),N=b.viewport,E=i.content-i.viewport,M=ht(g),k=ht(h),B=Et(x,10);function G(z){if(L.current){const F=z.clientX-L.current.left,Q=z.clientY-L.current.top;p({x:F,y:Q})}}return O(G,"handleDragScroll"),s.useEffect(()=>{const z=O(F=>{const Q=F.target;(v==null?void 0:v.contains(Q))&&M(F,E)},"handleWheel");return document.addEventListener("wheel",z,{passive:!1}),()=>document.removeEventListener("wheel",z,{passive:!1})},[N,v,E,M]),s.useEffect(k,[i,k]),pt(v,B),pt(b.content,B),n.jsx(ca,{scope:o,scrollbar:v,hasThumb:a,onThumbChange:ht(c),onThumbPointerUp:ht(u),onThumbPositionChange:k,onThumbPointerDown:ht(d),children:n.jsx(nt.div,{...f,ref:j,style:{position:"absolute",...f.style},onPointerDown:Ke(t.onPointerDown,z=>{z.button===0&&(z.target.setPointerCapture(z.pointerId),L.current=v.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),G(z))}),onPointerMove:Ke(t.onPointerMove,G),onPointerUp:Ke(t.onPointerUp,z=>{const F=z.target;F.hasPointerCapture(z.pointerId)&&F.releasePointerCapture(z.pointerId),document.body.style.webkitUserSelect=C.current,b.viewport&&(b.viewport.style.scrollBehavior=""),L.current=null})})})},"ScrollAreaScrollbarImpl")),Yt="ScrollAreaThumb",la=s.forwardRef(O(function(t,r){const{forceMount:o,...i}=t,a=er(Yt,t.__scopeScrollArea);return n.jsx(Mt,{present:o||a.hasThumb,children:n.jsx(ua,{ref:r,...i})})},"ScrollAreaThumb")),ua=s.forwardRef(O(function(t,r){const{__scopeScrollArea:o,style:i,...a}=t,c=Le(Yt,o),u=er(Yt,o),{onThumbPositionChange:d}=u,h=tt(r,u.onThumbChange),p=s.useRef(void 0),g=Et(()=>{p.current&&(p.current(),p.current=void 0)},100);return s.useEffect(()=>{const x=c.viewport;if(x){const f=O(()=>{if(g(),!p.current){const b=ha(x,d);p.current=b,d()}},"handleScroll");return d(),x.addEventListener("scroll",f),()=>x.removeEventListener("scroll",f)}},[c.viewport,g,d]),n.jsx(nt.div,{"data-state":u.hasThumb?"visible":"hidden",...a,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:Ke(t.onPointerDownCapture,x=>{const b=x.target.getBoundingClientRect(),v=x.clientX-b.left,T=x.clientY-b.top;u.onThumbPointerDown({x:v,y:T})}),onPointerUp:Ke(t.onPointerUp,u.onThumbPointerUp)})},"ScrollAreaThumbImpl")),nr="ScrollAreaCorner",da=s.forwardRef(O(function(t,r){const o=Le(nr,t.__scopeScrollArea),i=!!(o.scrollbarX&&o.scrollbarY);return o.type!=="scroll"&&i?n.jsx(fa,{...t,ref:r}):null},"ScrollAreaCorner")),fa=s.forwardRef(O(function(t,r){const{__scopeScrollArea:o,...i}=t,a=Le(nr,o),[c,u]=s.useState(0),[d,h]=s.useState(0),p=!!(c&&d),{onCornerWidthChange:g,onCornerHeightChange:x}=a;return pt(a.scrollbarX,()=>{var b;const f=((b=a.scrollbarX)==null?void 0:b.offsetHeight)||0;a.onCornerHeightChange(f),h(f)}),pt(a.scrollbarY,()=>{var b;const f=((b=a.scrollbarY)==null?void 0:b.offsetWidth)||0;a.onCornerWidthChange(f),u(f)}),s.useEffect(()=>()=>{g(0),x(0)},[g,x]),p?n.jsx(nt.div,{...i,ref:r,style:{width:c,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null},"ScrollAreaCornerImpl"));function Ct(e){return e?parseInt(e,10):0}O(Ct,"toInt");function tn(e,t){const r=e/t;return isNaN(r)?0:r}O(tn,"getThumbRatio");function Tt(e){const t=tn(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-r)*t;return Math.max(o,18)}O(Tt,"getThumbSize");function rr(e,t,r,o="ltr"){const i=Tt(r),a=i/2,c=t||a,u=i-c,d=r.scrollbar.paddingStart+c,h=r.scrollbar.size-r.scrollbar.paddingEnd-u,p=r.content-r.viewport,g=o==="ltr"?[0,p]:[p*-1,0];return nn([d,h],g)(e)}O(rr,"getScrollPositionFromPointer");function Gt(e,t,r="ltr"){const o=Tt(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,c=t.content-t.viewport,u=a-o,d=r==="ltr"?[0,c]:[c*-1,0],h=zr(e,d);return nn([0,c],[0,u])(h)}O(Gt,"getThumbOffsetFromScroll");function nn(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(r-e[0])}}O(nn,"linearScale");function rn(e,t){return e>0&&e<t}O(rn,"isScrollingWithinScrollbarBounds");var ha=O((e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},o=0;return O((function i(){const a={left:e.scrollLeft,top:e.scrollTop},c=r.left!==a.left,u=r.top!==a.top;(c||u)&&t(),r=a,o=window.requestAnimationFrame(i)}),"loop")(),()=>window.cancelAnimationFrame(o)},"addUnlinkedScrollListener");function Et(e,t){const r=ht(e),o=s.useRef(0);return s.useEffect(()=>()=>window.clearTimeout(o.current),[]),s.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,t)},[r,t])}O(Et,"useDebounceCallback");function pt(e,t){const r=ht(t);gr(()=>{let o=0;if(e){const i=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return i.observe(e),()=>{window.cancelAnimationFrame(o),i.unobserve(e)}}},[e,r])}O(pt,"useResizeObserver");var sr=ea,pa=na,ma=da;const or=s.forwardRef(({className:e,children:t,...r},o)=>n.jsxs(sr,{ref:o,className:te("relative overflow-hidden",e),...r,children:[n.jsx(pa,{className:"h-full w-full rounded-[inherit]",children:t}),n.jsx(ar,{}),n.jsx(ma,{})]}));or.displayName=sr.displayName;const ar=s.forwardRef(({className:e,orientation:t="vertical",...r},o)=>n.jsx(Qn,{ref:o,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:n.jsx(la,{className:"relative flex-1 rounded-full bg-border"})}));ar.displayName=Qn.displayName;function ir(e){return/[Zz]|[+-]\d{2}/.test(e)?new Date(e):new Date(e.replace(" ","T")+"Z")}function ga(e){const t=new Map;for(const i of e){const a=ir(i.created_at).toDateString();t.has(a)||t.set(a,[]),t.get(a).push(i)}const r=new Date().toDateString(),o=new Date(Date.now()-864e5).toDateString();return Array.from(t.entries()).map(([i,a])=>{let c;if(i===r)c="Today";else if(i===o)c="Yesterday";else{const u=new Date(i);c=u.toLocaleDateString(void 0,{month:"short",day:"numeric",...u.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}return{label:c,items:a}})}function xa(e){return ir(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}const ba=5*1024*1024,ya=["image/png","image/jpeg","image/webp"];function va({buildId:e}){const t=s.useId(),[r,o]=s.useState([]),[i,a]=s.useState(""),[c,u]=s.useState(null),[d,h]=s.useState(!1),[p,g]=s.useState(""),x=s.useRef(null),f=s.useRef({}),b=s.useCallback(()=>{fetch(`/api/v1/comments?build_id=${e}`,{credentials:"include"}).then(C=>C.ok?C.json():[]).then(o)},[e]);s.useEffect(()=>{b()},[b]),s.useEffect(()=>{const C=window.location.hash;if(!C.startsWith("#comment-"))return;const N=Number(C.replace("#comment-","")),E=f.current[N];if(!E)return;E.scrollIntoView({behavior:"smooth"});const M=document.documentElement.classList.contains("dark");E.style.backgroundColor=M?"rgb(0 112 243 / 0.18)":"#d3e5ff",setTimeout(()=>{E.style.backgroundColor=""},2e3)},[r]);function v(C){const N=`${location.origin}${location.pathname}${location.search}#comment-${C}`;navigator.clipboard.writeText(N).then(()=>Ne.success("Link copied")).catch(()=>Ne.error("Could not copy link"))}function T(C){if(g(""),!ya.includes(C.type)){g("Only png, jpg, webp allowed");return}if(C.size>ba){g("Max 5MB");return}u(C)}async function j(C){if(C.preventDefault(),!i.trim()&&!c)return;h(!0);const N=new FormData;N.append("build_id",String(e)),N.append("body",i),c&&N.append("attachment",c),(await fetch("/api/v1/comments",{method:"POST",credentials:"include",body:N})).ok&&(a(""),u(null),b()),h(!1)}const L=ga(r);return n.jsxs("div",{className:"flex h-full flex-col gap-3 px-1",children:[n.jsx(or,{className:"flex-1 rounded-md border",children:n.jsx("div",{className:"p-3",children:r.length===0?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No comments yet."}):n.jsx("div",{className:"flex flex-col",children:L.map(({label:C,items:N})=>n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-3",children:[n.jsx("div",{className:"h-px flex-1 bg-border"}),n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground px-1 select-none",children:C}),n.jsx("div",{className:"h-px flex-1 bg-border"})]}),n.jsx("div",{className:"flex flex-col gap-4",children:N.map(E=>n.jsxs("div",{id:`comment-${E.id}`,ref:M=>{f.current[E.id]=M},className:"group flex gap-2.5 rounded-md px-2 py-1.5 transition-all",children:[n.jsx("div",{className:"mt-0.5 shrink-0",children:n.jsx(br,{name:E.author,avatarUrl:E.authorAvatarUrl,size:28})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-semibold leading-none",children:E.author}),n.jsx("span",{className:"text-[11px] text-muted-foreground leading-none",children:xa(E.created_at)}),n.jsx(ie,{variant:"ghost",size:"icon",className:"h-4 w-4 ml-0.5 opacity-0 group-hover:opacity-50 hover:!opacity-100 group-focus-within:opacity-50 focus-visible:!opacity-100 transition-opacity","aria-label":"Copy link to comment",onClick:()=>v(E.id),children:n.jsx(In,{className:"h-3 w-3","aria-hidden":"true"})})]}),n.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap mt-1",children:E.body}),E.attachments.map(M=>{const k=decodeURIComponent(M.file_path.split("/").pop()??"image");return n.jsx("a",{href:M.file_path,target:"_blank",rel:"noreferrer",className:"mt-1.5 block","aria-label":`Open ${k} in a new tab`,children:n.jsx("img",{src:M.file_path,alt:k,className:"max-h-48 rounded border object-contain"})},M.id)})]})]},E.id))})]},C))})})}),n.jsx("div",{className:"pb-1",children:n.jsx("form",{onSubmit:j,children:n.jsxs("div",{className:"rounded-md border border-input bg-background ring-offset-background transition-shadow focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:[n.jsx(Kn,{"aria-label":"Comment",placeholder:"Leave a comment…",value:i,onChange:C=>a(C.target.value),className:"min-h-16 resize-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 text-sm"}),(c||p)&&n.jsxs("div",{className:"px-3 -mt-1 pb-1",children:[c&&n.jsx("p",{className:"text-xs text-muted-foreground",children:c.name}),p&&n.jsx("p",{id:t,role:"alert",className:"text-xs text-destructive",children:p})]}),n.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[n.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"Attach image","aria-describedby":p?t:void 0,onClick:()=>{var C;return(C=x.current)==null?void 0:C.click()},children:n.jsx(is,{className:"h-4 w-4","aria-hidden":"true"})}),n.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:C=>{var E;const N=(E=C.target.files)==null?void 0:E[0];N&&T(N)}}),n.jsx("div",{className:"flex-1"}),n.jsx(ie,{type:"submit",size:"icon",className:"h-7 w-7 rounded-full","aria-label":"Post comment",disabled:d||!i.trim()&&!c,children:n.jsx(Qr,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})})})]})}function wa(e){return e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Sa(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ra(e){const t=new Date(e).getTime()-Date.now();if(t<=0)return{label:"Expired",urgent:!0};const r=Math.floor(t/36e5);return r<1?{label:"< 1 hour left",urgent:!0}:r<24?{label:`Expires in ${r}h`,urgent:r<6}:{label:`Expires in ${Math.floor(r/24)}d`,urgent:!1}}function ka({buildId:e,refreshKey:t}){const[r,o]=s.useState([]),[i,a]=s.useState(!0),[c,u]=s.useState(!1);return s.useEffect(()=>{a(!0),u(!1);const d=setTimeout(()=>u(!0),250);return fetch(`/api/v1/recordings?buildId=${e}`,{credentials:"include"}).then(h=>h.ok?h.json():[]).then(h=>o(h)).catch(()=>o([])).finally(()=>{clearTimeout(d),a(!1)}),()=>clearTimeout(d)},[e,t]),i?c?n.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading recordings…"}):null:r.length===0?n.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No recordings yet."}):n.jsx("div",{className:"flex flex-col gap-2",children:r.map(d=>{const h=Ra(d.expiresAt);return n.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2 text-sm",children:[n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[n.jsx("span",{className:"text-xs font-medium truncate",children:Sa(d.createdAt)}),n.jsxs("span",{className:`text-xs ${h.urgent?"text-destructive":"text-muted-foreground"}`,children:[h.label," · ",wa(d.fileSize)]})]}),n.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 ml-2",title:"Download",onClick:()=>{const p=document.createElement("a");p.href=d.url,p.download="",p.click()},children:n.jsx(ns,{className:"h-3.5 w-3.5"})})]},d.id)})})}function ja({buildId:e,recordingsRefreshKey:t=0}){return n.jsxs(Nr,{defaultValue:"comments",className:"flex h-full flex-col",children:[n.jsx("div",{className:"shrink-0 px-1",children:n.jsxs(Ar,{className:"w-full",children:[n.jsxs(un,{value:"comments",className:"flex-1 gap-1.5",children:[n.jsx(hs,{className:"h-3.5 w-3.5"}),"Comments"]}),n.jsxs(un,{value:"recordings",className:"flex-1 gap-1.5",children:[n.jsx(ss,{className:"h-3.5 w-3.5"}),"Recordings"]})]})}),n.jsx(dn,{value:"comments",className:"mt-3 min-h-0 flex-1 overflow-hidden",children:n.jsx(va,{buildId:e})}),n.jsx(dn,{value:"recordings",className:"mt-3 min-h-0 flex-1 overflow-y-auto",children:n.jsx(ka,{buildId:e,refreshKey:t})})]})}const cr=s.forwardRef(({...e},t)=>n.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));cr.displayName="Breadcrumb";const lr=s.forwardRef(({className:e,...t},r)=>n.jsx("ol",{ref:r,className:te("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));lr.displayName="BreadcrumbList";const jt=s.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,className:te("inline-flex items-center gap-1.5",e),...t}));jt.displayName="BreadcrumbItem";const Pt=s.forwardRef(({asChild:e,className:t,...r},o)=>{const i=e?yr:"a";return n.jsx(i,{ref:o,className:te("transition-colors hover:text-foreground cursor-pointer",t),...r})});Pt.displayName="BreadcrumbLink";const Dt=s.forwardRef(({className:e,...t},r)=>n.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:te("font-medium text-foreground",e),...t}));Dt.displayName="BreadcrumbPage";const Lt=({children:e,className:t,...r})=>n.jsx("li",{role:"presentation","aria-hidden":"true",className:te("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...r,children:e??n.jsx(vr,{})});Lt.displayName="BreadcrumbSeparator";var Ca=Object.defineProperty,et=(e,t)=>Ca(e,"name",{value:t,configurable:!0}),sn="Switch",[Ta,Xa]=Tn(sn),[Ea,on]=Ta(sn);function ur(e){const{__scopeSwitch:t,checked:r,children:o,defaultChecked:i,disabled:a,form:c,name:u,onCheckedChange:d,required:h,value:p="on",internal_do_not_use_render:g}=e,[x,f]=Sr({prop:r,defaultProp:i??!1,onChange:d,caller:sn}),[b,v]=s.useState(null),[T,j]=s.useState(null),L=s.useRef(!1),[C,N]=s.useReducer(k=>k+1,0),E=b?!!c||!!b.closest("form"):!0,M={checked:x,setChecked:f,disabled:a,control:b,setControl:v,name:u,form:c,value:p,hasConsumerStoppedPropagationRef:L,userInteractionCount:C,onUserInteraction:N,required:h,defaultChecked:i,isFormControl:E,bubbleInput:T,setBubbleInput:j};return n.jsx(Ea,{scope:t,...M,children:fr(g)?g(M):o})}et(ur,"SwitchProvider");var Na="SwitchTrigger",Aa=s.forwardRef(et(function({__scopeSwitch:t,onClick:r,...o},i){const{control:a,form:c,value:u,disabled:d,checked:h,required:p,setControl:g,setChecked:x,hasConsumerStoppedPropagationRef:f,onUserInteraction:b,isFormControl:v,bubbleInput:T}=on(Na,t),j=tt(i,g),L=s.useRef(h);return s.useEffect(()=>{const C=c?a==null?void 0:a.ownerDocument.getElementById(c):a==null?void 0:a.form;if(C instanceof HTMLFormElement){const N=et(()=>x(L.current),"reset");return C.addEventListener("reset",N),()=>C.removeEventListener("reset",N)}},[a,c,x]),n.jsx(nt.button,{type:"button",role:"switch","aria-checked":h,"aria-required":p,"data-state":an(h),"data-disabled":d?"":void 0,disabled:d,value:u,...o,ref:j,onClick:Ke(r,C=>{b(),x(N=>!N),T&&v&&(f.current=C.isPropagationStopped(),f.current||C.stopPropagation())})})},"SwitchTrigger")),dr=s.forwardRef(et(function(t,r){const{__scopeSwitch:o,name:i,checked:a,defaultChecked:c,required:u,disabled:d,value:h,onCheckedChange:p,form:g,...x}=t;return n.jsx(ur,{__scopeSwitch:o,checked:a,defaultChecked:c,disabled:d,required:u,onCheckedChange:p,name:i,form:g,value:h,internal_do_not_use_render:({isFormControl:f})=>n.jsxs(n.Fragment,{children:[n.jsx(Aa,{...x,ref:r,__scopeSwitch:o}),f&&n.jsx(La,{__scopeSwitch:o})]})})},"Switch")),_a="SwitchThumb",Pa=s.forwardRef(et(function(t,r){const{__scopeSwitch:o,...i}=t,a=on(_a,o);return n.jsx(nt.span,{"data-state":an(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:r})},"SwitchThumb")),Da="SwitchBubbleInput",La=s.forwardRef(et(function({__scopeSwitch:t,onClick:r,...o},i){const{control:a,hasConsumerStoppedPropagationRef:c,userInteractionCount:u,checked:d,defaultChecked:h,required:p,disabled:g,name:x,value:f,form:b,bubbleInput:v,setBubbleInput:T}=on(Da,t),j=tt(i,T),L=wr(a),C=s.useRef(!1),N=s.useRef(d),E=s.useRef(u);s.useEffect(()=>{const k=v;if(!k)return;const B=window.HTMLInputElement.prototype,z=Object.getOwnPropertyDescriptor(B,"checked").set,F=u!==E.current;E.current=u;const Q=N.current!==d;N.current=d;const ue=!(F&&c.current);if(Q&&z){C.current=!F;const Ie=new Event("click",{bubbles:ue});z.call(k,d),k.dispatchEvent(Ie),C.current=!1}},[v,d,c,u]);const M=s.useRef(d);return n.jsx(nt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:h??M.current,required:p,disabled:g,name:x,value:f,form:b,...o,tabIndex:-1,ref:j,onClick:Ke(r,k=>{C.current&&k.stopPropagation()}),style:{...o.style,...L,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function fr(e){return typeof e=="function"}et(fr,"isFunction");function an(e){return e?"checked":"unchecked"}et(an,"getState");const hr=s.forwardRef(({className:e,...t},r)=>n.jsx(dr,{className:te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:r,children:n.jsx(Pa,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));hr.displayName=dr.displayName;const Rn=70,kn=80;function Ia(e,t){if(!e||t)return"unknown";const r=e.memUsedMB/e.memTotalMB*100;return e.cpuPercent>kn||r>kn?"overloaded":e.cpuPercent>=Rn||r>=Rn?"warning":"healthy"}const Ma={"agent-disconnected":{title:"The agent disconnected — this session ended.",description:"Pick the Mac again to start a new session."},"busy-elsewhere":{title:"This device is already open in another browser session.",description:"Someone else may be testing it. If you reloaded while your connection was down it is your own tab, and that clears within about 45 seconds."},"mac-overloaded":{title:"That Mac is too busy to start a session.",description:"Pick a different Mac, or wait for it to settle."}};function Ka(){const[e]=An(),t=_r(),r=e.get("id"),{build:o}=Ds(r),[i,a]=s.useState(0),c=(o==null?void 0:o.platform)??"ios",{sessions:u,selectedAgent:d,setSelectedAgent:h,activeSessionId:p,deviceId:g,booting:x,status:f,connected:b,agentGroups:v,startDevice:T,resetDevice:j,handleBack:L,handleBackToMacs:C,handleSessionEnded:N}=Ls(c),E=v.find(U=>U.agentName===d),{osVersions:M,osVersion:k,setOsVersion:B,deviceSearch:G,setDeviceSearch:z,versionedDevices:F,resetMode:Q,setResetMode:ue,appliedResetMode:Ie,consumeResetMode:Fe,fullResetSupported:be}=Is(E,c),Z=u.flatMap(U=>U.devices).find(U=>U.id===g),Ae=Z?`${Z.name}${Z.osVersion?` · ${Z.osVersion}`:""}`:"",Oe=s.useCallback(()=>a(U=>U+1),[]),He=s.useCallback(U=>{Fe(),T(U)},[Fe,T]),Me=s.useCallback(U=>{const q=Ma[U];Ne.error(q.title,{description:q.description}),N()},[N]),{setNode:Ue}=Rr();return s.useEffect(()=>{if(o)return Ue(n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(cr,{children:n.jsxs(lr,{children:[n.jsx(jt,{children:n.jsx(Pt,{asChild:!0,children:n.jsx("button",{onClick:()=>t(`/app-center?appId=${o.app_id}`),children:o.name})})}),n.jsx(Lt,{}),n.jsx(jt,{children:d?n.jsx(Pt,{asChild:!0,children:n.jsx("button",{onClick:C,children:ln(o)})}):n.jsx(Dt,{children:ln(o)})}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Lt,{}),n.jsx(jt,{children:p?n.jsx(Pt,{asChild:!0,children:n.jsx("button",{onClick:L,children:d})}):n.jsx(Dt,{children:d})})]}),p&&n.jsxs(n.Fragment,{children:[n.jsx(Lt,{}),n.jsx(jt,{children:n.jsx(Dt,{children:Ae})})]})]})}),!d&&o.status_label&&n.jsx(Kr,{tone:Tr[o.status_label],children:o.status_label})]})),()=>Ue(null)},[o,d,p,Ae,t,L,C,Ue]),n.jsxs("div",{className:"flex h-full min-h-0 gap-6 p-6",children:[n.jsx("div",{className:"flex flex-col gap-3 flex-1 min-w-0 min-h-0",children:n.jsx("div",{className:"flex-1 min-h-0 overflow-auto -ml-1 pl-1 -mr-4 pr-4",children:p?n.jsx("div",{className:"min-h-full flex items-center justify-center py-6 px-8 min-w-max",children:n.jsx(Jo,{sessionId:p,deviceId:g,buildId:o==null?void 0:o.id,resetMode:Ie,onRecordingUploaded:Oe,onSessionEnded:Me})}):d?n.jsxs("div",{className:"flex flex-col gap-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{onClick:C,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:"← All Macs"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Select device"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Er,{placeholder:"Search device…",value:G,onChange:z}),M.length>0&&n.jsxs(Wr,{value:k||"__all__",onValueChange:U=>{B(U==="__all__"?"":U),j()},children:[n.jsx(Vr,{className:"h-8 w-36 shrink-0",children:n.jsx(qr,{})}),n.jsxs(Xr,{children:[n.jsx(fn,{value:"__all__",children:"Any version"}),M.map(U=>n.jsx(fn,{value:U,children:U},U))]})]}),be&&n.jsx(Vt,{children:n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsxs("div",{className:"ml-auto flex items-center gap-2 shrink-0",children:[n.jsx(kr,{htmlFor:"reset-mode",className:"text-sm cursor-pointer whitespace-nowrap",children:"Full reset"}),n.jsx("span",{id:"reset-mode-desc",className:"sr-only",children:"When on, erases all data on the next device you pick"}),n.jsx(hr,{id:"reset-mode","aria-describedby":"reset-mode-desc",checked:Q==="full-erase",onCheckedChange:U=>ue(U?"full-erase":"app-only")})]})}),n.jsx(Ee,{children:Q==="full-erase"?"Erase all data on the next device you pick":"Keep existing data"})]})})]}),F.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:b?"No devices available for this OS.":"Connecting to relay…"}):n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-2",children:F.map(U=>{const q=U.status==="booted",K=U.busy,Se=K?"In use":q?"Booted":"Available",J=K?"bg-amber-400":q?"bg-emerald-400":"bg-muted-foreground/40";return n.jsxs("button",{disabled:K||x||!b,onClick:()=>He(U),className:te("flex flex-col gap-3 rounded-lg border p-3 text-left transition-colors min-h-[100px]","hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"),children:[n.jsx("span",{className:"text-sm font-medium leading-tight",children:U.name}),U.osVersion&&n.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:U.osVersion}),n.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx("span",{className:te("inline-block h-1.5 w-1.5 rounded-full",J)}),Se]})]},U.id)})}),f&&n.jsx("p",{className:"text-sm text-muted-foreground",children:f})]}):n.jsxs("div",{className:"flex flex-col gap-5",children:[n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Select Mac"}),v.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:b?`No agents available for ${c}.`:"Connecting to relay…"}):n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-2",children:v.map(U=>{const q=U.resources,K=q?Date.now()-q.reportedAt>3e4:!1,Se=U.devices.filter(We=>We.platform===c).length,J=(q==null?void 0:q.cpuPercent)??0,Re=q?q.memUsedMB/q.memTotalMB*100:0,de=Ia(q,K),ee=de==="overloaded";return n.jsx(Vt,{children:n.jsxs(Ce,{children:[n.jsx(Te,{asChild:!0,children:n.jsx("span",{tabIndex:ee?0:void 0,className:ee?"cursor-not-allowed":void 0,children:n.jsxs("button",{disabled:ee,"aria-disabled":ee,onClick:()=>h(U.agentName??null),className:te("flex flex-col gap-3 rounded-lg border p-3 text-left transition-colors min-h-[100px] w-full",ee?"pointer-events-none":"hover:bg-accent"),children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx(Ua,{health:de}),n.jsx("span",{className:"text-sm font-medium leading-tight truncate",children:U.agentName??"Unknown"})]}),K&&n.jsx("span",{className:"shrink-0 text-[10px] font-medium text-amber-500",children:"Stale"})]}),n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsxs("span",{children:[Se," device",Se!==1?"s":""]}),q&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("span",{children:[q.slotsAvailable,"/",q.slotsTotal," slots"]})]})]}),q&&!K&&n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[n.jsx(jn,{label:"CPU",percent:J,colorClass:"bg-blue-400"}),n.jsx(jn,{label:"RAM",percent:Re,colorClass:"bg-violet-400"})]})]})})}),ee&&n.jsx(Ee,{children:"This Mac is currently overloaded. Try again later."})]})},U.agentName)})})]})})}),r&&n.jsxs(n.Fragment,{children:[n.jsx(Cn,{orientation:"vertical",className:"h-auto"}),n.jsx("div",{className:"w-80 shrink-0 h-full",children:n.jsx(ja,{buildId:Number(r),recordingsRefreshKey:i})})]})]})}function Ua({health:e}){const t={unknown:"bg-muted-foreground/40",healthy:"bg-emerald-400",warning:"bg-amber-400",overloaded:"bg-red-500"}[e];return n.jsx("span",{"data-testid":"resource-health-dot",className:te("inline-block h-2 w-2 shrink-0 rounded-full",t)})}function jn({label:e,percent:t,colorClass:r}){return n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[n.jsx("span",{children:e}),n.jsxs("span",{children:[t.toFixed(0),"%"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:te("h-full rounded-full transition-all",r),style:{width:`${Math.min(100,t)}%`}})})]})}export{Ka as QASession};
@@ -1 +1 @@
1
- import{i as m,j as s}from"./vendor-react-AJpf4YZ0.js";import{ad as b,a5 as S,C as h,c as p,d as x,b as f,a as k,L as u,I as w,B as C,a2 as P,a3 as j}from"./index-9vdYIm7s.js";import{b as E,c as F}from"./vendor-router-ChFy8CZ1.js";const T=P({password:j().min(8),confirm:j()}).refine(r=>r.password===r.confirm,{message:"Passwords do not match",path:["confirm"]});function I(){const r=E(),[g]=F(),a=g.get("token")??"",[n,t]=m.useState("loading"),{register:o,handleSubmit:v,setError:d,formState:{errors:e,isSubmitting:c}}=b({resolver:S(T),mode:"onBlur"});m.useEffect(()=>{if(!a){t("invalid");return}fetch(`/api/v1/auth/reset-password/verify?token=${a}`).then(i=>i.ok?t("valid"):Promise.reject()).catch(()=>t("invalid"))},[a]);async function N(i){try{const l=await fetch("/api/v1/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,password:i.password})});if(!l.ok){const y=await l.json();d("root",{message:y.error??"Failed to reset password"});return}r("/login",{replace:!0})}catch{d("root",{message:"Network error. Please try again."})}}return n==="loading"?s.jsx("div",{className:"flex min-h-svh items-center justify-center"}):n==="invalid"?s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsx(h,{level:4,className:"w-full max-w-sm text-center",children:s.jsxs(p,{children:[s.jsx(x,{children:"Link expired"}),s.jsx(f,{children:"This password reset link is invalid or has expired. Ask your admin to send a new one."})]})})}):s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsxs(h,{level:4,className:"w-full max-w-sm",children:[s.jsxs(p,{className:"text-center",children:[s.jsx(x,{children:"Reset password"}),s.jsx(f,{children:"Enter your new password below."})]}),s.jsx(k,{children:s.jsxs("form",{onSubmit:v(N),className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"password",children:"New password"}),s.jsx(w,{id:"password",type:"password",...o("password")}),e.password&&s.jsx("p",{className:"text-sm text-destructive",children:e.password.message})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"confirm",children:"Confirm password"}),s.jsx(w,{id:"confirm",type:"password",...o("confirm")}),e.confirm&&s.jsx("p",{className:"text-sm text-destructive",children:e.confirm.message})]}),e.root&&s.jsx("p",{className:"text-sm text-destructive",children:e.root.message}),s.jsx(C,{type:"submit",disabled:c,className:"w-full",children:c?"Saving…":"Set new password"})]})})]})})}export{I as ResetPassword};
1
+ import{i as m,j as s}from"./vendor-react-AJpf4YZ0.js";import{ad as b,a5 as S,C as h,c as p,d as x,b as f,a as k,L as u,I as w,B as C,a2 as P,a3 as j}from"./index-CBfjqtE-.js";import{b as E,c as F}from"./vendor-router-BFibuab1.js";const T=P({password:j().min(8),confirm:j()}).refine(r=>r.password===r.confirm,{message:"Passwords do not match",path:["confirm"]});function I(){const r=E(),[g]=F(),a=g.get("token")??"",[n,t]=m.useState("loading"),{register:o,handleSubmit:v,setError:d,formState:{errors:e,isSubmitting:c}}=b({resolver:S(T),mode:"onBlur"});m.useEffect(()=>{if(!a){t("invalid");return}fetch(`/api/v1/auth/reset-password/verify?token=${a}`).then(i=>i.ok?t("valid"):Promise.reject()).catch(()=>t("invalid"))},[a]);async function N(i){try{const l=await fetch("/api/v1/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,password:i.password})});if(!l.ok){const y=await l.json();d("root",{message:y.error??"Failed to reset password"});return}r("/login",{replace:!0})}catch{d("root",{message:"Network error. Please try again."})}}return n==="loading"?s.jsx("div",{className:"flex min-h-svh items-center justify-center"}):n==="invalid"?s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsx(h,{level:4,className:"w-full max-w-sm text-center",children:s.jsxs(p,{children:[s.jsx(x,{children:"Link expired"}),s.jsx(f,{children:"This password reset link is invalid or has expired. Ask your admin to send a new one."})]})})}):s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsxs(h,{level:4,className:"w-full max-w-sm",children:[s.jsxs(p,{className:"text-center",children:[s.jsx(x,{children:"Reset password"}),s.jsx(f,{children:"Enter your new password below."})]}),s.jsx(k,{children:s.jsxs("form",{onSubmit:v(N),className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"password",children:"New password"}),s.jsx(w,{id:"password",type:"password",...o("password")}),e.password&&s.jsx("p",{className:"text-sm text-destructive",children:e.password.message})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"confirm",children:"Confirm password"}),s.jsx(w,{id:"confirm",type:"password",...o("confirm")}),e.confirm&&s.jsx("p",{className:"text-sm text-destructive",children:e.confirm.message})]}),e.root&&s.jsx("p",{className:"text-sm text-destructive",children:e.root.message}),s.jsx(C,{type:"submit",disabled:c,className:"w-full",children:c?"Saving…":"Set new password"})]})})]})})}export{I as ResetPassword};
@@ -1 +1 @@
1
- import{i as f,j as e}from"./vendor-react-AJpf4YZ0.js";import{ai as g,ad as j,a5 as w,C as v,c as N,d as b,a as y,L as i,I as o,B as C,a2 as S,a3 as l}from"./index-9vdYIm7s.js";import{b as k}from"./vendor-router-ChFy8CZ1.js";const E=S({email:l().email("Enter a valid email"),password:l().min(8,"Password must be at least 8 characters"),confirm:l()}).refine(a=>a.password===a.confirm,{message:"Passwords do not match",path:["confirm"]});function B(){const a=k(),{resolvedTheme:d}=g(),p=d==="dark"?"/logo-dark.svg":"/logo.svg",{register:r,handleSubmit:x,setError:c,formState:{errors:s,isSubmitting:m}}=j({resolver:w(E),mode:"onBlur"});f.useEffect(()=>{fetch("/api/v1/auth/status").then(t=>t.json()).then(({initialized:t})=>{t&&a("/login",{replace:!0})}).catch(()=>{})},[a]);async function h(t){try{const n=await fetch("/api/v1/auth/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t.email,password:t.password})});if(!n.ok){const u=await n.json();c("root",{message:u.error??"Failed to create account"});return}a("/login",{replace:!0})}catch{c("root",{message:"Network error. Please try again."})}}return e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:p,alt:"tapflow",className:"w-6 h-6"}),e.jsx("span",{className:"text-base font-semibold tracking-tight",children:"tapflow"})]}),e.jsxs(v,{level:4,className:"w-full",children:[e.jsx(N,{className:"text-center",children:e.jsx(b,{className:"text-2xl tracking-display-md",children:"Set up tapflow"})}),e.jsx(y,{children:e.jsxs("form",{onSubmit:x(h),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"email",children:"Admin email"}),e.jsx(o,{id:"email",type:"email",placeholder:"admin@yourteam.com",autoComplete:"email",...r("email")}),s.email&&e.jsx("p",{className:"text-sm text-destructive",children:s.email.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"password",children:"Password"}),e.jsx(o,{id:"password",type:"password",autoComplete:"new-password",...r("password")}),s.password&&e.jsx("p",{className:"text-sm text-destructive",children:s.password.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(o,{id:"confirm",type:"password",autoComplete:"new-password",...r("confirm")}),s.confirm&&e.jsx("p",{className:"text-sm text-destructive",children:s.confirm.message})]}),s.root&&e.jsx("p",{className:"text-sm text-destructive",children:s.root.message}),e.jsx(C,{type:"submit",size:"lg",disabled:m,className:"w-full mt-1",children:m?"Creating account…":"Create admin account"})]})})]})]})})}export{B as Setup};
1
+ import{i as f,j as e}from"./vendor-react-AJpf4YZ0.js";import{ai as g,ad as j,a5 as w,C as v,c as N,d as b,a as y,L as i,I as o,B as C,a2 as S,a3 as l}from"./index-CBfjqtE-.js";import{b as k}from"./vendor-router-BFibuab1.js";const E=S({email:l().email("Enter a valid email"),password:l().min(8,"Password must be at least 8 characters"),confirm:l()}).refine(a=>a.password===a.confirm,{message:"Passwords do not match",path:["confirm"]});function B(){const a=k(),{resolvedTheme:d}=g(),p=d==="dark"?"/logo-dark.svg":"/logo.svg",{register:r,handleSubmit:x,setError:c,formState:{errors:s,isSubmitting:m}}=j({resolver:w(E),mode:"onBlur"});f.useEffect(()=>{fetch("/api/v1/auth/status").then(t=>t.json()).then(({initialized:t})=>{t&&a("/login",{replace:!0})}).catch(()=>{})},[a]);async function h(t){try{const n=await fetch("/api/v1/auth/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t.email,password:t.password})});if(!n.ok){const u=await n.json();c("root",{message:u.error??"Failed to create account"});return}a("/login",{replace:!0})}catch{c("root",{message:"Network error. Please try again."})}}return e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:p,alt:"tapflow",className:"w-6 h-6"}),e.jsx("span",{className:"text-base font-semibold tracking-tight",children:"tapflow"})]}),e.jsxs(v,{level:4,className:"w-full",children:[e.jsx(N,{className:"text-center",children:e.jsx(b,{className:"text-2xl tracking-display-md",children:"Set up tapflow"})}),e.jsx(y,{children:e.jsxs("form",{onSubmit:x(h),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"email",children:"Admin email"}),e.jsx(o,{id:"email",type:"email",placeholder:"admin@yourteam.com",autoComplete:"email",...r("email")}),s.email&&e.jsx("p",{className:"text-sm text-destructive",children:s.email.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"password",children:"Password"}),e.jsx(o,{id:"password",type:"password",autoComplete:"new-password",...r("password")}),s.password&&e.jsx("p",{className:"text-sm text-destructive",children:s.password.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(o,{id:"confirm",type:"password",autoComplete:"new-password",...r("confirm")}),s.confirm&&e.jsx("p",{className:"text-sm text-destructive",children:s.confirm.message})]}),s.root&&e.jsx("p",{className:"text-sm text-destructive",children:s.root.message}),e.jsx(C,{type:"submit",size:"lg",disabled:m,className:"w-full mt-1",children:m?"Creating account…":"Create admin account"})]})})]})]})})}export{B as Setup};
@@ -1,5 +1,5 @@
1
- import{i as n,j as e}from"./vendor-react-AJpf4YZ0.js";import{W as _,ad as z,a5 as J,B as t,L as D,I as G,h as q,C as U,c as W,d as K,a as X,a4 as j,a2 as I,a3 as u,G as Y}from"./index-9vdYIm7s.js";import{D as Z,f as ee,a as se,d as ae,e as ie,S as N,i as w,j as T,g as k,h as i}from"./dialog-DK9a3b4z.js";import{A as ne,c as te,f as le,g as re,d as ce,e as oe,b as de,a as me}from"./alert-dialog-CgatMXjB.js";import{T as he,d as xe,e as A,c as l,a as je,b as r}from"./table-DW57-o1p.js";import"./vendor-router-ChFy8CZ1.js";/**
2
- * @license lucide-react v1.33.0 - ISC
1
+ import{i as n,j as e}from"./vendor-react-AJpf4YZ0.js";import{W as _,ad as z,a5 as J,B as t,L as D,I as G,h as q,C as U,c as W,d as K,a as X,a4 as j,a2 as I,a3 as u,G as Y}from"./index-CBfjqtE-.js";import{D as Z,f as ee,a as se,d as ae,e as ie,S as N,i as w,j as T,g as k,h as i}from"./dialog-B4Wg7TCg.js";import{A as ne,c as te,f as le,g as re,d as ce,e as oe,b as de,a as me}from"./alert-dialog-Cc_pQpe6.js";import{T as he,d as xe,e as A,c as l,a as je,b as r}from"./table-dbLmBL_w.js";import"./vendor-router-BFibuab1.js";/**
2
+ * @license lucide-react v1.41.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
@@ -0,0 +1 @@
1
+ import{i as n,j as e}from"./vendor-react-AJpf4YZ0.js";import{ad as $,a5 as H,B as d,a4 as t,L as k,I as S,C as O,c as z,d as V,b as W,a as M,a2 as J,a3 as A}from"./index-CBfjqtE-.js";import{B as I}from"./badge-CikXk90N.js";import{A as U,c as q,f as G,g as K,d as Q,e as X,b as Y}from"./alert-dialog-Cc_pQpe6.js";import{D as Z,f as ee,a as se,d as te,e as ae,S as ne,i as re,j as oe,g as ie,h as B}from"./dialog-B4Wg7TCg.js";import{T as le,d as ce,e as w,c as x,a as de,b as i}from"./table-dbLmBL_w.js";import{P as xe,T as he}from"./trash-VgeHmI8N.js";import"./vendor-router-BFibuab1.js";async function me(){const a=window.location.protocol==="https:"?"wss":"ws";if(["localhost","127.0.0.1","[::1]"].includes(window.location.hostname))try{const h=await fetch("/api/v1/relay/host",{credentials:"include"});if(h.ok){const{lanHost:l,port:o}=await h.json();if(l)return`${a}://${l}:${o}`}}catch{}return`${a}://${window.location.host}`}const pe=J({name:A().min(1),expiresDays:A().refine(a=>{const r=parseInt(a,10);return!isNaN(r)&&r>=1&&r<=365},{message:"Must be between 1 and 365"})});function Ne(){const[a,r]=n.useState([]),[h,l]=n.useState(!1),[o,y]=n.useState(""),[c,v]=n.useState("api"),[N,b]=n.useState(""),[u,j]=n.useState(null),{register:T,handleSubmit:E,reset:_,formState:{errors:m,isSubmitting:C}}=$({resolver:H(pe),mode:"onBlur",defaultValues:{name:"",expiresDays:"30"}});function g(){fetch("/api/v1/tokens",{credentials:"include"}).then(s=>s.json()).then(r)}n.useEffect(()=>{g()},[]);async function F(s){try{const p=await fetch("/api/v1/tokens",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,expires_in_days:parseInt(s.expiresDays,10),...c==="agent"?{scope:"agent"}:{}})});if(!p.ok){const f=await p.json().catch(()=>null);t.error((f==null?void 0:f.error)??"Failed to create token");return}const P=await p.json();c==="agent"&&b(await me()),t.success("Token created"),y(P.token),g()}catch{t.error("Network error")}}function R(s){l(s),s||(y(""),v("api"),b(""),_())}async function L(s){try{return(await fetch(`/api/v1/tokens/${s}`,{method:"DELETE",credentials:"include"})).ok?(t.success("Token revoked"),g(),!0):(t.error("Failed to revoke token"),!1)}catch{return t.error("Network error"),!1}}function D(s){return s.expires_at&&new Date(s.expires_at)<new Date}return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Personal Access Tokens"}),e.jsxs(Z,{open:h,onOpenChange:R,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(d,{size:"sm",children:[e.jsx(xe,{className:"mr-2 h-4 w-4"}),"New token"]})}),e.jsxs(se,{className:"sm:max-w-md",children:[e.jsx(te,{children:e.jsx(ae,{children:"Create token"})}),o?e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Copy this token now — it won't be shown again."}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all font-mono",children:o}),c==="agent"&&N&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this on the agent Mac to connect it to this relay:"}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all font-mono",children:`tapflow agent start --relay ${N} --token ${o}`})]}),e.jsx(d,{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{t.success("Token copied to clipboard"),l(!1)}).catch(()=>t.error("Failed to copy — copy manually"))},children:"Copy & close"})]}):e.jsxs("form",{onSubmit:E(F),className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"token-name",children:"Name"}),e.jsx(S,{id:"token-name",placeholder:"e.g. ci-deploy",...T("name")}),m.name&&e.jsx("p",{className:"text-sm text-destructive",children:m.name.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"expires",children:"Expires in (days)"}),e.jsx(S,{id:"expires",type:"number",...T("expiresDays")}),m.expiresDays&&e.jsx("p",{className:"text-sm text-destructive",children:m.expiresDays.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"token-type",children:"Type"}),e.jsxs(ne,{value:c,onValueChange:s=>v(s),children:[e.jsx(re,{id:"token-type",children:e.jsx(oe,{})}),e.jsxs(ie,{children:[e.jsx(B,{value:"api",children:"API — CI uploads & API access"}),e.jsx(B,{value:"agent",children:"Agent — connect remote device agents (Admin only)"})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Scope: ",e.jsx(I,{variant:"secondary",children:c==="agent"?"agent":"view, builds:write"})]}),e.jsx(d,{type:"submit",disabled:C,children:C?"Creating…":"Create token"})]})]})]})]}),e.jsxs(O,{children:[e.jsxs(z,{children:[e.jsx(V,{children:"Active tokens"}),e.jsxs(W,{children:["Use these tokens with ",e.jsx("code",{className:"text-xs",children:"Authorization: Bearer <token>"})," for API deployments."]})]}),e.jsx(M,{className:"px-4 pt-0 pb-2",children:e.jsxs(le,{children:[e.jsx(ce,{children:e.jsxs(w,{children:[e.jsx(x,{children:"Name"}),e.jsx(x,{children:"Scope"}),e.jsx(x,{children:"Last used"}),e.jsx(x,{children:"Expires"}),e.jsx(x,{className:"w-10"})]})}),e.jsx(de,{children:a.length===0?e.jsx(w,{children:e.jsx(i,{colSpan:5,className:"h-20 text-center text-muted-foreground",children:"No tokens yet."})}):a.map(s=>e.jsxs(w,{className:"hover:bg-transparent",children:[e.jsx(i,{className:"font-medium",children:s.name}),e.jsx(i,{children:e.jsx(I,{variant:"secondary",children:s.scope})}),e.jsx(i,{className:"text-muted-foreground text-sm",children:s.last_used_at?new Date(s.last_used_at).toLocaleDateString():"Never"}),e.jsx(i,{children:s.expires_at?e.jsx("span",{className:D(s)?"text-destructive text-sm":"text-muted-foreground text-sm",children:D(s)?"Expired":new Date(s.expires_at).toLocaleDateString()}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Never"})}),e.jsx(i,{children:e.jsx(d,{variant:"destructive",size:"icon",className:"h-7 w-7","aria-label":"Revoke token",onClick:()=>j(s.id),children:e.jsx(he,{className:"h-4 w-4"})})})]},s.id))})]})})]}),e.jsx(U,{open:u!==null,onOpenChange:s=>{s||j(null)},children:e.jsxs(q,{children:[e.jsxs(G,{children:[e.jsx(K,{children:"Revoke token?"}),e.jsx(Q,{children:"Any active API calls using this token will immediately fail."})]}),e.jsxs(X,{children:[e.jsx(Y,{children:"Cancel"}),e.jsx(d,{variant:"destructive",onClick:async()=>{if(u===null)return;await L(u)&&j(null)},children:"Revoke"})]})]})})]})}export{Ne as TokenSettings};
@@ -1 +1 @@
1
- import{i as r,j as o}from"./vendor-react-AJpf4YZ0.js";import{m as O,a9 as u,j as T,K as S,n as b,k as $,i as m,Q as v,l as E,O as h,D as z,o as F,J as g,H as x}from"./index-9vdYIm7s.js";var H=Object.defineProperty,n=(t,e)=>H(t,"name",{value:e,configurable:!0}),k="AlertDialog",[M,pe]=h(k,[v]),c=v(),I=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(z,{...l,...a,modal:!0})},"AlertDialog"),J=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(F,{...s,...i,ref:a})},"AlertDialogTrigger")),K=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(O,{...l,...a})},"AlertDialogPortal"),L=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(E,{...s,...i,ref:a})},"AlertDialogOverlay")),Q="AlertDialogContent",[V,q]=M(Q),B=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,children:i,...s}=e,p=c(l),f=r.useRef(null),P=u(a,f),D=r.useRef(null);return o.jsx(V,{scope:l,cancelRef:D,children:o.jsx(T,{role:"alertdialog",...p,...s,ref:P,onOpenAutoFocus:S(s.onOpenAutoFocus,d=>{var A;d.preventDefault(),(A=D.current)==null||A.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:i})})},"AlertDialogContent")),G=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(b,{...s,...i,ref:a})},"AlertDialogTitle")),U=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx($,{...s,...i,ref:a})},"AlertDialogDescription")),W=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(m,{...s,...i,ref:a})},"AlertDialogAction")),X="AlertDialogCancel",Y=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,{cancelRef:s}=q(X,l),p=c(l),f=u(a,s);return o.jsx(m,{...p,...i,ref:f})},"AlertDialogCancel")),Z=I,ee=J,ae=K,N=L,j=B,y=W,_=Y,C=G,R=U;const fe=Z,De=ee,te=ae,w=r.forwardRef(({className:t,...e},a)=>o.jsx(N,{className:g("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:a}));w.displayName=N.displayName;const oe=r.forwardRef(({className:t,...e},a)=>o.jsxs(te,{children:[o.jsx(w,{}),o.jsx(j,{ref:a,className:g("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));oe.displayName=j.displayName;const le=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col space-y-2 text-center sm:text-left",t),...e});le.displayName="AlertDialogHeader";const re=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});re.displayName="AlertDialogFooter";const se=r.forwardRef(({className:t,...e},a)=>o.jsx(C,{ref:a,className:g("text-lg font-semibold",t),...e}));se.displayName=C.displayName;const ie=r.forwardRef(({className:t,...e},a)=>o.jsx(R,{ref:a,className:g("text-sm text-muted-foreground",t),...e}));ie.displayName=R.displayName;const ne=r.forwardRef(({className:t,...e},a)=>o.jsx(y,{ref:a,className:g(x(),t),...e}));ne.displayName=y.displayName;const ce=r.forwardRef(({className:t,...e},a)=>o.jsx(_,{ref:a,className:g(x({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ce.displayName=_.displayName;export{fe as A,ne as a,ce as b,oe as c,ie as d,re as e,le as f,se as g,De as h};
1
+ import{i as r,j as o}from"./vendor-react-AJpf4YZ0.js";import{m as O,a9 as u,j as T,K as S,n as b,k as $,i as m,Q as v,l as E,O as h,D as z,o as F,J as g,H as x}from"./index-CBfjqtE-.js";var H=Object.defineProperty,n=(t,e)=>H(t,"name",{value:e,configurable:!0}),k="AlertDialog",[M,pe]=h(k,[v]),c=v(),I=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(z,{...l,...a,modal:!0})},"AlertDialog"),J=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(F,{...s,...i,ref:a})},"AlertDialogTrigger")),K=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(O,{...l,...a})},"AlertDialogPortal"),L=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(E,{...s,...i,ref:a})},"AlertDialogOverlay")),Q="AlertDialogContent",[V,q]=M(Q),B=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,children:i,...s}=e,p=c(l),f=r.useRef(null),P=u(a,f),D=r.useRef(null);return o.jsx(V,{scope:l,cancelRef:D,children:o.jsx(T,{role:"alertdialog",...p,...s,ref:P,onOpenAutoFocus:S(s.onOpenAutoFocus,d=>{var A;d.preventDefault(),(A=D.current)==null||A.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:i})})},"AlertDialogContent")),G=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(b,{...s,...i,ref:a})},"AlertDialogTitle")),U=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx($,{...s,...i,ref:a})},"AlertDialogDescription")),W=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(m,{...s,...i,ref:a})},"AlertDialogAction")),X="AlertDialogCancel",Y=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,{cancelRef:s}=q(X,l),p=c(l),f=u(a,s);return o.jsx(m,{...p,...i,ref:f})},"AlertDialogCancel")),Z=I,ee=J,ae=K,N=L,j=B,y=W,_=Y,C=G,R=U;const fe=Z,De=ee,te=ae,w=r.forwardRef(({className:t,...e},a)=>o.jsx(N,{className:g("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:a}));w.displayName=N.displayName;const oe=r.forwardRef(({className:t,...e},a)=>o.jsxs(te,{children:[o.jsx(w,{}),o.jsx(j,{ref:a,className:g("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));oe.displayName=j.displayName;const le=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col space-y-2 text-center sm:text-left",t),...e});le.displayName="AlertDialogHeader";const re=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});re.displayName="AlertDialogFooter";const se=r.forwardRef(({className:t,...e},a)=>o.jsx(C,{ref:a,className:g("text-lg font-semibold",t),...e}));se.displayName=C.displayName;const ie=r.forwardRef(({className:t,...e},a)=>o.jsx(R,{ref:a,className:g("text-sm text-muted-foreground",t),...e}));ie.displayName=R.displayName;const ne=r.forwardRef(({className:t,...e},a)=>o.jsx(y,{ref:a,className:g(x(),t),...e}));ne.displayName=y.displayName;const ce=r.forwardRef(({className:t,...e},a)=>o.jsx(_,{ref:a,className:g(x({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ce.displayName=_.displayName;export{fe as A,ne as a,ce as b,oe as c,ie as d,re as e,le as f,se as g,De as h};
@@ -1 +1 @@
1
- import{j as n}from"./vendor-react-AJpf4YZ0.js";import{J as d,a0 as o}from"./index-9vdYIm7s.js";const s=o("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"},tone:{backlog:"border-transparent bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",progress:"border-transparent bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",done:"border-transparent bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300",rejected:"border-transparent bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300",ios:"border-transparent bg-sky-50 text-sky-700 dark:bg-sky-950 dark:text-sky-300",android:"border-transparent bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300"}},defaultVariants:{variant:"default"}});function g({className:r,variant:e,tone:t,...a}){return n.jsx("div",{className:d(s({variant:e,tone:t}),r),...a})}export{g as B};
1
+ import{j as n}from"./vendor-react-AJpf4YZ0.js";import{J as d,a0 as o}from"./index-CBfjqtE-.js";const s=o("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"},tone:{backlog:"border-transparent bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",progress:"border-transparent bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",done:"border-transparent bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300",rejected:"border-transparent bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300",ios:"border-transparent bg-sky-50 text-sky-700 dark:bg-sky-950 dark:text-sky-300",android:"border-transparent bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300"}},defaultVariants:{variant:"default"}});function g({className:r,variant:e,tone:t,...a}){return n.jsx("div",{className:d(s({variant:e,tone:t}),r),...a})}export{g as B};