@tapflowio/relay 0.18.0 → 0.19.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.
- package/README.md +1 -1
- package/dist/RelayServer.d.ts +263 -2
- package/dist/RelayServer.d.ts.map +1 -1
- package/dist/RelayServer.js +936 -177
- package/dist/RelayServer.js.map +1 -1
- package/dist/SessionManager.d.ts +83 -17
- package/dist/SessionManager.d.ts.map +1 -1
- package/dist/SessionManager.js +107 -14
- package/dist/SessionManager.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +2 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/public/assets/{AppCenter-B3FO67aw.js → AppCenter-DyP0aqfF.js} +2 -2
- package/public/assets/AppCenter-DyP0aqfF.js.br +0 -0
- package/public/assets/Default-D7ScPE30.js +1 -0
- package/public/assets/Default-D7ScPE30.js.br +0 -0
- package/public/assets/Invite-UmhV5rAf.js +1 -0
- package/public/assets/Invite-UmhV5rAf.js.br +0 -0
- package/public/assets/MacResources-MS4E00w3.js +1 -0
- package/public/assets/MacResources-MS4E00w3.js.br +0 -0
- package/public/assets/NotFound-BoDDivK5.js +1 -0
- package/public/assets/NotFound-BoDDivK5.js.br +0 -0
- package/public/assets/QASession-CjgJHDZ3.js +125 -0
- package/public/assets/QASession-CjgJHDZ3.js.br +0 -0
- package/public/assets/ResetPassword-CAlB6CfP.js +1 -0
- package/public/assets/ResetPassword-CAlB6CfP.js.br +0 -0
- package/public/assets/Setup-CPm2-hPJ.js +1 -0
- package/public/assets/Setup-CPm2-hPJ.js.br +0 -0
- package/public/assets/{Team-CBsjuUwh.js → Team-GEIzrM1D.js} +2 -2
- package/public/assets/Team-GEIzrM1D.js.br +0 -0
- package/public/assets/Tokens-DSeBz_CJ.js +1 -0
- package/public/assets/Tokens-DSeBz_CJ.js.br +0 -0
- package/public/assets/alert-dialog-BsXI9SVV.js +1 -0
- package/public/assets/alert-dialog-BsXI9SVV.js.br +0 -0
- package/public/assets/badge-BkdYQFsh.js +1 -0
- package/public/assets/badge-BkdYQFsh.js.br +0 -0
- package/public/assets/{build-format-B78hbKY9.js → build-format-CXuQt1X2.js} +3 -3
- package/public/assets/build-format-CXuQt1X2.js.br +0 -0
- package/public/assets/{dialog-BxC9v2BL.js → dialog-DuXZpbiF.js} +3 -3
- package/public/assets/dialog-DuXZpbiF.js.br +0 -0
- package/public/assets/{index-uGJGo6ac.css → index-Bk2hqaHZ.css} +1 -1
- package/public/assets/index-Bk2hqaHZ.css.br +0 -0
- package/public/assets/index-bitr6DIC.js +215 -0
- package/public/assets/index-bitr6DIC.js.br +0 -0
- package/public/assets/{pencil-Cq64I9LV.js → pencil-iRR275s8.js} +1 -1
- package/public/assets/pencil-iRR275s8.js.br +0 -0
- package/public/assets/table-CHmhGpHG.js +1 -0
- package/public/assets/table-CHmhGpHG.js.br +0 -0
- package/public/assets/tabs-BnbeuAOe.js +1 -0
- package/public/assets/tabs-BnbeuAOe.js.br +0 -0
- package/public/assets/{trash-2-CszwJHEh.js → trash-2-QI162w2K.js} +1 -1
- package/public/assets/trash-2-QI162w2K.js.br +0 -0
- package/public/assets/vendor-charts-DyX5CBcf.js +5 -0
- package/public/assets/vendor-charts-DyX5CBcf.js.br +0 -0
- package/public/assets/vendor-react-AJpf4YZ0.js +49 -0
- package/public/assets/vendor-react-AJpf4YZ0.js.br +0 -0
- package/public/assets/vendor-router-ChFy8CZ1.js +12 -0
- package/public/assets/vendor-router-ChFy8CZ1.js.br +0 -0
- package/public/index.html +4 -2
- package/public/index.html.br +0 -0
- package/public/assets/AppCenter-B3FO67aw.js.br +0 -0
- package/public/assets/Default-BlNUv5dw.js +0 -1
- package/public/assets/Default-BlNUv5dw.js.br +0 -0
- package/public/assets/Invite-CKYFmy7S.js +0 -1
- package/public/assets/Invite-CKYFmy7S.js.br +0 -0
- package/public/assets/MacResources-BK4VQnFc.js +0 -5
- package/public/assets/MacResources-BK4VQnFc.js.br +0 -0
- package/public/assets/NotFound-BMmi1paB.js +0 -1
- package/public/assets/NotFound-BMmi1paB.js.br +0 -0
- package/public/assets/QASession-CVTlqW3d.js +0 -125
- package/public/assets/QASession-CVTlqW3d.js.br +0 -0
- package/public/assets/ResetPassword-VPPBWzSI.js +0 -1
- package/public/assets/ResetPassword-VPPBWzSI.js.br +0 -0
- package/public/assets/Setup-CRdnCl41.js +0 -1
- package/public/assets/Setup-CRdnCl41.js.br +0 -0
- package/public/assets/Team-CBsjuUwh.js.br +0 -0
- package/public/assets/Tokens-CU9HB9WD.js +0 -1
- package/public/assets/Tokens-CU9HB9WD.js.br +0 -0
- package/public/assets/alert-dialog-DWqGDQTB.js +0 -1
- package/public/assets/alert-dialog-DWqGDQTB.js.br +0 -0
- package/public/assets/badge-OToVq1dK.js +0 -1
- package/public/assets/badge-OToVq1dK.js.br +0 -0
- package/public/assets/build-format-B78hbKY9.js.br +0 -3
- package/public/assets/dialog-BxC9v2BL.js.br +0 -0
- package/public/assets/index-DXjMx9hQ.js +0 -274
- package/public/assets/index-DXjMx9hQ.js.br +0 -0
- package/public/assets/index-uGJGo6ac.css.br +0 -0
- package/public/assets/pencil-Cq64I9LV.js.br +0 -0
- package/public/assets/table-CbATN5Pi.js +0 -1
- package/public/assets/table-CbATN5Pi.js.br +0 -0
- package/public/assets/tabs-BVumgDA4.js +0 -1
- package/public/assets/tabs-BVumgDA4.js.br +0 -0
- package/public/assets/trash-2-CszwJHEh.js.br +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import{i as s,j as r}from"./vendor-react-AJpf4YZ0.js";import{W as ie,J as oe,y as Dt,T as Ee,z as Te,B as fe,x as Ae,S as hr,a4 as Ue,r as en,s as Et,K as He,a9 as Ke,t as Xe,O as pr,a8 as nt,af as tn,ab as rn,U as nn,w as sn,f as on,ag as an,aa as cn,a7 as ln,L as un}from"./index-bitr6DIC.js";import{f as dn,a as fn,P as mr,c as Jt,S as hn,b as pn}from"./build-format-CXuQt1X2.js";import{u as gr,n as J,T as mn,b as gn,c as Zt,a as Qt}from"./tabs-BnbeuAOe.js";import{c as xr,b as xn}from"./vendor-router-ChFy8CZ1.js";import{D as br,a as yr,d as bn,e as vr,b as yn,c as vn,k as wn,S as Sn,i as Rn,j as Cn,g as jn,h as er}from"./dialog-DuXZpbiF.js";import{B as kn}from"./badge-BkdYQFsh.js";/**
|
|
2
|
+
* @license lucide-react v0.577.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 En=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Tn=ie("arrow-left",En);/**
|
|
7
|
+
* @license lucide-react v0.577.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 An=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],_n=ie("arrow-up",An);/**
|
|
12
|
+
* @license lucide-react v0.577.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 Nn=[["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"}]],Pn=ie("camera",Nn);/**
|
|
17
|
+
* @license lucide-react v0.577.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 Dn=[["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"}]],Ln=ie("download",Dn);/**
|
|
22
|
+
* @license lucide-react v0.577.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 Mn=[["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"}]],In=ie("film",Mn);/**
|
|
27
|
+
* @license lucide-react v0.577.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 Un=[["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"}]],wr=ie("house",Un);/**
|
|
32
|
+
* @license lucide-react v0.577.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 Hn=[["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"}]],$n=ie("image-plus",Hn);/**
|
|
37
|
+
* @license lucide-react v0.577.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 Bn=[["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"}]],Fn=ie("keyboard",Bn);/**
|
|
42
|
+
* @license lucide-react v0.577.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 On=[["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"}]],Sr=ie("link-2",On);/**
|
|
47
|
+
* @license lucide-react v0.577.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 zn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],jt=ie("loader-circle",zn);/**
|
|
52
|
+
* @license lucide-react v0.577.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 Wn=[["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"}]],Vn=ie("message-square",Wn);/**
|
|
57
|
+
* @license lucide-react v0.577.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 Kn=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Xn=ie("power",Kn);/**
|
|
62
|
+
* @license lucide-react v0.577.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 qn=[["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"}]],Yn=ie("rotate-cw",qn);/**
|
|
67
|
+
* @license lucide-react v0.577.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 Gn=[["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"}]],Jn=ie("scan-line",Gn);/**
|
|
72
|
+
* @license lucide-react v0.577.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 Zn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Qn=ie("square",Zn);/**
|
|
77
|
+
* @license lucide-react v0.577.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 es=[["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"}]],ts=ie("video",es);/**
|
|
82
|
+
* @license lucide-react v0.577.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const rs=[["path",{d:"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"}]],ns=ie("volume-2",rs);/**
|
|
87
|
+
* @license lucide-react v0.577.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 ss=[["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"}]],os=ie("volume-1",ss);function as(t){const[e,n]=s.useState(null);return s.useEffect(()=>{t&&dn(t).then(n)},[t]),{build:e}}function is(t){const[e,n]=s.useState([]),[o,i]=s.useState(null),[a,c]=s.useState(null),[f,d]=s.useState(""),[p,m]=s.useState(!1),[g,b]=s.useState(""),l=s.useCallback(N=>{N.type==="agents:listed"&&n(N.sessions),N.type==="session:joined"&&(m(!1),b("Connected")),N.type==="error"&&(m(!1),b(`Error: ${N.message}`))},[]),{send:y,connected:j}=gr(l);s.useEffect(()=>{if(!j)return;y({type:"agents:list"});const N=setInterval(()=>y({type:"agents:list"}),5e3);return()=>clearInterval(N)},[j,y]);const _=s.useRef({sessionId:a,deviceId:f});s.useEffect(()=>{_.current={sessionId:a,deviceId:f}},[a,f]),s.useEffect(()=>()=>{const{sessionId:N,deviceId:O}=_.current;N&&O&&y({type:"device:shutdown",sessionId:N,payload:{deviceId:O}})},[y]);const T=e.filter(N=>N.devices.some(O=>O.platform===t)),k=s.useCallback(N=>{d(N.id),m(!0),b("Booting…"),c(N.sessionId)},[]),A=s.useCallback(()=>d(""),[]),R=s.useCallback(()=>{const{sessionId:N,deviceId:O}=_.current;N&&O&&y({type:"device:shutdown",sessionId:N,payload:{deviceId:O}}),c(null),m(!1),b("")},[y]),U=s.useCallback(()=>{const{sessionId:N,deviceId:O}=_.current;N&&O&&y({type:"device:shutdown",sessionId:N,payload:{deviceId:O}}),c(null),i(null),m(!1),b(""),y({type:"agents:list"})},[y]),M=s.useCallback(()=>{c(null),i(null),m(!1),b(""),y({type:"agents:list"})},[y]);return{sessions:e,selectedAgent:o,setSelectedAgent:i,activeSessionId:a,deviceId:f,booting:p,status:g,send:y,connected:j,agentGroups:T,startDevice:k,resetDevice:A,handleBack:R,handleBackToMacs:U,handleSessionEnded:M}}function cs(t,e){const[n,o]=s.useState(""),[i,a]=s.useState(""),[c,f]=s.useState("app-only"),[d,p]=s.useState("app-only"),m=e!=="android",g=s.useCallback(()=>{p(m?c:"app-only"),f("app-only")},[c,m]),b=(t==null?void 0:t.devices.filter(j=>j.platform===e))??[],l=[...new Set(b.map(j=>j.osVersion).filter(Boolean))].sort((j,_)=>{const T=R=>R.replace(/^[^\d]*/,"").split(".").map(Number),[k,A]=[T(j),T(_)];for(let R=0;R<Math.max(k.length,A.length);R++){const U=(A[R]??0)-(k[R]??0);if(U!==0)return U}return 0}),y=(n?b.filter(j=>j.osVersion===n):b).filter(j=>!i||j.name.toLowerCase().includes(i.toLowerCase()));return{filteredDevices:b,osVersions:l,osVersion:n,setOsVersion:o,deviceSearch:i,setDeviceSearch:a,versionedDevices:y,resetMode:c,setResetMode:f,appliedResetMode:d,consumeResetMode:g,fullResetSupported:m}}function ls(){const[t]=xr(),e=t.get("perf")==="1",[n,o]=s.useState(e);return s.useEffect(()=>{if(!e){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)},[e]),{perfMode:e,visible:n}}const us=["video/mp4;codecs=avc1","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function Rr({sessionId:t,buildId:e,onRecordingUploaded:n}){const[o,i]=s.useState("idle"),a=s.useRef(null),c=s.useRef(n);s.useEffect(()=>{c.current=n},[n]);const f=s.useRef(!1),d=s.useRef(null),p=s.useRef([]),m=s.useRef(""),g=s.useRef(0),b=s.useRef(null),l=s.useCallback(function _(){var T;f.current&&((T=b.current)==null||T.call(b),g.current=requestAnimationFrame(_))},[]),y=s.useCallback(_=>{const T=a.current;if(!T)return;const k=T.getContext("2d");k&&(k.fillStyle="#000",k.fillRect(0,0,T.width,T.height));const A=us.find(U=>MediaRecorder.isTypeSupported(U))??"";if(!A)return;m.current=A,p.current=[];const R=new MediaRecorder(T.captureStream(30),{mimeType:A});R.ondataavailable=U=>{U.data.size>0&&p.current.push(U.data)},d.current=R,R.start(1e3),b.current=_,f.current=!0,g.current=requestAnimationFrame(l),i("recording")},[l]),j=s.useCallback(async()=>{var U;i("uploading"),f.current=!1,cancelAnimationFrame(g.current);const _=d.current;if(!_){i("idle");return}await new Promise(M=>{const N=setTimeout(M,5e3);_.onstop=()=>{clearTimeout(N),M()};try{_.stop()}catch{clearTimeout(N),M()}}),d.current=null;const T=m.current,k=T.includes("mp4")?".mp4":".webm",A=new Blob(p.current,{type:T});p.current=[];const R=new FormData;R.append("file",A,`tapflow-${Date.now()}${k}`);try{const M=new URLSearchParams({sessionId:t});e&&M.set("buildId",String(e));const N=await fetch(`/api/v1/recordings/upload?${M}`,{method:"POST",credentials:"include",body:R}),O=await N.json();if(N.ok&&O.url){const re=document.createElement("a");re.href=O.url,re.download="",re.click(),(U=c.current)==null||U.call(c),i("done"),setTimeout(()=>i("idle"),2e3)}else i("idle")}catch{i("idle")}},[t,e]);return s.useEffect(()=>{if(o!=="recording")return;const _=()=>{document.visibilityState==="hidden"&&j()};return document.addEventListener("visibilitychange",_),()=>{var T;document.removeEventListener("visibilitychange",_),f.current&&(f.current=!1,cancelAnimationFrame(g.current),(T=d.current)==null||T.stop(),d.current=null)}},[o,j]),{recordState:o,recordCanvasRef:a,startClientRecording:y,stopClientRecording:j}}function Cr(){const t=s.useRef(0),[e,n]=s.useState(0);return s.useEffect(()=>{const o=setInterval(()=>{n(t.current),t.current=0},1e3);return()=>clearInterval(o)},[]),{fps:e,frameCount:t}}function rt({className:t,...e}){return r.jsx("kbd",{"data-slot":"kbd",className:oe("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",t),...e})}function Lt({className:t,...e}){return r.jsx("kbd",{"data-slot":"kbd-group",className:oe("inline-flex items-center gap-1",t),...e})}function dt({label:t,keys:e}){return r.jsxs("span",{className:"flex items-center gap-3",children:[t,r.jsx(Lt,{children:e.map(n=>r.jsx(rt,{children:n},n))})]})}function jr({joined:t,onScreenshot:e,onRecordToggle:n,recordState:o,onRotate:i,onDeepLink:a,platformSlot:c,launchSlot:f}){return t?r.jsx(Dt,{delayDuration:400,children:r.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:[f,c,r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:a,children:r.jsx(Sr,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:r.jsx(dt,{label:"Deeplink",keys:["⌘","K"]})})]}),r.jsx("div",{className:"w-4 h-px bg-border my-1"}),r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:e,children:r.jsx(Pn,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:r.jsx(dt,{label:"Screenshot",keys:["⌘","S"]})})]}),r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:oe("h-8 w-8",o==="recording"&&"text-red-500 hover:text-red-500"),disabled:o==="uploading"||o==="done",onClick:n,children:o==="uploading"?r.jsx(jt,{className:"h-4 w-4 animate-spin"}):o==="recording"?r.jsx(Qn,{className:"h-4 w-4 fill-current"}):r.jsx(ts,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:o==="idle"?r.jsx(dt,{label:"Start recording",keys:["⌘","⇧","Y"]}):o==="recording"?r.jsx(dt,{label:"Stop recording",keys:["⌘","⇧","Y"]}):"Processing…"})]}),r.jsx("div",{className:"w-4 h-px bg-border my-1"}),r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:i,children:r.jsx(Yn,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:r.jsx(dt,{label:"Rotate",keys:["⌘","⇧","O"]})})]})]})}):null}class Mt{constructor(e){this.bytes=e,this.bitPos=0}get position(){return this.bitPos}bit(){const e=this.bitPos>>3,n=7-(this.bitPos&7);return this.bitPos++,e>=this.bytes.length?0:this.bytes[e]>>n&1}bits(e){let n=0;for(let o=0;o<e;o++)n=n<<1|this.bit();return n>>>0}flag(){return this.bit()===1}ue(){let e=0;for(;this.bit()===0&&e<32;)e++;return e===0?0:(1<<e)-1+this.bits(e)}se(){const e=this.ue();return e&1?Math.ceil(e/2):-Math.ceil(e/2)}}class ds{constructor(){this.bitsArr=[]}bit(e){this.bitsArr.push(e&1)}ue(e){const n=e+1,o=Math.floor(Math.log2(n));for(let i=0;i<o;i++)this.bit(0);for(let i=o;i>=0;i--)this.bit(n>>i&1)}toBytes(){const e=[];for(let n=0;n<this.bitsArr.length;n+=8){let o=0;for(let i=0;i<8;i++)o=o<<1|(this.bitsArr[n+i]??0);e.push(o)}return new Uint8Array(e)}}function kr(t){const e=[];let n=0;for(let o=1;o<t.length;o++){const i=t[o];if(n>=2&&i===3){n=0;continue}e.push(i),n=i===0?n+1:0}return new Uint8Array(e)}function fs(t){const e=[];let n=0;for(const o of t)n>=2&&o<=3&&(e.push(3),n=0),e.push(o),n=o===0?n+1:0;return new Uint8Array(e)}const hs=new Set([100,110,122,244,44,83,86,118,128,138,139,134,135]);function tr(t){const e=t.ue()+1;t.bits(4),t.bits(4);for(let n=0;n<e;n++)t.ue(),t.ue(),t.flag();t.bits(5),t.bits(5),t.bits(5),t.bits(5)}function Er(t){const e=t.bits(8);t.bits(8);const n=t.bits(8);if(t.ue(),hs.has(e)){const g=t.ue();if(g===3&&t.flag(),t.ue(),t.ue(),t.flag(),t.flag()){const b=g!==3?8:12;for(let l=0;l<b;l++)if(t.flag()){const y=l<6?16:64;let j=8,_=8;for(let T=0;T<y;T++)_!==0&&(_=(j+t.se()+256)%256),j=_===0?j:_}}}t.ue();const o=t.ue();if(o===0)t.ue();else if(o===1){t.flag(),t.se(),t.se();const g=t.ue();for(let b=0;b<g;b++)t.se()}const i=t.ue();t.flag(),t.ue(),t.ue(),t.flag()||t.flag(),t.flag(),t.flag()&&(t.ue(),t.ue(),t.ue(),t.ue());const a={profileIdc:e,levelIdc:n,numRefFrames:i,bitstreamRestriction:!1,maxNumReorderFrames:null,maxDecFrameBuffering:null};if(!t.flag())return{...a,vuiPresent:!1,restrictionFlagPos:-1};t.flag()&&t.bits(8)===255&&(t.bits(16),t.bits(16)),t.flag()&&t.flag(),t.flag()&&(t.bits(3),t.flag(),t.flag()&&(t.bits(8),t.bits(8),t.bits(8))),t.flag()&&(t.ue(),t.ue()),t.flag()&&(t.bits(32),t.bits(32),t.flag());const f=t.flag();f&&tr(t);const d=t.flag();d&&tr(t),(f||d)&&t.flag(),t.flag();const p=t.position;return t.flag()?(t.flag(),t.ue(),t.ue(),t.ue(),t.ue(),{...a,vuiPresent:!0,bitstreamRestriction:!0,maxNumReorderFrames:t.ue(),maxDecFrameBuffering:t.ue(),restrictionFlagPos:p}):{...a,vuiPresent:!0,restrictionFlagPos:p}}function ps(t){const e=Er(new Mt(kr(t)));return{profileIdc:e.profileIdc,levelIdc:e.levelIdc,vuiPresent:e.vuiPresent,bitstreamRestriction:e.bitstreamRestriction,maxNumReorderFrames:e.maxNumReorderFrames,maxDecFrameBuffering:e.maxDecFrameBuffering}}function ms(t){const e=kr(t),n=Er(new Mt(e));if(!n.vuiPresent||n.restrictionFlagPos<0||n.bitstreamRestriction)return null;const o=new ds,i=new Mt(e);for(let a=0;a<n.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(n.numRefFrames),o.bit(1),Uint8Array.from([t[0],...fs(o.toBytes())])}function gs(t){const e=[],n=t.length;let o=-1,i=0;for(;i+2<n;){const a=i+3<n&&t[i]===0&&t[i+1]===0&&t[i+2]===0&&t[i+3]===1,c=t[i]===0&&t[i+1]===0&&t[i+2]===1;a||c?(o>=0&&e.push(t.subarray(o,i)),i+=a?4:3,o=i):i++}return o>=0&&e.push(t.subarray(o,n)),e}class xs{constructor(e){this.onFrame=e,this.decoder=null,this.sps=null,this.pps=null,this.frameCount=0,this.submitAt=new Map,this.spsLogged=!1}setDecodeSampler(e){this.decodeSampler=e}decode(e){const n=[];let o=!1;for(const p of gs(new Uint8Array(e))){const m=p[0]&31;if(m===7){const g=!this.sps||p.length!==this.sps.length||p.some((b,l)=>b!==this.sps[l]);this.sps=p,g&&this.decoder&&(this.decoder.close(),this.decoder=null)}else m===8?this.pps=p:m>=1&&m<=5&&(m===5&&(o=!0),n.push(p))}if(o&&this.sps&&this.pps&&!this.decoder&&this.initDecoder(this.sps,this.pps),!this.decoder||n.length===0)return;let i=0;for(const p of n)i+=4+p.length;const a=new Uint8Array(i),c=new DataView(a.buffer);let f=0;for(const p of n)c.setUint32(f,p.length,!1),f+=4,a.set(p,f),f+=p.length;const d=Math.round(this.frameCount++*(1e6/30));if(this.decodeSampler&&(this.submitAt.set(d,performance.now()),this.submitAt.size>120)){const p=this.submitAt.keys().next().value;p!==void 0&&this.submitAt.delete(p)}try{this.decoder.decode(new EncodedVideoChunk({type:o?"key":"delta",timestamp:d,data:a}))}catch{}}sampleDecode(e){var o;if(!this.decodeSampler)return;const n=this.submitAt.get(e.timestamp);n!==void 0&&(this.submitAt.delete(e.timestamp),this.decodeSampler({decodeMs:performance.now()-n,queueSize:((o=this.decoder)==null?void 0:o.decodeQueueSize)??0}))}close(){var e;(e=this.decoder)==null||e.close(),this.decoder=null}logSpsVui(e){if(!(this.spsLogged||!this.decodeSampler)){this.spsLogged=!0;try{console.log("[sps-vui]",JSON.stringify(ps(e)))}catch(n){console.warn("[sps-vui] parse failed",n)}}}initDecoder(e,n){this.logSpsVui(e);const o=ms(e)??e,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,n);this.decoder=new VideoDecoder({output:f=>{this.sampleDecode(f),this.onFrame(f)},error:f=>console.error("[WebCodecsCore]",f)}),this.decoder.configure({codec:a,description:c,optimizeForLatency:!0})}buildAVCC(e,n){const o=e[0]===0?e.subarray(4):e,i=n[0]===0?n.subarray(4):n,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 bs=`#version 300 es
|
|
92
|
+
in vec2 a_pos;
|
|
93
|
+
out vec2 v_uv;
|
|
94
|
+
void main() {
|
|
95
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
96
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
97
|
+
}`,ys=`#version 300 es
|
|
98
|
+
precision mediump float;
|
|
99
|
+
in vec2 v_uv;
|
|
100
|
+
uniform sampler2D u_tex;
|
|
101
|
+
out vec4 out_color;
|
|
102
|
+
void main() {
|
|
103
|
+
out_color = texture(u_tex, v_uv);
|
|
104
|
+
}`;function vs(t){const e=t.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!e)return null;const n=(m,g)=>{const b=e.createShader(m);return e.shaderSource(b,g),e.compileShader(b),b},o=e.createProgram(),i=n(e.VERTEX_SHADER,bs),a=n(e.FRAGMENT_SHADER,ys);e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.deleteShader(i),e.deleteShader(a),e.useProgram(o);const c=e.createVertexArray();e.bindVertexArray(c);const f=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);const d=e.getAttribLocation(o,"a_pos");e.enableVertexAttribArray(d),e.vertexAttribPointer(d,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const p=e.createTexture();return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,p),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,"u_tex"),0),{gl:e,program:o,tex:p,vao:c}}class ws{constructor(e){this.canvas=e,this.state=null}init(){return this.state=vs(this.canvas),this.state!==null}drawFrame(e){const n=this.state;if(!n)return e.close(),null;const o=e.displayWidth,i=e.displayHeight;try{return(this.canvas.width!==o||this.canvas.height!==i)&&(this.canvas.width=o,this.canvas.height=i,n.gl.viewport(0,0,o,i)),n.gl.activeTexture(n.gl.TEXTURE0),n.gl.bindTexture(n.gl.TEXTURE_2D,n.tex),n.gl.texImage2D(n.gl.TEXTURE_2D,0,n.gl.RGBA,n.gl.RGBA,n.gl.UNSIGNED_BYTE,e),n.gl.bindVertexArray(n.vao),n.gl.drawArrays(n.gl.TRIANGLES,0,6),n.gl.bindVertexArray(null),n.gl.bindTexture(n.gl.TEXTURE_2D,null),{width:o,height:i}}finally{e.close()}}dispose(){const e=this.state;e&&(e.gl.deleteTexture(e.tex),e.gl.deleteVertexArray(e.vao),e.gl.deleteProgram(e.program),this.state=null)}}function Ss(t){const e=new ws(t);return e.init(),e}class Rs{constructor(e=Ss){this._size=null,this.canvas=document.createElement("canvas"),this.renderer=e(this.canvas),this.core=new xs(n=>this.render(n))}get surface(){return this.canvas}get size(){return this._size}onResize(e){this.resizeCb=e}onDecodedFrame(e){this.decodedCb=e,this.core.setDecodeSampler(n=>{this.lastSample=n})}decode(e){this.core.decode(e)}close(){this.core.close(),this.renderer.dispose()}render(e){var o,i;const n=this.renderer.drawFrame(e);n&&((o=this.decodedCb)==null||o.call(this,performance.now(),this.lastSample),this.lastSample=void 0,(!this._size||this._size.width!==n.width||this._size.height!==n.height)&&(this._size=n,(i=this.resizeCb)==null||i.call(this,n)))}}const Cs=`#version 300 es
|
|
105
|
+
in vec2 a_pos;
|
|
106
|
+
out vec2 v_uv;
|
|
107
|
+
void main() {
|
|
108
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
109
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
110
|
+
}`,js=`#version 300 es
|
|
111
|
+
precision mediump float;
|
|
112
|
+
in vec2 v_uv;
|
|
113
|
+
uniform sampler2D u_texY;
|
|
114
|
+
uniform sampler2D u_texU;
|
|
115
|
+
uniform sampler2D u_texV;
|
|
116
|
+
out vec4 out_color;
|
|
117
|
+
void main() {
|
|
118
|
+
float Y = (texture(u_texY, v_uv).r - 0.0627451) * 1.1643836; // (y-16/255)*255/219
|
|
119
|
+
float U = (texture(u_texU, v_uv).r - 0.5019608) * 1.1383929; // (u-128/255)*255/224
|
|
120
|
+
float V = (texture(u_texV, v_uv).r - 0.5019608) * 1.1383929;
|
|
121
|
+
float r = Y + 1.5748 * V;
|
|
122
|
+
float g = Y - 0.1873 * U - 0.4681 * V;
|
|
123
|
+
float b = Y + 1.8556 * U;
|
|
124
|
+
out_color = vec4(r, g, b, 1.0);
|
|
125
|
+
}`;function _t(t,e,n,o){const i=t.createTexture();return t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,i),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,n),e),i}function ks(t){const e=t.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!e)return null;const n=(b,l)=>{const y=e.createShader(b);return e.shaderSource(y,l),e.compileShader(y),y},o=e.createProgram(),i=n(e.VERTEX_SHADER,Cs),a=n(e.FRAGMENT_SHADER,js);e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.deleteShader(i),e.deleteShader(a),e.useProgram(o);const c=e.createVertexArray();e.bindVertexArray(c);const f=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);const d=e.getAttribLocation(o,"a_pos");e.enableVertexAttribArray(d),e.vertexAttribPointer(d,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.pixelStorei(e.UNPACK_ALIGNMENT,1);const p=_t(e,0,"u_texY",o),m=_t(e,1,"u_texU",o),g=_t(e,2,"u_texV",o);return{gl:e,program:o,texY:p,texU:m,texV:g,vao:c}}class Es{constructor(e){this.canvas=e,this.state=null}init(){return this.state=ks(this.canvas),this.state!==null}drawI420(e,n,o){const i=this.state;if(!i)return null;const{gl:a}=i,c=n+1>>1,f=o+1>>1,d=n*o,p=c*f,m=e.subarray(0,d),g=e.subarray(d,d+p),b=e.subarray(d+p,d+2*p);(this.canvas.width!==n||this.canvas.height!==o)&&(this.canvas.width=n,this.canvas.height=o,a.viewport(0,0,n,o));const l=(y,j,_,T,k)=>{a.activeTexture(a.TEXTURE0+y),a.bindTexture(a.TEXTURE_2D,j),a.texImage2D(a.TEXTURE_2D,0,a.R8,_,T,0,a.RED,a.UNSIGNED_BYTE,k)};return l(0,i.texY,n,o,m),l(1,i.texU,c,f,g),l(2,i.texV,c,f,b),a.bindVertexArray(i.vao),a.drawArrays(a.TRIANGLES,0,6),a.bindVertexArray(null),{width:n,height:o}}dispose(){const e=this.state;e&&(e.gl.deleteTexture(e.texY),e.gl.deleteTexture(e.texU),e.gl.deleteTexture(e.texV),e.gl.deleteVertexArray(e.vao),e.gl.deleteProgram(e.program),this.state=null)}}const Ts=0;function As(t){const e=new Es(t);return e.init(),e}function _s(){return new Worker(new URL("/assets/tinyh264.worker-DiJ50Hai.js",import.meta.url),{type:"module"})}class Ns{constructor(e=As,n=_s){this.ready=!1,this.pending=[],this._size=null,this.canvas=document.createElement("canvas"),this.renderer=e(this.canvas),this.worker=n(),this.worker.onmessage=o=>this.onMessage(o.data)}get surface(){return this.canvas}get size(){return this._size}onResize(e){this.resizeCb=e}onDecodedFrame(e){this.decodedCb=e}decode(e){if(!this.ready){this.pending.push(e);return}this.post(e)}close(){this.worker.terminate(),this.renderer.dispose()}post(e){this.worker.postMessage({type:"decode",data:e,offset:0,length:e.byteLength,renderStateId:Ts},[e])}onMessage(e){var o,i;if(e.type==="decoderReady"){this.ready=!0;for(const a of this.pending)this.post(a);this.pending.length=0;return}const n=this.renderer.drawI420(new Uint8Array(e.data),e.width,e.height);n&&((o=this.decodedCb)==null||o.call(this,performance.now()),(!this._size||this._size.width!==n.width||this._size.height!==n.height)&&(this._size=n,(i=this.resizeCb)==null||i.call(this,n)))}}function $t(){const t=typeof window<"u";let e=!1;try{e=!!document.createElement("canvas").getContext("webgl2")}catch{e=!1}return{secureContext:t&&window.isSecureContext===!0,webCodecs:t&&"VideoDecoder"in window,webgl2:e,wasm:typeof WebAssembly<"u"&&typeof Worker<"u"}}function Ps(t=$t()){return t.secureContext&&t.webCodecs&&t.webgl2?new Rs:t.wasm&&t.webgl2?new Ns:null}function rr(t=$t()){return t.secureContext&&t.webCodecs&&t.webgl2||t.wasm&&t.webgl2}function Ds(t=$t()){return t.secureContext&&t.webCodecs&&t.webgl2?"high":t.wasm&&t.webgl2?"standard":"unsupported"}const Ls="https://www.tapflow.dev/reference/configuration#https-secure-context";function Ms({open:t,onOpenChange:e}){return r.jsx(br,{open:t,onOpenChange:e,children:r.jsxs(yr,{className:"sm:max-w-[440px]",children:[r.jsxs(bn,{children:[r.jsx(vr,{children:"Streaming in Standard mode"}),r.jsxs(yn,{className:"space-y-3 pt-1",children:[r.jsx("span",{className:"block",children:"This screen is running in Standard mode. For a faster, smoother picture, switch to Smooth."}),r.jsx("span",{className:"block",children:"Smooth needs the relay served over HTTPS. If you didn't set up tapflow, ask whoever did."})]})]}),r.jsxs(vn,{children:[r.jsx(fe,{variant:"outline",onClick:()=>window.open(Ls,"_blank","noopener,noreferrer"),children:"How to enable"}),r.jsx(fe,{onClick:()=>e(!1),children:"Got it"})]})]})})}const nr="tapflow.perfModeNoticeDismissed";function Is(t,e){return t==="standard"&&!e}const Us={high:"Smooth",standard:"Standard",unsupported:null};function Hs(t){const{connected:e,joined:n,bootError:o,deviceReady:i,installing:a,installError:c,agentAway:f}=t;return e?n?f?"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}`:null:"Starting device…":"Joining session…":"Connecting…"}function Bt(t){const{joined:e,fps:n,keyboardActive:o}=t,i=Hs(t),a=n>15,c=a?"#10b981":"#94a3b8",f=a?"Active":"Idle",d=s.useMemo(()=>Ds(),[]),p=Us[d],[m,g]=s.useState(!1);s.useEffect(()=>{let l=!1;try{l=localStorage.getItem(nr)==="1"}catch{}Is(d,l)&&g(!0)},[d]);const b=l=>{if(g(l),!l)try{localStorage.setItem(nr,"1")}catch{}};return r.jsxs("div",{className:"w-[300px] shrink-0 mt-3 rounded-xl border bg-background px-4 py-4 flex flex-col gap-3",children:[r.jsxs("div",{className:oe("flex items-center",o?"text-emerald-500":"text-muted-foreground"),style:{gap:6},children:[r.jsx(Jn,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"text-[12px] font-medium",children:"Focus"})]}),e&&r.jsxs("div",{className:"flex items-center gap-[12px]",children:[r.jsxs("div",{className:"flex items-center gap-[4px]",children:[r.jsx("span",{className:"h-2 w-2 rounded-full shrink-0 mr-1",style:{background:c}}),r.jsx("span",{className:"text-[12px] font-mono text-foreground/75",children:n}),r.jsx("span",{className:"text-[12px] text-muted-foreground",children:"fps"}),r.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"·"}),r.jsx("span",{className:oe("text-[11px]",a?"text-emerald-500":"text-muted-foreground/60"),children:f})]}),p&&r.jsxs(r.Fragment,{children:[r.jsx(hr,{orientation:"vertical",className:"h-3"}),d==="standard"?r.jsx("button",{type:"button",onClick:()=>g(!0),className:"text-[11px] text-foreground/70 hover:text-foreground underline-offset-2 hover:underline",children:p}):r.jsx("span",{className:"text-[11px] text-muted-foreground",children:p})]})]}),i&&r.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed break-all",children:i}),r.jsx(Ms,{open:m,onOpenChange:b})]})}function Tr({open:t,onOpenChange:e,openUrl:n}){const[o,i]=s.useState(""),a=s.useRef(null);s.useEffect(()=>{t?setTimeout(()=>{var f;return(f=a.current)==null?void 0:f.focus()},0):i("")},[t]);const c=()=>{o.trim()&&(n(o.trim()),e(!1))};return r.jsx(br,{open:t,onOpenChange:e,children:r.jsxs(yr,{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:[r.jsx(vr,{className:"sr-only",children:"Open Deeplink"}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex-1 h-[32px] flex items-center gap-2 pl-[4px] pb-[1px]",children:[r.jsx(fn,{className:"h-4 w-4 text-muted-foreground shrink-0","aria-hidden":"true"}),r.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:f=>i(f.target.value),onKeyDown:f=>{f.key==="Enter"&&c()}})]}),r.jsx(fe,{size:"sm",disabled:!o.trim(),onClick:c,className:"shrink-0 rounded-xl h-8 px-4",children:"Open"})]})]})})}function $s(t,e,n,o,i,a){const{x:c,y:f,width:d,height:p}=i;let m,g;if(a){const b=(t.x-e.left)/e.width;m=(1-(t.y-e.top)/e.height)*n,g=b*o}else m=(t.x-e.left)*(n/e.width),g=(t.y-e.top)*(o/e.height);return m<c||m>c+d||g<f||g>f+p?null:{x:(m-c)/d,y:(g-f)/p}}function Bs(t,e,n){const o=(t.x-e.left)/e.width,i=(t.y-e.top)/e.height;return o<0||o>1||i<0||i>1?null:n?{x:i,y:1-o}:{x:o,y:i}}function Ar(t){return{f0:{x:1-t.x,y:1-t.y},f1:t}}function Fs(t,e){return t>0?Math.min(1,e/t):1}const It=22,sr=[84,70,70,69],Os=1,zs=0,kt=1,_r=2,Ws=1,Vs=2,Ks=4;function Xs(t){if(t.byteLength<It)return null;const e=new DataView(t);for(let i=0;i<sr.length;i++)if(e.getUint8(i)!==sr[i])return null;if(e.getUint8(4)!==Os)return null;const n=e.getUint8(5),o=n&Ks?_r:n&Ws?kt:zs;return{capturedAt:Number(e.getBigUint64(6)),relayedAt:Number(e.getBigUint64(14)),codec:o,keyframe:o===kt&&(n&Vs)!==0}}function Nr(t){const{binaryFrameHandlerRef:e,perfHookRef:n,frameCount:o}=t,i=s.useRef(t);s.useLayoutEffect(()=>{i.current=t},[t]),s.useEffect(()=>{let a=null,c=!1,f=!1,d;const p=()=>{if(a)return a;if(c)return null;const m=Ps();return m?(a=m,m.onResize(g=>i.current.onResize(g)),d=i.current.onDecoderReady(m),m):(c=!0,i.current.onUnsupported(),console.warn("[decoder] none available — set up HTTPS or use a supported browser"),null)};return e.current=(m,g)=>{const b=i.current.onJpegFrame;if(b&&(g==null?void 0:g.codec)!==kt){b(m,g);return}const l=p();if(l){if(!f){if(!(g!=null&&g.keyframe))return;f=!0}l.decode(m),o.current+=1}},()=>{e.current=void 0,typeof d=="function"&&d(),a==null||a.close(),a==null||a.surface.remove(),a=null}},[e,n,o])}const qs=3e3+5*300,Ys=qs+500,wt=8;function Gs(){var t;return window.isSecureContext&&typeof ClipboardItem<"u"&&!!((t=navigator.clipboard)!=null&&t.write)}class ft extends Error{}function Js(t){const e=t.then(n=>new Blob([n],{type:"text/plain"}));return navigator.clipboard.write([new ClipboardItem({"text/plain":e})])}function Ft(t){return!(t.metaKey||t.ctrlKey)||t.altKey?!1:t.code==="KeyV"?!0:!t.shiftKey&&(t.code==="KeyC"||t.code==="KeyX")}const Zs=1024*1024,Qs=t=>new TextEncoder().encode(t).length,eo=t=>{var e;return!!((e=t.payload)!=null&&e.unsupported)},to=t=>{var e,n;return((e=t.payload)==null?void 0:e.sentinelParked)===!1||((n=t.payload)==null?void 0:n.unsupported)===!0};function ro(){const t=window.getSelection();return!!t&&!t.isCollapsed&&t.toString().length>0}function or(){const t=document.activeElement;return!!t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)}function Pr({sessionId:t,send:e,active:n,supported:o,handlerRef:i,sendChord:a,onError:c}){const f=s.useRef(new Map),d=s.useRef(null),p=s.useRef(c);s.useLayoutEffect(()=>{p.current=c});const m=s.useCallback(b=>{var l;d.current!==b&&(d.current=b,(l=p.current)==null||l.call(p,b))},[]);s.useEffect(()=>(i.current=b=>{if(!b.requestId)return;const l=f.current.get(b.requestId);l&&(f.current.delete(b.requestId),l(b))},()=>{i.current=void 0}),[i]);const g=s.useCallback((...[b,l])=>{const y=J();return new Promise(j=>{const _=setTimeout(()=>{f.current.delete(y),j(null)},Ys);f.current.set(y,T=>{clearTimeout(_),j(T)}),e({type:b,sessionId:t,requestId:y,payload:l})})},[e,t]);s.useEffect(()=>{if(!n||!o)return;const b=async y=>{if(y.code==="KeyV"||!Ft(y))return;const j=y.code==="KeyX";if(or()||ro()||(y.preventDefault(),y.repeat))return;if(!Gs()){a(j?"KeyX":"KeyC",wt),m("Copied on the device. Serving the dashboard over HTTPS also brings it to your clipboard.");return}let _,T;const k=new Promise((M,N)=>{_=M,T=N});k.catch(()=>{});const A=Js(k).catch(M=>{M instanceof ft||m(M instanceof Error&&M.name==="NotAllowedError"?"Your browser blocked the clipboard write":"Could not write to your clipboard")}),R=await g("clipboard:read",{press:j?"cut":"copy"});if(!R){T(new ft("timeout")),m("The device is taking too long — try again");return}if(R.type==="clipboard:error"){T(new ft(R.message||"read failed")),m(R.message||"Clipboard read failed"),to(R)&&a(j?"KeyX":"KeyC",wt);return}if(R.type!=="clipboard:data"){T(new ft("unexpected reply")),m("Clipboard read failed");return}const{text:U}=R.payload;if(d.current=null,!U){T(new ft("empty"));return}_(U),await A},l=y=>{var _;if(or())return;const j=((_=y.clipboardData)==null?void 0:_.getData("text"))??"";if(y.preventDefault(),!j){a("KeyV",wt);return}if(Qs(j)>Zs){m("That text is too large to send to the device");return}g("clipboard:write",{text:j,pasteAfter:!0}).then(T=>{if(!T){m("The device is taking too long — try again");return}if(T.type==="clipboard:write-done"){d.current=null;return}if(T.type!=="clipboard:error"){m("Clipboard write failed");return}m(T.message||"Clipboard write failed"),eo(T)&&a("KeyV",wt)})};return document.addEventListener("keydown",b),document.addEventListener("paste",l),()=>{document.removeEventListener("keydown",b),document.removeEventListener("paste",l)}},[n,o,g,a,m])}const Le=13,et=8,ar=16,no=.02,so=100;function oo({sessionId:t,buildId:e,send:n,openUrl:o,launchApp:i,connected:a,joined:c,deviceReady:f,installing:d,installed:p,installError:m,bootError:g,launching:b,chrome:l,binaryFrameHandlerRef:y,clipboardHandlerRef:j,clipboardSupported:_,onRecordingUploaded:T,swKeyboardVisible:k,swKeyboardPending:A,onKbdToggle:R,perfHookRef:U}){const M=s.useRef(null),N=s.useRef(null),O=s.useRef(null),{fps:re,frameCount:K}=Cr(),V=s.useRef(0),{recordState:ee,recordCanvasRef:Z,startClientRecording:Re,stopClientRecording:_e}=Rr({sessionId:t,buildId:e,onRecordingUploaded:T}),ge=s.useRef(0),[Ce,xe]=s.useState(!1),[je,Ne]=s.useState(!1),[te,Be]=s.useState(!1),[me,I]=s.useState(!1),[X,Q]=s.useState(null),[be,Pe]=s.useState(null),[De,ne]=s.useState(!1),[Y,ce]=s.useState(null),ae=s.useRef(Y);s.useEffect(()=>{ae.current=Y},[Y]);const ue=s.useRef(null),he=s.useRef(null),de=s.useRef(!1),le=s.useRef(!1),pe=s.useRef(0),S=s.useRef(null),F=s.useRef(null),W=s.useRef("idle"),q=s.useRef(null),ye=s.useRef(null),Fe=s.useRef(null);s.useEffect(()=>{Fe.current=l},[l]),s.useEffect(()=>{const u=new Image;u.onload=()=>{ye.current=u},u.src=`data:image/png;base64,${l.framePng}`},[l.framePng]),Nr({binaryFrameHandlerRef:y,perfHookRef:U,frameCount:K,onUnsupported:()=>{},onResize:u=>{const x=M.current;if(x&&(x.width!==u.width||x.height!==u.height)&&(x.width=u.width,x.height=u.height,!Fe.current)){const h=Z.current;h&&(h.width=u.width,h.height=u.height)}Ne(!0)},onDecoderReady:u=>{var w;const x=u.surface,h=M.current;x.style.position="absolute",h&&(x.style.left=h.style.left,x.style.top=h.style.top,x.style.width=h.style.width,x.style.height=h.style.height,x.style.borderRadius=h.style.borderRadius),x.style.objectFit="fill",x.style.zIndex="3",x.style.pointerEvents="none",(w=N.current)==null||w.appendChild(x);let E=null;const P=()=>{const L=M.current,H=L==null?void 0:L.getContext("2d");if(L&&H&&u.size)try{H.drawImage(u.surface,0,0,L.width,L.height)}catch{}E=requestAnimationFrame(P)};return E=requestAnimationFrame(P),()=>{E!==null&&cancelAnimationFrame(E)}},onJpegFrame:u=>{const x=performance.now();V.current&&x-V.current,V.current=x;const h=ge.current;createImageBitmap(new Blob([u],{type:"image/jpeg"})).then(E=>{if(performance.now()-x,ge.current!==h){E.close();return}const P=M.current,w=P==null?void 0:P.getContext("2d");if(!P||!w){E.close();return}if((P.width!==E.width||P.height!==E.height)&&(P.width=E.width,P.height=E.height,!Fe.current)){const H=Z.current;H&&(H.width=E.width,H.height=E.height)}const L=performance.now();w.drawImage(E,0,0),performance.now()-L,E.close(),Ne(!0),K.current+=1}).catch(()=>{})}}),s.useEffect(()=>{const u=Z.current,x=N.current;u&&x&&(u.width=x.clientWidth,u.height=x.clientHeight)},[l,Z]);const ct=s.useCallback(()=>{const u=Z.current,x=M.current;if(!u||!x)return;const h=u.getContext("2d");if(!h)return;const E=Fe.current;if(h.clearRect(0,0,u.width,u.height),E){ye.current&&h.drawImage(ye.current,0,0,u.width,u.height);const L=Math.round(E.screenCornerRadius/2*(u.height/(E.compositeHeight/2)));h.save(),h.beginPath(),L>0?h.roundRect(x.offsetLeft,x.offsetTop,x.clientWidth,x.clientHeight,L):h.rect(x.offsetLeft,x.offsetTop,x.clientWidth,x.clientHeight),h.clip(),h.drawImage(x,x.offsetLeft,x.offsetTop,x.clientWidth,x.clientHeight),h.restore()}else h.drawImage(x,0,0,u.width,u.height);const P=ae.current;if(P)for(const L of[P.f0,P.f1]){const H=E?x.offsetLeft+L.x*x.clientWidth:L.x*u.width,G=E?x.offsetTop+L.y*x.clientHeight:L.y*u.height;de.current?(h.beginPath(),h.arc(H,G,et,0,Math.PI*2),h.fillStyle="rgba(255,255,255,0.92)",h.fill(),h.strokeStyle="rgba(0,0,0,0.2)",h.lineWidth=1,h.stroke()):(h.beginPath(),h.arc(H,G,Le,0,Math.PI*2),h.strokeStyle="rgba(0,0,0,0.3)",h.lineWidth=3,h.stroke(),h.beginPath(),h.arc(H,G,Le,0,Math.PI*2),h.strokeStyle="rgba(255,255,255,0.65)",h.lineWidth=1.5,h.stroke())}const w=F.current;if(w){const L=W.current,H=q.current;if(h.save(),L==="down")h.beginPath(),h.arc(w.x,w.y,et,0,Math.PI*2),h.fillStyle="rgba(255,255,255,0.92)",h.fill(),h.strokeStyle="rgba(0,0,0,0.2)",h.lineWidth=1,h.stroke();else if(L==="release"&&H){const G=Math.min((performance.now()-H.startTime)/350,1);h.beginPath(),h.arc(w.x,w.y,et+26*G,0,Math.PI*2),h.strokeStyle=`rgba(255,255,255,${(1-G)*.55})`,h.lineWidth=1.5,h.stroke(),G>=1&&(W.current="idle",q.current=null)}else h.beginPath(),h.arc(w.x,w.y,Le,0,Math.PI*2),h.strokeStyle="rgba(0,0,0,0.3)",h.lineWidth=3,h.stroke(),h.beginPath(),h.arc(w.x,w.y,Le,0,Math.PI*2),h.strokeStyle="rgba(255,255,255,0.65)",h.lineWidth=1.5,h.stroke();h.restore()}},[Z]),lt=s.useCallback(()=>{const u=M.current;if(!u)return;const x=document.createElement("canvas"),h=x.getContext("2d");h&&(x.width=u.width,x.height=u.height,h.drawImage(u,0,0),x.toBlob(E=>{if(!E)return;const P=URL.createObjectURL(E),w=document.createElement("a");w.href=P,w.download=`tapflow-${Date.now()}.png`,w.click(),URL.revokeObjectURL(P)},"image/png"))},[]),qe=s.useCallback(()=>{if(ee==="idle"){const u=Z.current;if(!u)return;const x=N.current;if(x&&x.clientWidth>0)u.width=x.clientWidth,u.height=x.clientHeight;else{const h=M.current;if(h&&h.width>0)u.width=h.width,u.height=h.height;else return}Re(ct)}else ee==="recording"&&_e()},[ee,Re,_e,ct,Z]),ke=s.useCallback(()=>{n({type:"input:rotate",sessionId:t}),Be(u=>!u)},[n,t]),Oe=s.useRef(te);s.useEffect(()=>{Oe.current=te},[te]),s.useEffect(()=>()=>{Oe.current&&n({type:"input:rotate",sessionId:t})},[]);const Tt=s.useCallback((u,x)=>{n({type:"input:key",sessionId:t,requestId:J(),payload:{code:u,modifiers:x}})},[n,t]);Pr({sessionId:t,send:n,active:me,supported:_,handlerRef:j,sendChord:Tt,onError:u=>Ue.error(u)}),s.useEffect(()=>{const u=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),x=w=>{if(w.code==="AltLeft"||w.code==="AltRight"){le.current=!0;return}if(w.metaKey){const H=document.activeElement;if(!H||H.tagName!=="INPUT"&&H.tagName!=="TEXTAREA"){if(!w.shiftKey&&w.code==="KeyK"){w.preventDefault(),xe(!0);return}if(!w.shiftKey&&w.code==="KeyS"){w.preventDefault(),lt();return}if(w.shiftKey&&w.code==="KeyY"){w.preventDefault(),qe();return}if(w.shiftKey&&w.code==="KeyO"){w.preventDefault(),ke();return}if(w.shiftKey&&w.code==="KeyU"){w.preventDefault(),n({type:"input:button",sessionId:t,requestId:J(),payload:{name:"home"}});return}if(w.shiftKey&&w.code==="KeyK"){w.preventDefault(),A||R();return}}}if(!me||u.has(w.code)||_&&Ft(w))return;w.preventDefault();const L=(w.shiftKey?2:0)|(w.ctrlKey?1:0)|(w.metaKey?8:0);n({type:"input:key",sessionId:t,requestId:J(),payload:{code:w.code,modifiers:L}})},h=()=>{de.current&&(de.current=!1,ne(!1),n({type:"input:pinch:end",sessionId:t,requestId:J()})),le.current=!1,ce(null)},E=w=>{(w.code==="AltLeft"||w.code==="AltRight")&&h()},P=()=>{le.current&&h()};return window.addEventListener("keydown",x),window.addEventListener("keyup",E),window.addEventListener("blur",P),()=>{window.removeEventListener("keydown",x),window.removeEventListener("keyup",E),window.removeEventListener("blur",P)}},[me,_,n,t,lt,qe,ke,R,A]),s.useEffect(()=>{if(!me)return;const u=x=>{const h=N.current??M.current;h&&!h.contains(x.target)&&I(!1)};return document.addEventListener("pointerdown",u),()=>document.removeEventListener("pointerdown",u)},[me]);const Me=s.useCallback(u=>{const x=(te?O.current:null)??N.current;if(!x)return null;const h=x.getBoundingClientRect(),E=l.compositeWidth/2,P=l.compositeHeight/2,w=l.screenRect.x/2,L=l.screenRect.y/2,H=l.screenRect.width/2,G=l.screenRect.height/2;return $s({x:u.clientX,y:u.clientY},h,E,P,{x:w,y:L,width:H,height:G},te)},[l,te]),Ye=s.useCallback(u=>{const x=Me(u);return x?Ar(x):null},[Me]),ot=s.useCallback(u=>{const x=te?O.current:N.current;if(!x)return null;const h=x.getBoundingClientRect();let E,P;if(te){const L=h.height-(u.clientY-h.top),H=u.clientX-h.left;E=L*(l.compositeWidth/h.height),P=H*(l.compositeHeight/h.width)}else E=(u.clientX-h.left)*(l.compositeWidth/h.width),P=(u.clientY-h.top)*(l.compositeHeight/h.height);const w=l.screenRect;if(E>=w.x&&E<=w.x+w.width&&P>=w.y&&P<=w.y+w.height)return null;for(const L of l.buttons){const H=E-L.normalOffset.x,G=P-L.normalOffset.y;if(H*H+G*G<so**2)return L.name}return null},[l,te]),Ge=s.useCallback(u=>{const x=M.current,h=Z.current;return x&&x.clientWidth>0?{x:x.offsetLeft+u.x*x.clientWidth,y:x.offsetTop+u.y*x.clientHeight}:{x:u.x*((h==null?void 0:h.width)??1),y:u.y*((h==null?void 0:h.height)??1)}},[Z]),we=s.useCallback(u=>{if(I(!0),le.current){const w=Ye(u);if(!w)return;de.current=!0,ne(!0),u.target.setPointerCapture(u.pointerId),ce(w),n({type:"input:pinch:start",sessionId:t,payload:w});return}const x=ot(u);if(x){ue.current=x,Q(x),u.target.setPointerCapture(u.pointerId),n({type:"input:button",sessionId:t,requestId:J(),payload:{name:x,phase:"down"}});return}const h=Me(u);if(!h)return;he.current=h,u.target.setPointerCapture(u.pointerId),F.current=Ge(h),W.current="down",q.current=null;const E=u.currentTarget.getBoundingClientRect(),P=S.current;P&&(P.style.display="block",P.style.left=`${u.clientX-E.left}px`,P.style.top=`${u.clientY-E.top}px`,P.style.width=`${et*2}px`,P.style.height=`${et*2}px`,P.style.background="rgba(255,255,255,0.92)",P.style.border="1.5px solid rgba(0,0,0,0.2)",P.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"),n({type:"input:touch:start",sessionId:t,payload:h})},[ot,Me,Ye,Ge,n,t]),bt=s.useCallback(u=>{if(u.buttons===0){if(Pe(ot(u)),le.current){ce(Ye(u)),F.current=null;const L=S.current;L&&(L.style.display="none")}else{ce(null);const L=Me(u);F.current=L?Ge(L):null,W.current!=="down"&&(W.current="idle");const H=S.current;if(H)if(L){const G=u.currentTarget.getBoundingClientRect();H.style.display="block",H.style.left=`${u.clientX-G.left}px`,H.style.top=`${u.clientY-G.top}px`,H.style.width=`${Le*2}px`,H.style.height=`${Le*2}px`,H.style.background="transparent",H.style.border="1.5px solid rgba(255,255,255,0.6)",H.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"}else H.style.display="none"}return}if(de.current){const L=Ye(u);if(!L)return;const H=performance.now();if(H-pe.current<ar)return;pe.current=H,ce(L),n({type:"input:pinch:move",sessionId:t,payload:L});return}if(ue.current||!he.current)return;const x=Me(u);if(!x)return;const h=x.x-he.current.x,E=x.y-he.current.y;if(Math.sqrt(h*h+E*E)<no)return;const P=performance.now();if(P-pe.current<ar)return;pe.current=P,F.current=Ge(x);const w=S.current;if(w&&w.style.display!=="none"){const L=u.currentTarget.getBoundingClientRect();w.style.left=`${u.clientX-L.left}px`,w.style.top=`${u.clientY-L.top}px`}n({type:"input:touch:move",sessionId:t,payload:x})},[ot,Me,Ye,Ge,n,t]),ze=s.useCallback(()=>{if(de.current){de.current=!1,ne(!1),ce(null),n({type:"input:pinch:end",sessionId:t,requestId:J()});return}if(he.current=null,ue.current){n({type:"input:button",sessionId:t,requestId:J(),payload:{name:ue.current,phase:"up"}}),ue.current=null,setTimeout(()=>Q(null),100);return}W.current="release",q.current={startTime:performance.now()};const u=S.current;u&&(u.style.width=`${Le*2}px`,u.style.height=`${Le*2}px`,u.style.background="transparent",u.style.border="1.5px solid rgba(255,255,255,0.6)",u.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),n({type:"input:touch:end",sessionId:t,requestId:J()})},[n,t]),Je=s.useCallback(()=>{if(de.current){de.current=!1,ne(!1),ce(null),n({type:"input:pinch:end",sessionId:t,requestId:J()});return}if(he.current=null,ue.current){n({type:"input:button",sessionId:t,requestId:J(),payload:{name:ue.current,phase:"up"}}),ue.current=null,Q(null);return}W.current="release",q.current={startTime:performance.now()},n({type:"input:touch:end",sessionId:t,requestId:J()})},[n,t]),At=s.useCallback(()=>{Pe(null),ce(null),F.current=null;const u=S.current;u&&(u.style.display="none")},[]),We=l.compositeWidth/2,yt=l.compositeHeight/2,at=Fs(yt,750),Ze=Math.round(We*at),Qe=Math.round(yt*at),it=l.screenRect.x/l.compositeWidth*100,v=l.screenRect.y/l.compositeHeight*100,D=l.screenRect.width/l.compositeWidth*100,z=l.screenRect.height/l.compositeHeight*100,C=Math.round(l.screenCornerRadius/2*at),se=r.jsxs(r.Fragment,{children:[r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>n({type:"input:button",sessionId:t,requestId:J(),payload:{name:"home"}}),children:r.jsx(wr,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:r.jsxs("span",{className:"flex items-center gap-3",children:["Home ",r.jsxs(Lt,{children:[r.jsx(rt,{children:"⌘"}),r.jsx(rt,{children:"⇧"}),r.jsx(rt,{children:"U"})]})]})})]}),r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:A,onClick:R,"data-active":k,children:A?r.jsx(jt,{className:"h-4 w-4 animate-spin"}):r.jsx(Fn,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:r.jsxs("span",{className:"flex items-center gap-3",children:["Software keyboard ",r.jsxs(Lt,{children:[r.jsx(rt,{children:"⌘"}),r.jsx(rt,{children:"⇧"}),r.jsx(rt,{children:"K"})]})]})})]})]}),$=p&&e?r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:b,"aria-label":"Launch app",onClick:i,children:b?r.jsx(jt,{className:"h-4 w-4 animate-spin"}):r.jsx(mr,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:b?"Launching…":"Launch app"})]}):null;return r.jsxs("div",{className:"flex items-start justify-center gap-16",children:[r.jsx("canvas",{ref:Z,style:{display:"none"}}),r.jsx(Tr,{open:Ce,onOpenChange:xe,openUrl:o}),r.jsx(jr,{joined:c,onDeepLink:()=>xe(!0),onScreenshot:lt,onRecordToggle:qe,recordState:ee,onRotate:ke,platformSlot:se,launchSlot:$}),r.jsxs("div",{className:"flex items-start gap-8",children:[r.jsxs("div",{ref:O,style:{width:te?Qe:Ze,height:te?Ze:Qe,position:"relative",flexShrink:0},children:[r.jsxs("div",{ref:N,className:`relative ${be?"cursor-pointer":"cursor-default"}`,style:{width:Ze,height:Qe,...te?{position:"absolute",top:(Ze-Qe)/2,left:(Qe-Ze)/2,transform:"rotate(-90deg)",transformOrigin:"center center"}:{}},onPointerDown:we,onPointerMove:bt,onPointerUp:ze,onPointerCancel:Je,onPointerLeave:At,children:[r.jsx("img",{src:`data:image/png;base64,${l.framePng}`,style:{position:"absolute",top:0,left:0,zIndex:2,width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),r.jsx("canvas",{ref:M,style:{position:"absolute",zIndex:3,left:`${it}%`,top:`${v}%`,width:`${D}%`,height:`${z}%`,borderRadius:C>0?`${C}px`:void 0,backgroundColor:"#010101",cursor:"none",visibility:je?"visible":"hidden"}}),!je&&r.jsx("div",{className:"absolute animate-pulse bg-zinc-700",style:{zIndex:3,left:`${it}%`,top:`${v}%`,width:`${D}%`,height:`${z}%`,borderRadius:C>0?`${C}px`:void 0}}),Y&&(()=>{const u=it/100,x=v/100,h=D/100,E=z/100,P=(w,L)=>({left:`${(u+w*h)*100}%`,top:`${(x+L*E)*100}%`});return r.jsx(r.Fragment,{children:[Y.f0,Y.f1].map((w,L)=>r.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",...De?{width:et*2,height:et*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:Le*2,height:Le*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"},...P(w.x,w.y)}},L))})})(),c&&re===0&&r.jsx("div",{style:{position:"absolute",zIndex:8,left:`${it}%`,top:`${v}%`,width:`${D}%`,height:`${z}%`,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:r.jsx("span",{style:{color:"white",fontSize:"0.875rem"},children:"Waiting for first frame..."})}),l.buttons.map(u=>{const x=X===u.name,h=be===u.name,E=u.anchor==="bottom",P=u.anchor==="top",w=E?(u.normalOffset.y-u.buttonH/2)/l.compositeHeight*100:P?u.rolloverOffset.y/l.compositeHeight*100:(u.normalOffset.y-u.buttonH/2)/l.compositeHeight*100,L=u.buttonH/l.compositeHeight*100,H=u.buttonW/l.compositeWidth*100,G=u.buttonW/2,ve=(u.rolloverOffset.x-G)/l.compositeWidth*100,Ie=(2*u.rolloverOffset.x-u.normalOffset.x-G)/l.compositeWidth*100,vt=u.rolloverOffset.x/l.compositeWidth*100,ut=E?(u.normalOffset.y-u.buttonH/2)/l.compositeHeight*100:P?u.rolloverOffset.y/l.compositeHeight*100:(u.normalOffset.y-u.buttonH/2)/l.compositeHeight*100,Gt=P?(2*u.rolloverOffset.y-u.normalOffset.y)/l.compositeHeight*100:0,Qr=u.onTop?4:1;return r.jsxs(s.Fragment,{children:[u.buttonPng&&r.jsx("img",{src:`data:image/png;base64,${u.buttonPng}`,style:{position:"absolute",zIndex:Qr,top:`${P&&h?Gt:w}%`,left:`${P?ve:h?Ie:ve}%`,width:`${H}%`,height:`${L}%`,transition:P?"top 0.15s ease":"left 0.15s ease",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),x&&u.pressedPng&&u.pressedRect&&r.jsx("img",{src:`data:image/png;base64,${u.pressedPng}`,style:{position:"absolute",zIndex:u.onTop?3:1,left:`${P?ve:h?Ie:ve}%`,top:`${P&&h?Gt:w}%`,width:`${u.pressedRect.width/l.compositeWidth*100}%`,height:`${u.pressedRect.height/l.compositeHeight*100}%`,pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),h&&r.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:`${vt}%`,top:`${ut}%`,transform:"translate(-50%, calc(-100% - 8px))"},children:u.accessibilityTitle})]},u.name)})]}),r.jsx("div",{ref:S,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"}})]}),r.jsx(Bt,{joined:c,fps:re,connected:a,deviceReady:f,bootError:g,installing:d,installError:m,keyboardActive:me})]})]})}const tt=13,ht=8,ir=16,ao=.02,Nt=720;function io({sessionId:t,buildId:e,send:n,openUrl:o,launchApp:i,connected:a,joined:c,deviceReady:f,installing:d,installed:p,installError:m,bootError:g,launching:b,androidButtons:l,binaryFrameHandlerRef:y,clipboardHandlerRef:j,clipboardSupported:_,onRecordingUploaded:T,screenWidth:k,screenHeight:A,cornerRadius:R,perfHookRef:U}){const M=s.useRef(null),N=s.useRef(null),O=s.useRef(null),{fps:re,frameCount:K}=Cr(),{recordState:V,recordCanvasRef:ee,startClientRecording:Z,stopClientRecording:Re}=Rr({sessionId:t,buildId:e,onRecordingUploaded:T}),[_e,ge]=s.useState(!1),[Ce,xe]=s.useState(!1),[je,Ne]=s.useState(!1),te=s.useRef(null),[Be,me]=s.useState(null),[I,X]=s.useState(!1),[Q,be]=s.useState(!1),[Pe,De]=s.useState(!1),[ne,Y]=s.useState(null),ce=s.useRef(ne);s.useEffect(()=>{ce.current=ne},[ne]);const ae=s.useRef(!1),ue=s.useRef(!1),he=s.useRef(null),de=s.useRef(0),le=s.useRef(null),pe=s.useRef(null),S=s.useRef("idle"),F=s.useRef(null);Nr({binaryFrameHandlerRef:y,perfHookRef:U,frameCount:K,onUnsupported:()=>Ne(!0),onResize:v=>{xe(!0);const D=te.current;(!D||D.width!==v.width||D.height!==v.height)&&(te.current=v,me(v))},onDecoderReady:v=>{var z;O.current=v;const D=v.surface;D.style.display="block",D.style.width="100%",D.style.height="100%",D.style.objectFit="fill",(z=M.current)==null||z.appendChild(D)}});const W=s.useCallback(()=>{var H;const v=ee.current,D=(H=O.current)==null?void 0:H.surface,z=te.current;if(!v||!D||!z)return;const C=v.getContext("2d");if(!C)return;const se=z.width,$=z.height,u=v.width>v.height!=se>$;C.save(),u&&(C.translate(v.width,0),C.rotate(Math.PI/2)),C.drawImage(D,0,0,se,$);const x=Math.max(se,$),h=x>Nt?x/Nt:1,E=tt*h,P=ht*h,w=ce.current;if(w)for(const G of[w.f0,w.f1]){const ve=G.x*se,Ie=G.y*$;ae.current?(C.beginPath(),C.arc(ve,Ie,P,0,Math.PI*2),C.fillStyle="rgba(255,255,255,0.92)",C.fill(),C.strokeStyle="rgba(0,0,0,0.2)",C.lineWidth=h,C.stroke()):(C.beginPath(),C.arc(ve,Ie,E,0,Math.PI*2),C.strokeStyle="rgba(0,0,0,0.3)",C.lineWidth=3*h,C.stroke(),C.beginPath(),C.arc(ve,Ie,E,0,Math.PI*2),C.strokeStyle="rgba(255,255,255,0.65)",C.lineWidth=1.5*h,C.stroke())}const L=pe.current;if(L){const G=L.x*se,ve=L.y*$,Ie=S.current,vt=F.current;if(Ie==="down")C.beginPath(),C.arc(G,ve,P,0,Math.PI*2),C.fillStyle="rgba(255,255,255,0.92)",C.fill(),C.strokeStyle="rgba(0,0,0,0.2)",C.lineWidth=h,C.stroke();else if(Ie==="release"&&vt){const ut=Math.min((performance.now()-vt.startTime)/350,1);C.beginPath(),C.arc(G,ve,P+26*h*ut,0,Math.PI*2),C.strokeStyle=`rgba(255,255,255,${(1-ut)*.55})`,C.lineWidth=1.5*h,C.stroke(),ut>=1&&(S.current="idle",F.current=null)}else C.beginPath(),C.arc(G,ve,E,0,Math.PI*2),C.strokeStyle="rgba(0,0,0,0.3)",C.lineWidth=3*h,C.stroke(),C.beginPath(),C.arc(G,ve,E,0,Math.PI*2),C.strokeStyle="rgba(255,255,255,0.65)",C.lineWidth=1.5*h,C.stroke()}C.restore()},[ee]),q=s.useCallback(()=>{var se;const v=(se=O.current)==null?void 0:se.surface,D=te.current;if(!v||!D)return;const z=document.createElement("canvas"),C=z.getContext("2d");C&&(z.width=D.width,z.height=D.height,C.drawImage(v,0,0,D.width,D.height),z.toBlob($=>{if(!$)return;const u=URL.createObjectURL($),x=document.createElement("a");x.href=u,x.download=`tapflow-${Date.now()}.png`,x.click(),URL.revokeObjectURL(u)},"image/png"))},[]),ye=s.useCallback(()=>{if(V==="idle"){const v=ee.current;if(!v)return;const D=te.current;if(!D)return;const z=qe.current;v.width=z?D.height:D.width,v.height=z?D.width:D.height,Z(W)}else V==="recording"&&Re()},[V,Z,Re,W,ee]),Fe=s.useCallback(()=>{n({type:"input:rotate",sessionId:t}),X(v=>!v)},[n,t]),ct=s.useRef(I);s.useEffect(()=>{ct.current=I},[I]),s.useEffect(()=>()=>{ct.current&&n({type:"input:rotate",sessionId:t})},[]);const lt=s.useCallback((v,D)=>{n({type:"input:key",sessionId:t,requestId:J(),payload:{code:v,modifiers:D}})},[n,t]);Pr({sessionId:t,send:n,active:Q,supported:_,handlerRef:j,sendChord:lt,onError:v=>Ue.error(v)}),s.useEffect(()=>{const v=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),D=$=>{if($.code==="AltLeft"||$.code==="AltRight"){ue.current=!0;return}if($.metaKey){const x=document.activeElement;if(!x||x.tagName!=="INPUT"&&x.tagName!=="TEXTAREA"){if(!$.shiftKey&&$.code==="KeyK"){$.preventDefault(),ge(!0);return}if(!$.shiftKey&&$.code==="KeyS"){$.preventDefault(),q();return}if($.shiftKey&&$.code==="KeyY"){$.preventDefault(),ye();return}if($.shiftKey&&$.code==="KeyO"){$.preventDefault(),Fe();return}}}if(!Q||v.has($.code)||_&&Ft($))return;$.preventDefault();const u=($.shiftKey?2:0)|($.ctrlKey?1:0)|($.metaKey?8:0);n({type:"input:key",sessionId:t,requestId:J(),payload:{code:$.code,modifiers:u}})},z=()=>{ae.current&&(ae.current=!1,De(!1),n({type:"input:pinch:end",sessionId:t,requestId:J()})),ue.current=!1,Y(null)},C=$=>{($.code==="AltLeft"||$.code==="AltRight")&&z()},se=()=>{ue.current&&z()};return window.addEventListener("keydown",D),window.addEventListener("keyup",C),window.addEventListener("blur",se),()=>{window.removeEventListener("keydown",D),window.removeEventListener("keyup",C),window.removeEventListener("blur",se)}},[Q,_,n,t,q,ye,Fe]),s.useEffect(()=>{if(!Q)return;const v=D=>{const z=N.current??M.current;z&&!z.contains(D.target)&&be(!1)};return document.addEventListener("pointerdown",v),()=>document.removeEventListener("pointerdown",v)},[Q]);const qe=s.useRef(!1),ke=s.useCallback(v=>{const D=M.current;if(!D)return null;const z=D.getBoundingClientRect();return Bs({x:v.clientX,y:v.clientY},z,qe.current)},[]),Oe=s.useCallback(v=>{const D=ke(v);return D?Ar(D):null},[ke]),Tt=s.useCallback(v=>{if(ue.current){const se=Oe(v);if(!se)return;ae.current=!0,De(!0),v.target.setPointerCapture(v.pointerId);const $=le.current;$&&($.style.display="none"),Y(se),n({type:"input:pinch:start",sessionId:t,payload:se});return}const D=ke(v);if(!D)return;be(!0),he.current=D,v.target.setPointerCapture(v.pointerId);const z=v.currentTarget.getBoundingClientRect();pe.current=D,S.current="down",F.current=null;const C=le.current;C&&(C.style.display="block",C.style.left=`${v.clientX-z.left}px`,C.style.top=`${v.clientY-z.top}px`,C.style.width=`${ht*2}px`,C.style.height=`${ht*2}px`,C.style.background="rgba(255,255,255,0.92)",C.style.border="1.5px solid rgba(0,0,0,0.2)",C.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"),n({type:"input:touch:start",sessionId:t,payload:D})},[ke,Oe,n,t]),Me=s.useCallback(v=>{if(v.buttons===0){if(ue.current){Y(Oe(v)),pe.current=null;const P=le.current;P&&(P.style.display="none");return}const x=ke(v),h=v.currentTarget.getBoundingClientRect(),E=le.current;x?(pe.current=x,S.current!=="down"&&(S.current="idle"),E&&(E.style.display="block",E.style.left=`${v.clientX-h.left}px`,E.style.top=`${v.clientY-h.top}px`,E.style.width=`${tt*2}px`,E.style.height=`${tt*2}px`,E.style.background="transparent",E.style.border="1.5px solid rgba(255,255,255,0.6)",E.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)")):(pe.current=null,E&&(E.style.display="none"));return}if(ae.current){const x=Oe(v);if(!x)return;const h=performance.now();if(h-de.current<ir)return;de.current=h,Y(x),n({type:"input:pinch:move",sessionId:t,payload:x});return}if(!he.current)return;const D=ke(v);if(!D)return;const z=D.x-he.current.x,C=D.y-he.current.y;if(Math.sqrt(z*z+C*C)<ao)return;const se=performance.now();if(se-de.current<ir)return;de.current=se;const $=v.currentTarget.getBoundingClientRect();pe.current=D;const u=le.current;u&&u.style.display!=="none"&&(u.style.left=`${v.clientX-$.left}px`,u.style.top=`${v.clientY-$.top}px`),n({type:"input:touch:move",sessionId:t,payload:D})},[ke,Oe,n,t]),Ye=s.useCallback(()=>{if(ae.current){ae.current=!1,De(!1),Y(null),n({type:"input:pinch:end",sessionId:t,requestId:J()});return}he.current=null,S.current="release",F.current={startTime:performance.now()};const v=le.current;v&&(v.style.width=`${tt*2}px`,v.style.height=`${tt*2}px`,v.style.background="transparent",v.style.border="1.5px solid rgba(255,255,255,0.6)",v.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),n({type:"input:touch:end",sessionId:t,requestId:J()})},[n,t]),ot=s.useCallback(()=>{if(ae.current){ae.current=!1,De(!1),Y(null),n({type:"input:pinch:end",sessionId:t,requestId:J()});return}he.current=null,S.current="release",F.current={startTime:performance.now()},n({type:"input:touch:end",sessionId:t,requestId:J()})},[n,t]),Ge=s.useCallback(()=>{Y(null),pe.current=null;const v=le.current;v&&(v.style.display="none")},[]),we=Be??(k&&A?{width:k,height:A}:null),bt=we?Math.min(1,Nt/Math.max(we.width,we.height)):.3,ze=we?Math.round(we.width*bt):324,Je=we?Math.round(we.height*bt):720,At=we?we.width>we.height:!1,We=I&&!At;s.useLayoutEffect(()=>{qe.current=We},[We]);const yt=We?Je:ze,Yt=We?ze:Je,at=R!=null?Math.round(R*ze):22,Ze=We?{position:"absolute",width:ze,height:Je,top:(ze-Je)/2,left:(Je-ze)/2,transform:"rotate(90deg)",transformOrigin:"center center",visibility:Ce?"visible":"hidden",cursor:"none"}:{visibility:Ce?"visible":"hidden",cursor:"none"},Qe=r.jsx(r.Fragment,{children:l==null?void 0:l.map(v=>r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":v.accessibilityTitle,onClick:()=>n({type:"input:button",sessionId:t,requestId:J(),payload:{name:v.name}}),children:v.name==="back"?r.jsx(Tn,{className:"h-4 w-4"}):v.name==="recent_apps"?r.jsx(en,{className:"h-4 w-4"}):v.name==="volume_up"?r.jsx(ns,{className:"h-4 w-4"}):v.name==="volume_down"?r.jsx(os,{className:"h-4 w-4"}):v.name==="power"?r.jsx(Xn,{className:"h-4 w-4"}):r.jsx(wr,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:v.accessibilityTitle})]},v.name))}),it=p&&e?r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx(fe,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:b||d,"aria-label":"Launch app",onClick:i,children:b?r.jsx(jt,{className:"h-4 w-4 animate-spin"}):r.jsx(mr,{className:"h-4 w-4"})})}),r.jsx(Ae,{side:"left",children:b?"Launching…":d?"Installing…":"Launch app"})]}):null;return r.jsxs("div",{className:"flex items-start justify-center gap-16",children:[r.jsx("canvas",{ref:ee,style:{display:"none"}}),r.jsx(Tr,{open:_e,onOpenChange:ge,openUrl:o}),r.jsx(jr,{joined:c,onDeepLink:()=>ge(!0),onScreenshot:q,onRecordToggle:ye,recordState:V,onRotate:Fe,platformSlot:Qe,launchSlot:it}),r.jsxs("div",{className:"flex items-start gap-8",children:[r.jsx("div",{style:{background:"#1c1c1e",borderRadius:`${at+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:r.jsx("div",{ref:N,className:"relative",style:{width:yt,height:Yt,backgroundColor:"#010101",borderRadius:`${at}px`,overflow:"hidden"},children:je?r.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4 text-center",children:r.jsxs("span",{style:{color:"rgba(255,255,255,0.6)",fontSize:"0.875rem"},children:["이 환경에서는 스트리밍을 표시할 수 없습니다.",r.jsx("br",{}),"Chrome/Edge 또는 HTTPS 환경에서 다시 시도해 주세요."]})}):r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:M,className:We?void 0:"block w-full h-full",style:Ze,onPointerDown:Tt,onPointerMove:Me,onPointerUp:Ye,onPointerCancel:ot,onPointerLeave:Ge}),!Ce&&r.jsx("div",{className:"absolute inset-0 animate-pulse bg-zinc-700"}),!Ce&&f&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsx("span",{style:{color:"rgba(255,255,255,0.6)",fontSize:"0.875rem"},children:"Waiting for stream…"})}),r.jsx("div",{ref:le,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"}}),ne&&r.jsx(r.Fragment,{children:[ne.f0,ne.f1].map((v,D)=>r.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:`${v.x*100}%`,top:`${v.y*100}%`,...Pe?{width:ht*2,height:ht*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:tt*2,height:tt*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"}}},D))})]})})}),r.jsx(Bt,{joined:c,fps:re,connected:a,deviceReady:f,bootError:g,installing:d,installError:m,keyboardActive:Q})]})]})}function co(t,e){const n=new DataView(t),o=Math.floor(t.byteLength/2),i=Math.floor(o/e),a=[];for(let c=0;c<e;c++)a.push(new Float32Array(i));for(let c=0;c<i;c++)for(let f=0;f<e;f++){const d=n.getInt16((c*e+f)*2,!0);a[f][c]=d/32768}return a}const lo=44100,Pt=2,cr=.06,uo=.3;function fo(){const t=s.useRef(null),e=s.useRef(0),n=s.useCallback(()=>{if(t.current)return t.current;const i=window.AudioContext??window.webkitAudioContext;return i?(t.current=new i,t.current):null},[]),o=s.useCallback(i=>{var b;const a=n();if(!a)return;a.state==="suspended"&&a.resume();const c=co(i,Pt),f=((b=c[0])==null?void 0:b.length)??0;if(f===0)return;const d=a.createBuffer(Pt,f,lo);for(let l=0;l<Pt;l++)d.getChannelData(l).set(c[l]);const p=a.createBufferSource();p.buffer=d,p.connect(a.destination);const m=a.currentTime;let g=e.current;(g<m+.005||g>m+uo+cr)&&(g=m+cr),p.start(g),e.current=g+d.duration},[n]);return s.useEffect(()=>()=>{var i;(i=t.current)==null||i.close(),t.current=null},[]),{pushFrame:o}}const lr={"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 ho(t){const e=t!==void 0&&Object.hasOwn(lr,t)?t:"channel-unavailable";return{key:e,notice:lr[e]}}function po({sessionId:t,deviceId:e,buildId:n,resetMode:o,onRecordingUploaded:i,onSessionEnded:a}){const c=s.useRef(()=>{}),f=s.useRef(!1),d=s.useRef({pending:0,appInstalled:!1});ls();const p=s.useRef(null),m=s.useRef(null),g=s.useRef([]);s.useRef({onFrameBegin:()=>{var S;return(S=p.current)==null?void 0:S.onFrameBegin()},onFrameEnd:S=>{var q,ye;const F=g.current.shift()??null,W=F?{...S,capturedAt:F.capturedAt,relayedAt:F.relayedAt}:S;(q=p.current)==null||q.onFrameEnd(W),(ye=m.current)==null||ye.call(m,W)}});const[b,l]=s.useState(!1),[y,j]=s.useState(!1),[_,T]=s.useState(!1),[k,A]=s.useState(null),[R,U]=s.useState(!1),[M,N]=s.useState(!1),[O,re]=s.useState(null),[K,V]=s.useState(null),[ee,Z]=s.useState(!1),[Re,_e]=s.useState([]),ge=s.useRef(new Set),Ce=s.useRef(null),xe=s.useRef(new Set),je=s.useRef(new Set),Ne=s.useRef(new Set),[te,Be]=s.useState(!1),[me,I]=s.useState(!1),X=s.useRef(void 0),Q=s.useRef(void 0),{pushFrame:be}=fo(),Pe=s.useCallback(S=>{var F;if(!("sessionId"in S&&S.sessionId!==t)){if(S.type==="session:joined"){d.current={pending:0,appInstalled:!1},l(!0),j(!1),_e(S.capabilities??[]);const W=f.current?"app-only":o;f.current=!0,ge.current.clear();const q=J();ge.current.add(q),Ce.current=q,c.current({type:"device:boot",sessionId:t,requestId:q,payload:{deviceId:e,resetMode:W,acceptH264:rr(),secureContext:window.isSecureContext}})}if(S.type==="session:agent-away"){j(!0),A(null),T(!1);return}if(S.type==="session:terminated"){a==null||a(S.reason);return}if(S.type==="session:rebound"){T(!1),A(null),U(!1),re(null),V(null),Z(!1),I(!1),Be(!1),g.current=[],_e(S.capabilities);const W=y;j(!1),d.current={pending:d.current.pending+1,appInstalled:d.current.pending>0?d.current.appInstalled:M},f.current=!0;const q=J();ge.current.add(q),Ce.current=q,c.current({type:"device:boot",sessionId:t,requestId:q,payload:{deviceId:e,resetMode:"app-only",acceptH264:rr(),secureContext:window.isSecureContext}}),W||Ue.info("The agent restarted — reconnecting to the device.");return}if(S.type==="device:boot-error"){if(S.requestId!==void 0&&S.requestId!==Ce.current||y)return;d.current={pending:0,appInstalled:!1},V(S.message)}if(S.type==="input:error"){if(y)return;const{key:W,notice:q}=ho(S.reason);S.reason!==void 0&&S.reason!==W&&console.debug(`[tapflow] unrecognised input:error reason "${S.reason}", treated as ${W}`),q?Ue.error(q.title,{id:`input:${t}:${W}`,description:S.message?`${q.action} (${S.message})`:q.action,duration:6e3}):console.debug(`[tapflow] input refused, shown nowhere: ${W}${S.message?` — ${S.message}`:""}`)}if(S.type==="device:booting"&&(T(!1),U(!1),N(!1),re(null),V(null),je.current.clear(),Ne.current.clear(),A(null)),S.type==="device:ready"){if(T(!0),S.requestId!==void 0&&!ge.current.delete(S.requestId))return;if(d.current.pending>0){const{appInstalled:W}=d.current;if(d.current={pending:d.current.pending-1,appInstalled:W},W){N(!0);return}}if(n){U(!0);const W=J();je.current.add(W),c.current({type:"app:install",sessionId:t,requestId:W,buildId:n})}}if(S.type==="app:install-done"||S.type==="app:install-error"){if(!je.current.delete(S.requestId))return;U(!1),S.type==="app:install-done"?N(!0):re(S.message)}if(S.type==="app:launch-done"||S.type==="app:launch-error"){if(!Ne.current.delete(S.requestId))return;Z(!1)}if(S.type==="session:chrome"&&A(S.payload),S.type==="keyboard:toggled"){const{visible:W}=S.payload;Be(W),I(!1)}if((S.type==="clipboard:data"||S.type==="clipboard:write-done"||S.type==="clipboard:error")&&((F=Q.current)==null||F.call(Q,S)),S.type==="open-url:done"||S.type==="open-url:error"){if(!xe.current.delete(S.requestId))return;S.type==="open-url:done"?Ue.success("Deeplink opened"):Ue.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}}},[t,e,n,a,o,M,y]),De=s.useCallback(S=>{var ye;const F=Xs(S);if(F&&F.codec===_r){be(S.slice(It));return}F&&F.codec===kt||g.current.push(F);const W=F?S.slice(It):S,q=F?{codec:F.codec,keyframe:F.keyframe,capturedAt:F.capturedAt,relayedAt:F.relayedAt}:void 0;(ye=X.current)==null||ye.call(X,W,q)},[be]),{send:ne,connected:Y}=gr(Pe,De);s.useLayoutEffect(()=>{c.current=ne}),s.useEffect(()=>{Y&&ne({type:"session:start",sessionId:t})},[Y,ne,t]);const ce=k!==null&&"framePng"in k?k:null,ae=k!==null&&!("framePng"in k)?k:null,ue=()=>{I(!0),ne({type:"input:keyboard:toggle",sessionId:t})},he=s.useCallback(S=>{const F=J();xe.current.add(F),c.current({type:"open-url",sessionId:t,requestId:F,payload:{url:S}})},[t]),de=s.useCallback(()=>{if(n===void 0)return;const S=J();Ne.current.add(S),Z(!0),c.current({type:"app:launch",sessionId:t,requestId:S,buildId:n})},[t,n]),le={sessionId:t,buildId:n,send:ne,openUrl:he,launchApp:de,connected:Y,joined:b,deviceReady:_,installing:R,installed:M,installError:O,bootError:K,launching:ee,binaryFrameHandlerRef:X,clipboardHandlerRef:Q,clipboardSupported:Re.includes("clipboard"),onRecordingUploaded:i,swKeyboardVisible:te,swKeyboardPending:me,onKbdToggle:ue};if(!ce&&!ae)return r.jsxs("div",{className:"flex items-start justify-center gap-16",children:[r.jsx("div",{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,F)=>r.jsx("div",{className:"h-8 w-8 rounded-md bg-muted animate-pulse"},F))}),r.jsxs("div",{className:"flex items-start gap-8",children:[r.jsx("div",{style:{background:"#1c1c1e",borderRadius:"34px",padding:"12px",flexShrink:0},children:r.jsx("div",{className:"animate-pulse bg-zinc-700",style:{width:324,height:720,borderRadius:"22px"}})}),r.jsx(Bt,{joined:b,fps:0,connected:Y,deviceReady:_,bootError:K,installing:R,installError:O,keyboardActive:!1,agentAway:y})]})]});const pe=void 0;return r.jsxs(r.Fragment,{children:[ce&&r.jsx(oo,{...le,chrome:ce,perfHookRef:pe}),ae&&r.jsx(io,{...le,androidButtons:ae.buttons,screenWidth:ae.screenWidth,screenHeight:ae.screenHeight,cornerRadius:ae.cornerRadius,perfHookRef:pe}),!1]})}const Dr=s.forwardRef(({className:t,...e},n)=>r.jsx("textarea",{className:oe("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",t),ref:n,...e}));Dr.displayName="Textarea";var mo=Object.defineProperty,B=(t,e)=>mo(t,"name",{value:e,configurable:!0});function Lr(t,e){return s.useReducer((n,o)=>e[n][o]??n,t)}B(Lr,"useStateMachine");var Mr="ScrollArea",[Ir,ca]=pr(Mr),[go,Se]=Ir(Mr),xo=s.forwardRef(B(function(e,n){const{__scopeScrollArea:o,type:i="hover",dir:a,scrollHideDelay:c=600,...f}=e,[d,p]=s.useState(null),[m,g]=s.useState(null),[b,l]=s.useState(null),[y,j]=s.useState(null),[_,T]=s.useState(null),[k,A]=s.useState(0),[R,U]=s.useState(0),[M,N]=s.useState(!1),[O,re]=s.useState(!1),K=Ke(n,p),V=rn(a);return r.jsx(go,{scope:o,type:i,dir:V,scrollHideDelay:c,scrollArea:d,viewport:m,onViewportChange:g,content:b,onContentChange:l,scrollbarX:y,onScrollbarXChange:j,scrollbarXEnabled:M,onScrollbarXEnabledChange:N,scrollbarY:_,onScrollbarYChange:T,scrollbarYEnabled:O,onScrollbarYEnabledChange:re,onCornerWidthChange:A,onCornerHeightChange:U,children:r.jsx(Xe.div,{dir:V,...f,ref:K,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})},"ScrollArea")),bo="ScrollAreaViewport",yo=s.forwardRef(B(function(e,n){const{__scopeScrollArea:o,children:i,nonce:a,...c}=e,f=Se(bo,o),d=s.useRef(null),p=Ke(n,d,f.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx(vo,{nonce:a}),r.jsx(Xe.div,{"data-radix-scroll-area-viewport":"",...c,ref:p,style:{overflowX:f.scrollbarXEnabled?"scroll":"hidden",overflowY:f.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:f.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})},"ScrollAreaViewport")),vo=s.memo(B(function({nonce:e}){return r.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:e})},"ScrollAreaViewportStyle"),(t,e)=>t.nonce===e.nonce),$e="ScrollAreaScrollbar",Ur=s.forwardRef(B(function(e,n){const{forceMount:o,...i}=e,a=Se($e,e.__scopeScrollArea),{onScrollbarXEnabledChange:c,onScrollbarYEnabledChange:f}=a,d=e.orientation==="horizontal";return s.useEffect(()=>(d?c(!0):f(!0),()=>{d?c(!1):f(!1)}),[d,c,f]),a.type==="hover"?r.jsx(wo,{...i,ref:n,forceMount:o}):a.type==="scroll"?r.jsx(So,{...i,ref:n,forceMount:o}):a.type==="auto"?r.jsx(Hr,{...i,ref:n,forceMount:o}):a.type==="always"?r.jsx(Ot,{...i,ref:n,"data-state":"visible"}):null},"ScrollAreaScrollbar")),wo=s.forwardRef(B(function(e,n){const{forceMount:o,...i}=e,a=Se($e,e.__scopeScrollArea),[c,f]=s.useState(!1);return s.useEffect(()=>{const d=a.scrollArea;let p=0;if(d){const m=B(()=>{window.clearTimeout(p),f(!0)},"handlePointerEnter"),g=B(()=>{p=window.setTimeout(()=>f(!1),a.scrollHideDelay)},"handlePointerLeave");return d.addEventListener("pointerenter",m),d.addEventListener("pointerleave",g),()=>{window.clearTimeout(p),d.removeEventListener("pointerenter",m),d.removeEventListener("pointerleave",g)}}},[a.scrollArea,a.scrollHideDelay]),r.jsx(Et,{present:o||c,children:r.jsx(Hr,{"data-state":c?"visible":"hidden",...i,ref:n})})},"ScrollAreaScrollbarHover")),So=s.forwardRef(B(function(e,n){const{forceMount:o,...i}=e,a=Se($e,e.__scopeScrollArea),c=e.orientation==="horizontal",f=xt(()=>p("SCROLL_END"),100),[d,p]=Lr("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return s.useEffect(()=>{if(d==="idle"){const m=window.setTimeout(()=>p("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(m)}},[d,a.scrollHideDelay,p]),s.useEffect(()=>{const m=a.viewport,g=c?"scrollLeft":"scrollTop";if(m){let b=m[g];const l=B(()=>{const y=m[g];b!==y&&(p("SCROLL"),f()),b=y},"handleScroll");return m.addEventListener("scroll",l),()=>m.removeEventListener("scroll",l)}},[a.viewport,c,p,f]),r.jsx(Et,{present:o||d!=="hidden",children:r.jsx(Ot,{"data-state":d==="hidden"?"hidden":"visible",...i,ref:n,onPointerEnter:He(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:He(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Hr=s.forwardRef(B(function(e,n){const o=Se($e,e.__scopeScrollArea),{forceMount:i,...a}=e,[c,f]=s.useState(!1),d=e.orientation==="horizontal",p=xt(()=>{if(o.viewport){const m=o.viewport.offsetWidth<o.viewport.scrollWidth,g=o.viewport.offsetHeight<o.viewport.scrollHeight;f(d?m:g)}},10);return st(o.viewport,p),st(o.content,p),r.jsx(Et,{present:i||c,children:r.jsx(Ot,{"data-state":c?"visible":"hidden",...a,ref:n})})},"ScrollAreaScrollbarAuto")),Ot=s.forwardRef(B(function(e,n){const{orientation:o="vertical",...i}=e,a=Se($e,e.__scopeScrollArea),c=s.useRef(null),f=s.useRef(0),[d,p]=s.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=zt(d.viewport,d.content),g={...i,sizes:d,onSizesChange:p,hasThumb:m>0&&m<1,onThumbChange:B(l=>c.current=l,"onThumbChange"),onThumbPointerUp:B(()=>f.current=0,"onThumbPointerUp"),onThumbPointerDown:B(l=>f.current=l,"onThumbPointerDown")};function b(l,y){return Or(l,f.current,d,y)}return B(b,"getScrollPosition"),o==="horizontal"?r.jsx(Ro,{...g,ref:n,onThumbPositionChange:()=>{if(a.viewport&&c.current){const l=a.viewport.scrollLeft,y=Ht(l,d,a.dir);c.current.style.transform=`translate3d(${y}px, 0, 0)`}},onWheelScroll:l=>{a.viewport&&(a.viewport.scrollLeft=l)},onDragScroll:l=>{a.viewport&&(a.viewport.scrollLeft=b(l,a.dir))}}):o==="vertical"?r.jsx(Co,{...g,ref:n,onThumbPositionChange:()=>{if(a.viewport&&c.current){const l=a.viewport.scrollTop,y=Ht(l,d);c.current.style.transform=`translate3d(0, ${y}px, 0)`}},onWheelScroll:l=>{a.viewport&&(a.viewport.scrollTop=l)},onDragScroll:l=>{a.viewport&&(a.viewport.scrollTop=b(l))}}):null},"ScrollAreaScrollbarVisible")),Ro=s.forwardRef(B(function(e,n){const{sizes:o,onSizesChange:i,...a}=e,c=Se($e,e.__scopeScrollArea),[f,d]=s.useState(),p=s.useRef(null),m=Ke(n,p,c.onScrollbarXChange);return s.useEffect(()=>{p.current&&d(getComputedStyle(p.current))},[p]),r.jsx(Br,{"data-orientation":"horizontal",...a,ref:m,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":gt(o)+"px",...e.style},onThumbPointerDown:g=>e.onThumbPointerDown(g.x),onDragScroll:g=>e.onDragScroll(g.x),onWheelScroll:(g,b)=>{if(c.viewport){const l=c.viewport.scrollLeft+g.deltaX;e.onWheelScroll(l),Vt(l,b)&&g.preventDefault()}},onResize:()=>{p.current&&c.viewport&&f&&i({content:c.viewport.scrollWidth,viewport:c.viewport.offsetWidth,scrollbar:{size:p.current.clientWidth,paddingStart:mt(f.paddingLeft),paddingEnd:mt(f.paddingRight)}})}})},"ScrollAreaScrollbarX")),Co=s.forwardRef(B(function(e,n){const{sizes:o,onSizesChange:i,...a}=e,c=Se($e,e.__scopeScrollArea),[f,d]=s.useState(),p=s.useRef(null),m=Ke(n,p,c.onScrollbarYChange);return s.useEffect(()=>{p.current&&d(getComputedStyle(p.current))},[p]),r.jsx(Br,{"data-orientation":"vertical",...a,ref:m,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":gt(o)+"px",...e.style},onThumbPointerDown:g=>e.onThumbPointerDown(g.y),onDragScroll:g=>e.onDragScroll(g.y),onWheelScroll:(g,b)=>{if(c.viewport){const l=c.viewport.scrollTop+g.deltaY;e.onWheelScroll(l),Vt(l,b)&&g.preventDefault()}},onResize:()=>{p.current&&c.viewport&&f&&i({content:c.viewport.scrollHeight,viewport:c.viewport.offsetHeight,scrollbar:{size:p.current.clientHeight,paddingStart:mt(f.paddingTop),paddingEnd:mt(f.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[jo,$r]=Ir($e),Br=s.forwardRef(B(function(e,n){const{__scopeScrollArea:o,sizes:i,hasThumb:a,onThumbChange:c,onThumbPointerUp:f,onThumbPointerDown:d,onThumbPositionChange:p,onDragScroll:m,onWheelScroll:g,onResize:b,...l}=e,y=Se($e,o),[j,_]=s.useState(null),T=Ke(n,_),k=s.useRef(null),A=s.useRef(""),R=y.viewport,U=i.content-i.viewport,M=nt(g),N=nt(p),O=xt(b,10);function re(K){if(k.current){const V=K.clientX-k.current.left,ee=K.clientY-k.current.top;m({x:V,y:ee})}}return B(re,"handleDragScroll"),s.useEffect(()=>{const K=B(V=>{const ee=V.target;(j==null?void 0:j.contains(ee))&&M(V,U)},"handleWheel");return document.addEventListener("wheel",K,{passive:!1}),()=>document.removeEventListener("wheel",K,{passive:!1})},[R,j,U,M]),s.useEffect(N,[i,N]),st(j,O),st(y.content,O),r.jsx(jo,{scope:o,scrollbar:j,hasThumb:a,onThumbChange:nt(c),onThumbPointerUp:nt(f),onThumbPositionChange:N,onThumbPointerDown:nt(d),children:r.jsx(Xe.div,{...l,ref:T,style:{position:"absolute",...l.style},onPointerDown:He(e.onPointerDown,K=>{K.button===0&&(K.target.setPointerCapture(K.pointerId),k.current=j.getBoundingClientRect(),A.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",y.viewport&&(y.viewport.style.scrollBehavior="auto"),re(K))}),onPointerMove:He(e.onPointerMove,re),onPointerUp:He(e.onPointerUp,K=>{const V=K.target;V.hasPointerCapture(K.pointerId)&&V.releasePointerCapture(K.pointerId),document.body.style.webkitUserSelect=A.current,y.viewport&&(y.viewport.style.scrollBehavior=""),k.current=null})})})},"ScrollAreaScrollbarImpl")),Ut="ScrollAreaThumb",ko=s.forwardRef(B(function(e,n){const{forceMount:o,...i}=e,a=$r(Ut,e.__scopeScrollArea);return r.jsx(Et,{present:o||a.hasThumb,children:r.jsx(Eo,{ref:n,...i})})},"ScrollAreaThumb")),Eo=s.forwardRef(B(function(e,n){const{__scopeScrollArea:o,style:i,...a}=e,c=Se(Ut,o),f=$r(Ut,o),{onThumbPositionChange:d}=f,p=Ke(n,f.onThumbChange),m=s.useRef(void 0),g=xt(()=>{m.current&&(m.current(),m.current=void 0)},100);return s.useEffect(()=>{const b=c.viewport;if(b){const l=B(()=>{if(g(),!m.current){const y=_o(b,d);m.current=y,d()}},"handleScroll");return d(),b.addEventListener("scroll",l),()=>b.removeEventListener("scroll",l)}},[c.viewport,g,d]),r.jsx(Xe.div,{"data-state":f.hasThumb?"visible":"hidden",...a,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:He(e.onPointerDownCapture,b=>{const y=b.target.getBoundingClientRect(),j=b.clientX-y.left,_=b.clientY-y.top;f.onThumbPointerDown({x:j,y:_})}),onPointerUp:He(e.onPointerUp,f.onThumbPointerUp)})},"ScrollAreaThumbImpl")),Fr="ScrollAreaCorner",To=s.forwardRef(B(function(e,n){const o=Se(Fr,e.__scopeScrollArea),i=!!(o.scrollbarX&&o.scrollbarY);return o.type!=="scroll"&&i?r.jsx(Ao,{...e,ref:n}):null},"ScrollAreaCorner")),Ao=s.forwardRef(B(function(e,n){const{__scopeScrollArea:o,...i}=e,a=Se(Fr,o),[c,f]=s.useState(0),[d,p]=s.useState(0),m=!!(c&&d),{onCornerWidthChange:g,onCornerHeightChange:b}=a;return st(a.scrollbarX,()=>{var y;const l=((y=a.scrollbarX)==null?void 0:y.offsetHeight)||0;a.onCornerHeightChange(l),p(l)}),st(a.scrollbarY,()=>{var y;const l=((y=a.scrollbarY)==null?void 0:y.offsetWidth)||0;a.onCornerWidthChange(l),f(l)}),s.useEffect(()=>()=>{g(0),b(0)},[g,b]),m?r.jsx(Xe.div,{...i,ref:n,style:{width:c,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null},"ScrollAreaCornerImpl"));function mt(t){return t?parseInt(t,10):0}B(mt,"toInt");function zt(t,e){const n=t/e;return isNaN(n)?0:n}B(zt,"getThumbRatio");function gt(t){const e=zt(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=(t.scrollbar.size-n)*e;return Math.max(o,18)}B(gt,"getThumbSize");function Or(t,e,n,o="ltr"){const i=gt(n),a=i/2,c=e||a,f=i-c,d=n.scrollbar.paddingStart+c,p=n.scrollbar.size-n.scrollbar.paddingEnd-f,m=n.content-n.viewport,g=o==="ltr"?[0,m]:[m*-1,0];return Wt([d,p],g)(t)}B(Or,"getScrollPositionFromPointer");function Ht(t,e,n="ltr"){const o=gt(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,a=e.scrollbar.size-i,c=e.content-e.viewport,f=a-o,d=n==="ltr"?[0,c]:[c*-1,0],p=wn(t,d);return Wt([0,c],[0,f])(p)}B(Ht,"getThumbOffsetFromScroll");function Wt(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const o=(e[1]-e[0])/(t[1]-t[0]);return e[0]+o*(n-t[0])}}B(Wt,"linearScale");function Vt(t,e){return t>0&&t<e}B(Vt,"isScrollingWithinScrollbarBounds");var _o=B((t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},o=0;return B((function i(){const a={left:t.scrollLeft,top:t.scrollTop},c=n.left!==a.left,f=n.top!==a.top;(c||f)&&e(),n=a,o=window.requestAnimationFrame(i)}),"loop")(),()=>window.cancelAnimationFrame(o)},"addUnlinkedScrollListener");function xt(t,e){const n=nt(t),o=s.useRef(0);return s.useEffect(()=>()=>window.clearTimeout(o.current),[]),s.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,e)},[n,e])}B(xt,"useDebounceCallback");function st(t,e){const n=nt(e);tn(()=>{let o=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(n)});return i.observe(t),()=>{window.cancelAnimationFrame(o),i.unobserve(t)}}},[t,n])}B(st,"useResizeObserver");var zr=xo,No=yo,Po=To;const Wr=s.forwardRef(({className:t,children:e,...n},o)=>r.jsxs(zr,{ref:o,className:oe("relative overflow-hidden",t),...n,children:[r.jsx(No,{className:"h-full w-full rounded-[inherit]",children:e}),r.jsx(Vr,{}),r.jsx(Po,{})]}));Wr.displayName=zr.displayName;const Vr=s.forwardRef(({className:t,orientation:e="vertical",...n},o)=>r.jsx(Ur,{ref:o,orientation:e,className:oe("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...n,children:r.jsx(ko,{className:"relative flex-1 rounded-full bg-border"})}));Vr.displayName=Ur.displayName;function Kr(t){return/[Zz]|[+-]\d{2}/.test(t)?new Date(t):new Date(t.replace(" ","T")+"Z")}function Do(t){const e=new Map;for(const i of t){const a=Kr(i.created_at).toDateString();e.has(a)||e.set(a,[]),e.get(a).push(i)}const n=new Date().toDateString(),o=new Date(Date.now()-864e5).toDateString();return Array.from(e.entries()).map(([i,a])=>{let c;if(i===n)c="Today";else if(i===o)c="Yesterday";else{const f=new Date(i);c=f.toLocaleDateString(void 0,{month:"short",day:"numeric",...f.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}return{label:c,items:a}})}function Lo(t){return Kr(t).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}const Mo=5*1024*1024,Io=["image/png","image/jpeg","image/webp"];function Uo({buildId:t}){const[e,n]=s.useState([]),[o,i]=s.useState(""),[a,c]=s.useState(null),[f,d]=s.useState(!1),[p,m]=s.useState(""),g=s.useRef(null),b=s.useRef({}),l=s.useCallback(()=>{fetch(`/api/v1/comments?build_id=${t}`,{credentials:"include"}).then(k=>k.ok?k.json():[]).then(n)},[t]);s.useEffect(()=>{l()},[l]),s.useEffect(()=>{const k=window.location.hash;if(!k.startsWith("#comment-"))return;const A=Number(k.replace("#comment-","")),R=b.current[A];if(!R)return;R.scrollIntoView({behavior:"smooth"});const U=document.documentElement.classList.contains("dark");R.style.backgroundColor=U?"rgb(0 112 243 / 0.18)":"#d3e5ff",setTimeout(()=>{R.style.backgroundColor=""},2e3)},[e]);function y(k){const A=`${location.origin}${location.pathname}${location.search}#comment-${k}`;navigator.clipboard.writeText(A).then(()=>Ue.success("Link copied")).catch(()=>Ue.error("Could not copy link"))}function j(k){if(m(""),!Io.includes(k.type)){m("Only png, jpg, webp allowed");return}if(k.size>Mo){m("Max 5MB");return}c(k)}async function _(k){if(k.preventDefault(),!o.trim()&&!a)return;d(!0);const A=new FormData;A.append("build_id",String(t)),A.append("body",o),a&&A.append("attachment",a),(await fetch("/api/v1/comments",{method:"POST",credentials:"include",body:A})).ok&&(i(""),c(null),l()),d(!1)}const T=Do(e);return r.jsxs("div",{className:"flex h-full flex-col gap-3 px-1",children:[r.jsx(Wr,{className:"flex-1 rounded-md border",children:r.jsx("div",{className:"p-3",children:e.length===0?r.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No comments yet."}):r.jsx("div",{className:"flex flex-col",children:T.map(({label:k,items:A})=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 py-3",children:[r.jsx("div",{className:"h-px flex-1 bg-border"}),r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground px-1 select-none",children:k}),r.jsx("div",{className:"h-px flex-1 bg-border"})]}),r.jsx("div",{className:"flex flex-col gap-4",children:A.map(R=>r.jsxs("div",{id:`comment-${R.id}`,ref:U=>{b.current[R.id]=U},className:"group flex gap-2.5 rounded-md px-2 py-1.5 transition-all",children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx(nn,{name:R.author,avatarUrl:R.authorAvatarUrl,size:28})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-sm font-semibold leading-none",children:R.author}),r.jsx("span",{className:"text-[11px] text-muted-foreground leading-none",children:Lo(R.created_at)}),r.jsx(fe,{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:()=>y(R.id),children:r.jsx(Sr,{className:"h-3 w-3","aria-hidden":"true"})})]}),r.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap mt-1",children:R.body}),R.attachments.map(U=>{const M=decodeURIComponent(U.file_path.split("/").pop()??"image");return r.jsx("a",{href:U.file_path,target:"_blank",rel:"noreferrer",className:"mt-1.5 block","aria-label":`Open ${M} in a new tab`,children:r.jsx("img",{src:U.file_path,alt:M,className:"max-h-48 rounded border object-contain"})},U.id)})]})]},R.id))})]},k))})})}),r.jsx("div",{className:"pb-1",children:r.jsx("form",{onSubmit:_,children:r.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:[r.jsx(Dr,{"aria-label":"Comment",placeholder:"Leave a comment…",value:o,onChange:k=>i(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"}),(a||p)&&r.jsxs("div",{className:"px-3 -mt-1 pb-1",children:[a&&r.jsx("p",{className:"text-xs text-muted-foreground",children:a.name}),p&&r.jsx("p",{className:"text-xs text-destructive",children:p})]}),r.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[r.jsx(fe,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground","aria-label":"Attach image",onClick:()=>{var k;return(k=g.current)==null?void 0:k.click()},children:r.jsx($n,{className:"h-4 w-4","aria-hidden":"true"})}),r.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:k=>{var R;const A=(R=k.target.files)==null?void 0:R[0];A&&j(A)}}),r.jsx("div",{className:"flex-1"}),r.jsx(fe,{type:"submit",size:"icon",className:"h-7 w-7 rounded-full","aria-label":"Post comment",disabled:f||!o.trim()&&!a,children:r.jsx(_n,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})})})]})}function Ho(t){return t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function $o(t){return new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Bo(t){const e=new Date(t).getTime()-Date.now();if(e<=0)return{label:"Expired",urgent:!0};const n=Math.floor(e/36e5);return n<1?{label:"< 1 hour left",urgent:!0}:n<24?{label:`Expires in ${n}h`,urgent:n<6}:{label:`Expires in ${Math.floor(n/24)}d`,urgent:!1}}function Fo({buildId:t,refreshKey:e}){const[n,o]=s.useState([]),[i,a]=s.useState(!0),[c,f]=s.useState(!1);return s.useEffect(()=>{a(!0),f(!1);const d=setTimeout(()=>f(!0),250);return fetch(`/api/v1/recordings?buildId=${t}`,{credentials:"include"}).then(p=>p.ok?p.json():[]).then(p=>o(p)).catch(()=>o([])).finally(()=>{clearTimeout(d),a(!1)}),()=>clearTimeout(d)},[t,e]),i?c?r.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading recordings…"}):null:n.length===0?r.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No recordings yet."}):r.jsx("div",{className:"flex flex-col gap-2",children:n.map(d=>{const p=Bo(d.expiresAt);return r.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2 text-sm",children:[r.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[r.jsx("span",{className:"text-xs font-medium truncate",children:$o(d.createdAt)}),r.jsxs("span",{className:`text-xs ${p.urgent?"text-destructive":"text-muted-foreground"}`,children:[p.label," · ",Ho(d.fileSize)]})]}),r.jsx(fe,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 ml-2",title:"Download",onClick:()=>{const m=document.createElement("a");m.href=d.url,m.download="",m.click()},children:r.jsx(Ln,{className:"h-3.5 w-3.5"})})]},d.id)})})}function Oo({buildId:t,recordingsRefreshKey:e=0}){return r.jsxs(mn,{defaultValue:"comments",className:"flex h-full flex-col",children:[r.jsx("div",{className:"shrink-0 px-1",children:r.jsxs(gn,{className:"w-full",children:[r.jsxs(Zt,{value:"comments",className:"flex-1 gap-1.5",children:[r.jsx(Vn,{className:"h-3.5 w-3.5"}),"Comments"]}),r.jsxs(Zt,{value:"recordings",className:"flex-1 gap-1.5",children:[r.jsx(In,{className:"h-3.5 w-3.5"}),"Recordings"]})]})}),r.jsx(Qt,{value:"comments",className:"mt-3 min-h-0 flex-1 overflow-hidden",children:r.jsx(Uo,{buildId:t})}),r.jsx(Qt,{value:"recordings",className:"mt-3 min-h-0 flex-1 overflow-y-auto",children:r.jsx(Fo,{buildId:t,refreshKey:e})})]})}const Xr=s.forwardRef(({...t},e)=>r.jsx("nav",{ref:e,"aria-label":"breadcrumb",...t}));Xr.displayName="Breadcrumb";const qr=s.forwardRef(({className:t,...e},n)=>r.jsx("ol",{ref:n,className:oe("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...e}));qr.displayName="BreadcrumbList";const pt=s.forwardRef(({className:t,...e},n)=>r.jsx("li",{ref:n,className:oe("inline-flex items-center gap-1.5",t),...e}));pt.displayName="BreadcrumbItem";const St=s.forwardRef(({asChild:t,className:e,...n},o)=>{const i=t?sn:"a";return r.jsx(i,{ref:o,className:oe("transition-colors hover:text-foreground cursor-pointer",e),...n})});St.displayName="BreadcrumbLink";const Rt=s.forwardRef(({className:t,...e},n)=>r.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:oe("font-medium text-foreground",t),...e}));Rt.displayName="BreadcrumbPage";const Ct=({children:t,className:e,...n})=>r.jsx("li",{role:"presentation","aria-hidden":"true",className:oe("[&>svg]:h-3.5 [&>svg]:w-3.5",e),...n,children:t??r.jsx(on,{})});Ct.displayName="BreadcrumbSeparator";var zo=Object.defineProperty,Ve=(t,e)=>zo(t,"name",{value:e,configurable:!0}),Kt="Switch",[Wo,la]=pr(Kt),[Vo,Xt]=Wo(Kt);function Yr(t){const{__scopeSwitch:e,checked:n,children:o,defaultChecked:i,disabled:a,form:c,name:f,onCheckedChange:d,required:p,value:m="on",internal_do_not_use_render:g}=t,[b,l]=cn({prop:n,defaultProp:i??!1,onChange:d,caller:Kt}),[y,j]=s.useState(null),[_,T]=s.useState(null),k=s.useRef(!1),[A,R]=s.useReducer(N=>N+1,0),U=y?!!c||!!y.closest("form"):!0,M={checked:b,setChecked:l,disabled:a,control:y,setControl:j,name:f,form:c,value:m,hasConsumerStoppedPropagationRef:k,userInteractionCount:A,onUserInteraction:R,required:p,defaultChecked:i,isFormControl:U,bubbleInput:_,setBubbleInput:T};return r.jsx(Vo,{scope:e,...M,children:Jr(g)?g(M):o})}Ve(Yr,"SwitchProvider");var Ko="SwitchTrigger",Xo=s.forwardRef(Ve(function({__scopeSwitch:e,onClick:n,...o},i){const{control:a,form:c,value:f,disabled:d,checked:p,required:m,setControl:g,setChecked:b,hasConsumerStoppedPropagationRef:l,onUserInteraction:y,isFormControl:j,bubbleInput:_}=Xt(Ko,e),T=Ke(i,g),k=s.useRef(p);return s.useEffect(()=>{const A=c?a==null?void 0:a.ownerDocument.getElementById(c):a==null?void 0:a.form;if(A instanceof HTMLFormElement){const R=Ve(()=>b(k.current),"reset");return A.addEventListener("reset",R),()=>A.removeEventListener("reset",R)}},[a,c,b]),r.jsx(Xe.button,{type:"button",role:"switch","aria-checked":p,"aria-required":m,"data-state":qt(p),"data-disabled":d?"":void 0,disabled:d,value:f,...o,ref:T,onClick:He(n,A=>{y(),b(R=>!R),_&&j&&(l.current=A.isPropagationStopped(),l.current||A.stopPropagation())})})},"SwitchTrigger")),Gr=s.forwardRef(Ve(function(e,n){const{__scopeSwitch:o,name:i,checked:a,defaultChecked:c,required:f,disabled:d,value:p,onCheckedChange:m,form:g,...b}=e;return r.jsx(Yr,{__scopeSwitch:o,checked:a,defaultChecked:c,disabled:d,required:f,onCheckedChange:m,name:i,form:g,value:p,internal_do_not_use_render:({isFormControl:l})=>r.jsxs(r.Fragment,{children:[r.jsx(Xo,{...b,ref:n,__scopeSwitch:o}),l&&r.jsx(Jo,{__scopeSwitch:o})]})})},"Switch")),qo="SwitchThumb",Yo=s.forwardRef(Ve(function(e,n){const{__scopeSwitch:o,...i}=e,a=Xt(qo,o);return r.jsx(Xe.span,{"data-state":qt(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:n})},"SwitchThumb")),Go="SwitchBubbleInput",Jo=s.forwardRef(Ve(function({__scopeSwitch:e,onClick:n,...o},i){const{control:a,hasConsumerStoppedPropagationRef:c,userInteractionCount:f,checked:d,defaultChecked:p,required:m,disabled:g,name:b,value:l,form:y,bubbleInput:j,setBubbleInput:_}=Xt(Go,e),T=Ke(i,_),k=an(a),A=s.useRef(!1),R=s.useRef(d),U=s.useRef(f);s.useEffect(()=>{const N=j;if(!N)return;const O=window.HTMLInputElement.prototype,K=Object.getOwnPropertyDescriptor(O,"checked").set,V=f!==U.current;U.current=f;const ee=R.current!==d;R.current=d;const Z=!(V&&c.current);if(ee&&K){A.current=!V;const Re=new Event("click",{bubbles:Z});K.call(N,d),N.dispatchEvent(Re),A.current=!1}},[j,d,c,f]);const M=s.useRef(d);return r.jsx(Xe.input,{type:"checkbox","aria-hidden":!0,defaultChecked:p??M.current,required:m,disabled:g,name:b,value:l,form:y,...o,tabIndex:-1,ref:T,onClick:He(n,N=>{A.current&&N.stopPropagation()}),style:{...o.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function Jr(t){return typeof t=="function"}Ve(Jr,"isFunction");function qt(t){return t?"checked":"unchecked"}Ve(qt,"getState");const Zr=s.forwardRef(({className:t,...e},n)=>r.jsx(Gr,{className:oe("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",t),...e,ref:n,children:r.jsx(Yo,{className:oe("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")})}));Zr.displayName=Gr.displayName;const ur=70,dr=80;function Zo(t,e){if(!t||e)return"unknown";const n=t.memUsedMB/t.memTotalMB*100;return t.cpuPercent>dr||n>dr?"overloaded":t.cpuPercent>=ur||n>=ur?"warning":"healthy"}const Qo={"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 ua(){const[t]=xr(),e=xn(),n=t.get("id"),{build:o}=as(n),[i,a]=s.useState(0),c=(o==null?void 0:o.platform)??"ios",{sessions:f,selectedAgent:d,setSelectedAgent:p,activeSessionId:m,deviceId:g,booting:b,status:l,connected:y,agentGroups:j,startDevice:_,resetDevice:T,handleBack:k,handleBackToMacs:A,handleSessionEnded:R}=is(c),U=j.find(I=>I.agentName===d),{osVersions:M,osVersion:N,setOsVersion:O,deviceSearch:re,setDeviceSearch:K,versionedDevices:V,resetMode:ee,setResetMode:Z,appliedResetMode:Re,consumeResetMode:_e,fullResetSupported:ge}=cs(U,c),xe=f.flatMap(I=>I.devices).find(I=>I.id===g),je=xe?`${xe.name}${xe.osVersion?` · ${xe.osVersion}`:""}`:"",Ne=s.useCallback(()=>a(I=>I+1),[]),te=s.useCallback(I=>{_e(),_(I)},[_e,_]),Be=s.useCallback(I=>{const X=Qo[I];Ue.error(X.title,{description:X.description}),R()},[R]),{setNode:me}=ln();return s.useEffect(()=>{if(o)return me(r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Xr,{children:r.jsxs(qr,{children:[r.jsx(pt,{children:r.jsx(St,{asChild:!0,children:r.jsx("button",{onClick:()=>e(`/app-center?appId=${o.app_id}`),children:o.name})})}),r.jsx(Ct,{}),r.jsx(pt,{children:d?r.jsx(St,{asChild:!0,children:r.jsx("button",{onClick:A,children:Jt(o)})}):r.jsx(Rt,{children:Jt(o)})}),d&&r.jsxs(r.Fragment,{children:[r.jsx(Ct,{}),r.jsx(pt,{children:m?r.jsx(St,{asChild:!0,children:r.jsx("button",{onClick:k,children:d})}):r.jsx(Rt,{children:d})})]}),m&&r.jsxs(r.Fragment,{children:[r.jsx(Ct,{}),r.jsx(pt,{children:r.jsx(Rt,{children:je})})]})]})}),!d&&o.status_label&&r.jsx(kn,{tone:hn[o.status_label],children:o.status_label})]})),()=>me(null)},[o,d,m,je,e,k,A,me]),r.jsxs("div",{className:"flex h-full min-h-0 gap-6 p-6",children:[r.jsx("div",{className:"flex flex-col gap-3 flex-1 min-w-0 min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0 overflow-auto -ml-1 pl-1 -mr-4 pr-4",children:m?r.jsx("div",{className:"min-h-full flex items-center justify-center py-6 px-8 min-w-max",children:r.jsx(po,{sessionId:m,deviceId:g,buildId:o==null?void 0:o.id,resetMode:Re,onRecordingUploaded:Ne,onSessionEnded:Be})}):d?r.jsxs("div",{className:"flex flex-col gap-5",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:A,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:"← All Macs"}),r.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Select device"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(pn,{placeholder:"Search device…",value:re,onChange:K}),M.length>0&&r.jsxs(Sn,{value:N||"__all__",onValueChange:I=>{O(I==="__all__"?"":I),T()},children:[r.jsx(Rn,{className:"h-8 w-36 shrink-0",children:r.jsx(Cn,{})}),r.jsxs(jn,{children:[r.jsx(er,{value:"__all__",children:"Any version"}),M.map(I=>r.jsx(er,{value:I,children:I},I))]})]}),ge&&r.jsx(Dt,{children:r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsxs("div",{className:"ml-auto flex items-center gap-2 shrink-0",children:[r.jsx(un,{htmlFor:"reset-mode",className:"text-sm cursor-pointer whitespace-nowrap",children:"Full reset"}),r.jsx("span",{id:"reset-mode-desc",className:"sr-only",children:"When on, erases all data on the next device you pick"}),r.jsx(Zr,{id:"reset-mode","aria-describedby":"reset-mode-desc",checked:ee==="full-erase",onCheckedChange:I=>Z(I?"full-erase":"app-only")})]})}),r.jsx(Ae,{children:ee==="full-erase"?"Erase all data on the next device you pick":"Keep existing data"})]})})]}),V.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:y?"No devices available for this OS.":"Connecting to relay…"}):r.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-2",children:V.map(I=>{const X=I.status==="booted",Q=I.busy,be=Q?"In use":X?"Booted":"Available",Pe=Q?"bg-amber-400":X?"bg-emerald-400":"bg-muted-foreground/40";return r.jsxs("button",{disabled:Q||b||!y,onClick:()=>te(I),className:oe("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:[r.jsx("span",{className:"text-sm font-medium leading-tight",children:I.name}),I.osVersion&&r.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:I.osVersion}),r.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{className:oe("inline-block h-1.5 w-1.5 rounded-full",Pe)}),be]})]},I.id)})}),l&&r.jsx("p",{className:"text-sm text-muted-foreground",children:l})]}):r.jsxs("div",{className:"flex flex-col gap-5",children:[r.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Select Mac"}),j.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:y?`No agents available for ${c}.`:"Connecting to relay…"}):r.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-2",children:j.map(I=>{const X=I.resources,Q=X?Date.now()-X.reportedAt>3e4:!1,be=I.devices.filter(ce=>ce.platform===c).length,Pe=(X==null?void 0:X.cpuPercent)??0,De=X?X.memUsedMB/X.memTotalMB*100:0,ne=Zo(X,Q),Y=ne==="overloaded";return r.jsx(Dt,{children:r.jsxs(Ee,{children:[r.jsx(Te,{asChild:!0,children:r.jsx("span",{tabIndex:Y?0:void 0,className:Y?"cursor-not-allowed":void 0,children:r.jsxs("button",{disabled:Y,"aria-disabled":Y,onClick:()=>p(I.agentName??null),className:oe("flex flex-col gap-3 rounded-lg border p-3 text-left transition-colors min-h-[100px] w-full",Y?"pointer-events-none":"hover:bg-accent"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(ea,{health:ne}),r.jsx("span",{className:"text-sm font-medium leading-tight truncate",children:I.agentName??"Unknown"})]}),Q&&r.jsx("span",{className:"shrink-0 text-[10px] font-medium text-amber-500",children:"Stale"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsxs("span",{children:[be," device",be!==1?"s":""]}),X&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"·"}),r.jsxs("span",{children:[X.slotsAvailable,"/",X.slotsTotal," slots"]})]})]}),X&&!Q&&r.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[r.jsx(fr,{label:"CPU",percent:Pe,colorClass:"bg-blue-400"}),r.jsx(fr,{label:"RAM",percent:De,colorClass:"bg-violet-400"})]})]})})}),Y&&r.jsx(Ae,{children:"This Mac is currently overloaded. Try again later."})]})},I.agentName)})})]})})}),n&&r.jsxs(r.Fragment,{children:[r.jsx(hr,{orientation:"vertical",className:"h-auto"}),r.jsx("div",{className:"w-80 shrink-0 h-full",children:r.jsx(Oo,{buildId:Number(n),recordingsRefreshKey:i})})]})]})}function ea({health:t}){const e={unknown:"bg-muted-foreground/40",healthy:"bg-emerald-400",warning:"bg-amber-400",overloaded:"bg-red-500"}[t];return r.jsx("span",{"data-testid":"resource-health-dot",className:oe("inline-block h-2 w-2 shrink-0 rounded-full",e)})}function fr({label:t,percent:e,colorClass:n}){return r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[r.jsx("span",{children:t}),r.jsxs("span",{children:[e.toFixed(0),"%"]})]}),r.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:r.jsx("div",{className:oe("h-full rounded-full transition-all",n),style:{width:`${Math.min(100,e)}%`}})})]})}export{ua as QASession};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as m,j as s}from"./vendor-react-AJpf4YZ0.js";import{ad as b,a5 as S,C as h,c as p,d as x,b as f,a as k,L as u,I as w,B as C,a2 as P,a3 as j}from"./index-bitr6DIC.js";import{b as E,c as F}from"./vendor-router-ChFy8CZ1.js";const T=P({password:j().min(8),confirm:j()}).refine(r=>r.password===r.confirm,{message:"Passwords do not match",path:["confirm"]});function I(){const r=E(),[g]=F(),a=g.get("token")??"",[n,t]=m.useState("loading"),{register:o,handleSubmit:v,setError:d,formState:{errors:e,isSubmitting:c}}=b({resolver:S(T),mode:"onBlur"});m.useEffect(()=>{if(!a){t("invalid");return}fetch(`/api/v1/auth/reset-password/verify?token=${a}`).then(i=>i.ok?t("valid"):Promise.reject()).catch(()=>t("invalid"))},[a]);async function N(i){try{const l=await fetch("/api/v1/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,password:i.password})});if(!l.ok){const y=await l.json();d("root",{message:y.error??"Failed to reset password"});return}r("/login",{replace:!0})}catch{d("root",{message:"Network error. Please try again."})}}return n==="loading"?s.jsx("div",{className:"flex min-h-svh items-center justify-center"}):n==="invalid"?s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsx(h,{level:4,className:"w-full max-w-sm text-center",children:s.jsxs(p,{children:[s.jsx(x,{children:"Link expired"}),s.jsx(f,{children:"This password reset link is invalid or has expired. Ask your admin to send a new one."})]})})}):s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsxs(h,{level:4,className:"w-full max-w-sm",children:[s.jsxs(p,{className:"text-center",children:[s.jsx(x,{children:"Reset password"}),s.jsx(f,{children:"Enter your new password below."})]}),s.jsx(k,{children:s.jsxs("form",{onSubmit:v(N),className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"password",children:"New password"}),s.jsx(w,{id:"password",type:"password",...o("password")}),e.password&&s.jsx("p",{className:"text-sm text-destructive",children:e.password.message})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"confirm",children:"Confirm password"}),s.jsx(w,{id:"confirm",type:"password",...o("confirm")}),e.confirm&&s.jsx("p",{className:"text-sm text-destructive",children:e.confirm.message})]}),e.root&&s.jsx("p",{className:"text-sm text-destructive",children:e.root.message}),s.jsx(C,{type:"submit",disabled:c,className:"w-full",children:c?"Saving…":"Set new password"})]})})]})})}export{I as ResetPassword};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as f,j as e}from"./vendor-react-AJpf4YZ0.js";import{ai as g,ad as j,a5 as w,C as v,c as N,d as b,a as y,L as i,I as o,B as C,a2 as S,a3 as l}from"./index-bitr6DIC.js";import{b as k}from"./vendor-router-ChFy8CZ1.js";const E=S({email:l().email("Enter a valid email"),password:l().min(8,"Password must be at least 8 characters"),confirm:l()}).refine(a=>a.password===a.confirm,{message:"Passwords do not match",path:["confirm"]});function B(){const a=k(),{resolvedTheme:d}=g(),p=d==="dark"?"/logo-dark.svg":"/logo.svg",{register:r,handleSubmit:x,setError:c,formState:{errors:s,isSubmitting:m}}=j({resolver:w(E),mode:"onBlur"});f.useEffect(()=>{fetch("/api/v1/auth/status").then(t=>t.json()).then(({initialized:t})=>{t&&a("/login",{replace:!0})}).catch(()=>{})},[a]);async function h(t){try{const n=await fetch("/api/v1/auth/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t.email,password:t.password})});if(!n.ok){const u=await n.json();c("root",{message:u.error??"Failed to create account"});return}a("/login",{replace:!0})}catch{c("root",{message:"Network error. Please try again."})}}return e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:p,alt:"tapflow",className:"w-6 h-6"}),e.jsx("span",{className:"text-base font-semibold tracking-tight",children:"tapflow"})]}),e.jsxs(v,{level:4,className:"w-full",children:[e.jsx(N,{className:"text-center",children:e.jsx(b,{className:"text-2xl tracking-display-md",children:"Set up tapflow"})}),e.jsx(y,{children:e.jsxs("form",{onSubmit:x(h),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"email",children:"Admin email"}),e.jsx(o,{id:"email",type:"email",placeholder:"admin@yourteam.com",autoComplete:"email",...r("email")}),s.email&&e.jsx("p",{className:"text-sm text-destructive",children:s.email.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"password",children:"Password"}),e.jsx(o,{id:"password",type:"password",autoComplete:"new-password",...r("password")}),s.password&&e.jsx("p",{className:"text-sm text-destructive",children:s.password.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(o,{id:"confirm",type:"password",autoComplete:"new-password",...r("confirm")}),s.confirm&&e.jsx("p",{className:"text-sm text-destructive",children:s.confirm.message})]}),s.root&&e.jsx("p",{className:"text-sm text-destructive",children:s.root.message}),e.jsx(C,{type:"submit",size:"lg",disabled:m,className:"w-full mt-1",children:m?"Creating account…":"Create admin account"})]})})]})]})})}export{B as Setup};
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as n,j as e}from"./vendor-react-AJpf4YZ0.js";import{W as _,ad as z,a5 as J,B as t,L as D,I as G,h as q,C as U,c as W,d as K,a as X,a4 as j,a2 as I,a3 as u,G as Y}from"./index-bitr6DIC.js";import{D as Z,f as ee,a as se,d as ae,e as ie,S as N,i as w,j as T,g as k,h as i}from"./dialog-DuXZpbiF.js";import{A as ne,c as te,f as le,g as re,d as ce,e as oe,b as de,a as me}from"./alert-dialog-BsXI9SVV.js";import{T as he,d as xe,e as A,c as l,a as je,b as r}from"./table-CHmhGpHG.js";import"./vendor-router-ChFy8CZ1.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ue=[["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"}]],ve=_("user-plus",ue),pe=I({email:u().email(),role:u().min(1)}),ge=I({token:u(),emailSent:Y()});function
|
|
6
|
+
*/const ue=[["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"}]],ve=_("user-plus",ue),pe=I({email:u().email(),role:u().min(1)}),ge=I({token:u(),emailSent:Y()});function Ne(){const[v,R]=n.useState([]),[E,p]=n.useState({}),[g,f]=n.useState(""),[O,b]=n.useState(!1),[o,d]=n.useState(null),{register:V,handleSubmit:H,control:L,reset:P,formState:{errors:S,isSubmitting:y}}=z({resolver:J(pe),mode:"onBlur",defaultValues:{email:"",role:"QA"}});function m(){fetch("/api/v1/team/members",{credentials:"include"}).then(s=>s.json()).then(R)}n.useEffect(()=>{m()},[]);async function $(s){try{const a=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(!a.ok)throw new Error(`Server error: ${a.status}`);const h=ge.parse(await a.json()),c=`${location.origin}/invite?token=${h.token}`;f(c),navigator.clipboard.writeText(c).catch(()=>{}),h.emailSent?j.success(`Invite email sent to ${s.email}`):j.warning("Invite link copied — email could not be sent. Check your SMTP settings.")}catch{j.error("Failed to create invite link")}}function F(s){b(s),s||(f(""),P())}async function M(s,a){await fetch(`/api/v1/team/members/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({role:a})}),m()}async function Q(s){const c=(await(await fetch(`/api/v1/team/members/${s}/send-reset`,{method:"POST",credentials:"include"})).json()).emailSent?"Sent":"No SMTP";p(x=>({...x,[s]:c})),setTimeout(()=>p(x=>{const C={...x};return delete C[s],C}),3e3)}async function B(s){await fetch(`/api/v1/team/members/${s}`,{method:"DELETE",credentials:"include"}),d(null),m()}return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx(ne,{open:o!==null,onOpenChange:s=>{s||d(null)},children:e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(re,{children:"Remove this member?"}),e.jsx(ce,{children:"This member will lose access to the team immediately."})]}),e.jsxs(oe,{children:[e.jsx(de,{children:"Cancel"}),e.jsx(me,{className:"bg-destructive/10 text-destructive hover:bg-destructive/20 border-0",onClick:()=>o!==null&&B(o),children:"Remove"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Team"}),e.jsxs(Z,{open:O,onOpenChange:F,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(t,{size:"sm",children:[e.jsx(ve,{className:"mr-2 h-4 w-4"}),"Invite member"]})}),e.jsxs(se,{className:"sm:max-w-md",children:[e.jsx(ae,{children:e.jsx(ie,{children:"Invite team member"})}),g?e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Invite link copied to clipboard:"}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all",children:g}),e.jsx(t,{onClick:()=>b(!1),children:"Done"})]}):e.jsxs("form",{onSubmit:H($),className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(D,{htmlFor:"invite-email",children:"Email"}),e.jsx(G,{id:"invite-email",type:"email",...V("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(D,{htmlFor:"invite-role",children:"Role"}),e.jsx(q,{name:"role",control:L,render:({field:s})=>e.jsxs(N,{value:s.value,onValueChange:s.onChange,children:[e.jsx(w,{id:"invite-role",children:e.jsx(T,{})}),e.jsxs(k,{children:[e.jsx(i,{value:"Admin",children:"Admin"}),e.jsx(i,{value:"Developer",children:"Developer"}),e.jsx(i,{value:"QA",children:"QA"}),e.jsx(i,{value:"Viewer",children:"Viewer"})]})]})})]}),e.jsx(t,{type:"submit",disabled:y,children:y?"Creating link…":"Generate invite link"})]})]})]})]}),e.jsxs(U,{children:[e.jsx(W,{children:e.jsxs(K,{children:["Members (",v.length,")"]})}),e.jsx(X,{className:"px-4 pt-0 pb-2",children:e.jsxs(he,{children:[e.jsx(xe,{children:e.jsxs(A,{children:[e.jsx(l,{children:"Nickname"}),e.jsx(l,{children:"Email"}),e.jsx(l,{children:"Role"}),e.jsx(l,{children:"Joined"}),e.jsx(l,{className:"w-10"})]})}),e.jsx(je,{children:v.map(s=>e.jsxs(A,{className:"hover:bg-transparent",children:[e.jsx(r,{className:"font-medium",children:s.display_name||"—"}),e.jsx(r,{className:"text-muted-foreground text-sm",children:s.email}),e.jsx(r,{children:e.jsxs(N,{value:s.role,onValueChange:a=>M(s.id,a),children:[e.jsx(w,{className:"h-7 w-28",children:e.jsx(T,{})}),e.jsxs(k,{children:[e.jsx(i,{value:"Admin",children:"Admin"}),e.jsx(i,{value:"Developer",children:"Developer"}),e.jsx(i,{value:"QA",children:"QA"}),e.jsx(i,{value:"Viewer",children:"Viewer"})]})]})}),e.jsx(r,{className:"text-muted-foreground text-sm",children:new Date(s.joined_at).toLocaleDateString()}),e.jsx(r,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{variant:"secondary",size:"nav",onClick:()=>Q(s.id),children:E[s.id]??"Reset pwd"}),e.jsx(t,{variant:"destructive",size:"nav",onClick:()=>d(s.id),children:"Remove"})]})})]},s.id))})]})})]})]})}export{Ne as TeamSettings};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as n,j as e}from"./vendor-react-AJpf4YZ0.js";import{ad as $,a5 as H,B as d,a4 as t,L as k,I as S,C as O,c as z,d as V,b as W,a as M,a2 as J,a3 as A}from"./index-bitr6DIC.js";import{B as I}from"./badge-BkdYQFsh.js";import{A as U,c as q,f as G,g as K,d as Q,e as X,b as Y}from"./alert-dialog-BsXI9SVV.js";import{D as Z,f as ee,a as se,d as te,e as ae,S as ne,i as re,j as oe,g as ie,h as B}from"./dialog-DuXZpbiF.js";import{T as le,d as ce,e as w,c as x,a as de,b as i}from"./table-CHmhGpHG.js";import{P as xe,T as he}from"./trash-2-QI162w2K.js";import"./vendor-router-ChFy8CZ1.js";async function me(){const a=window.location.protocol==="https:"?"wss":"ws";if(["localhost","127.0.0.1","[::1]"].includes(window.location.hostname))try{const h=await fetch("/api/v1/relay/host",{credentials:"include"});if(h.ok){const{lanHost:l,port:o}=await h.json();if(l)return`${a}://${l}:${o}`}}catch{}return`${a}://${window.location.host}`}const pe=J({name:A().min(1),expiresDays:A().refine(a=>{const r=parseInt(a,10);return!isNaN(r)&&r>=1&&r<=365},{message:"Must be between 1 and 365"})});function Ne(){const[a,r]=n.useState([]),[h,l]=n.useState(!1),[o,y]=n.useState(""),[c,v]=n.useState("api"),[N,b]=n.useState(""),[u,j]=n.useState(null),{register:T,handleSubmit:E,reset:_,formState:{errors:m,isSubmitting:C}}=$({resolver:H(pe),mode:"onBlur",defaultValues:{name:"",expiresDays:"30"}});function g(){fetch("/api/v1/tokens",{credentials:"include"}).then(s=>s.json()).then(r)}n.useEffect(()=>{g()},[]);async function F(s){try{const p=await fetch("/api/v1/tokens",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,expires_in_days:parseInt(s.expiresDays,10),...c==="agent"?{scope:"agent"}:{}})});if(!p.ok){const f=await p.json().catch(()=>null);t.error((f==null?void 0:f.error)??"Failed to create token");return}const P=await p.json();c==="agent"&&b(await me()),t.success("Token created"),y(P.token),g()}catch{t.error("Network error")}}function R(s){l(s),s||(y(""),v("api"),b(""),_())}async function L(s){try{return(await fetch(`/api/v1/tokens/${s}`,{method:"DELETE",credentials:"include"})).ok?(t.success("Token revoked"),g(),!0):(t.error("Failed to revoke token"),!1)}catch{return t.error("Network error"),!1}}function D(s){return s.expires_at&&new Date(s.expires_at)<new Date}return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Personal Access Tokens"}),e.jsxs(Z,{open:h,onOpenChange:R,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(d,{size:"sm",children:[e.jsx(xe,{className:"mr-2 h-4 w-4"}),"New token"]})}),e.jsxs(se,{className:"sm:max-w-md",children:[e.jsx(te,{children:e.jsx(ae,{children:"Create token"})}),o?e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Copy this token now — it won't be shown again."}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all font-mono",children:o}),c==="agent"&&N&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this on the agent Mac to connect it to this relay:"}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all font-mono",children:`tapflow agent start --relay ${N} --token ${o}`})]}),e.jsx(d,{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{t.success("Token copied to clipboard"),l(!1)}).catch(()=>t.error("Failed to copy — copy manually"))},children:"Copy & close"})]}):e.jsxs("form",{onSubmit:E(F),className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"token-name",children:"Name"}),e.jsx(S,{id:"token-name",placeholder:"e.g. ci-deploy",...T("name")}),m.name&&e.jsx("p",{className:"text-sm text-destructive",children:m.name.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"expires",children:"Expires in (days)"}),e.jsx(S,{id:"expires",type:"number",...T("expiresDays")}),m.expiresDays&&e.jsx("p",{className:"text-sm text-destructive",children:m.expiresDays.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"token-type",children:"Type"}),e.jsxs(ne,{value:c,onValueChange:s=>v(s),children:[e.jsx(re,{id:"token-type",children:e.jsx(oe,{})}),e.jsxs(ie,{children:[e.jsx(B,{value:"api",children:"API — CI uploads & API access"}),e.jsx(B,{value:"agent",children:"Agent — connect remote device agents (Admin only)"})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Scope: ",e.jsx(I,{variant:"secondary",children:c==="agent"?"agent":"view, builds:write"})]}),e.jsx(d,{type:"submit",disabled:C,children:C?"Creating…":"Create token"})]})]})]})]}),e.jsxs(O,{children:[e.jsxs(z,{children:[e.jsx(V,{children:"Active tokens"}),e.jsxs(W,{children:["Use these tokens with ",e.jsx("code",{className:"text-xs",children:"Authorization: Bearer <token>"})," for API deployments."]})]}),e.jsx(M,{className:"px-4 pt-0 pb-2",children:e.jsxs(le,{children:[e.jsx(ce,{children:e.jsxs(w,{children:[e.jsx(x,{children:"Name"}),e.jsx(x,{children:"Scope"}),e.jsx(x,{children:"Last used"}),e.jsx(x,{children:"Expires"}),e.jsx(x,{className:"w-10"})]})}),e.jsx(de,{children:a.length===0?e.jsx(w,{children:e.jsx(i,{colSpan:5,className:"h-20 text-center text-muted-foreground",children:"No tokens yet."})}):a.map(s=>e.jsxs(w,{className:"hover:bg-transparent",children:[e.jsx(i,{className:"font-medium",children:s.name}),e.jsx(i,{children:e.jsx(I,{variant:"secondary",children:s.scope})}),e.jsx(i,{className:"text-muted-foreground text-sm",children:s.last_used_at?new Date(s.last_used_at).toLocaleDateString():"Never"}),e.jsx(i,{children:s.expires_at?e.jsx("span",{className:D(s)?"text-destructive text-sm":"text-muted-foreground text-sm",children:D(s)?"Expired":new Date(s.expires_at).toLocaleDateString()}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Never"})}),e.jsx(i,{children:e.jsx(d,{variant:"destructive",size:"icon",className:"h-7 w-7","aria-label":"Revoke token",onClick:()=>j(s.id),children:e.jsx(he,{className:"h-4 w-4"})})})]},s.id))})]})})]}),e.jsx(U,{open:u!==null,onOpenChange:s=>{s||j(null)},children:e.jsxs(q,{children:[e.jsxs(G,{children:[e.jsx(K,{children:"Revoke token?"}),e.jsx(Q,{children:"Any active API calls using this token will immediately fail."})]}),e.jsxs(X,{children:[e.jsx(Y,{children:"Cancel"}),e.jsx(d,{variant:"destructive",onClick:async()=>{if(u===null)return;await L(u)&&j(null)},children:"Revoke"})]})]})})]})}export{Ne as TokenSettings};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as r,j as o}from"./vendor-react-AJpf4YZ0.js";import{m as O,a9 as u,j as T,K as S,n as b,k as $,i as m,Q as v,l as E,O as h,D as z,o as F,J as g,H as x}from"./index-bitr6DIC.js";var H=Object.defineProperty,n=(t,e)=>H(t,"name",{value:e,configurable:!0}),k="AlertDialog",[M,pe]=h(k,[v]),c=v(),I=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(z,{...l,...a,modal:!0})},"AlertDialog"),J=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(F,{...s,...i,ref:a})},"AlertDialogTrigger")),K=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(O,{...l,...a})},"AlertDialogPortal"),L=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(E,{...s,...i,ref:a})},"AlertDialogOverlay")),Q="AlertDialogContent",[V,q]=M(Q),B=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,children:i,...s}=e,p=c(l),f=r.useRef(null),P=u(a,f),D=r.useRef(null);return o.jsx(V,{scope:l,cancelRef:D,children:o.jsx(T,{role:"alertdialog",...p,...s,ref:P,onOpenAutoFocus:S(s.onOpenAutoFocus,d=>{var A;d.preventDefault(),(A=D.current)==null||A.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:i})})},"AlertDialogContent")),G=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(b,{...s,...i,ref:a})},"AlertDialogTitle")),U=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx($,{...s,...i,ref:a})},"AlertDialogDescription")),W=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(m,{...s,...i,ref:a})},"AlertDialogAction")),X="AlertDialogCancel",Y=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,{cancelRef:s}=q(X,l),p=c(l),f=u(a,s);return o.jsx(m,{...p,...i,ref:f})},"AlertDialogCancel")),Z=I,ee=J,ae=K,N=L,j=B,y=W,_=Y,C=G,R=U;const fe=Z,De=ee,te=ae,w=r.forwardRef(({className:t,...e},a)=>o.jsx(N,{className:g("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:a}));w.displayName=N.displayName;const oe=r.forwardRef(({className:t,...e},a)=>o.jsxs(te,{children:[o.jsx(w,{}),o.jsx(j,{ref:a,className:g("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));oe.displayName=j.displayName;const le=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col space-y-2 text-center sm:text-left",t),...e});le.displayName="AlertDialogHeader";const re=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});re.displayName="AlertDialogFooter";const se=r.forwardRef(({className:t,...e},a)=>o.jsx(C,{ref:a,className:g("text-lg font-semibold",t),...e}));se.displayName=C.displayName;const ie=r.forwardRef(({className:t,...e},a)=>o.jsx(R,{ref:a,className:g("text-sm text-muted-foreground",t),...e}));ie.displayName=R.displayName;const ne=r.forwardRef(({className:t,...e},a)=>o.jsx(y,{ref:a,className:g(x(),t),...e}));ne.displayName=y.displayName;const ce=r.forwardRef(({className:t,...e},a)=>o.jsx(_,{ref:a,className:g(x({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ce.displayName=_.displayName;export{fe as A,ne as a,ce as b,oe as c,ie as d,re as e,le as f,se as g,De as h};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as n}from"./vendor-react-AJpf4YZ0.js";import{J as d,a0 as o}from"./index-bitr6DIC.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
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{W as r,
|
|
1
|
+
import{W as r,I as o}from"./index-bitr6DIC.js";import{j as i}from"./vendor-react-AJpf4YZ0.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const c=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],
|
|
6
|
+
*/const c=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],h=r("play",c);/**
|
|
7
7
|
* @license lucide-react v0.577.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const d=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],l=r("search",d);function
|
|
11
|
+
*/const d=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],l=r("search",d);function m({value:e,onChange:t,placeholder:a,className:n}){return i.jsxs("div",{className:"relative",children:[i.jsx(l,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),i.jsx(o,{placeholder:a,value:e,onChange:s=>t(s.target.value),className:`h-8 pl-8 ${n??"w-48"}`})]})}async function y(){const e=await fetch("/api/v1/apps",{credentials:"include"});return e.ok?(await e.json()).items:[]}async function b({appId:e,search:t,statusFilter:a}){const n=new URLSearchParams({app_id:String(e),limit:"100",sort:"uploaded_at",dir:"desc"});t&&n.set("q",t),a&&a!=="all"&&n.set("status",a);const s=await fetch(`/api/v1/builds?${n}`,{credentials:"include"});return s.ok?(await s.json()).items:[]}async function w(e){const t=await fetch("/api/v1/apps",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return t.status===409?{error:"App with this bundle ID and platform already exists"}:t.ok?t.json():null}async function _(e,t){await fetch(`/api/v1/builds/${e}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status_label:t})})}async function j(e){const t=await fetch(`/api/v1/builds/${e}/schedule-deletion`,{method:"POST",credentials:"include"});if(!t.ok)throw new Error(`Failed to schedule deletion (${t.status})`);return(await t.json()).delete_after}async function v(e){const t=await fetch(`/api/v1/builds/${e}/schedule-deletion`,{method:"DELETE",credentials:"include"});if(!t.ok)throw new Error(`Failed to cancel scheduled deletion (${t.status})`)}async function g(e){const t=await fetch(`/api/v1/builds/${e}`,{credentials:"include"});return t.ok?t.json():null}function k(e){const t=new Map;for(const a of e){const n=a.version_name??"Unversioned";t.has(n)||t.set(n,[]),t.get(n).push(a)}return Array.from(t.entries()).map(([a,n])=>({versionName:a,builds:n}))}const S={Backlog:"backlog","In Progress":"progress",Done:"done",Rejected:"rejected"};function $(e){return e.version_name&&e.build_number?`${e.version_name} · build ${e.build_number}`:e.version_name??e.version_label??(e.build_number?`build ${e.build_number}`:"Build")}export{h as P,S,l as a,m as b,$ as c,v as d,w as e,g as f,y as g,b as h,k as i,j as s,_ as u};
|
|
Binary file
|