@tapflowio/relay 0.23.0 → 0.25.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 (204) hide show
  1. package/dist/RelayServer.d.ts +45 -0
  2. package/dist/RelayServer.d.ts.map +1 -1
  3. package/dist/RelayServer.js +263 -38
  4. package/dist/RelayServer.js.map +1 -1
  5. package/dist/api/apps.d.ts.map +1 -1
  6. package/dist/api/apps.js +6 -16
  7. package/dist/api/apps.js.map +1 -1
  8. package/dist/api/auth.d.ts +1 -1
  9. package/dist/api/auth.d.ts.map +1 -1
  10. package/dist/api/auth.js +13 -14
  11. package/dist/api/auth.js.map +1 -1
  12. package/dist/api/builds.d.ts +1 -1
  13. package/dist/api/builds.d.ts.map +1 -1
  14. package/dist/api/builds.js +15 -7
  15. package/dist/api/builds.js.map +1 -1
  16. package/dist/api/comments.d.ts.map +1 -1
  17. package/dist/api/comments.js +41 -15
  18. package/dist/api/comments.js.map +1 -1
  19. package/dist/api/invitations.d.ts +1 -1
  20. package/dist/api/invitations.d.ts.map +1 -1
  21. package/dist/api/invitations.js +7 -3
  22. package/dist/api/invitations.js.map +1 -1
  23. package/dist/api/passwordReset.js +2 -2
  24. package/dist/api/team.d.ts +2 -2
  25. package/dist/api/team.d.ts.map +1 -1
  26. package/dist/api/team.js +6 -2
  27. package/dist/api/team.js.map +1 -1
  28. package/dist/api/tokens.d.ts +1 -1
  29. package/dist/api/tokens.d.ts.map +1 -1
  30. package/dist/api/tokens.js +26 -7
  31. package/dist/api/tokens.js.map +1 -1
  32. package/dist/api/webhooks.d.ts.map +1 -1
  33. package/dist/api/webhooks.js +11 -5
  34. package/dist/api/webhooks.js.map +1 -1
  35. package/dist/index.d.ts +3 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +2 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/lib/buildFiles.d.ts +23 -0
  40. package/dist/lib/buildFiles.d.ts.map +1 -0
  41. package/dist/lib/buildFiles.js +39 -0
  42. package/dist/lib/buildFiles.js.map +1 -0
  43. package/dist/lib/clientAddress.d.ts +7 -0
  44. package/dist/lib/clientAddress.d.ts.map +1 -1
  45. package/dist/lib/clientAddress.js +15 -0
  46. package/dist/lib/clientAddress.js.map +1 -1
  47. package/dist/lib/config.d.ts +26 -1
  48. package/dist/lib/config.d.ts.map +1 -1
  49. package/dist/lib/config.js +81 -17
  50. package/dist/lib/config.js.map +1 -1
  51. package/dist/lib/connectionAuth.d.ts +57 -2
  52. package/dist/lib/connectionAuth.d.ts.map +1 -1
  53. package/dist/lib/connectionAuth.js +65 -6
  54. package/dist/lib/connectionAuth.js.map +1 -1
  55. package/dist/lib/dataDir.d.ts +48 -1
  56. package/dist/lib/dataDir.d.ts.map +1 -1
  57. package/dist/lib/dataDir.js +108 -12
  58. package/dist/lib/dataDir.js.map +1 -1
  59. package/dist/middleware/auth.d.ts +44 -4
  60. package/dist/middleware/auth.d.ts.map +1 -1
  61. package/dist/middleware/auth.js +102 -30
  62. package/dist/middleware/auth.js.map +1 -1
  63. package/dist/server.js +2 -1
  64. package/dist/server.js.map +1 -1
  65. package/package.json +4 -4
  66. package/public/assets/AppCenter-D_1rFI40.js +26 -0
  67. package/public/assets/AppCenter-D_1rFI40.js.br +0 -0
  68. package/public/assets/AppCenter-D_1rFI40.js.gz +0 -0
  69. package/public/assets/Default-DF_X2_3I.js +1 -0
  70. package/public/assets/Default-DF_X2_3I.js.br +0 -0
  71. package/public/assets/Default-DF_X2_3I.js.gz +0 -0
  72. package/public/assets/Invite-DETTWdYp.js +1 -0
  73. package/public/assets/Invite-DETTWdYp.js.br +0 -0
  74. package/public/assets/Invite-DETTWdYp.js.gz +0 -0
  75. package/public/assets/MacResources--1Enisxs.js +1 -0
  76. package/public/assets/MacResources--1Enisxs.js.br +0 -0
  77. package/public/assets/MacResources--1Enisxs.js.gz +0 -0
  78. package/public/assets/NotFound-wHOnT2Fl.js +1 -0
  79. package/public/assets/NotFound-wHOnT2Fl.js.br +0 -0
  80. package/public/assets/NotFound-wHOnT2Fl.js.gz +0 -0
  81. package/public/assets/QASession-BjoD9Toj.js +150 -0
  82. package/public/assets/QASession-BjoD9Toj.js.br +0 -0
  83. package/public/assets/QASession-BjoD9Toj.js.gz +0 -0
  84. package/public/assets/ResetPassword-B9miyXTP.js +1 -0
  85. package/public/assets/ResetPassword-B9miyXTP.js.br +0 -0
  86. package/public/assets/ResetPassword-B9miyXTP.js.gz +0 -0
  87. package/public/assets/Setup-CywZCqHU.js +1 -0
  88. package/public/assets/Setup-CywZCqHU.js.br +0 -0
  89. package/public/assets/Setup-CywZCqHU.js.gz +0 -0
  90. package/public/assets/Team-CxdX_9mY.js +6 -0
  91. package/public/assets/Team-CxdX_9mY.js.br +0 -0
  92. package/public/assets/Team-CxdX_9mY.js.gz +0 -0
  93. package/public/assets/Tokens-BQnnawvG.js +1 -0
  94. package/public/assets/Tokens-BQnnawvG.js.br +0 -0
  95. package/public/assets/Tokens-BQnnawvG.js.gz +0 -0
  96. package/public/assets/alert-dialog-CuPdBkxF.js +1 -0
  97. package/public/assets/alert-dialog-CuPdBkxF.js.br +0 -0
  98. package/public/assets/alert-dialog-CuPdBkxF.js.gz +0 -0
  99. package/public/assets/badge-CSVsKOK_.js +1 -0
  100. package/public/assets/badge-CSVsKOK_.js.br +0 -0
  101. package/public/assets/badge-CSVsKOK_.js.gz +0 -0
  102. package/public/assets/build-format-l9BrlbZl.js +11 -0
  103. package/public/assets/build-format-l9BrlbZl.js.br +0 -0
  104. package/public/assets/build-format-l9BrlbZl.js.gz +0 -0
  105. package/public/assets/dialog-B6jt7-2f.js +11 -0
  106. package/public/assets/dialog-B6jt7-2f.js.br +0 -0
  107. package/public/assets/dialog-B6jt7-2f.js.gz +0 -0
  108. package/public/assets/index-Cm17I31a.js +218 -0
  109. package/public/assets/index-Cm17I31a.js.br +0 -0
  110. package/public/assets/index-Cm17I31a.js.gz +0 -0
  111. package/public/assets/index-D_P99bPX.css +1 -0
  112. package/public/assets/index-D_P99bPX.css.br +0 -0
  113. package/public/assets/index-D_P99bPX.css.gz +0 -0
  114. package/public/assets/list-view-Bp6pvsde.js +1 -0
  115. package/public/assets/list-view-Bp6pvsde.js.br +0 -0
  116. package/public/assets/list-view-Bp6pvsde.js.gz +0 -0
  117. package/public/assets/{pencil-CPaoEKFm.js → pencil-g-WiK1F2.js} +2 -2
  118. package/public/assets/pencil-g-WiK1F2.js.br +0 -0
  119. package/public/assets/pencil-g-WiK1F2.js.gz +0 -0
  120. package/public/assets/resource-health-BbeyA8an.js +1 -0
  121. package/public/assets/resource-health-BbeyA8an.js.br +0 -0
  122. package/public/assets/resource-health-BbeyA8an.js.gz +0 -0
  123. package/public/assets/{trash-CD9Y9G-i.js → trash-DHPg15P4.js} +3 -3
  124. package/public/assets/trash-DHPg15P4.js.br +0 -0
  125. package/public/assets/trash-DHPg15P4.js.gz +0 -0
  126. package/public/assets/useFocusAfterSwap-BY3N9f9v.js +1 -0
  127. package/public/assets/useFocusAfterSwap-BY3N9f9v.js.br +0 -0
  128. package/public/assets/useFocusAfterSwap-BY3N9f9v.js.gz +0 -0
  129. package/public/assets/{vendor-charts-YPhPkjLw.js → vendor-charts-BykzUV2D.js} +1 -1
  130. package/public/assets/vendor-charts-BykzUV2D.js.br +0 -0
  131. package/public/assets/vendor-charts-BykzUV2D.js.gz +0 -0
  132. package/public/assets/{vendor-react-C5H_1fOn.js → vendor-react-BlPSzrEe.js} +18 -10
  133. package/public/assets/vendor-react-BlPSzrEe.js.br +0 -0
  134. package/public/assets/vendor-react-BlPSzrEe.js.gz +0 -0
  135. package/public/assets/{vendor-router-CnmrRwJF.js → vendor-router-B_lVHrKl.js} +3 -3
  136. package/public/assets/vendor-router-B_lVHrKl.js.br +0 -0
  137. package/public/assets/vendor-router-B_lVHrKl.js.gz +0 -0
  138. package/public/index.html +4 -4
  139. package/public/index.html.br +0 -0
  140. package/public/index.html.gz +0 -0
  141. package/public/assets/AppCenter-OTDuqwSf.js +0 -21
  142. package/public/assets/AppCenter-OTDuqwSf.js.br +0 -0
  143. package/public/assets/AppCenter-OTDuqwSf.js.gz +0 -0
  144. package/public/assets/Default-D9GLpWlN.js +0 -1
  145. package/public/assets/Default-D9GLpWlN.js.br +0 -0
  146. package/public/assets/Default-D9GLpWlN.js.gz +0 -0
  147. package/public/assets/Invite-Bhiam8En.js +0 -1
  148. package/public/assets/Invite-Bhiam8En.js.br +0 -0
  149. package/public/assets/Invite-Bhiam8En.js.gz +0 -0
  150. package/public/assets/MacResources-DObzVJxQ.js +0 -3
  151. package/public/assets/MacResources-DObzVJxQ.js.br +0 -0
  152. package/public/assets/MacResources-DObzVJxQ.js.gz +0 -0
  153. package/public/assets/NotFound-Dz_k_Mzf.js +0 -1
  154. package/public/assets/NotFound-Dz_k_Mzf.js.br +0 -0
  155. package/public/assets/NotFound-Dz_k_Mzf.js.gz +0 -0
  156. package/public/assets/QASession-2crubOLY.js +0 -150
  157. package/public/assets/QASession-2crubOLY.js.br +0 -0
  158. package/public/assets/QASession-2crubOLY.js.gz +0 -0
  159. package/public/assets/ResetPassword-EUm12ojo.js +0 -1
  160. package/public/assets/ResetPassword-EUm12ojo.js.br +0 -0
  161. package/public/assets/ResetPassword-EUm12ojo.js.gz +0 -0
  162. package/public/assets/Setup-Fc_0RW0a.js +0 -1
  163. package/public/assets/Setup-Fc_0RW0a.js.br +0 -0
  164. package/public/assets/Setup-Fc_0RW0a.js.gz +0 -0
  165. package/public/assets/Team-Ac5aOGgx.js +0 -6
  166. package/public/assets/Team-Ac5aOGgx.js.br +0 -0
  167. package/public/assets/Team-Ac5aOGgx.js.gz +0 -0
  168. package/public/assets/Tokens-pEnCy-7l.js +0 -1
  169. package/public/assets/Tokens-pEnCy-7l.js.br +0 -0
  170. package/public/assets/Tokens-pEnCy-7l.js.gz +0 -0
  171. package/public/assets/alert-dialog-DhOTocMh.js +0 -1
  172. package/public/assets/alert-dialog-DhOTocMh.js.br +0 -0
  173. package/public/assets/alert-dialog-DhOTocMh.js.gz +0 -0
  174. package/public/assets/badge-B4gbViMs.js +0 -1
  175. package/public/assets/badge-B4gbViMs.js.br +0 -0
  176. package/public/assets/badge-B4gbViMs.js.gz +0 -0
  177. package/public/assets/build-format-DKGajT96.js +0 -11
  178. package/public/assets/build-format-DKGajT96.js.br +0 -0
  179. package/public/assets/build-format-DKGajT96.js.gz +0 -0
  180. package/public/assets/dialog-DEL1xxKJ.js +0 -11
  181. package/public/assets/dialog-DEL1xxKJ.js.br +0 -0
  182. package/public/assets/dialog-DEL1xxKJ.js.gz +0 -0
  183. package/public/assets/index-Bxs7CdEi.css +0 -1
  184. package/public/assets/index-Bxs7CdEi.css.br +0 -0
  185. package/public/assets/index-Bxs7CdEi.css.gz +0 -0
  186. package/public/assets/index-COIlCLCW.js +0 -218
  187. package/public/assets/index-COIlCLCW.js.br +0 -0
  188. package/public/assets/index-COIlCLCW.js.gz +0 -0
  189. package/public/assets/pencil-CPaoEKFm.js.br +0 -0
  190. package/public/assets/pencil-CPaoEKFm.js.gz +0 -0
  191. package/public/assets/resource-health-Ca4-5Rde.js +0 -1
  192. package/public/assets/resource-health-Ca4-5Rde.js.br +0 -0
  193. package/public/assets/resource-health-Ca4-5Rde.js.gz +0 -0
  194. package/public/assets/table-CSeGVnii.js +0 -1
  195. package/public/assets/table-CSeGVnii.js.br +0 -0
  196. package/public/assets/table-CSeGVnii.js.gz +0 -0
  197. package/public/assets/trash-CD9Y9G-i.js.br +0 -0
  198. package/public/assets/trash-CD9Y9G-i.js.gz +0 -0
  199. package/public/assets/vendor-charts-YPhPkjLw.js.br +0 -0
  200. package/public/assets/vendor-charts-YPhPkjLw.js.gz +0 -0
  201. package/public/assets/vendor-react-C5H_1fOn.js.br +0 -0
  202. package/public/assets/vendor-react-C5H_1fOn.js.gz +0 -0
  203. package/public/assets/vendor-router-CnmrRwJF.js.br +0 -0
  204. package/public/assets/vendor-router-CnmrRwJF.js.gz +0 -0
@@ -1,150 +0,0 @@
1
- import{i as s,j as n}from"./vendor-react-C5H_1fOn.js";import{a1 as ee,W as re,J as pn,T as be,K as ye,B as ae,H as ve,q as cs,u as ls,r as us,s as ds,t as fs,S as Jn,a9 as Le,w as hs,x as en,Y as tt,ae as ut,y as dt,$ as Qn,ad as Rt,ak as ps,ag as ms,U as gs,G as xs,f as bs,al as ys,af as vs,ac as ws,L as Ss}from"./index-COIlCLCW.js";import{f as Rs,a as ks,P as Zn,c as Mn,S as js,b as Cs}from"./build-format-DKGajT96.js";import{u as er,n as G,T as Ts,b as Es,c as In,a as $n,R as As,g as _s}from"./resource-health-Ca4-5Rde.js";import{c as tr,b as Ns}from"./vendor-router-CnmrRwJF.js";import{A as Ps,c as Ds,f as Ls,g as Ms,d as Is,e as $s,b as Us,a as zs}from"./alert-dialog-DhOTocMh.js";import{D as nr,a as rr,d as Fs,e as sr,b as Bs,c as Os,k as Hs,S as Vs,i as Ws,j as qs,g as Xs,h as Un}from"./dialog-DEL1xxKJ.js";import{l as zn,j as Ks}from"./publicLink-D6zKS_wu.js";import{B as Ys}from"./badge-B4gbViMs.js";/**
2
- * @license lucide-react v1.45.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 or={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};or.node;const Gs=ee(or);/**
7
- * @license lucide-react v1.45.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 ar={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};ar.node;const Js=ee(ar);/**
12
- * @license lucide-react v1.45.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 ir={name:"camera",size:24,node:[["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"}]]};ir.node;const Qs=ee(ir);/**
17
- * @license lucide-react v1.45.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 cr={name:"download",size:24,node:[["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"}]]};cr.node;const Zs=ee(cr);/**
22
- * @license lucide-react v1.45.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 lr={name:"film",size:24,node:[["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"}]]};lr.node;const eo=ee(lr);/**
27
- * @license lucide-react v1.45.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 ur={name:"fold-horizontal",size:24,node:[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]};ur.node;const to=ee(ur);/**
32
- * @license lucide-react v1.45.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 dr={name:"house",size:24,node:[["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"}]],aliases:["home"]};dr.node;const fr=ee(dr);/**
37
- * @license lucide-react v1.45.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 hr={name:"image-plus",size:24,node:[["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"}]]};hr.node;const no=ee(hr);/**
42
- * @license lucide-react v1.45.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 pr={name:"keyboard",size:24,node:[["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"}]]};pr.node;const ro=ee(pr);/**
47
- * @license lucide-react v1.45.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 mr={name:"link-2",size:24,node:[["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"}]]};mr.node;const gr=ee(mr);/**
52
- * @license lucide-react v1.45.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 xr={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};xr.node;const kt=ee(xr);/**
57
- * @license lucide-react v1.45.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 br={name:"message-square",size:24,node:[["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"}]]};br.node;const so=ee(br);/**
62
- * @license lucide-react v1.45.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 yr={name:"power",size:24,node:[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]};yr.node;const oo=ee(yr);/**
67
- * @license lucide-react v1.45.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 vr={name:"radio-off",size:24,node:[["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"}]]};vr.node;const ao=ee(vr);/**
72
- * @license lucide-react v1.45.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 wr={name:"radio",size:24,node:[["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"}]]};wr.node;const un=ee(wr);/**
77
- * @license lucide-react v1.45.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 Sr={name:"refresh-cw",size:24,node:[["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"}]]};Sr.node;const io=ee(Sr);/**
82
- * @license lucide-react v1.45.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 Rr={name:"rotate-cw",size:24,node:[["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"}]]};Rr.node;const co=ee(Rr);/**
87
- * @license lucide-react v1.45.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 kr={name:"scan-line",size:24,node:[["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"}]]};kr.node;const lo=ee(kr);/**
92
- * @license lucide-react v1.45.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 jr={name:"square",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]};jr.node;const uo=ee(jr);/**
97
- * @license lucide-react v1.45.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 Cr={name:"unfold-horizontal",size:24,node:[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]};Cr.node;const fo=ee(Cr);/**
102
- * @license lucide-react v1.45.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 Tr={name:"video",size:24,node:[["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"}]]};Tr.node;const ho=ee(Tr);/**
107
- * @license lucide-react v1.45.0 - ISC
108
- *
109
- * This source code is licensed under the ISC license.
110
- * See the LICENSE file in the root directory of this source tree.
111
- */const Er={name:"volume-1",size:24,node:[["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"}]]};Er.node;const po=ee(Er);/**
112
- * @license lucide-react v1.45.0 - ISC
113
- *
114
- * This source code is licensed under the ISC license.
115
- * See the LICENSE file in the root directory of this source tree.
116
- */const Ar={name:"volume-2",size:24,node:[["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"}]]};Ar.node;const mo=ee(Ar);function go(e){const[t,r]=s.useState(null);return s.useEffect(()=>{e&&Rs(e).then(r)},[e]),{build:t}}function xo(e){const[t,r]=s.useState([]),[o,i]=s.useState(null),[a,c]=s.useState(null),[l,u]=s.useState(""),[h,f]=s.useState(!1),[m,g]=s.useState(""),d=s.useCallback(R=>{R.type==="agents:listed"&&r(R.sessions),R.type==="session:joined"&&(f(!1),g("Connected")),R.type==="error"&&(f(!1),g(`Error: ${R.message}`))},[]),{send:b,connected:v}=er(d);s.useEffect(()=>{if(!v)return;b({type:"agents:list"});const R=setInterval(()=>b({type:"agents:list"}),5e3);return()=>clearInterval(R)},[v,b]);const _=s.useRef({sessionId:a,deviceId:l});s.useEffect(()=>{_.current={sessionId:a,deviceId:l}},[a,l]),s.useEffect(()=>()=>{const{sessionId:R,deviceId:$}=_.current;R&&$&&b({type:"device:shutdown",sessionId:R,payload:{deviceId:$}})},[b]);const C=t.filter(R=>R.devices.some($=>$.platform===e)),D=s.useCallback(R=>{u(R.id),f(!0),g("Booting…"),c(R.sessionId)},[]),k=s.useCallback(()=>u(""),[]),A=s.useCallback(()=>{const{sessionId:R,deviceId:$}=_.current;R&&$&&b({type:"device:shutdown",sessionId:R,payload:{deviceId:$}}),c(null),f(!1),g("")},[b]),T=s.useCallback(()=>{const{sessionId:R,deviceId:$}=_.current;R&&$&&b({type:"device:shutdown",sessionId:R,payload:{deviceId:$}}),c(null),i(null),f(!1),g(""),b({type:"agents:list"})},[b]),P=s.useCallback(()=>{c(null),i(null),f(!1),g(""),b({type:"agents:list"})},[b]);return{sessions:t,selectedAgent:o,setSelectedAgent:i,activeSessionId:a,deviceId:l,booting:h,status:m,send:b,connected:v,agentGroups:C,startDevice:D,resetDevice:k,handleBack:A,handleBackToMacs:T,handleSessionEnded:P}}function bo(e,t){const[r,o]=s.useState(""),[i,a]=s.useState(""),[c,l]=s.useState("app-only"),[u,h]=s.useState("app-only"),f=(e==null?void 0:e.capabilities.includes("full-reset"))??!1,m=s.useCallback(()=>{h(f?c:"app-only"),l("app-only")},[c,f]),g=(e==null?void 0:e.devices.filter(v=>v.platform===t))??[],d=[...new Set(g.map(v=>v.osVersion).filter(Boolean))].sort((v,_)=>{const C=A=>A.replace(/^[^\d]*/,"").split(".").map(Number),[D,k]=[C(v),C(_)];for(let A=0;A<Math.max(D.length,k.length);A++){const T=(k[A]??0)-(D[A]??0);if(T!==0)return T}return 0}),b=(r?g.filter(v=>v.osVersion===r):g).filter(v=>!i||v.name.toLowerCase().includes(i.toLowerCase()));return{filteredDevices:g,osVersions:d,osVersion:r,setOsVersion:o,deviceSearch:i,setDeviceSearch:a,versionedDevices:b,resetMode:c,setResetMode:l,appliedResetMode:u,consumeResetMode:m,fullResetSupported:f}}function yo(){const[e]=tr(),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 _r(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 vo(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 wo(e,t,r,o){let i=null,a=1/0;for(const c of r){const l=vo(e,t,_r(c));l<a&&(a=l,i=c.name)}return a<=o?i:null}const So=["video/mp4;codecs=avc1","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Nr({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 l=s.useRef(!1),u=s.useRef(null),h=s.useRef([]),f=s.useRef(""),m=s.useRef(0),g=s.useRef(null),d=s.useCallback(function _(){var C;l.current&&((C=g.current)==null||C.call(g),m.current=requestAnimationFrame(_))},[]),b=s.useCallback(_=>{const C=a.current;if(!C)return;const D=C.getContext("2d");D&&(D.fillStyle="#000",D.fillRect(0,0,C.width,C.height));const k=So.find(T=>MediaRecorder.isTypeSupported(T))??"";if(!k)return;f.current=k,h.current=[];const A=new MediaRecorder(C.captureStream(30),{mimeType:k});A.ondataavailable=T=>{T.data.size>0&&h.current.push(T.data)},u.current=A,A.start(1e3),g.current=_,l.current=!0,m.current=requestAnimationFrame(d),i("recording")},[d]),v=s.useCallback(async()=>{var T;i("uploading"),l.current=!1,cancelAnimationFrame(m.current);const _=u.current;if(!_){i("idle");return}await new Promise(P=>{const R=setTimeout(P,5e3);_.onstop=()=>{clearTimeout(R),P()};try{_.stop()}catch{clearTimeout(R),P()}}),u.current=null;const C=f.current,D=C.includes("mp4")?".mp4":".webm",k=new Blob(h.current,{type:C});h.current=[];const A=new FormData;A.append("file",k,`tapflow-${Date.now()}${D}`);try{const P=new URLSearchParams({sessionId:e});t&&P.set("buildId",String(t));const R=await fetch(`/api/v1/recordings/upload?${P}`,{method:"POST",credentials:"include",body:A}),$=await R.json();if(R.ok&&$.url){const Y=document.createElement("a");Y.href=$.url,Y.download="",Y.click(),(T=c.current)==null||T.call(c),i("done"),setTimeout(()=>i("idle"),2e3)}else i("idle")}catch{i("idle")}},[e,t]);return s.useEffect(()=>{if(o!=="recording")return;const _=()=>{document.visibilityState==="hidden"&&v()};return document.addEventListener("visibilitychange",_),()=>{var C;document.removeEventListener("visibilitychange",_),l.current&&(l.current=!1,cancelAnimationFrame(m.current),(C=u.current)==null||C.stop(),u.current=null)}},[o,v]),{recordState:o,recordCanvasRef:a,startClientRecording:b,stopClientRecording:v}}function Pr(){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 St({className:e,...t}){return n.jsx("kbd",{"data-slot":"kbd",className:re("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 mn({className:e,...t}){return n.jsx("kbd",{"data-slot":"kbd-group",className:re("inline-flex items-center gap-1",e),...t})}function Mt({label:e,keys:t}){return n.jsxs("span",{className:"flex items-center gap-3",children:[e,n.jsx(mn,{children:t.map(r=>n.jsx(St,{children:r},r))})]})}const Fn="text-muted-foreground hover:text-muted-foreground",Bn="text-destructive hover:text-destructive";function Ro(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 ko({position:e,steerable:t,reason:r}){const o=r==="awaiting-app",i=!t&&r==="state-unconfirmed"?" animate-pulse":"",a=t?"":Ro(r);switch(e){case"offline":return{Icon:ao,className:(t||o?"text-amber-500 hover:text-amber-500":Bn)+i,status:`Device is offline.${a}`};case"online":return{Icon:un,className:(t||o?"":Bn)+i,status:`Device is on the network.${a}`};case"waiting":return{Icon:un,className:`${Fn} animate-pulse`,status:"Checking the network state."};case"unknown":return{Icon:un,className:Fn,status:"No network state has been reported."}}}function jo({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 Dr({joined:e,onScreenshot:t,onRecordToggle:r,recordState:o,onRotate:i,posture:a,onDeepLink:c,navigationSlot:l,deviceSlot:u,launchSlot:h,network:f,reboot:m}){var D;const g=s.useId(),d=s.useId(),b=s.useId(),v=s.useId(),[_,C]=s.useState(!1);return e?n.jsxs(pn,{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:[h,l,n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Open a deeplink",onClick:c,children:n.jsx(gr,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:n.jsx(Mt,{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(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Rotate the device",onClick:i,children:n.jsx(co,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:n.jsx(Mt,{label:"Rotate",keys:["⌘","⇧","O"]})})]}),a&&a.postures.length>1&&n.jsx("span",{id:b,role:"status","aria-live":"polite",className:"sr-only",children:a.pending?"Changing posture":((D=a.postures.find(k=>k.id===a.currentId))==null?void 0:D.label)??""}),a&&a.postures.length>1&&(()=>{const k=a.postures.findIndex(W=>W.id===a.currentId),A=k===-1?null:a.postures[k],T=a.postures.length===2,P=a.postures[(k+1)%a.postures.length],R=k===-1?!1:T?a.postures.indexOf(P)>k:k===0,$=R?fo:to,Y=R?"Unfold":"Fold",U=T?A?`${Y}: ${A.label} to ${P.label}`:`${Y}: ${P.label}`:A?`Posture: ${A.label}`:"Posture",z=W=>n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8 aria-disabled:opacity-50","aria-label":a.pending?`${U} — changing`:U,"aria-busy":a.pending,"aria-disabled":a.pending,"aria-describedby":b,onClick:()=>{a.pending||W==null||W()},children:a.pending?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):n.jsx($,{className:"h-4 w-4"})});return a.pending?n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:z(T?()=>a.onSelect(P.id):void 0)}),n.jsx(ve,{side:"left",children:`${U} — changing`})]}):T?n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:z(()=>a.onSelect(P.id))}),n.jsx(ve,{side:"left",children:U})]}):n.jsxs(cs,{children:[n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ls,{asChild:!0,children:z()})}),n.jsx(ve,{side:"left",children:U})]}),n.jsx(us,{side:"left",align:"start",children:n.jsx(ds,{value:a.currentId??"",onValueChange:a.onSelect,children:a.postures.map(W=>n.jsx(fs,{value:W.id,children:W.label},W.id))})})]})})(),m&&(()=>{const k=m.pending?"Restarting the device":"Restart the device";return n.jsxs(n.Fragment,{children:[n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{ref:m.buttonRef,variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":k,"aria-busy":m.pending,"aria-disabled":m.pending,"aria-describedby":d,onClick:()=>{m.pending||C(!0)},children:m.pending?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):n.jsx(io,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:k})]}),n.jsx("span",{id:d,role:"status",className:"sr-only",children:m.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(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Take a screenshot",onClick:t,children:n.jsx(Qs,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:n.jsx(Mt,{label:"Screenshot",keys:["⌘","S"]})})]}),n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:re("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":v,onClick:()=>{(o==="idle"||o==="recording")&&r()},children:o==="uploading"?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):o==="recording"?n.jsx(uo,{className:"h-4 w-4 fill-current"}):n.jsx(ho,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:o==="idle"?n.jsx(Mt,{label:"Start recording",keys:["⌘","⇧","Y"]}):o==="recording"?n.jsx(Mt,{label:"Stop recording",keys:["⌘","⇧","Y"]}):o==="done"?"Recording saved":"Processing the recording"})]}),n.jsx("span",{id:v,role:"status",className:"sr-only",children:o==="recording"?"Recording.":o==="uploading"?"Processing the recording.":o==="done"?"Recording saved.":""})]}),f&&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:f&&(()=>{const{Icon:k,className:A,status:T}=ko(f),P=jo(f),R=f.position==="waiting"||f.position==="unknown"||!f.steerable;return n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:re("h-8 w-8",A),"aria-label":P,"aria-busy":f.pending,"aria-disabled":f.pending,"aria-describedby":g,onClick:()=>{f.pending||f.onToggle()},children:f.pending?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):n.jsx(k,{className:"h-4 w-4"})})}),n.jsx("span",{id:g,role:"status",className:"sr-only",children:f.pending?"Changing the network state.":T}),n.jsx(ve,{side:"left",children:R?`${P} — ${T}`:P})]})})()})]})]}),m&&n.jsx(Ps,{open:_,onOpenChange:C,children:n.jsxs(Ds,{children:[n.jsxs(Ls,{children:[n.jsx(Ms,{children:"Restart this device?"}),n.jsx(Is,{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($s,{children:[n.jsx(Us,{children:"Cancel"}),n.jsx(zs,{onClick:()=>{C(!1),m.onReboot()},children:"Restart"})]})]})})]}):null}const Co=3e3,To=8e3;function Lr({sessionId:e,send:t,supported:r,deviceReady:o,handlerRef:i,onError:a}){const[c,l]=s.useState("waiting"),[u,h]=s.useState(!0),[f,m]=s.useState(void 0),g=s.useRef(void 0),[d,b]=s.useState(!1),v=s.useRef(null),_=s.useRef(new Set),C=s.useRef(a);s.useEffect(()=>{C.current=a},[a]);const D=s.useRef(o);s.useEffect(()=>{D.current=o},[o]);const k=s.useRef(o);s.useEffect(()=>{l("waiting"),h(!0),m(void 0),g.current=void 0,b(!1),v.current=null,k.current=D.current,_.current.clear()},[e]),s.useEffect(()=>{var R;if(o){k.current=!0,l("waiting");return}l(k.current?"unknown":"waiting"),h(!0),m(void 0),g.current=void 0,v.current&&((R=C.current)==null||R.call(C,"The device became unavailable before it answered. Its network state is unchanged as far as tapflow can tell."),_.current.add(v.current)),b(!1),v.current=null},[o]),s.useEffect(()=>{if(r)return i.current=R=>{var Y,U;if(R.type==="network:error"){R.requestId===v.current&&(v.current=null,b(!1),(Y=C.current)==null||Y.call(C,R.message));return}if(R.type!=="network:state"||!D.current||R.requestId!==void 0&&_.current.has(R.requestId))return;const $=R.payload.available?void 0:R.payload.reason;l(R.payload.offline?"offline":"online"),h(R.payload.available),m($),$==="enforcement-lost"&&g.current!=="enforcement-lost"&&((U=C.current)==null||U.call(C,"The device went back on the network before you took it off. Anything checked while it was offline needs checking again.")),g.current=$,R.requestId!==void 0&&R.requestId===v.current&&(v.current=null,b(!1))},()=>{i.current=void 0}},[i,r]),s.useEffect(()=>{if(!r||!o||c!=="waiting")return;const R=setTimeout(()=>l($=>$==="waiting"?"unknown":$),Co);return()=>clearTimeout(R)},[r,o,c]);const A=s.useCallback(()=>{if(!r||d)return;const R=G();v.current=R,b(!0),t({type:"network:set",sessionId:e,requestId:R,payload:{offline:c!=="offline"}})},[c,d,t,e,r]),[T,P]=s.useState(null);return s.useEffect(()=>{P(d?v.current:null)},[d]),s.useEffect(()=>{if(T===null)return;const R=setTimeout(()=>{var $;v.current===T&&(v.current=null,b(!1),($=C.current)==null||$.call(C,"The device did not answer. Its network state is unchanged as far as tapflow can tell."))},To);return()=>clearTimeout(R)},[T]),{position:c,steerable:u,reason:f,pending:d,toggle:A}}class gn{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 Eo{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 Mr(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 Ao(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 _o=new Set([100,110,122,244,44,83,86,118,128,138,139,134,135]);function On(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 Ir(e){const t=e.bits(8);e.bits(8);const r=e.bits(8);if(e.ue(),_o.has(t)){const m=e.ue();if(m===3&&e.flag(),e.ue(),e.ue(),e.flag(),e.flag()){const g=m!==3?8:12;for(let d=0;d<g;d++)if(e.flag()){const b=d<6?16:64;let v=8,_=8;for(let C=0;C<b;C++)_!==0&&(_=(v+e.se()+256)%256),v=_===0?v:_}}}e.ue();const o=e.ue();if(o===0)e.ue();else if(o===1){e.flag(),e.se(),e.se();const m=e.ue();for(let g=0;g<m;g++)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 l=e.flag();l&&On(e);const u=e.flag();u&&On(e),(l||u)&&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 No(e){const t=Ir(new gn(Mr(e)));return{profileIdc:t.profileIdc,levelIdc:t.levelIdc,vuiPresent:t.vuiPresent,bitstreamRestriction:t.bitstreamRestriction,maxNumReorderFrames:t.maxNumReorderFrames,maxDecFrameBuffering:t.maxDecFrameBuffering}}function Po(e){const t=Mr(e),r=Ir(new gn(t));if(!r.vuiPresent||r.restrictionFlagPos<0||r.bitstreamRestriction)return null;const o=new Eo,i=new gn(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],...Ao(o.toBytes())])}function Do(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 Lo{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 Do(new Uint8Array(t))){const f=h[0]&31;if(f===7){const m=!this.sps||h.length!==this.sps.length||h.some((g,d)=>g!==this.sps[d]);this.sps=h,m&&this.decoder&&(this.decoder.close(),this.decoder=null)}else f===8?this.pps=h:f>=1&&f<=5&&(f===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 l=0;for(const h of r)c.setUint32(l,h.length,!1),l+=4,a.set(h,l),l+=h.length;const u=Math.round(this.frameCount++*(1e6/30));if(this.decodeSampler&&(this.submitAt.set(u,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:u,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(No(t)))}catch(r){console.warn("[sps-vui] parse failed",r)}}}initDecoder(t,r){this.logSpsVui(t);const o=Po(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:l=>{this.sampleDecode(l),this.onFrame(l)},error:l=>console.error("[WebCodecsCore]",l)}),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 Mo=`#version 300 es
117
- in vec2 a_pos;
118
- out vec2 v_uv;
119
- void main() {
120
- v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
121
- gl_Position = vec4(a_pos, 0.0, 1.0);
122
- }`,Io=`#version 300 es
123
- precision mediump float;
124
- in vec2 v_uv;
125
- uniform sampler2D u_tex;
126
- out vec4 out_color;
127
- void main() {
128
- out_color = texture(u_tex, v_uv);
129
- }`;function $o(e){const t=e.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!t)return null;const r=(f,m)=>{const g=t.createShader(f);return t.shaderSource(g,m),t.compileShader(g),g},o=t.createProgram(),i=r(t.VERTEX_SHADER,Mo),a=r(t.FRAGMENT_SHADER,Io);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 l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const u=t.getAttribLocation(o,"a_pos");t.enableVertexAttribArray(u),t.vertexAttribPointer(u,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 Uo{constructor(t){this.canvas=t,this.state=null}init(){return this.state=$o(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 zo(e){const t=new Uo(e);return t.init(),t}class Fo{constructor(t=zo){this._size=null,this.canvas=document.createElement("canvas"),this.renderer=t(this.canvas),this.core=new Lo(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 Bo=`#version 300 es
130
- in vec2 a_pos;
131
- out vec2 v_uv;
132
- void main() {
133
- v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
134
- gl_Position = vec4(a_pos, 0.0, 1.0);
135
- }`,Oo=`#version 300 es
136
- precision mediump float;
137
- in vec2 v_uv;
138
- uniform sampler2D u_texY;
139
- uniform sampler2D u_texU;
140
- uniform sampler2D u_texV;
141
- out vec4 out_color;
142
- void main() {
143
- float Y = (texture(u_texY, v_uv).r - 0.0627451) * 1.1643836; // (y-16/255)*255/219
144
- float U = (texture(u_texU, v_uv).r - 0.5019608) * 1.1383929; // (u-128/255)*255/224
145
- float V = (texture(u_texV, v_uv).r - 0.5019608) * 1.1383929;
146
- float r = Y + 1.5748 * V;
147
- float g = Y - 0.1873 * U - 0.4681 * V;
148
- float b = Y + 1.8556 * U;
149
- out_color = vec4(r, g, b, 1.0);
150
- }`;function dn(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 Ho(e){const t=e.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!t)return null;const r=(g,d)=>{const b=t.createShader(g);return t.shaderSource(b,d),t.compileShader(b),b},o=t.createProgram(),i=r(t.VERTEX_SHADER,Bo),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 l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),t.STATIC_DRAW);const u=t.getAttribLocation(o,"a_pos");t.enableVertexAttribArray(u),t.vertexAttribPointer(u,2,t.FLOAT,!1,0,0),t.bindVertexArray(null),t.pixelStorei(t.UNPACK_ALIGNMENT,1);const h=dn(t,0,"u_texY",o),f=dn(t,1,"u_texU",o),m=dn(t,2,"u_texV",o);return{gl:t,program:o,texY:h,texU:f,texV:m,vao:c}}class Vo{constructor(t){this.canvas=t,this.state=null}init(){return this.state=Ho(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,l=o+1>>1,u=r*o,h=c*l,f=t.subarray(0,u),m=t.subarray(u,u+h),g=t.subarray(u+h,u+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 d=(b,v,_,C,D)=>{a.activeTexture(a.TEXTURE0+b),a.bindTexture(a.TEXTURE_2D,v),a.texImage2D(a.TEXTURE_2D,0,a.R8,_,C,0,a.RED,a.UNSIGNED_BYTE,D)};return d(0,i.texY,r,o,f),d(1,i.texU,c,l,m),d(2,i.texV,c,l,g),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 Wo=0;function qo(e){const t=new Vo(e);return t.init(),t}function Xo(){return new Worker(new URL("/assets/tinyh264.worker-DiJ50Hai.js",import.meta.url),{type:"module"})}class Ko{constructor(t=qo,r=Xo){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:Wo},[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 vn(){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 Yo(e=vn()){return e.secureContext&&e.webCodecs&&e.webgl2?new Fo:e.wasm&&e.webgl2?new Ko:null}function Go(e=vn()){return e.secureContext&&e.webCodecs&&e.webgl2||e.wasm&&e.webgl2}function Jo(e=vn()){return e.secureContext&&e.webCodecs&&e.webgl2?"high":e.wasm&&e.webgl2?"standard":"unsupported"}const Qo="https://www.tapflow.dev/reference/configuration#https-secure-context";function Zo({open:e,onOpenChange:t}){return n.jsx(nr,{open:e,onOpenChange:t,children:n.jsxs(rr,{className:"sm:max-w-[440px]",children:[n.jsxs(Fs,{children:[n.jsx(sr,{children:"Streaming in Standard mode"}),n.jsxs(Bs,{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(Os,{children:[n.jsx(ae,{variant:"outline",onClick:()=>window.open(Qo,"_blank","noopener,noreferrer"),children:"How to enable"}),n.jsx(ae,{onClick:()=>t(!1),children:"Got it"})]})]})})}const Hn="tapflow.perfModeNoticeDismissed";function ea(e,t){return e==="standard"&&!t}const ta={high:"Smooth",standard:"Standard",unsupported:null};function na(e){const{connected:t,joined:r,bootError:o,deviceReady:i,installing:a,installError:c,agentAway:l,decoderUnsupported:u}=e;return t?r?l?"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}`:u?"Streaming is not supported in this environment.":null:"Starting device…":"Joining session…":"Connecting…"}function wn(e){const{joined:t,fps:r,keyboardActive:o}=e,i=na(e),a=r>15,c=a?"#10b981":"#94a3b8",l=a?"Active":"Idle",u=s.useMemo(()=>Jo(),[]),h=ta[u],[f,m]=s.useState(!1);s.useEffect(()=>{let d=!1;try{d=localStorage.getItem(Hn)==="1"}catch{}ea(u,d)&&m(!0)},[u]);const g=d=>{if(m(d),!d)try{localStorage.setItem(Hn,"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:re("flex items-center",o?"text-emerald-500":"text-muted-foreground"),style:{gap:6},children:[n.jsx(lo,{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:re("text-[11px]",a?"text-emerald-500":"text-muted-foreground/60"),children:l})]}),h&&n.jsxs(n.Fragment,{children:[n.jsx(Jn,{orientation:"vertical",className:"h-3"}),u==="standard"?n.jsx("button",{type:"button",onClick:()=>m(!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(Zo,{open:f,onOpenChange:g})]})}function $r({open:e,onOpenChange:t,openUrl:r}){const[o,i]=s.useState(""),a=s.useRef(null);s.useEffect(()=>{e?setTimeout(()=>{var l;return(l=a.current)==null?void 0:l.focus()},0):i("")},[e]);const c=()=>{o.trim()&&(r(o.trim()),t(!1))};return n.jsx(nr,{open:e,onOpenChange:t,children:n.jsxs(rr,{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(sr,{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(ks,{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:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c()}})]}),n.jsx(ae,{size:"sm",disabled:!o.trim(),onClick:c,className:"shrink-0 rounded-xl h-8 px-4",children:"Open"})]})]})})}function ra(e,t,r,o,i,a){const{x:c,y:l,width:u,height:h}=i;let f,m;if(a){const g=(e.x-t.left)/t.width;f=(1-(e.y-t.top)/t.height)*r,m=g*o}else f=(e.x-t.left)*(r/t.width),m=(e.y-t.top)*(o/t.height);return f<c||f>c+u||m<l||m>l+h?null:{x:(f-c)/u,y:(m-l)/h}}function sa(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 Ur(e){return{f0:{x:1-e.x,y:1-e.y},f1:e}}function oa(e,t){return e>0?Math.min(1,t/e):1}function aa(e,t){return(e+(t?90:0))%360}function zt(e,t,r){const o=r===90||r===270;return{width:o?t:e,height:o?e:t}}function ia(e,t,r,o,i){const{width:a,height:c}=zt(r,o,i),l=Math.min(e/a,t/c);return{picW:a,picH:c,scale:l,left:(e-a*l)/2,top:(t-c*l)/2}}function ca(e,t,r){const o=e===90||e===270,i=o?r:t,a=o?t:r;return{width:i,height:a,left:(t-i)/2,top:(r-a)/2}}function la(e,t,r,o){const{width:i,height:a}=zt(e,t,o);return{width:i,height:a,turn:(r-o+360)%360}}function ua(e){return!e.ready||e.rotating?!1:e.aspectAgrees||!e.frameIsAhead}function da(e,t,r){if(!e||!t)return!0;const{width:o,height:i}=zt(e.width,e.height,r);return Math.abs(o/i-t.width/t.height)<.05}function fa(e,t){return Math.max(0,e-t)}const xn=22,Vn=[84,70,70,69],ha=1,pa=0,Zt=1,zr=2,ma=1,ga=2,xa=4;function ba(e){if(e.byteLength<xn)return null;const t=new DataView(e);for(let i=0;i<Vn.length;i++)if(t.getUint8(i)!==Vn[i])return null;if(t.getUint8(4)!==ha)return null;const r=t.getUint8(5),o=r&xa?zr:r&ma?Zt:pa;return{capturedAt:Number(t.getBigUint64(6)),relayedAt:Number(t.getBigUint64(14)),codec:o,keyframe:o===Zt&&(r&ga)!==0}}function Fr(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,l=!1,u;const h=()=>{if(a)return a;if(c)return null;const f=Yo();return f?(a=f,f.onResize(m=>i.current.onResize(m)),u=i.current.onDecoderReady(f),f):(c=!0,i.current.onUnsupported(),console.warn("[decoder] none available — set up HTTPS or use a supported browser"),null)};return t.current=(f,m)=>{const g=i.current.onJpegFrame;if(g&&(m==null?void 0:m.codec)!==Zt){g(f,m);return}const d=h();if(d){if(!l){if(!(m!=null&&m.keyframe))return;l=!0}d.decode(f),o.current+=1}},()=>{t.current=void 0,typeof u=="function"&&u(),a==null||a.close(),a==null||a.surface.remove(),a=null}},[t,r,o])}const ya=3e3+5*300,va=ya+500,Yt=8;function wa(){var e;return window.isSecureContext&&typeof ClipboardItem<"u"&&!!((e=navigator.clipboard)!=null&&e.write)}class It extends Error{}function Sa(e){const t=e.then(r=>new Blob([r],{type:"text/plain"}));return navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}function Sn(e){return!(e.metaKey||e.ctrlKey)||e.altKey?!1:e.code==="KeyV"?!0:!e.shiftKey&&(e.code==="KeyC"||e.code==="KeyX")}const Ra=1024*1024,ka=e=>new TextEncoder().encode(e).length,ja=e=>{var t;return!!((t=e.payload)!=null&&t.unsupported)},Ca=e=>{var t,r;return((t=e.payload)==null?void 0:t.sentinelParked)===!1||((r=e.payload)==null?void 0:r.unsupported)===!0};function Ta(){const e=window.getSelection();return!!e&&!e.isCollapsed&&e.toString().length>0}function Wn(){const e=document.activeElement;return!!e&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)}function Br({sessionId:e,send:t,active:r,supported:o,handlerRef:i,sendChord:a,onError:c}){const l=s.useRef(new Map),u=s.useRef(null),h=s.useRef(c);s.useLayoutEffect(()=>{h.current=c});const f=s.useCallback(g=>{var d;u.current!==g&&(u.current=g,(d=h.current)==null||d.call(h,g))},[]);s.useEffect(()=>(i.current=g=>{if(!g.requestId)return;const d=l.current.get(g.requestId);d&&(l.current.delete(g.requestId),d(g))},()=>{i.current=void 0}),[i]);const m=s.useCallback((...[g,d])=>{const b=G();return new Promise(v=>{const _=setTimeout(()=>{l.current.delete(b),v(null)},va);l.current.set(b,C=>{clearTimeout(_),v(C)}),t({type:g,sessionId:e,requestId:b,payload:d})})},[t,e]);s.useEffect(()=>{if(!r||!o)return;const g=async b=>{if(b.code==="KeyV"||!Sn(b))return;const v=b.code==="KeyX";if(Wn()||Ta()||(b.preventDefault(),b.repeat))return;if(!wa()){a(v?"KeyX":"KeyC",Yt),f("Copied on the device. Serving the dashboard over HTTPS also brings it to your clipboard.");return}let _,C;const D=new Promise((P,R)=>{_=P,C=R});D.catch(()=>{});const k=Sa(D).catch(P=>{P instanceof It||f(P instanceof Error&&P.name==="NotAllowedError"?"Your browser blocked the clipboard write":"Could not write to your clipboard")}),A=await m("clipboard:read",{press:v?"cut":"copy"});if(!A){C(new It("timeout")),f("The device is taking too long — try again");return}if(A.type==="clipboard:error"){C(new It(A.message||"read failed")),f(A.message||"Clipboard read failed"),Ca(A)&&a(v?"KeyX":"KeyC",Yt);return}if(A.type!=="clipboard:data"){C(new It("unexpected reply")),f("Clipboard read failed");return}const{text:T}=A.payload;if(u.current=null,!T){C(new It("empty"));return}_(T),await k},d=b=>{var _;if(Wn())return;const v=((_=b.clipboardData)==null?void 0:_.getData("text"))??"";if(b.preventDefault(),!v){a("KeyV",Yt);return}if(ka(v)>Ra){f("That text is too large to send to the device");return}m("clipboard:write",{text:v,pasteAfter:!0}).then(C=>{if(!C){f("The device is taking too long — try again");return}if(C.type==="clipboard:write-done"){u.current=null;return}if(C.type!=="clipboard:error"){f("Clipboard write failed");return}f(C.message||"Clipboard write failed"),ja(C)&&a("KeyV",Yt)})};return document.addEventListener("keydown",g),document.addEventListener("paste",d),()=>{document.removeEventListener("keydown",g),document.removeEventListener("paste",d)}},[r,o,m,a,f])}const Ye=13,vt=8,qn=16,Ea=.02,Aa=100;function _a({sessionId:e,buildId:t,send:r,openUrl:o,launchApp:i,connected:a,joined:c,deviceReady:l,installing:u,installed:h,installError:f,bootError:m,launching:g,chrome:d,binaryFrameHandlerRef:b,clipboardHandlerRef:v,clipboardSupported:_,networkHandlerRef:C,networkSupported:D,onRecordingUploaded:k,swKeyboardVisible:A,swKeyboardPending:T,onKbdToggle:P,rebootPending:R,onReboot:$,restartButtonRef:Y,perfHookRef:U}){const z=s.useRef(null),W=s.useRef(null),ce=s.useRef(null),{fps:$e,frameCount:Ee}=Pr(),Ve=s.useRef(0),{recordState:We,recordCanvasRef:Q,startClientRecording:Re,stopClientRecording:qe}=Nr({sessionId:e,buildId:t,onRecordingUploaded:k}),Ue=s.useRef(0),[Ge,Ae]=s.useState(!1),[F,J]=s.useState(!1),[ke,_e]=s.useState(!1),[q,ze]=s.useState(!1),[fe,he]=s.useState(!1),[Fe,je]=s.useState(null),[ft,Be]=s.useState(null),[Ct,Ne]=s.useState(!1),[pe,te]=s.useState(null),se=s.useRef(pe);s.useEffect(()=>{se.current=pe},[pe]);const Pe=s.useRef(null),ie=s.useRef(null),le=s.useRef(!1),we=s.useRef(!1),Me=s.useRef(0),ne=s.useRef(null),me=s.useRef(null),ue=s.useRef("idle"),Ce=s.useRef(null),Je=s.useRef(null),S=s.useRef(null);s.useEffect(()=>{S.current=d},[d]),s.useEffect(()=>{const p=new Image;p.onload=()=>{Je.current=p},p.src=`data:image/png;base64,${d.framePng}`},[d.framePng]),Fr({binaryFrameHandlerRef:b,perfHookRef:U,frameCount:Ee,onUnsupported:()=>_e(!0),onResize:p=>{const y=z.current;if(y&&(y.width!==p.width||y.height!==p.height)&&(y.width=p.width,y.height=p.height,!S.current)){const x=Q.current;x&&(x.width=p.width,x.height=p.height)}J(!0)},onDecoderReady:p=>{var j;const y=p.surface,x=z.current;y.style.position="absolute",x&&(y.style.left=x.style.left,y.style.top=x.style.top,y.style.width=x.style.width,y.style.height=x.style.height,y.style.borderRadius=x.style.borderRadius),y.style.objectFit="fill",y.style.zIndex="3",y.style.pointerEvents="none",(j=W.current)==null||j.appendChild(y);let L=null;const M=()=>{const I=z.current,B=I==null?void 0:I.getContext("2d");if(I&&B&&p.size)try{B.drawImage(p.surface,0,0,I.width,I.height)}catch{}L=requestAnimationFrame(M)};return L=requestAnimationFrame(M),()=>{L!==null&&cancelAnimationFrame(L)}},onJpegFrame:p=>{const y=performance.now();Ve.current&&y-Ve.current,Ve.current=y;const x=Ue.current;createImageBitmap(new Blob([p],{type:"image/jpeg"})).then(L=>{if(performance.now()-y,Ue.current!==x){L.close();return}const M=z.current,j=M==null?void 0:M.getContext("2d");if(!M||!j){L.close();return}if((M.width!==L.width||M.height!==L.height)&&(M.width=L.width,M.height=L.height,!S.current)){const B=Q.current;B&&(B.width=L.width,B.height=L.height)}const I=performance.now();j.drawImage(L,0,0),performance.now()-I,L.close(),J(!0),Ee.current+=1}).catch(()=>{})}}),s.useEffect(()=>{const p=Q.current,y=W.current;p&&y&&(p.width=y.clientWidth,p.height=y.clientHeight)},[d,Q]);const V=s.useCallback(()=>{const p=Q.current,y=z.current;if(!p||!y)return;const x=p.getContext("2d");if(!x)return;const L=S.current;if(x.clearRect(0,0,p.width,p.height),L){Je.current&&x.drawImage(Je.current,0,0,p.width,p.height);const I=Math.round(L.screenCornerRadius/2*(p.height/(L.compositeHeight/2)));x.save(),x.beginPath(),I>0?x.roundRect(y.offsetLeft,y.offsetTop,y.clientWidth,y.clientHeight,I):x.rect(y.offsetLeft,y.offsetTop,y.clientWidth,y.clientHeight),x.clip(),x.drawImage(y,y.offsetLeft,y.offsetTop,y.clientWidth,y.clientHeight),x.restore()}else x.drawImage(y,0,0,p.width,p.height);const M=se.current;if(M)for(const I of[M.f0,M.f1]){const B=L?y.offsetLeft+I.x*y.clientWidth:I.x*p.width,ge=L?y.offsetTop+I.y*y.clientHeight:I.y*p.height;le.current?(x.beginPath(),x.arc(B,ge,vt,0,Math.PI*2),x.fillStyle="rgba(255,255,255,0.92)",x.fill(),x.strokeStyle="rgba(0,0,0,0.2)",x.lineWidth=1,x.stroke()):(x.beginPath(),x.arc(B,ge,Ye,0,Math.PI*2),x.strokeStyle="rgba(0,0,0,0.3)",x.lineWidth=3,x.stroke(),x.beginPath(),x.arc(B,ge,Ye,0,Math.PI*2),x.strokeStyle="rgba(255,255,255,0.65)",x.lineWidth=1.5,x.stroke())}const j=me.current;if(j){const I=ue.current,B=Ce.current;if(x.save(),I==="down")x.beginPath(),x.arc(j.x,j.y,vt,0,Math.PI*2),x.fillStyle="rgba(255,255,255,0.92)",x.fill(),x.strokeStyle="rgba(0,0,0,0.2)",x.lineWidth=1,x.stroke();else if(I==="release"&&B){const ge=Math.min((performance.now()-B.startTime)/350,1);x.beginPath(),x.arc(j.x,j.y,vt+26*ge,0,Math.PI*2),x.strokeStyle=`rgba(255,255,255,${(1-ge)*.55})`,x.lineWidth=1.5,x.stroke(),ge>=1&&(ue.current="idle",Ce.current=null)}else x.beginPath(),x.arc(j.x,j.y,Ye,0,Math.PI*2),x.strokeStyle="rgba(0,0,0,0.3)",x.lineWidth=3,x.stroke(),x.beginPath(),x.arc(j.x,j.y,Ye,0,Math.PI*2),x.strokeStyle="rgba(255,255,255,0.65)",x.lineWidth=1.5,x.stroke();x.restore()}},[Q]),oe=s.useCallback(()=>{const p=z.current;if(!p)return;const y=document.createElement("canvas"),x=y.getContext("2d");x&&(y.width=p.width,y.height=p.height,x.drawImage(p,0,0),y.toBlob(L=>{if(!L)return;const M=URL.createObjectURL(L),j=document.createElement("a");j.href=M,j.download=`tapflow-${Date.now()}.png`,j.click(),URL.revokeObjectURL(M)},"image/png"))},[]),Te=s.useCallback(()=>{if(We==="idle"){const p=Q.current;if(!p)return;const y=W.current;if(y&&y.clientWidth>0)p.width=y.clientWidth,p.height=y.clientHeight;else{const x=z.current;if(x&&x.width>0)p.width=x.width,p.height=x.height;else return}Re(V)}else We==="recording"&&qe()},[We,Re,qe,V,Q]),K=s.useCallback(()=>{r({type:"input:rotate",sessionId:e}),ze(p=>!p)},[r,e]),Xe=s.useRef(q);s.useEffect(()=>{Xe.current=q},[q]),s.useEffect(()=>()=>{Xe.current&&r({type:"input:rotate",sessionId:e})},[]);const tn=s.useCallback((p,y)=>{r({type:"input:key",sessionId:e,requestId:G(),payload:{code:p,modifiers:y}})},[r,e]);Br({sessionId:e,send:r,active:fe,supported:_,handlerRef:v,sendChord:tn,onError:p=>Le.error(p)});const Qe=Lr({sessionId:e,send:r,supported:D,deviceReady:l,handlerRef:C,onError:p=>Le.error(p)});s.useEffect(()=>{const p=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),y=j=>{if(j.code==="AltLeft"||j.code==="AltRight"){we.current=!0;return}if(j.metaKey){const B=document.activeElement;if(!B||B.tagName!=="INPUT"&&B.tagName!=="TEXTAREA"){if(!j.shiftKey&&j.code==="KeyK"){j.preventDefault(),Ae(!0);return}if(!j.shiftKey&&j.code==="KeyS"){j.preventDefault(),oe();return}if(j.shiftKey&&j.code==="KeyY"){j.preventDefault(),Te();return}if(j.shiftKey&&j.code==="KeyO"){j.preventDefault(),K();return}if(j.shiftKey&&j.code==="KeyU"){j.preventDefault(),r({type:"input:button",sessionId:e,requestId:G(),payload:{name:"home"}});return}if(j.shiftKey&&j.code==="KeyK"){j.preventDefault(),T||P();return}}}if(!fe||p.has(j.code)||_&&Sn(j))return;j.preventDefault();const I=(j.shiftKey?2:0)|(j.ctrlKey?1:0)|(j.metaKey?8:0);r({type:"input:key",sessionId:e,requestId:G(),payload:{code:j.code,modifiers:I}})},x=()=>{le.current&&(le.current=!1,Ne(!1),r({type:"input:pinch:end",sessionId:e,requestId:G()})),we.current=!1,te(null)},L=j=>{(j.code==="AltLeft"||j.code==="AltRight")&&x()},M=()=>{we.current&&x()};return window.addEventListener("keydown",y),window.addEventListener("keyup",L),window.addEventListener("blur",M),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",L),window.removeEventListener("blur",M)}},[fe,_,r,e,oe,Te,K,P,T]),s.useEffect(()=>{if(!fe)return;const p=y=>{const x=W.current??z.current;x&&!x.contains(y.target)&&he(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[fe]);const Oe=s.useCallback(p=>{const y=(q?ce.current:null)??W.current;if(!y)return null;const x=y.getBoundingClientRect(),L=d.compositeWidth/2,M=d.compositeHeight/2,j=d.screenRect.x/2,I=d.screenRect.y/2,B=d.screenRect.width/2,ge=d.screenRect.height/2;return ra({x:p.clientX,y:p.clientY},x,L,M,{x:j,y:I,width:B,height:ge},q)},[d,q]),rt=s.useCallback(p=>{const y=Oe(p);return y?Ur(y):null},[Oe]),st=s.useCallback(p=>{const y=q?ce.current:W.current;if(!y)return null;const x=y.getBoundingClientRect();let L,M;if(q){const I=x.height-(p.clientY-x.top),B=p.clientX-x.left;L=I*(d.compositeWidth/x.height),M=B*(d.compositeHeight/x.width)}else L=(p.clientX-x.left)*(d.compositeWidth/x.width),M=(p.clientY-x.top)*(d.compositeHeight/x.height);const j=d.screenRect;return L>=j.x&&L<=j.x+j.width&&M>=j.y&&M<=j.y+j.height?null:wo(L,M,d.buttons,Aa)},[d,q]),ot=s.useCallback(p=>{const y=z.current,x=Q.current;return y&&y.clientWidth>0?{x:y.offsetLeft+p.x*y.clientWidth,y:y.offsetTop+p.y*y.clientHeight}:{x:p.x*((x==null?void 0:x.width)??1),y:p.y*((x==null?void 0:x.height)??1)}},[Q]),nn=s.useCallback(p=>{if(he(!0),we.current){const j=rt(p);if(!j)return;le.current=!0,Ne(!0),p.target.setPointerCapture(p.pointerId),te(j),r({type:"input:pinch:start",sessionId:e,payload:j});return}const y=st(p);if(y){Pe.current=y,je(y),p.target.setPointerCapture(p.pointerId),r({type:"input:button",sessionId:e,requestId:G(),payload:{name:y,phase:"down"}});return}const x=Oe(p);if(!x)return;ie.current=x,p.target.setPointerCapture(p.pointerId),me.current=ot(x),ue.current="down",Ce.current=null;const L=p.currentTarget.getBoundingClientRect(),M=ne.current;M&&(M.style.display="block",M.style.left=`${p.clientX-L.left}px`,M.style.top=`${p.clientY-L.top}px`,M.style.width=`${vt*2}px`,M.style.height=`${vt*2}px`,M.style.background="rgba(255,255,255,0.92)",M.style.border="1.5px solid rgba(0,0,0,0.2)",M.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:x})},[st,Oe,rt,ot,r,e]),ht=s.useCallback(p=>{if(p.buttons===0){if(Be(st(p)),we.current){te(rt(p)),me.current=null;const I=ne.current;I&&(I.style.display="none")}else{te(null);const I=Oe(p);me.current=I?ot(I):null,ue.current!=="down"&&(ue.current="idle");const B=ne.current;if(B)if(I){const ge=p.currentTarget.getBoundingClientRect();B.style.display="block",B.style.left=`${p.clientX-ge.left}px`,B.style.top=`${p.clientY-ge.top}px`,B.style.width=`${Ye*2}px`,B.style.height=`${Ye*2}px`,B.style.background="transparent",B.style.border="1.5px solid rgba(255,255,255,0.6)",B.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"}else B.style.display="none"}return}if(le.current){const I=rt(p);if(!I)return;const B=performance.now();if(B-Me.current<qn)return;Me.current=B,te(I),r({type:"input:pinch:move",sessionId:e,payload:I});return}if(Pe.current||!ie.current)return;const y=Oe(p);if(!y)return;const x=y.x-ie.current.x,L=y.y-ie.current.y;if(Math.sqrt(x*x+L*L)<Ea)return;const M=performance.now();if(M-Me.current<qn)return;Me.current=M,me.current=ot(y);const j=ne.current;if(j&&j.style.display!=="none"){const I=p.currentTarget.getBoundingClientRect();j.style.left=`${p.clientX-I.left}px`,j.style.top=`${p.clientY-I.top}px`}r({type:"input:touch:move",sessionId:e,payload:y})},[st,Oe,rt,ot,r,e]),Ht=s.useCallback(()=>{if(le.current){le.current=!1,Ne(!1),te(null),r({type:"input:pinch:end",sessionId:e,requestId:G()});return}if(ie.current=null,Pe.current){r({type:"input:button",sessionId:e,requestId:G(),payload:{name:Pe.current,phase:"up"}}),Pe.current=null,setTimeout(()=>je(null),100);return}ue.current="release",Ce.current={startTime:performance.now()};const p=ne.current;p&&(p.style.width=`${Ye*2}px`,p.style.height=`${Ye*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)"),r({type:"input:touch:end",sessionId:e,requestId:G()})},[r,e]),Tt=s.useCallback(()=>{if(le.current){le.current=!1,Ne(!1),te(null),r({type:"input:pinch:end",sessionId:e,requestId:G()});return}if(ie.current=null,Pe.current){r({type:"input:button",sessionId:e,requestId:G(),payload:{name:Pe.current,phase:"up"}}),Pe.current=null,je(null);return}ue.current="release",Ce.current={startTime:performance.now()},r({type:"input:touch:end",sessionId:e,requestId:G()})},[r,e]),Vt=s.useCallback(()=>{Be(null),te(null),me.current=null;const p=ne.current;p&&(p.style.display="none")},[]),Ze=d.compositeWidth/2,at=d.compositeHeight/2,Pt=oa(at,750),pt=Math.round(Ze*Pt),mt=Math.round(at*Pt),Et=d.screenRect.x/d.compositeWidth*100,gt=d.screenRect.y/d.compositeHeight*100,Se=d.screenRect.width/d.compositeWidth*100,xt=d.screenRect.height/d.compositeHeight*100,it=Math.round(d.screenCornerRadius/2*Pt),Wt=n.jsx(n.Fragment,{children:n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Home",onClick:()=>r({type:"input:button",sessionId:e,requestId:G(),payload:{name:"home"}}),children:n.jsx(fr,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:n.jsxs("span",{className:"flex items-center gap-3",children:["Home ",n.jsxs(mn,{children:[n.jsx(St,{children:"⌘"}),n.jsx(St,{children:"⇧"}),n.jsx(St,{children:"U"})]})]})})]})}),qt=s.useId(),bt=n.jsxs(n.Fragment,{children:[n.jsx("span",{id:qt,role:"status",className:"sr-only",children:T?"Changing the software keyboard.":A?"The software keyboard is up.":"The software keyboard is down."}),n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":T?"Software keyboard — changing it":"Software keyboard","aria-pressed":A,"aria-busy":T,"aria-disabled":T,"aria-describedby":qt,onClick:()=>{T||P()},"data-active":A,children:T?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):n.jsx(ro,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:T?n.jsx("span",{children:"Software keyboard — changing it"}):n.jsxs("span",{className:"flex items-center gap-3",children:["Software keyboard ",n.jsxs(mn,{children:[n.jsx(St,{children:"⌘"}),n.jsx(St,{children:"⇧"}),n.jsx(St,{children:"K"})]})]})})]})]}),At=h&&t?n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:g,"aria-label":"Launch app",onClick:i,children:g?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):n.jsx(Zn,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:g?"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:Q,style:{display:"none"}}),n.jsx($r,{open:Ge,onOpenChange:Ae,openUrl:o}),n.jsx(Dr,{joined:c,onDeepLink:()=>Ae(!0),onScreenshot:oe,onRecordToggle:Te,recordState:We,onRotate:K,navigationSlot:Wt,deviceSlot:bt,launchSlot:At,network:D?{position:Qe.position,steerable:Qe.steerable,reason:Qe.reason,pending:Qe.pending,onToggle:Qe.toggle}:void 0,reboot:{pending:R,onReboot:$,buttonRef:Y}}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsxs("div",{ref:ce,style:{width:q?mt:pt,height:q?pt:mt,position:"relative",flexShrink:0},children:[n.jsxs("div",{ref:W,className:`relative ${ft?"cursor-pointer":"cursor-default"}`,style:{width:pt,height:mt,...q?{position:"absolute",top:(pt-mt)/2,left:(mt-pt)/2,transform:"rotate(-90deg)",transformOrigin:"center center"}:{}},onPointerDown:nn,onPointerMove:ht,onPointerUp:Ht,onPointerCancel:Tt,onPointerLeave:Vt,children:[n.jsx("img",{src:`data:image/png;base64,${d.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:z,style:{position:"absolute",zIndex:3,left:`${Et}%`,top:`${gt}%`,width:`${Se}%`,height:`${xt}%`,borderRadius:it>0?`${it}px`:void 0,backgroundColor:"#010101",cursor:"none",visibility:F?"visible":"hidden"}}),!F&&n.jsx("div",{className:"absolute animate-pulse bg-zinc-700",style:{zIndex:3,left:`${Et}%`,top:`${gt}%`,width:`${Se}%`,height:`${xt}%`,borderRadius:it>0?`${it}px`:void 0}}),pe&&(()=>{const p=Et/100,y=gt/100,x=Se/100,L=xt/100,M=(j,I)=>({left:`${(p+j*x)*100}%`,top:`${(y+I*L)*100}%`});return n.jsx(n.Fragment,{children:[pe.f0,pe.f1].map((j,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",...Ct?{width:vt*2,height:vt*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:Ye*2,height:Ye*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"},...M(j.x,j.y)}},I))})})(),c&&$e===0&&n.jsx("div",{style:{position:"absolute",zIndex:8,left:`${Et}%`,top:`${gt}%`,width:`${Se}%`,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..."})}),d.buttons.map(p=>{const y=Fe===p.name,x=ft===p.name,L=p.anchor==="top",M=_r(p),j=M.top/d.compositeHeight*100,I=p.buttonH/d.compositeHeight*100,B=p.buttonW/d.compositeWidth*100,ge=p.buttonW/2,_t=M.left/d.compositeWidth*100,Dt=(2*p.rolloverOffset.x-p.normalOffset.x-ge)/d.compositeWidth*100,rn=p.rolloverOffset.x/d.compositeWidth*100,sn=j,Xt=L?(2*p.rolloverOffset.y-p.normalOffset.y)/d.compositeHeight*100:0,w=p.onTop?4:1;return n.jsxs(s.Fragment,{children:[p.buttonPng&&n.jsx("img",{src:`data:image/png;base64,${p.buttonPng}`,style:{position:"absolute",zIndex:w,top:`${L&&x?Xt:j}%`,left:`${L?_t:x?Dt:_t}%`,width:`${B}%`,height:`${I}%`,transition:L?"top 0.15s ease":"left 0.15s ease",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),y&&p.pressedPng&&p.pressedRect&&n.jsx("img",{src:`data:image/png;base64,${p.pressedPng}`,style:{position:"absolute",zIndex:p.onTop?3:1,left:`${L?_t:x?Dt:_t}%`,top:`${L&&x?Xt:j}%`,width:`${p.pressedRect.width/d.compositeWidth*100}%`,height:`${p.pressedRect.height/d.compositeHeight*100}%`,pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),x&&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:`${rn}%`,top:`${sn}%`,transform:"translate(-50%, calc(-100% - 8px))"},children:p.accessibilityTitle})]},p.name)})]}),n.jsx("div",{ref:ne,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(wn,{joined:c,fps:$e,connected:a,deviceReady:l,bootError:m,installing:u,installError:f,decoderUnsupported:ke,keyboardActive:fe})]})]})}const wt=13,$t=8,Xn=16,Na=.02,fn=720;function Pa({sessionId:e,buildId:t,send:r,openUrl:o,launchApp:i,connected:a,joined:c,deviceReady:l,installing:u,installed:h,installError:f,bootError:m,launching:g,androidButtons:d,binaryFrameHandlerRef:b,clipboardHandlerRef:v,clipboardSupported:_,networkHandlerRef:C,networkSupported:D,onRecordingUploaded:k,rebootPending:A,onReboot:T,restartButtonRef:P,screenWidth:R,screenHeight:$,cornerRadius:Y,postures:U,streamRotation:z=0,perfHookRef:W}){const ce=s.useRef(null),$e=s.useRef(null),Ee=s.useRef(null),{fps:Ve,frameCount:We}=Pr(),{recordState:Q,recordCanvasRef:Re,startClientRecording:qe,stopClientRecording:Ue}=Nr({sessionId:e,buildId:t,onRecordingUploaded:k}),[Ge,Ae]=s.useState(!1),[F,J]=s.useState(!1),[ke,_e]=s.useState(!1),q=s.useRef(null),[ze,fe]=s.useState(null),[he,Fe]=s.useState(!1),[je,ft]=s.useState(!1),[Be,Ct]=s.useState(!1),[Ne,pe]=s.useState(!1),[te,se]=s.useState(null),Pe=s.useRef(te);s.useEffect(()=>{Pe.current=te},[te]);const ie=s.useRef(!1),le=s.useRef(!1),we=s.useRef(null),Me=s.useRef(0),ne=s.useRef(null),me=s.useRef(null),ue=s.useRef("idle"),Ce=s.useRef(null);Fr({binaryFrameHandlerRef:b,perfHookRef:W,frameCount:We,onUnsupported:()=>_e(!0),onResize:w=>{J(!0);const N=q.current;(!N||N.width!==w.width||N.height!==w.height)&&(q.current=w,fe(w),Fe(!0))},onDecoderReady:w=>{var X;Ee.current=w;const N=w.surface;N.style.display="block",N.style.width="100%",N.style.height="100%",N.style.objectFit="fill",(X=ce.current)==null||X.appendChild(N)}});const Je=s.useCallback(()=>{var Dn;const w=Re.current,N=(Dn=Ee.current)==null?void 0:Dn.surface,X=q.current;if(!w||!N||!X)return;const E=w.getContext("2d");if(!E)return;const de=X.width,O=X.height,De=Tt.current,{picW:xe,picH:He,scale:Z,left:Lt,top:Nn}=ia(w.width,w.height,de,O,De);E.clearRect(0,0,w.width,w.height),E.save(),E.translate(Lt+xe*Z/2,Nn+He*Z/2),E.scale(Z,Z),E.rotate(De*Math.PI/180),E.drawImage(N,-de/2,-O/2,de,O),E.restore();const et=la(de,O,De,Vt.current);E.save(),E.translate(Lt+xe*Z/2,Nn+He*Z/2),E.scale(Z,Z),E.rotate(et.turn*Math.PI/180),E.translate(-et.width/2,-et.height/2);const Pn=Math.max(et.width,et.height),Ke=Pn>fn?Pn/fn:1,Kt=wt*Ke,on=$t*Ke,an=Pe.current;if(an)for(const yt of[an.f0,an.f1]){const ct=yt.x*et.width,Nt=yt.y*et.height;ie.current?(E.beginPath(),E.arc(ct,Nt,on,0,Math.PI*2),E.fillStyle="rgba(255,255,255,0.92)",E.fill(),E.strokeStyle="rgba(0,0,0,0.2)",E.lineWidth=Ke,E.stroke()):(E.beginPath(),E.arc(ct,Nt,Kt,0,Math.PI*2),E.strokeStyle="rgba(0,0,0,0.3)",E.lineWidth=3*Ke,E.stroke(),E.beginPath(),E.arc(ct,Nt,Kt,0,Math.PI*2),E.strokeStyle="rgba(255,255,255,0.65)",E.lineWidth=1.5*Ke,E.stroke())}const cn=me.current;if(cn){const yt=cn.x*et.width,ct=cn.y*et.height,Nt=ue.current,Ln=Ce.current;if(Nt==="down")E.beginPath(),E.arc(yt,ct,on,0,Math.PI*2),E.fillStyle="rgba(255,255,255,0.92)",E.fill(),E.strokeStyle="rgba(0,0,0,0.2)",E.lineWidth=Ke,E.stroke();else if(Nt==="release"&&Ln){const ln=Math.min((performance.now()-Ln.startTime)/350,1);E.beginPath(),E.arc(yt,ct,on+26*Ke*ln,0,Math.PI*2),E.strokeStyle=`rgba(255,255,255,${(1-ln)*.55})`,E.lineWidth=1.5*Ke,E.stroke(),ln>=1&&(ue.current="idle",Ce.current=null)}else E.beginPath(),E.arc(yt,ct,Kt,0,Math.PI*2),E.strokeStyle="rgba(0,0,0,0.3)",E.lineWidth=3*Ke,E.stroke(),E.beginPath(),E.arc(yt,ct,Kt,0,Math.PI*2),E.strokeStyle="rgba(255,255,255,0.65)",E.lineWidth=1.5*Ke,E.stroke()}E.restore()},[Re]),S=s.useCallback(()=>{var De;const w=(De=Ee.current)==null?void 0:De.surface,N=q.current;if(!w||!N)return;const X=document.createElement("canvas"),E=X.getContext("2d");if(!E)return;const de=Tt.current,O=zt(N.width,N.height,de);X.width=O.width,X.height=O.height,E.translate(X.width/2,X.height/2),E.rotate(de*Math.PI/180),E.drawImage(w,-N.width/2,-N.height/2,N.width,N.height),X.toBlob(xe=>{if(!xe)return;const He=URL.createObjectURL(xe),Z=document.createElement("a");Z.href=He,Z.download=`tapflow-${Date.now()}.png`,Z.click(),URL.revokeObjectURL(He)},"image/png")},[]),V=s.useCallback(()=>{if(Q==="idle"){const w=Re.current;if(!w)return;const N=q.current;if(!N)return;const X=zt(N.width,N.height,Tt.current);w.width=X.width,w.height=X.height,qe(Je)}else Q==="recording"&&Ue()},[Q,qe,Ue,Je,Re]),[oe,Te]=s.useState(null),K=oe!==null,Xe=s.useRef(0),tn=s.useCallback(w=>{Xe.current=Date.now()+8e3,Te(w),r({type:"input:posture",sessionId:e,payload:{postureId:w}})},[r,e]);s.useEffect(()=>{if(oe===null)return;const w=(U==null?void 0:U.currentId)===oe,N=setTimeout(()=>Te(null),w?0:fa(Xe.current,Date.now()));return()=>clearTimeout(N)},[oe,U]);const[Qe,Oe]=s.useState(!1);s.useEffect(()=>{if(!Qe)return;const w=setTimeout(()=>Oe(!1),400);return()=>clearTimeout(w)},[Qe]);const rt=s.useRef(!1);s.useEffect(()=>{if(!rt.current){rt.current=!0;return}Oe(!1)},[z,R,$]),s.useEffect(()=>{Fe(!1)},[z,R,$]);const st=s.useCallback(()=>{Oe(!0),r({type:"input:rotate",sessionId:e}),ft(w=>!w)},[r,e]),ot=s.useRef(je);s.useEffect(()=>{ot.current=je},[je]),s.useEffect(()=>()=>{ot.current&&r({type:"input:rotate",sessionId:e})},[]);const nn=s.useCallback((w,N)=>{r({type:"input:key",sessionId:e,requestId:G(),payload:{code:w,modifiers:N}})},[r,e]);Br({sessionId:e,send:r,active:Be,supported:_,handlerRef:v,sendChord:nn,onError:w=>Le.error(w)});const ht=Lr({sessionId:e,send:r,supported:D,deviceReady:l,handlerRef:C,onError:w=>Le.error(w)});s.useEffect(()=>{const w=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),N=O=>{if(O.code==="AltLeft"||O.code==="AltRight"){le.current=!0;return}if(O.metaKey){const xe=document.activeElement;if(!xe||xe.tagName!=="INPUT"&&xe.tagName!=="TEXTAREA"){if(!O.shiftKey&&O.code==="KeyK"){O.preventDefault(),Ae(!0);return}if(!O.shiftKey&&O.code==="KeyS"){O.preventDefault(),S();return}if(O.shiftKey&&O.code==="KeyY"){O.preventDefault(),V();return}if(O.shiftKey&&O.code==="KeyO"){O.preventDefault(),st();return}}}if(!Be||w.has(O.code)||_&&Sn(O))return;O.preventDefault();const De=(O.shiftKey?2:0)|(O.ctrlKey?1:0)|(O.metaKey?8:0);r({type:"input:key",sessionId:e,requestId:G(),payload:{code:O.code,modifiers:De}})},X=()=>{ie.current&&(ie.current=!1,pe(!1),r({type:"input:pinch:end",sessionId:e,requestId:G()})),le.current=!1,se(null)},E=O=>{(O.code==="AltLeft"||O.code==="AltRight")&&X()},de=()=>{le.current&&X()};return window.addEventListener("keydown",N),window.addEventListener("keyup",E),window.addEventListener("blur",de),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",E),window.removeEventListener("blur",de)}},[Be,_,r,e,S,V,st]),s.useEffect(()=>{if(!Be)return;const w=N=>{const X=$e.current??ce.current;X&&!X.contains(N.target)&&Ct(!1)};return document.addEventListener("pointerdown",w),()=>document.removeEventListener("pointerdown",w)},[Be]);const Ht=s.useRef(!1),Tt=s.useRef(0),Vt=s.useRef(0),Ze=s.useCallback(w=>{const N=ce.current;if(!N)return null;const X=N.getBoundingClientRect();return sa({x:w.clientX,y:w.clientY},X,Ht.current)},[]),at=s.useCallback(w=>{const N=Ze(w);return N?Ur(N):null},[Ze]),_n=s.useCallback(w=>{if(le.current){const de=at(w);if(!de)return;ie.current=!0,pe(!0),w.target.setPointerCapture(w.pointerId);const O=ne.current;O&&(O.style.display="none"),se(de),r({type:"input:pinch:start",sessionId:e,payload:de});return}const N=Ze(w);if(!N)return;Ct(!0),we.current=N,w.target.setPointerCapture(w.pointerId);const X=w.currentTarget.getBoundingClientRect();me.current=N,ue.current="down",Ce.current=null;const E=ne.current;E&&(E.style.display="block",E.style.left=`${w.clientX-X.left}px`,E.style.top=`${w.clientY-X.top}px`,E.style.width=`${$t*2}px`,E.style.height=`${$t*2}px`,E.style.background="rgba(255,255,255,0.92)",E.style.border="1.5px solid rgba(0,0,0,0.2)",E.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:N})},[Ze,at,r,e]),Pt=s.useCallback(w=>{if(w.buttons===0){if(le.current){se(at(w)),me.current=null;const Lt=ne.current;Lt&&(Lt.style.display="none");return}const xe=Ze(w),He=w.currentTarget.getBoundingClientRect(),Z=ne.current;xe?(me.current=xe,ue.current!=="down"&&(ue.current="idle"),Z&&(Z.style.display="block",Z.style.left=`${w.clientX-He.left}px`,Z.style.top=`${w.clientY-He.top}px`,Z.style.width=`${wt*2}px`,Z.style.height=`${wt*2}px`,Z.style.background="transparent",Z.style.border="1.5px solid rgba(255,255,255,0.6)",Z.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)")):(me.current=null,Z&&(Z.style.display="none"));return}if(ie.current){const xe=at(w);if(!xe)return;const He=performance.now();if(He-Me.current<Xn)return;Me.current=He,se(xe),r({type:"input:pinch:move",sessionId:e,payload:xe});return}if(!we.current)return;const N=Ze(w);if(!N)return;const X=N.x-we.current.x,E=N.y-we.current.y;if(Math.sqrt(X*X+E*E)<Na)return;const de=performance.now();if(de-Me.current<Xn)return;Me.current=de;const O=w.currentTarget.getBoundingClientRect();me.current=N;const De=ne.current;De&&De.style.display!=="none"&&(De.style.left=`${w.clientX-O.left}px`,De.style.top=`${w.clientY-O.top}px`),r({type:"input:touch:move",sessionId:e,payload:N})},[Ze,at,r,e]),pt=s.useCallback(()=>{if(ie.current){ie.current=!1,pe(!1),se(null),r({type:"input:pinch:end",sessionId:e,requestId:G()});return}we.current=null,ue.current="release",Ce.current={startTime:performance.now()};const w=ne.current;w&&(w.style.width=`${wt*2}px`,w.style.height=`${wt*2}px`,w.style.background="transparent",w.style.border="1.5px solid rgba(255,255,255,0.6)",w.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),r({type:"input:touch:end",sessionId:e,requestId:G()})},[r,e]),mt=s.useCallback(()=>{if(ie.current){ie.current=!1,pe(!1),se(null),r({type:"input:pinch:end",sessionId:e,requestId:G()});return}we.current=null,ue.current="release",Ce.current={startTime:performance.now()},r({type:"input:touch:end",sessionId:e,requestId:G()})},[r,e]),Et=s.useCallback(()=>{se(null),me.current=null;const w=ne.current;w&&(w.style.display="none")},[]),gt=R&&$?{width:R,height:$}:null,Se=gt??ze,xt=Se?Math.min(1,fn/Math.max(Se.width,Se.height)):.3,it=Se?Math.round(Se.width*xt):324,Wt=Se?Math.round(Se.height*xt):720,qt=Se?Se.width>Se.height:!1,bt=je&&!qt,At=aa(z,bt);s.useLayoutEffect(()=>{Ht.current=bt},[bt]),s.useLayoutEffect(()=>{Tt.current=At},[At]),s.useLayoutEffect(()=>{Vt.current=z},[z]);const p=bt?Wt:it,y=bt?it:Wt,x=Y!=null?Math.round(Y*it):22,L=da(ze,gt,z),M=ua({ready:F,aspectAgrees:L,frameIsAhead:he,rotating:Qe}),I={position:"absolute",...ca(At,p,y),transform:`rotate(${At}deg)`,transformOrigin:"center center",visibility:M?"visible":"hidden",cursor:"none"},B=["home","back","recent_apps"],ge=["volume_up","volume_down","power"],_t=w=>w==="back"?n.jsx(Gs,{className:"h-4 w-4"}):w==="recent_apps"?n.jsx(hs,{className:"h-4 w-4"}):w==="volume_up"?n.jsx(mo,{className:"h-4 w-4"}):w==="volume_down"?n.jsx(po,{className:"h-4 w-4"}):w==="power"?n.jsx(oo,{className:"h-4 w-4"}):n.jsx(fr,{className:"h-4 w-4"}),Dt=w=>n.jsx(n.Fragment,{children:w.map(N=>d==null?void 0:d.find(X=>X.name===N)).filter(N=>N!==void 0).map(N=>n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":N.accessibilityTitle,onClick:()=>r({type:"input:button",sessionId:e,requestId:G(),payload:{name:N.name}}),children:_t(N.name)})}),n.jsx(ve,{side:"left",children:N.accessibilityTitle})]},N.name))}),rn=Dt(B),sn=Dt(ge),Xt=h&&t?n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:g||u,"aria-label":"Launch app",onClick:i,children:g?n.jsx(kt,{className:"h-4 w-4 animate-spin"}):n.jsx(Zn,{className:"h-4 w-4"})})}),n.jsx(ve,{side:"left",children:g?"Launching…":u?"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:Re,style:{display:"none"}}),n.jsx($r,{open:Ge,onOpenChange:Ae,openUrl:o}),n.jsx(Dr,{joined:c,onDeepLink:()=>Ae(!0),onScreenshot:S,onRecordToggle:V,recordState:Q,onRotate:st,posture:U&&U.postures.length>1?{postures:U.postures,currentId:U.currentId,pending:K,onSelect:tn}:void 0,navigationSlot:rn,deviceSlot:sn,launchSlot:Xt,network:D?{position:ht.position,steerable:ht.steerable,reason:ht.reason,pending:ht.pending,onToggle:ht.toggle}:void 0,reboot:{pending:A,onReboot:T,buttonRef:P}}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsx("div",{style:{background:"#1c1c1e",borderRadius:`${x+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:$e,className:"relative",style:{width:p,height:y,backgroundColor:"#010101",borderRadius:`${x}px`,overflow:"hidden"},children:!ke&&n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:ce,style:I,onPointerDown:_n,onPointerMove:Pt,onPointerUp:pt,onPointerCancel:mt,onPointerLeave:Et}),!M&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-zinc-700"}),!M&&l&&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:K||!L?"Changing posture…":"Waiting for stream…"})}),n.jsx("div",{ref:ne,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"}}),te&&n.jsx(n.Fragment,{children:[te.f0,te.f1].map((w,N)=>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:`${w.x*100}%`,top:`${w.y*100}%`,...Ne?{width:$t*2,height:$t*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:wt*2,height:wt*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"}}},N))})]})})}),n.jsx(wn,{joined:c,fps:Ve,connected:a,deviceReady:l,bootError:m,installing:u,installError:f,decoderUnsupported:ke,keyboardActive:Be})]})]})}function Da(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 l=0;l<t;l++){const u=r.getInt16((c*t+l)*2,!0);a[l][c]=u/32768}return a}const La=44100,hn=2,Kn=.06,Ma=.3;function Ia(){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 g;const a=r();if(!a)return;a.state==="suspended"&&a.resume();const c=Da(i,hn),l=((g=c[0])==null?void 0:g.length)??0;if(l===0)return;const u=a.createBuffer(hn,l,La);for(let d=0;d<hn;d++)u.getChannelData(d).set(c[d]);const h=a.createBufferSource();h.buffer=u,h.connect(a.destination);const f=a.currentTime;let m=t.current;(m<f+.005||m>f+Ma+Kn)&&(m=f+Kn),h.start(m),t.current=m+u.duration},[r]);return s.useEffect(()=>()=>{var i;(i=e.current)==null||i.close(),e.current=null},[]),{pushFrame:o}}const $a=2e4;function Ua({sessionId:e,deviceId:t,deviceReady:r,send:o,handlerRef:i,onShutdownComplete:a,onError:c}){const[l,u]=s.useState(!1),h=s.useRef(null),f=s.useRef(a),m=s.useRef(c);s.useEffect(()=>{f.current=a},[a]),s.useEffect(()=>{m.current=c},[c]),s.useEffect(()=>{u(!1),h.current=null},[e]),s.useEffect(()=>{r||(u(!1),h.current=null)},[r]),s.useEffect(()=>(i.current=v=>{if(v.requestId===h.current){if(h.current=null,u(!1),v.type==="device:shutdown-error"){m.current(`The device was not restarted. ${v.message}`);return}f.current()}},()=>{i.current=void 0}),[i]);const[g,d]=s.useState(null);s.useEffect(()=>{d(l?h.current:null)},[l]),s.useEffect(()=>{if(g===null)return;const v=setTimeout(()=>{h.current===g&&(u(!1),m.current("The device has not answered the restart yet. If its answer arrives tapflow will finish restarting it; if nothing changes, press Restart again."))},$a);return()=>clearTimeout(v)},[g]);const b=s.useCallback(()=>{if(l)return;const v=G();h.current=v,u(!0),o({type:"device:shutdown",sessionId:e,requestId:v,payload:{deviceId:t}})},[l,o,e,t]);return{pending:l,reboot:b}}const Yn={"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 za(e){const t=e!==void 0&&Object.hasOwn(Yn,e)?e:"channel-unavailable";return{key:t,notice:Yn[t]}}function Fa({sessionId:e,deviceId:t,buildId:r,resetMode:o,onRecordingUploaded:i,onSessionEnded:a}){const c=s.useRef(()=>{}),l=s.useRef(!1),u=s.useRef({pending:0,appInstalled:!1});yo();const h=s.useRef(null),f=s.useRef(null),m=s.useRef([]);s.useRef({onFrameBegin:()=>{var S;return(S=h.current)==null?void 0:S.onFrameBegin()},onFrameEnd:S=>{var Te,K;const V=m.current.shift()??null,oe=V?{...S,capturedAt:V.capturedAt,relayedAt:V.relayedAt}:S;(Te=h.current)==null||Te.onFrameEnd(oe),(K=f.current)==null||K.call(f,oe)}});const[g,d]=s.useState(!1),[b,v]=s.useState(!1),[_,C]=s.useState(!1),[D,k]=s.useState(null),[A,T]=s.useState({postures:[],currentId:null}),[P,R]=s.useState(!1),[$,Y]=s.useState(!1),[U,z]=s.useState(null),[W,ce]=s.useState(null),[$e,Ee]=s.useState(!1),[Ve,We]=s.useState([]),Q=s.useRef(new Set),Re=s.useRef(null),qe=s.useRef(new Set),Ue=s.useRef(new Set),Ge=s.useRef(new Set),[Ae,F]=s.useState(!1),J=8e3,[ke,_e]=s.useState(!1),q=s.useRef(null);s.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]);const ze=s.useRef(void 0),fe=s.useRef(void 0),he=s.useRef(void 0),Fe=s.useRef(void 0),je=s.useCallback(S=>{const V=G();Q.current.add(V),Re.current=V,c.current({type:"device:boot",sessionId:e,requestId:V,payload:{deviceId:t,resetMode:S,acceptH264:Go(),secureContext:window.isSecureContext}})},[e,t]),{pushFrame:ft}=Ia(),Be=s.useCallback(S=>{var V,oe,Te;if(!("sessionId"in S&&S.sessionId!==e)){if(S.type==="session:joined"){u.current={pending:0,appInstalled:!1},d(!0),v(!1),We(S.capabilities??[]);const K=l.current?"app-only":o;l.current=!0,Q.current.clear(),je(K)}if(S.type==="session:agent-away"){v(!0),k(null),C(!1);return}if(S.type==="session:terminated"){a==null||a(S.reason);return}if(S.type==="session:rebound"){C(!1),k(null),R(!1),z(null),ce(null),Ee(!1),_e(!1),q.current&&clearTimeout(q.current),F(!1),m.current=[],We(S.capabilities);const K=b;v(!1),u.current={pending:u.current.pending+1,appInstalled:u.current.pending>0?u.current.appInstalled:$},l.current=!0,je("app-only"),K||Le.info("The agent restarted — reconnecting to the device.");return}if(S.type==="device:boot-error"){if(S.requestId!==void 0&&S.requestId!==Re.current||b)return;u.current={pending:0,appInstalled:!1},ce(S.message)}if(S.type==="input:error"){if(b)return;const{key:K,notice:Xe}=za(S.reason);S.reason!==void 0&&S.reason!==K&&console.debug(`[tapflow] unrecognised input:error reason "${S.reason}", treated as ${K}`),Xe?Le.error(Xe.title,{id:`input:${e}:${K}`,description:S.message?`${Xe.action} (${S.message})`:Xe.action,duration:6e3}):console.debug(`[tapflow] input refused, shown nowhere: ${K}${S.message?` — ${S.message}`:""}`)}if(S.type==="device:booting"&&(C(!1),R(!1),Y(!1),z(null),ce(null),T({postures:[],currentId:null}),Ue.current.clear(),Ge.current.clear(),k(null)),S.type==="device:ready"){if(C(!0),S.requestId!==void 0&&!Q.current.delete(S.requestId))return;if(u.current.pending>0){const{appInstalled:K}=u.current;if(u.current={pending:u.current.pending-1,appInstalled:K},K){Y(!0);return}}if(r){R(!0);const K=G();Ue.current.add(K),c.current({type:"app:install",sessionId:e,requestId:K,buildId:r})}}if(S.type==="app:install-done"||S.type==="app:install-error"){if(!Ue.current.delete(S.requestId))return;R(!1),S.type==="app:install-done"?Y(!0):z(S.message)}if(S.type==="app:launch-done"||S.type==="app:launch-error"){if(!Ge.current.delete(S.requestId))return;Ee(!1)}if(S.type==="session:chrome"&&k(S.payload),S.type==="device:postures"&&T(S.payload),S.type==="keyboard:toggled"){const{visible:K}=S.payload;F(K),_e(!1),q.current&&clearTimeout(q.current)}if(S.type==="network:state"||S.type==="network:error"){(V=he.current)==null||V.call(he,S);return}if(S.type==="device:shutdown-done"||S.type==="device:shutdown-error"){(oe=Fe.current)==null||oe.call(Fe,S);return}if((S.type==="clipboard:data"||S.type==="clipboard:write-done"||S.type==="clipboard:error")&&((Te=fe.current)==null||Te.call(fe,S)),S.type==="open-url:done"||S.type==="open-url:error"){if(!qe.current.delete(S.requestId))return;S.type==="open-url:done"?Le.success("Deeplink opened"):Le.error(S.message)}if(S.type==="error")switch(S.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,$,b,je]),Ct=s.useCallback(S=>{var K;const V=ba(S);if(V&&V.codec===zr){ft(S.slice(xn));return}V&&V.codec===Zt||m.current.push(V);const oe=V?S.slice(xn):S,Te=V?{codec:V.codec,keyframe:V.keyframe,capturedAt:V.capturedAt,relayedAt:V.relayedAt}:void 0;(K=ze.current)==null||K.call(ze,oe,Te)},[ft]),{send:Ne,connected:pe}=er(Be,Ct);s.useLayoutEffect(()=>{c.current=Ne}),s.useEffect(()=>{pe&&Ne({type:"session:start",sessionId:e})},[pe,Ne,e]);const te=D!==null&&"framePng"in D?D:null,se=D!==null&&!("framePng"in D)?D:null,Pe=()=>{_e(!0),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{_e(!1),Le.error("The device did not answer. The software keyboard is where it was, as far as tapflow can tell.")},J),Ne({type:"input:keyboard:toggle",sessionId:e})},ie=s.useCallback(S=>{const V=G();qe.current.add(V),c.current({type:"open-url",sessionId:e,requestId:V,payload:{url:S}})},[e]),le=s.useCallback(()=>{if(r===void 0)return;const S=G();Ge.current.add(S),Ee(!0),c.current({type:"app:launch",sessionId:e,requestId:S,buildId:r})},[e,r]),we=s.useRef(null),Me=s.useRef(!1),ne=s.useRef(!1),{pending:me,reboot:ue}=Ua({sessionId:e,deviceId:t,deviceReady:_,send:Ne,handlerRef:Fe,onShutdownComplete:s.useCallback(()=>{ne.current=!0,je("app-only")},[je]),onError:s.useCallback(S=>{Le.error(S)},[])});s.useEffect(()=>{var oe;const S=!!(te??se),V=!Me.current&&S;Me.current=S,!(!V||!ne.current)&&(ne.current=!1,document.activeElement===document.body&&((oe=we.current)==null||oe.focus()))},[te,se]),s.useEffect(()=>{(W||b)&&(ne.current=!1)},[W,b]);const Ce={sessionId:e,buildId:r,send:Ne,openUrl:ie,launchApp:le,connected:pe,joined:g,deviceReady:_,installing:P,installed:$,installError:U,bootError:W,launching:$e,binaryFrameHandlerRef:ze,clipboardHandlerRef:fe,clipboardSupported:Ve.includes("clipboard"),networkHandlerRef:he,networkSupported:Ve.includes("network-control"),onRecordingUploaded:i,swKeyboardVisible:Ae,swKeyboardPending:ke,onKbdToggle:Pe,rebootPending:me,onReboot:ue,restartButtonRef:we};if(!te&&!se)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((S,V)=>n.jsx("div",{className:"h-8 w-8 rounded-md bg-muted animate-pulse"},V))}),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(wn,{joined:g,fps:0,connected:pe,deviceReady:_,bootError:W,installing:P,installError:U,decoderUnsupported:!1,keyboardActive:!1,agentAway:b})]})]});const Je=void 0;return n.jsxs(n.Fragment,{children:[te&&n.jsx(_a,{...Ce,chrome:te,perfHookRef:Je}),se&&n.jsx(Pa,{...Ce,androidButtons:se.buttons,screenWidth:se.screenWidth,screenHeight:se.screenHeight,cornerRadius:se.cornerRadius,postures:A,streamRotation:se.streamRotation,perfHookRef:Je}),!1]})}const Or=s.forwardRef(({className:e,...t},r)=>n.jsx("textarea",{className:re("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}));Or.displayName="Textarea";var Ba=Object.defineProperty,H=(e,t)=>Ba(e,"name",{value:t,configurable:!0});function Hr(e,t){return s.useReducer((r,o)=>t[r][o]??r,e)}H(Hr,"useStateMachine");var Vr="ScrollArea",[Wr,Mi]=Qn(Vr),[Oa,Ie]=Wr(Vr),Ha=s.forwardRef(H(function(t,r){const{__scopeScrollArea:o,type:i="hover",dir:a,scrollHideDelay:c=600,...l}=t,[u,h]=s.useState(null),[f,m]=s.useState(null),[g,d]=s.useState(null),[b,v]=s.useState(null),[_,C]=s.useState(null),[D,k]=s.useState(0),[A,T]=s.useState(0),[P,R]=s.useState(!1),[$,Y]=s.useState(!1),U=ut(r,h),z=ms(a);return n.jsx(Oa,{scope:o,type:i,dir:z,scrollHideDelay:c,scrollArea:u,viewport:f,onViewportChange:m,content:g,onContentChange:d,scrollbarX:b,onScrollbarXChange:v,scrollbarXEnabled:P,onScrollbarXEnabledChange:R,scrollbarY:_,onScrollbarYChange:C,scrollbarYEnabled:$,onScrollbarYEnabledChange:Y,onCornerWidthChange:k,onCornerHeightChange:T,children:n.jsx(dt.div,{dir:z,...l,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":D+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})},"ScrollArea")),Va="ScrollAreaViewport",Wa=s.forwardRef(H(function(t,r){const{__scopeScrollArea:o,children:i,nonce:a,...c}=t,l=Ie(Va,o),u=s.useRef(null),h=ut(r,u,l.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx(qa,{nonce:a}),n.jsx(dt.div,{"data-radix-scroll-area-viewport":"",...c,ref:h,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:n.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})},"ScrollAreaViewport")),qa=s.memo(H(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),nt="ScrollAreaScrollbar",qr=s.forwardRef(H(function(t,r){const{forceMount:o,...i}=t,a=Ie(nt,t.__scopeScrollArea),{onScrollbarXEnabledChange:c,onScrollbarYEnabledChange:l}=a,u=t.orientation==="horizontal";return s.useEffect(()=>(u?c(!0):l(!0),()=>{u?c(!1):l(!1)}),[u,c,l]),a.type==="hover"?n.jsx(Xa,{...i,ref:r,forceMount:o}):a.type==="scroll"?n.jsx(Ka,{...i,ref:r,forceMount:o}):a.type==="auto"?n.jsx(Xr,{...i,ref:r,forceMount:o}):a.type==="always"?n.jsx(Rn,{...i,ref:r,"data-state":"visible"}):null},"ScrollAreaScrollbar")),Xa=s.forwardRef(H(function(t,r){const{forceMount:o,...i}=t,a=Ie(nt,t.__scopeScrollArea),[c,l]=s.useState(!1);return s.useEffect(()=>{const u=a.scrollArea;let h=0;if(u){const f=H(()=>{window.clearTimeout(h),l(!0)},"handlePointerEnter"),m=H(()=>{h=window.setTimeout(()=>l(!1),a.scrollHideDelay)},"handlePointerLeave");return u.addEventListener("pointerenter",f),u.addEventListener("pointerleave",m),()=>{window.clearTimeout(h),u.removeEventListener("pointerenter",f),u.removeEventListener("pointerleave",m)}}},[a.scrollArea,a.scrollHideDelay]),n.jsx(en,{present:o||c,children:n.jsx(Xr,{"data-state":c?"visible":"hidden",...i,ref:r})})},"ScrollAreaScrollbarHover")),Ka=s.forwardRef(H(function(t,r){const{forceMount:o,...i}=t,a=Ie(nt,t.__scopeScrollArea),c=t.orientation==="horizontal",l=Ot(()=>h("SCROLL_END"),100),[u,h]=Hr("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(u==="idle"){const f=window.setTimeout(()=>h("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(f)}},[u,a.scrollHideDelay,h]),s.useEffect(()=>{const f=a.viewport,m=c?"scrollLeft":"scrollTop";if(f){let g=f[m];const d=H(()=>{const b=f[m];g!==b&&(h("SCROLL"),l()),g=b},"handleScroll");return f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[a.viewport,c,h,l]),n.jsx(en,{present:o||u!=="hidden",children:n.jsx(Rn,{"data-state":u==="hidden"?"hidden":"visible",...i,ref:r,onPointerEnter:tt(t.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:tt(t.onPointerLeave,()=>h("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Xr=s.forwardRef(H(function(t,r){const o=Ie(nt,t.__scopeScrollArea),{forceMount:i,...a}=t,[c,l]=s.useState(!1),u=t.orientation==="horizontal",h=Ot(()=>{if(o.viewport){const f=o.viewport.offsetWidth<o.viewport.scrollWidth,m=o.viewport.offsetHeight<o.viewport.scrollHeight;l(u?f:m)}},10);return jt(o.viewport,h),jt(o.content,h),n.jsx(en,{present:i||c,children:n.jsx(Rn,{"data-state":c?"visible":"hidden",...a,ref:r})})},"ScrollAreaScrollbarAuto")),Rn=s.forwardRef(H(function(t,r){const{orientation:o="vertical",...i}=t,a=Ie(nt,t.__scopeScrollArea),c=s.useRef(null),l=s.useRef(0),[u,h]=s.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=kn(u.viewport,u.content),m={...i,sizes:u,onSizesChange:h,hasThumb:f>0&&f<1,onThumbChange:H(d=>c.current=d,"onThumbChange"),onThumbPointerUp:H(()=>l.current=0,"onThumbPointerUp"),onThumbPointerDown:H(d=>l.current=d,"onThumbPointerDown")};function g(d,b){return Jr(d,l.current,u,b)}return H(g,"getScrollPosition"),o==="horizontal"?n.jsx(Ya,{...m,ref:r,onThumbPositionChange:()=>{if(a.viewport&&c.current){const d=a.viewport.scrollLeft,b=yn(d,u,a.dir);c.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:d=>{a.viewport&&(a.viewport.scrollLeft=d)},onDragScroll:d=>{a.viewport&&(a.viewport.scrollLeft=g(d,a.dir))}}):o==="vertical"?n.jsx(Ga,{...m,ref:r,onThumbPositionChange:()=>{if(a.viewport&&c.current){const d=a.viewport.scrollTop,b=yn(d,u);c.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:d=>{a.viewport&&(a.viewport.scrollTop=d)},onDragScroll:d=>{a.viewport&&(a.viewport.scrollTop=g(d))}}):null},"ScrollAreaScrollbarVisible")),Ya=s.forwardRef(H(function(t,r){const{sizes:o,onSizesChange:i,...a}=t,c=Ie(nt,t.__scopeScrollArea),[l,u]=s.useState(),h=s.useRef(null),f=ut(r,h,c.onScrollbarXChange);return s.useEffect(()=>{h.current&&u(getComputedStyle(h.current))},[h]),n.jsx(Yr,{"data-orientation":"horizontal",...a,ref:f,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":Bt(o)+"px",...t.style},onThumbPointerDown:m=>t.onThumbPointerDown(m.x),onDragScroll:m=>t.onDragScroll(m.x),onWheelScroll:(m,g)=>{if(c.viewport){const d=c.viewport.scrollLeft+m.deltaX;t.onWheelScroll(d),Cn(d,g)&&m.preventDefault()}},onResize:()=>{h.current&&c.viewport&&l&&i({content:c.viewport.scrollWidth,viewport:c.viewport.offsetWidth,scrollbar:{size:h.current.clientWidth,paddingStart:Ft(l.paddingLeft),paddingEnd:Ft(l.paddingRight)}})}})},"ScrollAreaScrollbarX")),Ga=s.forwardRef(H(function(t,r){const{sizes:o,onSizesChange:i,...a}=t,c=Ie(nt,t.__scopeScrollArea),[l,u]=s.useState(),h=s.useRef(null),f=ut(r,h,c.onScrollbarYChange);return s.useEffect(()=>{h.current&&u(getComputedStyle(h.current))},[h]),n.jsx(Yr,{"data-orientation":"vertical",...a,ref:f,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":Bt(o)+"px",...t.style},onThumbPointerDown:m=>t.onThumbPointerDown(m.y),onDragScroll:m=>t.onDragScroll(m.y),onWheelScroll:(m,g)=>{if(c.viewport){const d=c.viewport.scrollTop+m.deltaY;t.onWheelScroll(d),Cn(d,g)&&m.preventDefault()}},onResize:()=>{h.current&&c.viewport&&l&&i({content:c.viewport.scrollHeight,viewport:c.viewport.offsetHeight,scrollbar:{size:h.current.clientHeight,paddingStart:Ft(l.paddingTop),paddingEnd:Ft(l.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[Ja,Kr]=Wr(nt),Yr=s.forwardRef(H(function(t,r){const{__scopeScrollArea:o,sizes:i,hasThumb:a,onThumbChange:c,onThumbPointerUp:l,onThumbPointerDown:u,onThumbPositionChange:h,onDragScroll:f,onWheelScroll:m,onResize:g,...d}=t,b=Ie(nt,o),[v,_]=s.useState(null),C=ut(r,_),D=s.useRef(null),k=s.useRef(""),A=b.viewport,T=i.content-i.viewport,P=Rt(m),R=Rt(h),$=Ot(g,10);function Y(U){if(D.current){const z=U.clientX-D.current.left,W=U.clientY-D.current.top;f({x:z,y:W})}}return H(Y,"handleDragScroll"),s.useEffect(()=>{const U=H(z=>{const W=z.target;(v==null?void 0:v.contains(W))&&P(z,T)},"handleWheel");return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[A,v,T,P]),s.useEffect(R,[i,R]),jt(v,$),jt(b.content,$),n.jsx(Ja,{scope:o,scrollbar:v,hasThumb:a,onThumbChange:Rt(c),onThumbPointerUp:Rt(l),onThumbPositionChange:R,onThumbPointerDown:Rt(u),children:n.jsx(dt.div,{...d,ref:C,style:{position:"absolute",...d.style},onPointerDown:tt(t.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),D.current=v.getBoundingClientRect(),k.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),Y(U))}),onPointerMove:tt(t.onPointerMove,Y),onPointerUp:tt(t.onPointerUp,U=>{const z=U.target;z.hasPointerCapture(U.pointerId)&&z.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=k.current,b.viewport&&(b.viewport.style.scrollBehavior=""),D.current=null})})})},"ScrollAreaScrollbarImpl")),bn="ScrollAreaThumb",Qa=s.forwardRef(H(function(t,r){const{forceMount:o,...i}=t,a=Kr(bn,t.__scopeScrollArea);return n.jsx(en,{present:o||a.hasThumb,children:n.jsx(Za,{ref:r,...i})})},"ScrollAreaThumb")),Za=s.forwardRef(H(function(t,r){const{__scopeScrollArea:o,style:i,...a}=t,c=Ie(bn,o),l=Kr(bn,o),{onThumbPositionChange:u}=l,h=ut(r,l.onThumbChange),f=s.useRef(void 0),m=Ot(()=>{f.current&&(f.current(),f.current=void 0)},100);return s.useEffect(()=>{const g=c.viewport;if(g){const d=H(()=>{if(m(),!f.current){const b=ni(g,u);f.current=b,u()}},"handleScroll");return u(),g.addEventListener("scroll",d),()=>g.removeEventListener("scroll",d)}},[c.viewport,m,u]),n.jsx(dt.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:h,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:tt(t.onPointerDownCapture,g=>{const b=g.target.getBoundingClientRect(),v=g.clientX-b.left,_=g.clientY-b.top;l.onThumbPointerDown({x:v,y:_})}),onPointerUp:tt(t.onPointerUp,l.onThumbPointerUp)})},"ScrollAreaThumbImpl")),Gr="ScrollAreaCorner",ei=s.forwardRef(H(function(t,r){const o=Ie(Gr,t.__scopeScrollArea),i=!!(o.scrollbarX&&o.scrollbarY);return o.type!=="scroll"&&i?n.jsx(ti,{...t,ref:r}):null},"ScrollAreaCorner")),ti=s.forwardRef(H(function(t,r){const{__scopeScrollArea:o,...i}=t,a=Ie(Gr,o),[c,l]=s.useState(0),[u,h]=s.useState(0),f=!!(c&&u),{onCornerWidthChange:m,onCornerHeightChange:g}=a;return jt(a.scrollbarX,()=>{var b;const d=((b=a.scrollbarX)==null?void 0:b.offsetHeight)||0;a.onCornerHeightChange(d),h(d)}),jt(a.scrollbarY,()=>{var b;const d=((b=a.scrollbarY)==null?void 0:b.offsetWidth)||0;a.onCornerWidthChange(d),l(d)}),s.useEffect(()=>()=>{m(0),g(0)},[m,g]),f?n.jsx(dt.div,{...i,ref:r,style:{width:c,height:u,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null},"ScrollAreaCornerImpl"));function Ft(e){return e?parseInt(e,10):0}H(Ft,"toInt");function kn(e,t){const r=e/t;return isNaN(r)?0:r}H(kn,"getThumbRatio");function Bt(e){const t=kn(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-r)*t;return Math.max(o,18)}H(Bt,"getThumbSize");function Jr(e,t,r,o="ltr"){const i=Bt(r),a=i/2,c=t||a,l=i-c,u=r.scrollbar.paddingStart+c,h=r.scrollbar.size-r.scrollbar.paddingEnd-l,f=r.content-r.viewport,m=o==="ltr"?[0,f]:[f*-1,0];return jn([u,h],m)(e)}H(Jr,"getScrollPositionFromPointer");function yn(e,t,r="ltr"){const o=Bt(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,c=t.content-t.viewport,l=a-o,u=r==="ltr"?[0,c]:[c*-1,0],h=Hs(e,u);return jn([0,c],[0,l])(h)}H(yn,"getThumbOffsetFromScroll");function jn(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])}}H(jn,"linearScale");function Cn(e,t){return e>0&&e<t}H(Cn,"isScrollingWithinScrollbarBounds");var ni=H((e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},o=0;return H((function i(){const a={left:e.scrollLeft,top:e.scrollTop},c=r.left!==a.left,l=r.top!==a.top;(c||l)&&t(),r=a,o=window.requestAnimationFrame(i)}),"loop")(),()=>window.cancelAnimationFrame(o)},"addUnlinkedScrollListener");function Ot(e,t){const r=Rt(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])}H(Ot,"useDebounceCallback");function jt(e,t){const r=Rt(t);ps(()=>{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])}H(jt,"useResizeObserver");var Qr=Ha,ri=Wa,si=ei;const Zr=s.forwardRef(({className:e,children:t,...r},o)=>n.jsxs(Qr,{ref:o,className:re("relative overflow-hidden",e),...r,children:[n.jsx(ri,{className:"h-full w-full rounded-[inherit]",children:t}),n.jsx(es,{}),n.jsx(si,{})]}));Zr.displayName=Qr.displayName;const es=s.forwardRef(({className:e,orientation:t="vertical",...r},o)=>n.jsx(qr,{ref:o,orientation:t,className:re("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(Qa,{className:"relative flex-1 rounded-full bg-border"})}));es.displayName=qr.displayName;function ts(e){return/[Zz]|[+-]\d{2}/.test(e)?new Date(e):new Date(e.replace(" ","T")+"Z")}function oi(e){const t=new Map;for(const i of e){const a=ts(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 l=new Date(i);c=l.toLocaleDateString(void 0,{month:"short",day:"numeric",...l.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}return{label:c,items:a}})}function ai(e){return ts(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}const ii=5*1024*1024,ci=["image/png","image/jpeg","image/webp"];function li({buildId:e}){const t=s.useId(),[r,o]=s.useState([]),[i,a]=s.useState(""),[c,l]=s.useState(null),[u,h]=s.useState(!1),[f,m]=s.useState(""),g=s.useRef(null),d=s.useRef({}),b=s.useCallback(()=>{fetch(`/api/v1/comments?build_id=${e}`,{credentials:"include"}).then(k=>k.ok?k.json():[]).then(o)},[e]);s.useEffect(()=>{b()},[b]),s.useEffect(()=>{const k=window.location.hash;if(!k.startsWith("#comment-"))return;const A=Number(k.replace("#comment-","")),T=d.current[A];if(!T)return;T.scrollIntoView({behavior:"smooth"});const P=document.documentElement.classList.contains("dark");T.style.backgroundColor=P?"rgb(0 112 243 / 0.18)":"#d3e5ff",setTimeout(()=>{T.style.backgroundColor=""},2e3)},[r]),s.useEffect(()=>{zn()},[]);async function v(k){const{linkBase:A}=await zn(),T=Ks(A,`${location.pathname}${location.search}#comment-${k}`);try{if(!navigator.clipboard)throw new Error("no clipboard");await navigator.clipboard.writeText(T),Le.success("Link copied")}catch{Le.error("Could not copy link")}}function _(k){if(m(""),!ci.includes(k.type)){m("Only png, jpg, webp allowed");return}if(k.size>ii){m("Max 5MB");return}l(k)}async function C(k){if(k.preventDefault(),!i.trim()&&!c)return;h(!0);const A=new FormData;A.append("build_id",String(e)),A.append("body",i),c&&A.append("attachment",c),(await fetch("/api/v1/comments",{method:"POST",credentials:"include",body:A})).ok&&(a(""),l(null),b()),h(!1)}const D=oi(r);return n.jsxs("div",{className:"flex h-full flex-col gap-3 px-1",children:[n.jsx(Zr,{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:D.map(({label:k,items:A})=>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:k}),n.jsx("div",{className:"h-px flex-1 bg-border"})]}),n.jsx("div",{className:"flex flex-col gap-4",children:A.map(T=>n.jsxs("div",{id:`comment-${T.id}`,ref:P=>{d.current[T.id]=P},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(gs,{name:T.author,avatarUrl:T.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:T.author}),n.jsx("span",{className:"text-[11px] text-muted-foreground leading-none",children:ai(T.created_at)}),n.jsx(ae,{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:()=>void v(T.id),children:n.jsx(gr,{className:"h-3 w-3","aria-hidden":"true"})})]}),n.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap mt-1",children:T.body}),T.attachments.map(P=>{const R=decodeURIComponent(P.file_path.split("/").pop()??"image");return n.jsx("a",{href:P.file_path,target:"_blank",rel:"noreferrer",className:"mt-1.5 block","aria-label":`Open ${R} in a new tab`,children:n.jsx("img",{src:P.file_path,alt:R,className:"max-h-48 rounded border object-contain"})},P.id)})]})]},T.id))})]},k))})})}),n.jsx("div",{className:"pb-1",children:n.jsx("form",{onSubmit:C,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(Or,{"aria-label":"Comment",placeholder:"Leave a comment…",value:i,onChange:k=>a(k.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||f)&&n.jsxs("div",{className:"px-3 -mt-1 pb-1",children:[c&&n.jsx("p",{className:"text-xs text-muted-foreground",children:c.name}),f&&n.jsx("p",{id:t,role:"alert",className:"text-xs text-destructive",children:f})]}),n.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[n.jsx(ae,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"Attach image","aria-describedby":f?t:void 0,onClick:()=>{var k;return(k=g.current)==null?void 0:k.click()},children:n.jsx(no,{className:"h-4 w-4","aria-hidden":"true"})}),n.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:k=>{var T;const A=(T=k.target.files)==null?void 0:T[0];A&&_(A)}}),n.jsx("div",{className:"flex-1"}),n.jsx(ae,{type:"submit",size:"icon",className:"h-7 w-7 rounded-full","aria-label":"Post comment",disabled:u||!i.trim()&&!c,children:n.jsx(Js,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})})})]})}function ui(e){return e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function di(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function fi(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 hi({buildId:e,refreshKey:t}){const[r,o]=s.useState([]),[i,a]=s.useState(!0),[c,l]=s.useState(!1);return s.useEffect(()=>{a(!0),l(!1);const u=setTimeout(()=>l(!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(u),a(!1)}),()=>clearTimeout(u)},[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(u=>{const h=fi(u.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:di(u.createdAt)}),n.jsxs("span",{className:`text-xs ${h.urgent?"text-destructive":"text-muted-foreground"}`,children:[h.label," · ",ui(u.fileSize)]})]}),n.jsx(ae,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 ml-2",title:"Download",onClick:()=>{const f=document.createElement("a");f.href=u.url,f.download="",f.click()},children:n.jsx(Zs,{className:"h-3.5 w-3.5"})})]},u.id)})})}function pi({buildId:e,recordingsRefreshKey:t=0}){return n.jsxs(Ts,{defaultValue:"comments",className:"flex h-full flex-col",children:[n.jsx("div",{className:"shrink-0 px-1",children:n.jsxs(Es,{className:"w-full",children:[n.jsxs(In,{value:"comments",className:"flex-1 gap-1.5",children:[n.jsx(so,{className:"h-3.5 w-3.5"}),"Comments"]}),n.jsxs(In,{value:"recordings",className:"flex-1 gap-1.5",children:[n.jsx(eo,{className:"h-3.5 w-3.5"}),"Recordings"]})]})}),n.jsx($n,{value:"comments",className:"mt-3 min-h-0 flex-1 overflow-hidden",children:n.jsx(li,{buildId:e})}),n.jsx($n,{value:"recordings",className:"mt-3 min-h-0 flex-1 overflow-y-auto",children:n.jsx(hi,{buildId:e,refreshKey:t})})]})}const ns=s.forwardRef(({...e},t)=>n.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));ns.displayName="Breadcrumb";const rs=s.forwardRef(({className:e,...t},r)=>n.jsx("ol",{ref:r,className:re("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));rs.displayName="BreadcrumbList";const Ut=s.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,className:re("inline-flex items-center gap-1.5",e),...t}));Ut.displayName="BreadcrumbItem";const Gt=s.forwardRef(({asChild:e,className:t,...r},o)=>{const i=e?xs:"a";return n.jsx(i,{ref:o,className:re("transition-colors hover:text-foreground cursor-pointer",t),...r})});Gt.displayName="BreadcrumbLink";const Jt=s.forwardRef(({className:e,...t},r)=>n.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:re("font-medium text-foreground",e),...t}));Jt.displayName="BreadcrumbPage";const Qt=({children:e,className:t,...r})=>n.jsx("li",{role:"presentation","aria-hidden":"true",className:re("[&>svg]:h-3.5 [&>svg]:w-3.5",t),...r,children:e??n.jsx(bs,{})});Qt.displayName="BreadcrumbSeparator";var mi=Object.defineProperty,lt=(e,t)=>mi(e,"name",{value:t,configurable:!0}),Tn="Switch",[gi,Ii]=Qn(Tn),[xi,En]=gi(Tn);function ss(e){const{__scopeSwitch:t,checked:r,children:o,defaultChecked:i,disabled:a,form:c,name:l,onCheckedChange:u,required:h,value:f="on",internal_do_not_use_render:m}=e,[g,d]=vs({prop:r,defaultProp:i??!1,onChange:u,caller:Tn}),[b,v]=s.useState(null),[_,C]=s.useState(null),D=s.useRef(!1),[k,A]=s.useReducer(R=>R+1,0),T=b?!!c||!!b.closest("form"):!0,P={checked:g,setChecked:d,disabled:a,control:b,setControl:v,name:l,form:c,value:f,hasConsumerStoppedPropagationRef:D,userInteractionCount:k,onUserInteraction:A,required:h,defaultChecked:i,isFormControl:T,bubbleInput:_,setBubbleInput:C};return n.jsx(xi,{scope:t,...P,children:as(m)?m(P):o})}lt(ss,"SwitchProvider");var bi="SwitchTrigger",yi=s.forwardRef(lt(function({__scopeSwitch:t,onClick:r,...o},i){const{control:a,form:c,value:l,disabled:u,checked:h,required:f,setControl:m,setChecked:g,hasConsumerStoppedPropagationRef:d,onUserInteraction:b,isFormControl:v,bubbleInput:_}=En(bi,t),C=ut(i,m),D=s.useRef(h);return s.useEffect(()=>{const k=c?a==null?void 0:a.ownerDocument.getElementById(c):a==null?void 0:a.form;if(k instanceof HTMLFormElement){const A=lt(()=>g(D.current),"reset");return k.addEventListener("reset",A),()=>k.removeEventListener("reset",A)}},[a,c,g]),n.jsx(dt.button,{type:"button",role:"switch","aria-checked":h,"aria-required":f,"data-state":An(h),"data-disabled":u?"":void 0,disabled:u,value:l,...o,ref:C,onClick:tt(r,k=>{b(),g(A=>!A),_&&v&&(d.current=k.isPropagationStopped(),d.current||k.stopPropagation())})})},"SwitchTrigger")),os=s.forwardRef(lt(function(t,r){const{__scopeSwitch:o,name:i,checked:a,defaultChecked:c,required:l,disabled:u,value:h,onCheckedChange:f,form:m,...g}=t;return n.jsx(ss,{__scopeSwitch:o,checked:a,defaultChecked:c,disabled:u,required:l,onCheckedChange:f,name:i,form:m,value:h,internal_do_not_use_render:({isFormControl:d})=>n.jsxs(n.Fragment,{children:[n.jsx(yi,{...g,ref:r,__scopeSwitch:o}),d&&n.jsx(Ri,{__scopeSwitch:o})]})})},"Switch")),vi="SwitchThumb",wi=s.forwardRef(lt(function(t,r){const{__scopeSwitch:o,...i}=t,a=En(vi,o);return n.jsx(dt.span,{"data-state":An(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:r})},"SwitchThumb")),Si="SwitchBubbleInput",Ri=s.forwardRef(lt(function({__scopeSwitch:t,onClick:r,...o},i){const{control:a,hasConsumerStoppedPropagationRef:c,userInteractionCount:l,checked:u,defaultChecked:h,required:f,disabled:m,name:g,value:d,form:b,bubbleInput:v,setBubbleInput:_}=En(Si,t),C=ut(i,_),D=ys(a),k=s.useRef(!1),A=s.useRef(u),T=s.useRef(l);s.useEffect(()=>{const R=v;if(!R)return;const $=window.HTMLInputElement.prototype,U=Object.getOwnPropertyDescriptor($,"checked").set,z=l!==T.current;T.current=l;const W=A.current!==u;A.current=u;const ce=!(z&&c.current);if(W&&U){k.current=!z;const $e=new Event("click",{bubbles:ce});U.call(R,u),R.dispatchEvent($e),k.current=!1}},[v,u,c,l]);const P=s.useRef(u);return n.jsx(dt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:h??P.current,required:f,disabled:m,name:g,value:d,form:b,...o,tabIndex:-1,ref:C,onClick:tt(r,R=>{k.current&&R.stopPropagation()}),style:{...o.style,...D,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function as(e){return typeof e=="function"}lt(as,"isFunction");function An(e){return e?"checked":"unchecked"}lt(An,"getState");const is=s.forwardRef(({className:e,...t},r)=>n.jsx(os,{className:re("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(wi,{className:re("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")})}));is.displayName=os.displayName;const ki={"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 $i(){const[e]=tr(),t=Ns(),r=e.get("id"),{build:o}=go(r),[i,a]=s.useState(0),c=(o==null?void 0:o.platform)??"ios",{sessions:l,selectedAgent:u,setSelectedAgent:h,activeSessionId:f,deviceId:m,booting:g,status:d,connected:b,agentGroups:v,startDevice:_,resetDevice:C,handleBack:D,handleBackToMacs:k,handleSessionEnded:A}=xo(c),T=v.find(F=>F.agentName===u),{osVersions:P,osVersion:R,setOsVersion:$,deviceSearch:Y,setDeviceSearch:U,versionedDevices:z,resetMode:W,setResetMode:ce,appliedResetMode:$e,consumeResetMode:Ee,fullResetSupported:Ve}=bo(T,c),Q=l.flatMap(F=>F.devices).find(F=>F.id===m),Re=Q?`${Q.name}${Q.osVersion?` · ${Q.osVersion}`:""}`:"",qe=s.useCallback(()=>a(F=>F+1),[]),Ue=s.useCallback(F=>{Ee(),_(F)},[Ee,_]),Ge=s.useCallback(F=>{const J=ki[F];Le.error(J.title,{description:J.description}),A()},[A]),{setNode:Ae}=ws();return s.useEffect(()=>{if(o)return Ae(n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(ns,{children:n.jsxs(rs,{children:[n.jsx(Ut,{children:n.jsx(Gt,{asChild:!0,children:n.jsx("button",{onClick:()=>t(`/app-center?appId=${o.app_id}`),children:o.name})})}),n.jsx(Qt,{}),n.jsx(Ut,{children:u?n.jsx(Gt,{asChild:!0,children:n.jsx("button",{onClick:k,children:Mn(o)})}):n.jsx(Jt,{children:Mn(o)})}),u&&n.jsxs(n.Fragment,{children:[n.jsx(Qt,{}),n.jsx(Ut,{children:f?n.jsx(Gt,{asChild:!0,children:n.jsx("button",{onClick:D,children:u})}):n.jsx(Jt,{children:u})})]}),f&&n.jsxs(n.Fragment,{children:[n.jsx(Qt,{}),n.jsx(Ut,{children:n.jsx(Jt,{children:Re})})]})]})}),!u&&o.status_label&&n.jsx(Ys,{tone:js[o.status_label],children:o.status_label})]})),()=>Ae(null)},[o,u,f,Re,t,D,k,Ae]),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:f?n.jsx("div",{className:"min-h-full flex items-center justify-center py-6 px-8 min-w-max",children:n.jsx(Fa,{sessionId:f,deviceId:m,buildId:o==null?void 0:o.id,resetMode:$e,onRecordingUploaded:qe,onSessionEnded:Ge})}):u?n.jsxs("div",{className:"flex flex-col gap-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{onClick:k,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(Cs,{placeholder:"Search device…",value:Y,onChange:U}),P.length>0&&n.jsxs(Vs,{value:R||"__all__",onValueChange:F=>{$(F==="__all__"?"":F),C()},children:[n.jsx(Ws,{className:"h-8 w-36 shrink-0",children:n.jsx(qs,{})}),n.jsxs(Xs,{children:[n.jsx(Un,{value:"__all__",children:"Any version"}),P.map(F=>n.jsx(Un,{value:F,children:F},F))]})]}),Ve&&n.jsx(pn,{children:n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsxs("div",{className:"ml-auto flex items-center gap-2 shrink-0",children:[n.jsx(Ss,{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(is,{id:"reset-mode","aria-describedby":"reset-mode-desc",checked:W==="full-erase",onCheckedChange:F=>ce(F?"full-erase":"app-only")})]})}),n.jsx(ve,{children:W==="full-erase"?"Erase all data on the next device you pick":"Keep existing data"})]})})]}),z.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:z.map(F=>{const J=F.status==="booted",ke=F.busy,_e=ke?"In use":J?"Booted":"Available",q=ke?"bg-amber-400":J?"bg-emerald-400":"bg-muted-foreground/40";return n.jsxs("button",{disabled:ke||g||!b,onClick:()=>Ue(F),className:re("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:F.name}),F.osVersion&&n.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:F.osVersion}),n.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx("span",{className:re("inline-block h-1.5 w-1.5 rounded-full",q)}),_e]})]},F.id)})}),d&&n.jsx("p",{className:"text-sm text-muted-foreground",children:d})]}):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(F=>{const J=F.resources,ke=J?Date.now()-J.reportedAt>As:!1,_e=F.devices.filter(Fe=>Fe.platform===c).length,q=(J==null?void 0:J.cpuPercent)??0,ze=J?J.memUsedMB/J.memTotalMB*100:0,fe=_s(J,ke),he=fe==="overloaded";return n.jsx(pn,{children:n.jsxs(be,{children:[n.jsx(ye,{asChild:!0,children:n.jsx("span",{tabIndex:he?0:void 0,className:he?"cursor-not-allowed":void 0,children:n.jsxs("button",{disabled:he,"aria-disabled":he,onClick:()=>h(F.agentName??null),className:re("flex flex-col gap-3 rounded-lg border p-3 text-left transition-colors min-h-[100px] w-full",he?"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(ji,{health:fe}),n.jsx("span",{className:"text-sm font-medium leading-tight truncate",children:F.agentName??"Unknown"})]}),ke&&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:[_e," device",_e!==1?"s":""]}),J&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("span",{children:[J.slotsAvailable,"/",J.slotsTotal," slots"]})]})]}),J&&!ke&&n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[n.jsx(Gn,{label:"CPU",percent:q,colorClass:"bg-blue-400"}),n.jsx(Gn,{label:"RAM",percent:ze,colorClass:"bg-violet-400"})]})]})})}),he&&n.jsx(ve,{children:"This Mac is currently overloaded. Try again later."})]})},F.agentName)})})]})})}),r&&n.jsxs(n.Fragment,{children:[n.jsx(Jn,{orientation:"vertical",className:"h-auto"}),n.jsx("div",{className:"w-80 shrink-0 h-full",children:n.jsx(pi,{buildId:Number(r),recordingsRefreshKey:i})})]})]})}function ji({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:re("inline-block h-2 w-2 shrink-0 rounded-full",t)})}function Gn({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:re("h-full rounded-full transition-all",r),style:{width:`${Math.min(100,t)}%`}})})]})}export{$i as QASession};
@@ -1 +0,0 @@
1
- import{i as m,j as s}from"./vendor-react-C5H_1fOn.js";import{ai as b,aa 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,a7 as P,a8 as j}from"./index-COIlCLCW.js";import{b as E,c as F}from"./vendor-router-CnmrRwJF.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 +0,0 @@
1
- import{i as f,j as e}from"./vendor-react-C5H_1fOn.js";import{an as g,ai as j,aa as w,C as v,c as N,d as b,a as y,L as i,I as o,B as C,a7 as S,a8 as l}from"./index-COIlCLCW.js";import{b as k}from"./vendor-router-CnmrRwJF.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};
Binary file
Binary file
@@ -1,6 +0,0 @@
1
- import{i,j as e}from"./vendor-react-C5H_1fOn.js";import{a1 as X,ai as Y,aa as Z,B as r,I as N,L as A,h as ee,C as se,c as ie,d as te,a as ne,a9 as x,a7 as L,a8 as u,O as ae}from"./index-COIlCLCW.js";import{D as le,f as re,a as oe,d as ce,e as de,S as I,i as R,j as E,g as O,h as n}from"./dialog-DEL1xxKJ.js";import{A as me,c as he,f as xe,g as ue,d as je,e as ve,b as pe,a as ge}from"./alert-dialog-DhOTocMh.js";import{T as fe,d as be,e as P,c as o,a as Se,b as c}from"./table-CSeGVnii.js";import{j as ye,l as Ce}from"./publicLink-D6zKS_wu.js";import"./vendor-router-CnmrRwJF.js";/**
2
- * @license lucide-react v1.45.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 $={name:"user-plus",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]};$.node;const ke=X($),we=L({email:u().email(),role:u().min(1)}),De=L({token:u(),emailSent:ae(),inviteUrl:u().nullable()});function Pe(){const[g,V]=i.useState([]),[F,f]=i.useState({}),[d,b]=i.useState(""),[H,S]=i.useState(!1),[B,m]=i.useState(""),y=i.useId(),C=i.useRef(null),[M,Q]=i.useState(!1),[j,v]=i.useState(null),{register:z,handleSubmit:_,control:J,reset:U,formState:{errors:k,isSubmitting:w}}=Y({resolver:Z(we),mode:"onBlur",defaultValues:{email:"",role:"QA"}});function p(){fetch("/api/v1/team/members",{credentials:"include"}).then(s=>s.json()).then(V)}i.useEffect(()=>{p()},[]),i.useEffect(()=>{var s;d&&((s=C.current)==null||s.focus())},[d]);async function q(s){m("");try{const t=await fetch("/api/v1/team/invite",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s.email,role:s.role})});if(!t.ok)throw new Error(`Server error: ${t.status}`);const l=De.parse(await t.json()),h=l.inviteUrl??ye((await Ce()).linkBase,`/invite?token=${l.token}`),a=await(navigator.clipboard?navigator.clipboard.writeText(h):Promise.reject(new Error("no clipboard"))).then(()=>!0,()=>!1);b(h),S(a),m(`${l.emailSent?`Invite email sent to ${s.email}.`:"Email could not be sent."} ${a?"Invite link copied to clipboard.":"Copy the invite link."}`),l.emailSent?x.success(`Invite email sent to ${s.email}`):a?x.warning("Invite link copied — email could not be sent. Check your SMTP settings."):x.warning("Email could not be sent. Copy the invite link from the dialog, and check your SMTP settings.")}catch{x.error("Failed to create invite link"),m("Failed to create invite link.")}}function D(s){Q(s),s||(b(""),S(!1),m(""),U())}async function G(s,t){await fetch(`/api/v1/team/members/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({role:t})}),p()}async function K(s){const h=(await(await fetch(`/api/v1/team/members/${s}/send-reset`,{method:"POST",credentials:"include"})).json()).emailSent?"Sent":"No SMTP";f(a=>({...a,[s]:h})),setTimeout(()=>f(a=>{const T={...a};return delete T[s],T}),3e3)}async function W(s){await fetch(`/api/v1/team/members/${s}`,{method:"DELETE",credentials:"include"}),v(null),p()}return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx(me,{open:j!==null,onOpenChange:s=>{s||v(null)},children:e.jsxs(he,{children:[e.jsxs(xe,{children:[e.jsx(ue,{children:"Remove this member?"}),e.jsx(je,{children:"This member will lose access to the team immediately."})]}),e.jsxs(ve,{children:[e.jsx(pe,{children:"Cancel"}),e.jsx(ge,{className:"bg-destructive/10 text-destructive hover:bg-destructive/20 border-0",onClick:()=>j!==null&&W(j),children:"Remove"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Team"}),e.jsxs(le,{open:M,onOpenChange:D,children:[e.jsx(re,{asChild:!0,children:e.jsxs(r,{size:"sm",children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),"Invite member"]})}),e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsx(ce,{children:e.jsx(de,{children:"Invite team member"})}),e.jsx("p",{role:"status",className:"sr-only",children:B}),d?e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsx("p",{id:y,className:"text-sm text-muted-foreground",children:H?"Invite link copied to clipboard:":"Copy this invite link:"}),e.jsx(N,{ref:C,readOnly:!0,value:d,"aria-labelledby":y,onFocus:s=>s.currentTarget.select(),className:"font-mono text-xs"}),e.jsx(r,{onClick:()=>D(!1),children:"Done"})]}):e.jsxs("form",{onSubmit:_(q),className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"invite-email",children:"Email"}),e.jsx(N,{id:"invite-email",type:"email",...z("email")}),k.email&&e.jsx("p",{className:"text-sm text-destructive",children:k.email.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"invite-role",children:"Role"}),e.jsx(ee,{name:"role",control:J,render:({field:s})=>e.jsxs(I,{value:s.value,onValueChange:s.onChange,children:[e.jsx(R,{id:"invite-role",children:e.jsx(E,{})}),e.jsxs(O,{children:[e.jsx(n,{value:"Admin",children:"Admin"}),e.jsx(n,{value:"Developer",children:"Developer"}),e.jsx(n,{value:"QA",children:"QA"}),e.jsx(n,{value:"Viewer",children:"Viewer"})]})]})})]}),e.jsx(r,{type:"submit",disabled:w,children:w?"Creating link…":"Generate invite link"})]})]})]})]}),e.jsxs(se,{children:[e.jsx(ie,{children:e.jsxs(te,{children:["Members (",g.length,")"]})}),e.jsx(ne,{className:"px-4 pt-0 pb-2",children:e.jsxs(fe,{children:[e.jsx(be,{children:e.jsxs(P,{children:[e.jsx(o,{children:"Nickname"}),e.jsx(o,{children:"Email"}),e.jsx(o,{children:"Role"}),e.jsx(o,{children:"Joined"}),e.jsx(o,{className:"w-10"})]})}),e.jsx(Se,{children:g.map(s=>e.jsxs(P,{className:"hover:bg-transparent",children:[e.jsx(c,{className:"font-medium",children:s.display_name||"—"}),e.jsx(c,{className:"text-muted-foreground text-sm",children:s.email}),e.jsx(c,{children:e.jsxs(I,{value:s.role,onValueChange:t=>G(s.id,t),children:[e.jsx(R,{className:"h-7 w-28",children:e.jsx(E,{})}),e.jsxs(O,{children:[e.jsx(n,{value:"Admin",children:"Admin"}),e.jsx(n,{value:"Developer",children:"Developer"}),e.jsx(n,{value:"QA",children:"QA"}),e.jsx(n,{value:"Viewer",children:"Viewer"})]})]})}),e.jsx(c,{className:"text-muted-foreground text-sm",children:new Date(s.joined_at).toLocaleDateString()}),e.jsx(c,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{variant:"secondary",size:"nav",onClick:()=>K(s.id),children:F[s.id]??"Reset pwd"}),e.jsx(r,{variant:"destructive",size:"nav",onClick:()=>v(s.id),children:"Remove"})]})})]},s.id))})]})})]})]})}export{Pe as TeamSettings};
Binary file
Binary file
@@ -1 +0,0 @@
1
- import{i as t,j as e}from"./vendor-react-C5H_1fOn.js";import{ai as $,aa as M,B as d,I as p,a9 as a,L as y,C as J,c as U,d as q,b as G,a as K,a7 as Q,a8 as F}from"./index-COIlCLCW.js";import{B}from"./badge-B4gbViMs.js";import{A as X,c as Y,f as Z,g as ee,d as se,e as te,b as ae}from"./alert-dialog-DhOTocMh.js";import{D as ne,f as re,a as oe,d as le,e as ie,S as ce,i as de,j as xe,g as me,h as R}from"./dialog-DEL1xxKJ.js";import{T as he,d as ue,e as v,c as x,a as pe,b as l}from"./table-CSeGVnii.js";import{l as je}from"./publicLink-D6zKS_wu.js";import{P as ge,T as fe}from"./trash-CD9Y9G-i.js";import"./vendor-router-CnmrRwJF.js";const ke=Q({name:F().min(1),expiresDays:F().refine(m=>{const i=parseInt(m,10);return!isNaN(i)&&i>=1&&i<=365},{message:"Must be between 1 and 365"})});function Ae(){const[m,i]=t.useState([]),[_,P]=t.useState(!1),[n,N]=t.useState(""),[c,b]=t.useState("api"),[w,T]=t.useState(""),[j,g]=t.useState(null),C=t.useId(),D=t.useId(),f=t.useRef(null),[L,r]=t.useState(""),{register:S,handleSubmit:O,reset:H,formState:{errors:h,isSubmitting:A}}=$({resolver:M(ke),mode:"onBlur",defaultValues:{name:"",expiresDays:"30"}});function k(){fetch("/api/v1/tokens",{credentials:"include"}).then(s=>s.json()).then(i)}t.useEffect(()=>{k()},[]),t.useEffect(()=>{var s;n&&((s=f.current)==null||s.focus())},[n]);async function z(s){r("");try{const u=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(!u.ok){const o=await u.json().catch(()=>null);a.error((o==null?void 0:o.error)??"Failed to create token"),r((o==null?void 0:o.error)??"Failed to create token");return}const W=await u.json();c==="agent"&&T((await je()).agentWsBase),a.success("Token created"),N(W.token),k()}catch{a.error("Network error"),r("Network error")}}function I(s){P(s),s||(N(""),b("api"),T(""),r(""),H())}async function V(s){try{return(await fetch(`/api/v1/tokens/${s}`,{method:"DELETE",credentials:"include"})).ok?(a.success("Token revoked"),k(),!0):(a.error("Failed to revoke token"),!1)}catch{return a.error("Network error"),!1}}function E(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(ne,{open:_,onOpenChange:I,children:[e.jsx(re,{asChild:!0,children:e.jsxs(d,{size:"sm",children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),"New token"]})}),e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsx(le,{children:e.jsx(ie,{children:"Create token"})}),e.jsx("p",{role:"status",className:"sr-only",children:L}),n?e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsx("p",{id:C,className:"text-sm text-muted-foreground",children:"Copy this token now — it won't be shown again."}),e.jsx(p,{ref:f,readOnly:!0,value:n,"aria-labelledby":C,onFocus:s=>s.currentTarget.select(),className:"font-mono text-xs"}),c==="agent"&&w&&e.jsxs(e.Fragment,{children:[e.jsx("p",{id:D,className:"text-sm text-muted-foreground",children:"Run this on the agent Mac to connect it to this relay:"}),e.jsx(p,{readOnly:!0,value:`tapflow agent start --relay ${w} --token ${n}`,"aria-labelledby":D,onFocus:s=>s.currentTarget.select(),className:"font-mono text-xs"})]}),e.jsx(d,{onClick:()=>{r(""),(navigator.clipboard?navigator.clipboard.writeText(n):Promise.reject(new Error("no clipboard"))).then(()=>{a.success("Token copied to clipboard"),I(!1)}).catch(()=>{var s;a.error("Failed to copy — copy manually"),r("Could not copy the token. Select it and copy it by hand."),(s=f.current)==null||s.focus()})},children:"Copy & close"})]}):e.jsxs("form",{onSubmit:O(z),className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(y,{htmlFor:"token-name",children:"Name"}),e.jsx(p,{id:"token-name",placeholder:"e.g. ci-deploy",...S("name")}),h.name&&e.jsx("p",{className:"text-sm text-destructive",children:h.name.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(y,{htmlFor:"expires",children:"Expires in (days)"}),e.jsx(p,{id:"expires",type:"number",...S("expiresDays")}),h.expiresDays&&e.jsx("p",{className:"text-sm text-destructive",children:h.expiresDays.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(y,{htmlFor:"token-type",children:"Type"}),e.jsxs(ce,{value:c,onValueChange:s=>b(s),children:[e.jsx(de,{id:"token-type",children:e.jsx(xe,{})}),e.jsxs(me,{children:[e.jsx(R,{value:"api",children:"API — CI uploads & API access"}),e.jsx(R,{value:"agent",children:"Agent — connect remote device agents (Admin only)"})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Scope: ",e.jsx(B,{variant:"secondary",children:c==="agent"?"agent":"view, builds:write"})]}),e.jsx(d,{type:"submit",disabled:A,children:A?"Creating…":"Create token"})]})]})]})]}),e.jsxs(J,{children:[e.jsxs(U,{children:[e.jsx(q,{children:"Active tokens"}),e.jsxs(G,{children:["Use these tokens with ",e.jsx("code",{className:"text-xs",children:"Authorization: Bearer <token>"})," for API deployments."]})]}),e.jsx(K,{className:"px-4 pt-0 pb-2",children:e.jsxs(he,{children:[e.jsx(ue,{children:e.jsxs(v,{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(pe,{children:m.length===0?e.jsx(v,{children:e.jsx(l,{colSpan:5,className:"h-20 text-center text-muted-foreground",children:"No tokens yet."})}):m.map(s=>e.jsxs(v,{className:"hover:bg-transparent",children:[e.jsx(l,{className:"font-medium",children:s.name}),e.jsx(l,{children:e.jsx(B,{variant:"secondary",children:s.scope})}),e.jsx(l,{className:"text-muted-foreground text-sm",children:s.last_used_at?new Date(s.last_used_at).toLocaleDateString():"Never"}),e.jsx(l,{children:s.expires_at?e.jsx("span",{className:E(s)?"text-destructive text-sm":"text-muted-foreground text-sm",children:E(s)?"Expired":new Date(s.expires_at).toLocaleDateString()}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Never"})}),e.jsx(l,{children:e.jsx(d,{variant:"destructive",size:"icon",className:"h-7 w-7","aria-label":"Revoke token",onClick:()=>g(s.id),children:e.jsx(fe,{className:"h-4 w-4"})})})]},s.id))})]})})]}),e.jsx(X,{open:j!==null,onOpenChange:s=>{s||g(null)},children:e.jsxs(Y,{children:[e.jsxs(Z,{children:[e.jsx(ee,{children:"Revoke token?"}),e.jsx(se,{children:"Any active API calls using this token will immediately fail."})]}),e.jsxs(te,{children:[e.jsx(ae,{children:"Cancel"}),e.jsx(d,{variant:"destructive",onClick:async()=>{if(j===null)return;await V(j)&&g(null)},children:"Revoke"})]})]})})]})}export{Ae as TokenSettings};
Binary file
Binary file
@@ -1 +0,0 @@
1
- import{i as r,j as o}from"./vendor-react-C5H_1fOn.js";import{m as T,ae as u,j as O,Y as S,n as b,k as $,i as m,a0 as v,l as E,$ as h,D as z,o as F,W as g,Q as x}from"./index-COIlCLCW.js";var k=Object.defineProperty,n=(t,e)=>k(t,"name",{value:e,configurable:!0}),H="AlertDialog",[M,pe]=h(H,[v]),c=v(),I=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(z,{...l,...a,modal:!0})},"AlertDialog"),L=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(F,{...s,...i,ref:a})},"AlertDialogTrigger")),Q=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(T,{...l,...a})},"AlertDialogPortal"),V=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(E,{...s,...i,ref:a})},"AlertDialogOverlay")),W="AlertDialogContent",[Y,q]=M(W),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(Y,{scope:l,cancelRef:D,children:o.jsx(O,{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")),J=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx($,{...s,...i,ref:a})},"AlertDialogDescription")),K=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(m,{...s,...i,ref:a})},"AlertDialogAction")),U="AlertDialogCancel",X=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,{cancelRef:s}=q(U,l),p=c(l),f=u(a,s);return o.jsx(m,{...p,...i,ref:f})},"AlertDialogCancel")),Z=I,ee=L,ae=Q,N=V,j=B,y=K,_=X,C=G,R=J;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 +0,0 @@
1
- import{j as n}from"./vendor-react-C5H_1fOn.js";import{W as d,a5 as o}from"./index-COIlCLCW.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};
Binary file
Binary file