@tapflowio/relay 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/package.json +4 -4
  2. package/public/assets/{AISessionWatch-DxsyhjAy.js → AISessionWatch-DMfOAt_U.js} +7 -7
  3. package/public/assets/AISessionWatch-DMfOAt_U.js.br +0 -0
  4. package/public/assets/AISessionWatch-DMfOAt_U.js.gz +0 -0
  5. package/public/assets/AndroidDeviceScreen-1RaPu10r.js +35 -0
  6. package/public/assets/AndroidDeviceScreen-1RaPu10r.js.br +0 -0
  7. package/public/assets/AndroidDeviceScreen-1RaPu10r.js.gz +0 -0
  8. package/public/assets/{AppCenter-CZMTgfBh.js → AppCenter-BWgstOJH.js} +6 -6
  9. package/public/assets/AppCenter-BWgstOJH.js.br +0 -0
  10. package/public/assets/AppCenter-BWgstOJH.js.gz +0 -0
  11. package/public/assets/{Default-DCk7wCIg.js → Default-Obywi6hR.js} +1 -1
  12. package/public/assets/Default-Obywi6hR.js.br +0 -0
  13. package/public/assets/Default-Obywi6hR.js.gz +0 -0
  14. package/public/assets/{Invite-BNgu8qb9.js → Invite-BVRKLYJu.js} +1 -1
  15. package/public/assets/Invite-BVRKLYJu.js.br +0 -0
  16. package/public/assets/Invite-BVRKLYJu.js.gz +0 -0
  17. package/public/assets/{MacResources-B26lSN5B.js → MacResources-B6_Es8ye.js} +1 -1
  18. package/public/assets/MacResources-B6_Es8ye.js.br +0 -0
  19. package/public/assets/MacResources-B6_Es8ye.js.gz +0 -0
  20. package/public/assets/QASession-BuQdx-pq.js +81 -0
  21. package/public/assets/QASession-BuQdx-pq.js.br +0 -0
  22. package/public/assets/QASession-BuQdx-pq.js.gz +0 -0
  23. package/public/assets/{ResetPassword-CQsALVBn.js → ResetPassword-DU97TnMC.js} +1 -1
  24. package/public/assets/ResetPassword-DU97TnMC.js.br +0 -0
  25. package/public/assets/ResetPassword-DU97TnMC.js.gz +0 -0
  26. package/public/assets/{RunDetail-D0JKuXAS.js → RunDetail-BspFUFg2.js} +4 -4
  27. package/public/assets/RunDetail-BspFUFg2.js.br +0 -0
  28. package/public/assets/RunDetail-BspFUFg2.js.gz +0 -0
  29. package/public/assets/{Runs-DSHpDs0m.js → Runs-BdCnN_dH.js} +2 -2
  30. package/public/assets/Runs-BdCnN_dH.js.br +0 -0
  31. package/public/assets/Runs-BdCnN_dH.js.gz +0 -0
  32. package/public/assets/{Setup-4-HC1rwb.js → Setup-D4DsciMG.js} +1 -1
  33. package/public/assets/Setup-D4DsciMG.js.br +0 -0
  34. package/public/assets/Setup-D4DsciMG.js.gz +0 -0
  35. package/public/assets/{Team-CgJM95TR.js → Team-B2Txvi0a.js} +2 -2
  36. package/public/assets/Team-B2Txvi0a.js.br +0 -0
  37. package/public/assets/Team-B2Txvi0a.js.gz +0 -0
  38. package/public/assets/{Tokens-D2wbiDVG.js → Tokens-D-ekP8kU.js} +1 -1
  39. package/public/assets/Tokens-D-ekP8kU.js.br +0 -0
  40. package/public/assets/Tokens-D-ekP8kU.js.gz +0 -0
  41. package/public/assets/WatchedDevice-D-SfDxp8.js +1 -0
  42. package/public/assets/WatchedDevice-D-SfDxp8.js.br +0 -0
  43. package/public/assets/WatchedDevice-D-SfDxp8.js.gz +0 -0
  44. package/public/assets/{aiSession-DE80E1QU.js → aiSession-p7Uu2swu.js} +6 -6
  45. package/public/assets/aiSession-p7Uu2swu.js.br +0 -0
  46. package/public/assets/aiSession-p7Uu2swu.js.gz +0 -0
  47. package/public/assets/{alert-dialog-nxQTqXgk.js → alert-dialog-DPNbpxqG.js} +1 -1
  48. package/public/assets/alert-dialog-DPNbpxqG.js.br +0 -0
  49. package/public/assets/alert-dialog-DPNbpxqG.js.gz +0 -0
  50. package/public/assets/{badge-DM1m4CLq.js → badge-Bjwwchrt.js} +1 -1
  51. package/public/assets/badge-Bjwwchrt.js.br +0 -0
  52. package/public/assets/badge-Bjwwchrt.js.gz +0 -0
  53. package/public/assets/{dialog-CTc84wr4.js → dialog-CrzZQwxn.js} +1 -1
  54. package/public/assets/dialog-CrzZQwxn.js.br +0 -0
  55. package/public/assets/dialog-CrzZQwxn.js.gz +0 -0
  56. package/public/assets/{field-hint-xptj_gfn.js → field-hint-CIJmSABE.js} +1 -1
  57. package/public/assets/field-hint-CIJmSABE.js.br +2 -0
  58. package/public/assets/field-hint-CIJmSABE.js.gz +0 -0
  59. package/public/assets/index-CiJwpDAf.js +248 -0
  60. package/public/assets/index-CiJwpDAf.js.br +0 -0
  61. package/public/assets/index-CiJwpDAf.js.gz +0 -0
  62. package/public/assets/index-DKKkUgNI.css +1 -0
  63. package/public/assets/index-DKKkUgNI.css.br +0 -0
  64. package/public/assets/index-DKKkUgNI.css.gz +0 -0
  65. package/public/assets/{list-view-BzI8tLvX.js → list-view-DpnCsTM-.js} +1 -1
  66. package/public/assets/list-view-DpnCsTM-.js.br +0 -0
  67. package/public/assets/list-view-DpnCsTM-.js.gz +0 -0
  68. package/public/assets/{pencil-CEWs8Of9.js → pencil-CE5LnE8i.js} +2 -2
  69. package/public/assets/pencil-CE5LnE8i.js.br +0 -0
  70. package/public/assets/pencil-CE5LnE8i.js.gz +0 -0
  71. package/public/assets/{play-Dab2J3Tw.js → play-BR_CdQzZ.js} +2 -2
  72. package/public/assets/play-BR_CdQzZ.js.br +0 -0
  73. package/public/assets/play-BR_CdQzZ.js.gz +0 -0
  74. package/public/assets/{search-input-BK7cFT1m.js → search-input-2MuvmbBR.js} +2 -2
  75. package/public/assets/search-input-2MuvmbBR.js.br +0 -0
  76. package/public/assets/search-input-2MuvmbBR.js.gz +0 -0
  77. package/public/assets/{select-BH7E2Q0r.js → select-7EkQtxVy.js} +3 -3
  78. package/public/assets/select-7EkQtxVy.js.br +0 -0
  79. package/public/assets/select-7EkQtxVy.js.gz +0 -0
  80. package/public/assets/{slider-B4sPZi8m.js → slider-ifEFgQFt.js} +1 -1
  81. package/public/assets/slider-ifEFgQFt.js.br +0 -0
  82. package/public/assets/slider-ifEFgQFt.js.gz +0 -0
  83. package/public/assets/{tabs-CYoB-S2t.js → tabs-SLpwFQLx.js} +1 -1
  84. package/public/assets/tabs-SLpwFQLx.js.br +0 -0
  85. package/public/assets/tabs-SLpwFQLx.js.gz +0 -0
  86. package/public/assets/{tech-label-fz5PvoAL.js → tech-label-DpVGqU2Y.js} +1 -1
  87. package/public/assets/tech-label-DpVGqU2Y.js.br +0 -0
  88. package/public/assets/tech-label-DpVGqU2Y.js.gz +0 -0
  89. package/public/assets/{trash-CZ-V9h2G.js → trash-DFsQhdZ1.js} +3 -3
  90. package/public/assets/trash-DFsQhdZ1.js.br +0 -0
  91. package/public/assets/trash-DFsQhdZ1.js.gz +0 -0
  92. package/public/assets/{video-CilstoqV.js → video-D1ajuM3p.js} +2 -2
  93. package/public/assets/video-D1ajuM3p.js.br +0 -0
  94. package/public/assets/video-D1ajuM3p.js.gz +0 -0
  95. package/public/index.html +2 -2
  96. package/public/index.html.br +0 -0
  97. package/public/index.html.gz +0 -0
  98. package/public/assets/AISessionWatch-DxsyhjAy.js.br +0 -0
  99. package/public/assets/AISessionWatch-DxsyhjAy.js.gz +0 -0
  100. package/public/assets/AndroidDeviceScreen-C55msKfh.js +0 -35
  101. package/public/assets/AndroidDeviceScreen-C55msKfh.js.br +0 -0
  102. package/public/assets/AndroidDeviceScreen-C55msKfh.js.gz +0 -0
  103. package/public/assets/AppCenter-CZMTgfBh.js.br +0 -0
  104. package/public/assets/AppCenter-CZMTgfBh.js.gz +0 -0
  105. package/public/assets/Default-DCk7wCIg.js.br +0 -0
  106. package/public/assets/Default-DCk7wCIg.js.gz +0 -0
  107. package/public/assets/Invite-BNgu8qb9.js.br +0 -0
  108. package/public/assets/Invite-BNgu8qb9.js.gz +0 -0
  109. package/public/assets/MacResources-B26lSN5B.js.br +0 -0
  110. package/public/assets/MacResources-B26lSN5B.js.gz +0 -0
  111. package/public/assets/QASession-Rin1Ol-2.js +0 -81
  112. package/public/assets/QASession-Rin1Ol-2.js.br +0 -0
  113. package/public/assets/QASession-Rin1Ol-2.js.gz +0 -0
  114. package/public/assets/ResetPassword-CQsALVBn.js.br +0 -0
  115. package/public/assets/ResetPassword-CQsALVBn.js.gz +0 -0
  116. package/public/assets/RunDetail-D0JKuXAS.js.br +0 -0
  117. package/public/assets/RunDetail-D0JKuXAS.js.gz +0 -0
  118. package/public/assets/Runs-DSHpDs0m.js.br +0 -0
  119. package/public/assets/Runs-DSHpDs0m.js.gz +0 -0
  120. package/public/assets/Setup-4-HC1rwb.js.br +0 -0
  121. package/public/assets/Setup-4-HC1rwb.js.gz +0 -0
  122. package/public/assets/Team-CgJM95TR.js.br +0 -0
  123. package/public/assets/Team-CgJM95TR.js.gz +0 -0
  124. package/public/assets/Tokens-D2wbiDVG.js.br +0 -0
  125. package/public/assets/Tokens-D2wbiDVG.js.gz +0 -0
  126. package/public/assets/WatchedDevice-CpaKHa1x.js +0 -1
  127. package/public/assets/WatchedDevice-CpaKHa1x.js.br +0 -0
  128. package/public/assets/WatchedDevice-CpaKHa1x.js.gz +0 -0
  129. package/public/assets/aiSession-DE80E1QU.js.br +0 -0
  130. package/public/assets/aiSession-DE80E1QU.js.gz +0 -0
  131. package/public/assets/alert-dialog-nxQTqXgk.js.br +0 -0
  132. package/public/assets/alert-dialog-nxQTqXgk.js.gz +0 -0
  133. package/public/assets/badge-DM1m4CLq.js.br +0 -0
  134. package/public/assets/badge-DM1m4CLq.js.gz +0 -0
  135. package/public/assets/dialog-CTc84wr4.js.br +0 -0
  136. package/public/assets/dialog-CTc84wr4.js.gz +0 -0
  137. package/public/assets/field-hint-xptj_gfn.js.br +0 -0
  138. package/public/assets/field-hint-xptj_gfn.js.gz +0 -0
  139. package/public/assets/index-2zL1a5_0.js +0 -248
  140. package/public/assets/index-2zL1a5_0.js.br +0 -0
  141. package/public/assets/index-2zL1a5_0.js.gz +0 -0
  142. package/public/assets/index-h2hiZ2OM.css +0 -1
  143. package/public/assets/index-h2hiZ2OM.css.br +0 -0
  144. package/public/assets/index-h2hiZ2OM.css.gz +0 -0
  145. package/public/assets/list-view-BzI8tLvX.js.br +0 -0
  146. package/public/assets/list-view-BzI8tLvX.js.gz +0 -0
  147. package/public/assets/pencil-CEWs8Of9.js.br +0 -0
  148. package/public/assets/pencil-CEWs8Of9.js.gz +0 -0
  149. package/public/assets/play-Dab2J3Tw.js.br +0 -0
  150. package/public/assets/play-Dab2J3Tw.js.gz +0 -0
  151. package/public/assets/search-input-BK7cFT1m.js.br +0 -0
  152. package/public/assets/search-input-BK7cFT1m.js.gz +0 -0
  153. package/public/assets/select-BH7E2Q0r.js.br +0 -0
  154. package/public/assets/select-BH7E2Q0r.js.gz +0 -0
  155. package/public/assets/slider-B4sPZi8m.js.br +0 -0
  156. package/public/assets/slider-B4sPZi8m.js.gz +0 -0
  157. package/public/assets/tabs-CYoB-S2t.js.br +0 -0
  158. package/public/assets/tabs-CYoB-S2t.js.gz +0 -0
  159. package/public/assets/tech-label-fz5PvoAL.js.br +0 -3
  160. package/public/assets/tech-label-fz5PvoAL.js.gz +0 -0
  161. package/public/assets/trash-CZ-V9h2G.js.br +0 -0
  162. package/public/assets/trash-CZ-V9h2G.js.gz +0 -0
  163. package/public/assets/video-CilstoqV.js.br +0 -0
  164. package/public/assets/video-CilstoqV.js.gz +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapflowio/relay",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "WebSocket relay server for tapflow — NAT traversal, session routing, JWT auth, bundled dashboard",
5
5
  "keywords": [
6
6
  "tapflow",
@@ -49,11 +49,11 @@
49
49
  "better-sqlite3": "^12.11.1",
50
50
  "busboy": "^1.6.0",
51
51
  "jsonwebtoken": "^9.0.3",
52
- "nodemailer": "^10.1.7",
52
+ "nodemailer": "^10.2.1",
53
53
  "ws": "^8.22.0",
54
54
  "zod": "^4.6.7",
55
- "@tapflowio/agent-core": "0.30.0",
56
- "@tapflowio/protocol": "0.30.0"
55
+ "@tapflowio/agent-core": "0.31.0",
56
+ "@tapflowio/protocol": "0.31.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/better-sqlite3": "^7.6.13",
@@ -1,30 +1,30 @@
1
- import{c as H,r as x,j as n}from"./vendor-react-DTSdA8m-.js";import{G as T,a2 as oe,a3 as ie,ax as le,O as re,ak as ce,S as de,B as fe}from"./index-2zL1a5_0.js";import{u as ue}from"./useRelay-CES3I1Mt.js";import{k as he,C as me,H as pe}from"./AndroidDeviceScreen-C55msKfh.js";import{N as xe,M as ye,i as ke,t as ge,a as je,b as be,W as ve}from"./WatchedDevice-CpaKHa1x.js";import{L as we,D as _e,K as Se,H as Ne,h as U,w as Ae,a as Re,A as Me}from"./aiSession-DE80E1QU.js";import{P as Le}from"./play-Dab2J3Tw.js";import{d as ze,L as Ce}from"./vendor-router-B1pQim9Z.js";/**
2
- * @license lucide-react v1.59.0 - ISC
1
+ import{c as H,r as x,j as n}from"./vendor-react-DTSdA8m-.js";import{G as T,a2 as oe,a3 as ie,ax as le,O as re,ak as ce,S as de,B as fe}from"./index-CiJwpDAf.js";import{u as ue}from"./useRelay-CES3I1Mt.js";import{n as he,C as me,H as pe}from"./AndroidDeviceScreen-1RaPu10r.js";import{N as xe,M as ye,i as ke,t as ge,a as je,b as be,W as ve}from"./WatchedDevice-D-SfDxp8.js";import{L as we,D as _e,K as Se,H as Ne,h as U,w as Ae,a as Re,A as Me}from"./aiSession-p7Uu2swu.js";import{P as Le}from"./play-BR_CdQzZ.js";import{d as ze,L as Ce}from"./vendor-router-B1pQim9Z.js";/**
2
+ * @license lucide-react v1.61.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
6
  */const X={name:"corner-down-left",size:24,node:[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]};X.node;const De=T(X);/**
7
- * @license lucide-react v1.59.0 - ISC
7
+ * @license lucide-react v1.61.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
11
  */const Z={name:"eraser",size:24,node:[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]};Z.node;const He=T(Z);/**
12
- * @license lucide-react v1.59.0 - ISC
12
+ * @license lucide-react v1.61.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */const J={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};J.node;const Te=T(J);/**
17
- * @license lucide-react v1.59.0 - ISC
17
+ * @license lucide-react v1.61.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
21
  */const Q={name:"move-horizontal",size:24,node:[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]};Q.node;const Ee=T(Q);/**
22
- * @license lucide-react v1.59.0 - ISC
22
+ * @license lucide-react v1.61.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
26
  */const Y={name:"move-vertical",size:24,node:[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]};Y.node;const $e=T(Y);/**
27
- * @license lucide-react v1.59.0 - ISC
27
+ * @license lucide-react v1.61.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
@@ -0,0 +1,35 @@
1
+ import{c as pe,r as y,j as S}from"./vendor-react-DTSdA8m-.js";const ze={width:324,height:720},Fe={width:540,height:720},Oe={width:376,height:548};function zt(t,e){return t==="foldable"?e==="ios"?Oe:Fe:t!=="tablet"?ze:e==="android"?{width:720,height:450}:Fe}const Ge="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAXpeqz8AAAAASUVORK5CYII=",Me=1500,Le=new Map,We=new WeakSet;function Ot(t,e){const n=Me,s=Math.round(Me*t.width/t.height),i=`${s}x${n}x${e??"guess"}`,o=Le.get(i);if(o)return o;const r={framePng:Ge,bezelWidth:s,bezelHeight:n,compositeWidth:s,compositeHeight:n,padding:{left:0,right:0,top:0,bottom:0},screenRect:{x:0,y:0,width:s,height:n},screenCornerRadius:e??Math.round(s*(s/n>.6?.03:.12)),logicalWidth:Math.round(s/2),logicalHeight:Math.round(n/2),buttons:[]};return Le.set(i,r),We.add(r),r}function Gt(t){return We.has(t)}function jt(){const t=pe.c(4),e=y.useRef(0),[n,s]=y.useState(0);let i,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const a=setInterval(()=>{s(e.current),e.current=0},1e3);return()=>clearInterval(a)},o=[],t[0]=i,t[1]=o):(i=t[0],o=t[1]),y.useEffect(i,o);let r;return t[2]!==n?(r={fps:n,frameCount:e},t[2]=n,t[3]=r):r=t[3],r}class De{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 s=0;s<e;s++)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 je{constructor(){this.bitsArr=[]}bit(e){this.bitsArr.push(e&1)}ue(e){const n=e+1,s=Math.floor(Math.log2(n));for(let i=0;i<s;i++)this.bit(0);for(let i=s;i>=0;i--)this.bit(n>>i&1)}toBytes(){const e=[];for(let n=0;n<this.bitsArr.length;n+=8){let s=0;for(let i=0;i<8;i++)s=s<<1|(this.bitsArr[n+i]??0);e.push(s)}return new Uint8Array(e)}}function $e(t){const e=[];let n=0;for(let s=1;s<t.length;s++){const i=t[s];if(n>=2&&i===3){n=0;continue}e.push(i),n=i===0?n+1:0}return new Uint8Array(e)}function Be(t){const e=[];let n=0;for(const s of t)n>=2&&s<=3&&(e.push(3),n=0),e.push(s),n=s===0?n+1:0;return new Uint8Array(e)}const Xe=new Set([100,110,122,244,44,83,86,118,128,138,139,134,135]);function He(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 ke(t){const e=t.bits(8);t.bits(8);const n=t.bits(8);if(t.ue(),Xe.has(e)){const d=t.ue();if(d===3&&t.flag(),t.ue(),t.ue(),t.flag(),t.flag()){const g=d!==3?8:12;for(let l=0;l<g;l++)if(t.flag()){const h=l<6?16:64;let x=8,U=8;for(let A=0;A<h;A++)U!==0&&(U=(x+t.se()+256)%256),x=U===0?x:U}}}t.ue();const s=t.ue();if(s===0)t.ue();else if(s===1){t.flag(),t.se(),t.se();const d=t.ue();for(let g=0;g<d;g++)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 o={profileIdc:e,levelIdc:n,numRefFrames:i,bitstreamRestriction:!1,maxNumReorderFrames:null,maxDecFrameBuffering:null};if(!t.flag())return{...o,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 a=t.flag();a&&He(t);const f=t.flag();f&&He(t),(a||f)&&t.flag(),t.flag();const c=t.position;return t.flag()?(t.flag(),t.ue(),t.ue(),t.ue(),t.ue(),{...o,vuiPresent:!0,bitstreamRestriction:!0,maxNumReorderFrames:t.ue(),maxDecFrameBuffering:t.ue(),restrictionFlagPos:c}):{...o,vuiPresent:!0,restrictionFlagPos:c}}function Ye(t){const e=ke(new De($e(t)));return{profileIdc:e.profileIdc,levelIdc:e.levelIdc,vuiPresent:e.vuiPresent,bitstreamRestriction:e.bitstreamRestriction,maxNumReorderFrames:e.maxNumReorderFrames,maxDecFrameBuffering:e.maxDecFrameBuffering}}function qe(t){const e=$e(t),n=ke(new De(e));if(!n.vuiPresent||n.restrictionFlagPos<0||n.bitstreamRestriction)return null;const s=new je,i=new De(e);for(let o=0;o<n.restrictionFlagPos;o++)s.bit(i.bit());return s.bit(1),s.bit(1),s.ue(0),s.ue(0),s.ue(0),s.ue(0),s.ue(0),s.ue(n.numRefFrames),s.bit(1),Uint8Array.from([t[0],...Be(s.toBytes())])}function Je(t){const e=[],n=t.length;let s=-1,i=0;for(;i+2<n;){const o=i+3<n&&t[i]===0&&t[i+1]===0&&t[i+2]===0&&t[i+3]===1,r=t[i]===0&&t[i+1]===0&&t[i+2]===1;o||r?(s>=0&&e.push(t.subarray(s,i)),i+=o?4:3,s=i):i++}return s>=0&&e.push(t.subarray(s,n)),e}class Ke{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 s=!1;for(const c of Je(new Uint8Array(e))){const u=c[0]&31;if(u===7){const d=!this.sps||c.length!==this.sps.length||c.some((g,l)=>g!==this.sps[l]);this.sps=c,d&&this.decoder&&(this.decoder.close(),this.decoder=null)}else u===8?this.pps=c:u>=1&&u<=5&&(u===5&&(s=!0),n.push(c))}if(s&&this.sps&&this.pps&&!this.decoder&&this.initDecoder(this.sps,this.pps),!this.decoder||n.length===0)return;let i=0;for(const c of n)i+=4+c.length;const o=new Uint8Array(i),r=new DataView(o.buffer);let a=0;for(const c of n)r.setUint32(a,c.length,!1),a+=4,o.set(c,a),a+=c.length;const f=Math.round(this.frameCount++*(1e6/30));if(this.decodeSampler&&(this.submitAt.set(f,performance.now()),this.submitAt.size>120)){const c=this.submitAt.keys().next().value;c!==void 0&&this.submitAt.delete(c)}try{this.decoder.decode(new EncodedVideoChunk({type:s?"key":"delta",timestamp:f,data:o}))}catch{}}sampleDecode(e){var s;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:((s=this.decoder)==null?void 0:s.decodeQueueSize)??0}))}flush(){var e;(e=this.decoder)==null||e.flush().catch(()=>{})}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(Ye(e)))}catch(n){console.warn("[sps-vui] parse failed",n)}}}initDecoder(e,n){this.logSpsVui(e);const s=qe(e)??e,i=s[0]===0?s.subarray(4):s,o=`avc1.${i[1].toString(16).padStart(2,"0")}${i[2].toString(16).padStart(2,"0")}${i[3].toString(16).padStart(2,"0")}`,r=this.buildAVCC(s,n);this.decoder=new VideoDecoder({output:a=>{this.sampleDecode(a),this.onFrame(a)},error:a=>console.error("[WebCodecsCore]",a)}),this.decoder.configure({codec:o,description:r,optimizeForLatency:!0})}buildAVCC(e,n){const s=e[0]===0?e.subarray(4):e,i=n[0]===0?n.subarray(4):n,o=new Uint8Array(8+s.length+1+2+i.length);let r=0;return o[r++]=1,o[r++]=s[1],o[r++]=s[2],o[r++]=s[3],o[r++]=255,o[r++]=225,o[r++]=s.length>>8&255,o[r++]=s.length&255,o.set(s,r),r+=s.length,o[r++]=1,o[r++]=i.length>>8&255,o[r++]=i.length&255,o.set(i,r),o}}const Qe=`#version 300 es
2
+ in vec2 a_pos;
3
+ out vec2 v_uv;
4
+ void main() {
5
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
6
+ gl_Position = vec4(a_pos, 0.0, 1.0);
7
+ }`,Ze=`#version 300 es
8
+ precision mediump float;
9
+ in vec2 v_uv;
10
+ uniform sampler2D u_tex;
11
+ out vec4 out_color;
12
+ void main() {
13
+ out_color = texture(u_tex, v_uv);
14
+ }`;function et(t){const e=t.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!e)return null;const n=(u,d)=>{const g=e.createShader(u);return e.shaderSource(g,d),e.compileShader(g),g},s=e.createProgram(),i=n(e.VERTEX_SHADER,Qe),o=n(e.FRAGMENT_SHADER,Ze);e.attachShader(s,i),e.attachShader(s,o),e.linkProgram(s),e.deleteShader(i),e.deleteShader(o),e.useProgram(s);const r=e.createVertexArray();e.bindVertexArray(r);const a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);const f=e.getAttribLocation(s,"a_pos");e.enableVertexAttribArray(f),e.vertexAttribPointer(f,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const c=e.createTexture();return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,c),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(s,"u_tex"),0),{gl:e,program:s,tex:c,vao:r}}class tt{constructor(e){this.canvas=e,this.state=null}init(){return this.state=et(this.canvas),this.state!==null}drawFrame(e){const n=this.state;if(!n)return e.close(),null;const s=e.displayWidth,i=e.displayHeight;try{return(this.canvas.width!==s||this.canvas.height!==i)&&(this.canvas.width=s,this.canvas.height=i,n.gl.viewport(0,0,s,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:s,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 st(t){const e=new tt(t);return e.init(),e}class nt{constructor(e=st){this._size=null,this.presented=new Set,this.canvas=document.createElement("canvas"),this.renderer=e(this.canvas),this.core=new Ke(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})}onPresented(e){return this.presented.add(e),()=>{this.presented.delete(e)}}decode(e){this.core.decode(e)}flush(){this.core.flush()}close(){this.core.close(),this.renderer.dispose()}render(e){var s,i;const n=this.renderer.drawFrame(e);if(n){(s=this.decodedCb)==null||s.call(this,performance.now(),this.lastSample),this.lastSample=void 0;for(const o of this.presented)o();(!this._size||this._size.width!==n.width||this._size.height!==n.height)&&(this._size=n,(i=this.resizeCb)==null||i.call(this,n))}}}const it=`#version 300 es
15
+ in vec2 a_pos;
16
+ out vec2 v_uv;
17
+ void main() {
18
+ v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
19
+ gl_Position = vec4(a_pos, 0.0, 1.0);
20
+ }`,ot=`#version 300 es
21
+ precision mediump float;
22
+ in vec2 v_uv;
23
+ uniform sampler2D u_texY;
24
+ uniform sampler2D u_texU;
25
+ uniform sampler2D u_texV;
26
+ out vec4 out_color;
27
+ void main() {
28
+ float Y = (texture(u_texY, v_uv).r - 0.0627451) * 1.1643836; // (y-16/255)*255/219
29
+ float U = (texture(u_texU, v_uv).r - 0.5019608) * 1.1383929; // (u-128/255)*255/224
30
+ float V = (texture(u_texV, v_uv).r - 0.5019608) * 1.1383929;
31
+ float r = Y + 1.5748 * V;
32
+ float g = Y - 0.1873 * U - 0.4681 * V;
33
+ float b = Y + 1.8556 * U;
34
+ out_color = vec4(r, g, b, 1.0);
35
+ }`;function Pe(t,e,n,s){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(s,n),e),i}function rt(t){const e=t.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!e)return null;const n=(g,l)=>{const h=e.createShader(g);return e.shaderSource(h,l),e.compileShader(h),h},s=e.createProgram(),i=n(e.VERTEX_SHADER,it),o=n(e.FRAGMENT_SHADER,ot);e.attachShader(s,i),e.attachShader(s,o),e.linkProgram(s),e.deleteShader(i),e.deleteShader(o),e.useProgram(s);const r=e.createVertexArray();e.bindVertexArray(r);const a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);const f=e.getAttribLocation(s,"a_pos");e.enableVertexAttribArray(f),e.vertexAttribPointer(f,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.pixelStorei(e.UNPACK_ALIGNMENT,1);const c=Pe(e,0,"u_texY",s),u=Pe(e,1,"u_texU",s),d=Pe(e,2,"u_texV",s);return{gl:e,program:s,texY:c,texU:u,texV:d,vao:r}}class at{constructor(e){this.canvas=e,this.state=null}init(){return this.state=rt(this.canvas),this.state!==null}drawI420(e,n,s){const i=this.state;if(!i)return null;const{gl:o}=i,r=n+1>>1,a=s+1>>1,f=n*s,c=r*a,u=e.subarray(0,f),d=e.subarray(f,f+c),g=e.subarray(f+c,f+2*c);(this.canvas.width!==n||this.canvas.height!==s)&&(this.canvas.width=n,this.canvas.height=s,o.viewport(0,0,n,s));const l=(h,x,U,A,z)=>{o.activeTexture(o.TEXTURE0+h),o.bindTexture(o.TEXTURE_2D,x),o.texImage2D(o.TEXTURE_2D,0,o.R8,U,A,0,o.RED,o.UNSIGNED_BYTE,z)};return l(0,i.texY,n,s,u),l(1,i.texU,r,a,d),l(2,i.texV,r,a,g),o.bindVertexArray(i.vao),o.drawArrays(o.TRIANGLES,0,6),o.bindVertexArray(null),{width:n,height:s}}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 ct=0;function lt(t){const e=new at(t);return e.init(),e}function ut(){return new Worker(new URL("/assets/tinyh264.worker-DiJ50Hai.js",import.meta.url),{type:"module"})}class dt{constructor(e=lt,n=ut){this.ready=!1,this.pending=[],this._size=null,this.presented=new Set,this.canvas=document.createElement("canvas"),this.renderer=e(this.canvas),this.worker=n(),this.worker.onmessage=s=>this.onMessage(s.data)}get surface(){return this.canvas}get size(){return this._size}onResize(e){this.resizeCb=e}onDecodedFrame(e){this.decodedCb=e}onPresented(e){return this.presented.add(e),()=>{this.presented.delete(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:ct},[e])}onMessage(e){var s,i;if(e.type==="decoderReady"){this.ready=!0;for(const o of this.pending)this.post(o);this.pending.length=0;return}const n=this.renderer.drawI420(new Uint8Array(e.data),e.width,e.height);if(n){(s=this.decodedCb)==null||s.call(this,performance.now());for(const o of this.presented)o();(!this._size||this._size.width!==n.width||this._size.height!==n.height)&&(this._size=n,(i=this.resizeCb)==null||i.call(this,n))}}}function Ce(){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 ft(t=Ce()){return t.secureContext&&t.webCodecs&&t.webgl2?new nt:t.wasm&&t.webgl2?new dt:null}function Bt(t=Ce()){return t.secureContext&&t.webCodecs&&t.webgl2||t.wasm&&t.webgl2}function Xt(t=Ce()){return t.secureContext&&t.webCodecs&&t.webgl2?"high":t.wasm&&t.webgl2?"standard":"unsupported"}function Yt(t,e,n,s,i,o){const{x:r,y:a,width:f,height:c}=i,u=(t.x-e.left)/e.width,d=(t.y-e.top)/e.height,[g,l]=o===90?[d,1-u]:o===180?[1-u,1-d]:o===270?[1-d,u]:[u,d],h=g*n,x=l*s;return h<r||h>r+f||x<a||x>a+c?null:{x:(h-r)/f,y:(x-a)/c}}function qt(t,e){return t!==void 0?t:e?270:0}function Jt(t,e,n){const s=(t.x-e.left)/e.width,i=(t.y-e.top)/e.height;return s<0||s>1||i<0||i>1?null:n?{x:i,y:1-s}:{x:s,y:i}}function Kt(t,e){switch(e){case 0:return t;case 90:return{x:1-t.y,y:t.x};case 180:return{x:1-t.x,y:1-t.y};case 270:return{x:t.y,y:1-t.x}}}function Qt(t){return{f0:{x:1-t.x,y:1-t.y},f1:t}}function ht(t,e){return t>0?Math.min(1,e/t):1}function gt(t,e){return(t+(e?90:0))%360}function Ae(t,e,n){const s=n===90||n===270;return{width:s?e:t,height:s?t:e}}const pt=1920;function Zt(t){const e=Math.min(1,pt/Math.max(t.width,t.height)),n=s=>Math.max(2,2*Math.round(s*e/2));return{width:n(t.width),height:n(t.height)}}function es(t,e,n,s,i){const{width:o,height:r}=Ae(n,s,i),a=Math.min(t/o,e/r);return{picW:o,picH:r,scale:a,left:(t-o*a)/2,top:(e-r*a)/2}}function mt(t,e,n){const s=t===90||t===270,i=s?n:e,o=s?e:n;return{width:i,height:o,left:(e-i)/2,top:(n-o)/2}}function ts(t,e,n,s){const{width:i,height:o}=Ae(t,e,s);return{width:i,height:o,turn:(n-s+360)%360}}function yt(t){return!t.ready||t.rotating?!1:t.aspectAgrees||!t.frameIsAhead}function xt(t,e,n){if(!t||!e)return!0;const{width:s,height:i}=Ae(t.width,t.height,n);return Math.abs(s/i-e.width/e.height)<.05}function ss(t,e){return Math.max(0,t-e)}const bt=22,Ne=[84,70,70,69],wt=1,Rt=0,Ue=1,vt=2,At=1,Et=2,St=4;function ns(t){if(t.byteLength<bt)return null;const e=new DataView(t);for(let i=0;i<Ne.length;i++)if(e.getUint8(i)!==Ne[i])return null;if(e.getUint8(4)!==wt)return null;const n=e.getUint8(5),s=n&St?vt:n&At?Ue:Rt;return{capturedAt:Number(e.getBigUint64(6)),relayedAt:Number(e.getBigUint64(14)),codec:s,keyframe:s===Ue&&(n&Et)!==0}}function Ve(t){const{binaryFrameHandlerRef:e,perfHookRef:n,frameCount:s}=t,i=y.useRef(t);y.useLayoutEffect(()=>{i.current=t},[t]),y.useEffect(()=>{let o=null,r=!1,a=!1,f;const c=()=>{if(o)return o;if(r)return null;const u=ft();return u?(o=u,u.onResize(d=>i.current.onResize(d)),f=i.current.onDecoderReady(u),u):(r=!0,i.current.onUnsupported(),console.warn("[decoder] none available — set up HTTPS or use a supported browser"),null)};return e.current=(u,d)=>{var h;const g=i.current.onJpegFrame;if(g&&(d==null?void 0:d.codec)!==Ue){g(u,d);return}const l=c();if(l){if(!a){if(!(d!=null&&d.keyframe))return;a=!0}l.decode(u),d!=null&&d.flush&&((h=l.flush)==null||h.call(l)),s.current+=1}},()=>{e.current=void 0,typeof f=="function"&&f(),o==null||o.close(),o==null||o.surface.remove(),o=null}},[e,n,s])}const _t=2500;function is(t){const e=pe.c(26),{chrome:n,binaryFrameHandlerRef:s,perfHookRef:i,fps:o,frameCount:r,onCanvasResize:a}=t,f=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(0),g=y.useRef(0),[l,h]=y.useState(!1),[x,U]=y.useState(!1);o!==0&&x&&U(!1);let A,z;e[0]!==l||e[1]!==o?(A=()=>{if(o!==0||!l)return;const m=setTimeout(()=>U(!0),_t);return()=>clearTimeout(m)},z=[o,l],e[0]=l,e[1]=o,e[2]=A,e[3]=z):(A=e[2],z=e[3]),y.useEffect(A,z);const[O,k]=y.useState(!1),H=y.useRef(null);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=m=>{const p=f.current;p&&(m.style.left=p.style.left,m.style.top=p.style.top,m.style.width=p.style.width,m.style.height=p.style.height,m.style.borderRadius=p.style.borderRadius,m.style.maskImage=p.style.maskImage)},e[4]=_):_=e[4];const C=_;let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{H.current&&C(H.current)},e[5]=N):N=e[5];let T;e[6]!==n?(T=[n],e[6]=n,e[7]=T):T=e[7],y.useLayoutEffect(N,T);let F;e[8]===Symbol.for("react.memo_cache_sentinel")?(F=()=>k(!0),e[8]=F):F=e[8];let I;e[9]!==a?(I=m=>{const p=f.current;p&&(p.width!==m.width||p.height!==m.height)&&(p.width=m.width,p.height=m.height,a==null||a({width:m.width,height:m.height})),h(!0)},e[9]=a,e[10]=I):I=e[10];let W;e[11]===Symbol.for("react.memo_cache_sentinel")?(W=m=>{var G,M;const p=m.surface;p.style.position="absolute",C(p),H.current=p,p.style.objectFit="fill",p.style.zIndex="3",p.style.pointerEvents="none",(G=c.current)==null||G.appendChild(p);let R=null;const v=()=>{R=null;const P=f.current,ne=P==null?void 0:P.getContext("2d");if(P&&ne&&m.size)try{ne.drawImage(m.surface,0,0,P.width,P.height)}catch{}},b=(M=m.onPresented)==null?void 0:M.call(m,()=>{R===null&&(R=requestAnimationFrame(v))});if(!b){const P=()=>{v(),R=requestAnimationFrame(P)};R=requestAnimationFrame(P)}return()=>{b==null||b(),R!==null&&cancelAnimationFrame(R),H.current===p&&(H.current=null)}},e[11]=W):W=e[11];let E;e[12]!==r||e[13]!==a||e[14]!==i?(E=m=>{const p=performance.now();d.current&&p-d.current,d.current=p;const R=g.current;createImageBitmap(new Blob([m],{type:"image/jpeg"})).then(v=>{if(performance.now()-p,g.current!==R){v.close();return}const b=f.current,G=b==null?void 0:b.getContext("2d");if(!b||!G){v.close();return}(b.width!==v.width||b.height!==v.height)&&(b.width=v.width,b.height=v.height,a==null||a({width:v.width,height:v.height}));const M=performance.now();G.drawImage(v,0,0),performance.now()-M,v.close(),h(!0),r.current=r.current+1}).catch(Tt)},e[12]=r,e[13]=a,e[14]=i,e[15]=E):E=e[15];let $;e[16]!==s||e[17]!==r||e[18]!==i||e[19]!==I||e[20]!==E?($={binaryFrameHandlerRef:s,perfHookRef:i,frameCount:r,onUnsupported:F,onResize:I,onDecoderReady:W,onJpegFrame:E},e[16]=s,e[17]=r,e[18]=i,e[19]=I,e[20]=E,e[21]=$):$=e[21],Ve($);let D;return e[22]!==l||e[23]!==O||e[24]!==x?(D={canvasRef:f,containerRef:c,screenAreaRef:u,canvasReady:l,stalled:x,decoderUnsupported:O},e[22]=l,e[23]=O,e[24]=x,e[25]=D):D=e[25],D}function Tt(){}function Ie(t){const e=t.rolloverOffset.x-t.buttonW/2,n=t.anchor==="top"?t.rolloverOffset.y:t.normalOffset.y-t.buttonH/2;return{left:e,top:n,right:e+t.buttonW,bottom:n+t.buttonH}}function Pt(t,e){return t.map(n=>{const s=Ie(n);if(n.onTop)return s;const i=(s.left+s.right)/2,o=(s.top+s.bottom)/2;switch(n.anchor){case"left":return{...s,left:0,right:i};case"right":return{...s,left:i,right:e.width};case"top":return{...s,top:0,bottom:o};case"bottom":return{...s,top:o,bottom:e.height};default:return s}})}const Dt=12,Ut=233,Ct=234;function It(t,e,n,s){const i=t.map(g=>g.accessibilityTitle);if(s!=="tablet")return i;const o=g=>t.findIndex(l=>l.usagePage===Dt&&l.usage===g),r=o(Ut),a=o(Ct);if(r<0||a<0)return i;const f=g=>{const l=Ie(g),h=(l.left+l.right)/2,x=(l.top+l.bottom)/2;switch(n){case 90:return{x:e.height-x,y:h};case 180:return{x:e.width-h,y:e.height-x};case 270:return{x,y:e.width-h};default:return{x:h,y:x}}},c=f(t[r]),u=f(t[a]);return(Math.abs(c.x-u.x)>Math.abs(c.y-u.y)?c.x>u.x:c.y<u.y)||([i[r],i[a]]=[i[a],i[r]]),i}function Ft(t){return t.includes("Firefox/")&&t.includes("Macintosh")?"linear-gradient(#fff,#fff)":void 0}const Mt=750;function Lt(t){const e=t.compositeWidth/2,n=t.compositeHeight/2,s=ht((t.scaleBasis??t.compositeHeight)/2,Mt),i=Math.round(e*s),o=Math.round(n*s),r=t.screenRect.x/t.compositeWidth*100,a=t.screenRect.y/t.compositeHeight*100,f=t.screenRect.width/t.compositeWidth*100,c=t.screenRect.height/t.compositeHeight*100,u=U=>Math.round(U/2*s),d=u(t.screenCornerRadius),g=t.screenCornerRadii,l=g?`${u(g.topLeft)}px ${u(g.topRight)}px ${u(g.bottomRight)}px ${u(g.bottomLeft)}px`:d>0?`${d}px`:void 0,h=d>0?Ft(navigator.userAgent):void 0,x={left:`${r}%`,top:`${a}%`,width:`${f}%`,height:`${c}%`,borderRadius:l,maskImage:h};return{displayW:i,displayH:o,screenPctLeft:r,screenPctTop:a,screenPctW:f,screenPctH:c,screenBox:x}}function Ht(t,e){const n=pe.c(4),s=y.useRef(e);let i,o;n[0]!==t||n[1]!==e?(i=()=>{var a;if(s.current===e)return;s.current=e;const r=t.current;typeof(r==null?void 0:r.animate)!="function"||(a=window.matchMedia)!=null&&a.call(window,"(prefers-reduced-motion: reduce)").matches||r.animate([{opacity:0},{opacity:1}],{duration:200,easing:"ease-out"})},o=[e,t],n[0]=t,n[1]=e,n[2]=i,n[3]=o):(i=n[2],o=n[3]),y.useEffect(i,o)}function os(t){const e=pe.c(68),{screen:n,chrome:s,formFactor:i,turn:o,joined:r,fps:a,containerHandlers:f,buttons:c,overlay:u,areaOverlay:d,folding:g}=t,l=g===void 0?null:g,{canvasRef:h,containerRef:x,screenAreaRef:U,canvasReady:A,stalled:z}=n;let O;e[0]!==s?(O=Lt(s),e[0]=s,e[1]=O):O=e[1];const{displayW:k,displayH:H,screenBox:_}=O;let C,N,T;if(e[2]!==s.buttons||e[3]!==s.compositeHeight||e[4]!==s.compositeWidth||e[5]!==i||e[6]!==o){const Z={width:s.compositeWidth,height:s.compositeHeight};T=Pt(s.buttons,Z),C=o===90||o===270,N=It(s.buttons,Z,o,i),e[2]=s.buttons,e[3]=s.compositeHeight,e[4]=s.compositeWidth,e[5]=i,e[6]=o,e[7]=C,e[8]=N,e[9]=T}else C=e[7],N=e[8],T=e[9];const F=N,I=o;let W;e[10]!==s.framePng||e[11]!==I||e[12]!==o?(W={turn:o,deg:I,frame:s.framePng,animate:!1},e[10]=s.framePng,e[11]=I,e[12]=o,e[13]=W):W=e[13];const[E,$]=y.useState(W);(E.turn!==o||E.frame!==s.framePng)&&$({turn:o,deg:E.deg+(o-E.turn+540)%360-180,frame:s.framePng,animate:E.frame===s.framePng}),Ht(x,E.frame);const D=l?l==="fold"?"Folding...":"Unfolding...":r&&a===0&&(!A||z)?A?"Waiting for next frame...":"Waiting for first frame...":null,m=E.animate?"motion-safe:duration-300 motion-safe:ease-in-out":"",p=E.animate?`motion-safe:transition-[width,height] ${m}`:void 0,R=C?H:k,v=C?k:H;let b;e[14]!==R||e[15]!==v?(b={width:R,height:v,position:"relative",flexShrink:0},e[14]=R,e[15]=v,e[16]=b):b=e[16];const G=E.animate?`cursor-default motion-safe:transition-transform ${m}`:"cursor-default",M=`translate(-50%, -50%) rotate(${E.deg}deg)`;let P;e[17]!==H||e[18]!==k||e[19]!==M?(P={position:"absolute",top:"50%",left:"50%",width:k,height:H,transform:M,transformOrigin:"center center"},e[17]=H,e[18]=k,e[19]=M,e[20]=P):P=e[20];const ne=`data:image/png;base64,${s.framePng}`;let ie;e[21]===Symbol.for("react.memo_cache_sentinel")?(ie={position:"absolute",top:0,left:0,zIndex:2,width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none"},e[21]=ie):ie=e[21];let q;e[22]!==ne?(q=S.jsx("img",{src:ne,style:ie,draggable:!1,alt:""}),e[22]=ne,e[23]=q):q=e[23];const oe=A?"visible":"hidden";let J;e[24]!==_||e[25]!==oe?(J={position:"absolute",zIndex:3,..._,backgroundColor:"#010101",cursor:"none",visibility:oe},e[24]=_,e[25]=oe,e[26]=J):J=e[26];let j;e[27]!==h||e[28]!==J?(j=S.jsx("canvas",{ref:h,style:J}),e[27]=h,e[28]=J,e[29]=j):j=e[29];let L;e[30]!==A||e[31]!==_?(L=!A&&S.jsx("div",{className:"absolute overflow-hidden",style:{zIndex:3,..._},children:S.jsx("div",{className:"absolute inset-0 animate-pulse bg-zinc-700"})}),e[30]=A,e[31]=_,e[32]=L):L=e[32];let re;e[33]!==A||e[34]!==_||e[35]!==o||e[36]!==D?(re=D&&S.jsxs("div",{"data-testid":"screen-waiting",className:"absolute overflow-hidden pointer-events-none flex items-center justify-center",style:{zIndex:8,..._},children:[A&&S.jsx("div",{"aria-hidden":"true",className:"absolute inset-0 bg-black/60 bg-screen-shimmer bg-[length:200%_100%] animate-screen-shimmer motion-reduce:animate-none"}),S.jsx("span",{className:"relative text-sm text-white whitespace-nowrap",style:{transform:`rotate(${-o}deg)`},children:D})]}),e[33]=A,e[34]=_,e[35]=o,e[36]=D,e[37]=re):re=e[37];let V;if(e[38]!==c||e[39]!==s.buttons||e[40]!==s.compositeHeight||e[41]!==s.compositeWidth||e[42]!==T||e[43]!==F){let Z;e[45]!==c||e[46]!==s.compositeHeight||e[47]!==s.compositeWidth||e[48]!==T||e[49]!==F?(Z=(w,ce)=>{const we=(c==null?void 0:c.flashed)===w.name,ee=(c==null?void 0:c.hovered)===w.name,K=w.anchor==="top",me=Ie(w),te=me.top/s.compositeHeight*100,ye=w.buttonH/s.compositeHeight*100,de=w.buttonW/s.compositeWidth*100,fe=w.buttonW/2,le=me.left/s.compositeWidth*100,he=(2*w.rolloverOffset.x-w.normalOffset.x-fe)/s.compositeWidth*100,Ee=w.rolloverOffset.x/s.compositeWidth*100,ge=te,ue=K?(2*w.rolloverOffset.y-w.normalOffset.y)/s.compositeHeight*100:0,xe=w.onTop?4:1,se=T[ce];return S.jsxs(y.Fragment,{children:[c&&S.jsx("div",{"data-frame-button":w.name,"aria-hidden":"true",onPointerDown:ae=>c.onPress(w.name,ae),onPointerEnter:()=>c.onHoverChange(w.name),onPointerLeave:()=>c.onHoverChange(ae=>ae===w.name?null:ae),style:{position:"absolute",zIndex:6,cursor:"pointer",left:`${se.left/s.compositeWidth*100}%`,top:`${se.top/s.compositeHeight*100}%`,width:`${(se.right-se.left)/s.compositeWidth*100}%`,height:`${(se.bottom-se.top)/s.compositeHeight*100}%`}}),w.buttonPng&&S.jsx("img",{src:`data:image/png;base64,${w.buttonPng}`,style:{position:"absolute",zIndex:xe,top:`${K&&ee?ue:te}%`,left:`${K?le:ee?he:le}%`,width:`${de}%`,height:`${ye}%`,transition:K?"top 0.15s ease":"left 0.15s ease",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),we&&w.pressedPng&&w.pressedRect&&S.jsx("img",{src:`data:image/png;base64,${w.pressedPng}`,style:{position:"absolute",zIndex:w.onTop?3:1,left:`${K?le:ee?he:le}%`,top:`${K&&ee?ue:te}%`,width:`${w.pressedRect.width/s.compositeWidth*100}%`,height:`${w.pressedRect.height/s.compositeHeight*100}%`,pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),ee&&S.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:`${Ee}%`,top:`${ge}%`,transform:"translate(-50%, calc(-100% - 8px))"},children:F[ce]})]},w.name)},e[45]=c,e[46]=s.compositeHeight,e[47]=s.compositeWidth,e[48]=T,e[49]=F,e[50]=Z):Z=e[50],V=s.buttons.map(Z),e[38]=c,e[39]=s.buttons,e[40]=s.compositeHeight,e[41]=s.compositeWidth,e[42]=T,e[43]=F,e[44]=V}else V=e[44];let B;e[51]!==f||e[52]!==x||e[53]!==u||e[54]!==G||e[55]!==P||e[56]!==q||e[57]!==j||e[58]!==L||e[59]!==re||e[60]!==V?(B=S.jsxs("div",{ref:x,className:G,style:P,...f,children:[q,j,L,u,re,V]}),e[51]=f,e[52]=x,e[53]=u,e[54]=G,e[55]=P,e[56]=q,e[57]=j,e[58]=L,e[59]=re,e[60]=V,e[61]=B):B=e[61];let X;return e[62]!==d||e[63]!==U||e[64]!==B||e[65]!==p||e[66]!==b?(X=S.jsxs("div",{ref:U,className:p,style:b,children:[B,d]}),e[62]=d,e[63]=U,e[64]=B,e[65]=p,e[66]=b,e[67]=X):X=e[67],X}const Nt=720,Wt=4e3,$t=350;function rs(t){const e=pe.c(42),{binaryFrameHandlerRef:n,perfHookRef:s,frameCount:i,screenWidth:o,screenHeight:r,streamRotation:a,cornerRadius:f,userWantsLandscape:c,rotatePending:u,bodyRotation:d,turnsAsked:g}=t,l=g===void 0?0:g,h=d!==void 0,x=y.useRef(null),U=y.useRef(null),A=y.useRef(null),[z,O]=y.useState(!1),[k,H]=y.useState(!1),_=y.useRef(null),[C,N]=y.useState(null),[T,F]=y.useState(!1),I=`${a}:${o??""}:${r??""}`,[W,E]=y.useState(I);W!==I&&(E(I),F(!1));let $,D,m;e[0]===Symbol.for("react.memo_cache_sentinel")?($=()=>H(!0),D=Y=>{O(!0);const Q=_.current;(!Q||Q.width!==Y.width||Q.height!==Y.height)&&(_.current=Y,N(Y),F(!0))},m=Y=>{var be;A.current=Y;const Q=Y.surface;Q.style.display="block",Q.style.width="100%",Q.style.height="100%",Q.style.objectFit="fill",(be=x.current)==null||be.appendChild(Q)},e[0]=$,e[1]=D,e[2]=m):($=e[0],D=e[1],m=e[2]);let p;e[3]!==n||e[4]!==i||e[5]!==s?(p={binaryFrameHandlerRef:n,perfHookRef:s,frameCount:i,onUnsupported:$,onResize:D,onDecoderReady:m},e[3]=n,e[4]=i,e[5]=s,e[6]=p):p=e[6],Ve(p);const R=C?C.width>C.height:null;let v;e[7]!==R||e[8]!==l?(v={asked:l,owed:0,frameLandscape:R,animate:!1},e[7]=R,e[8]=l,e[9]=v):v=e[9];const[b,G]=y.useState(v);if(b.asked!==l||b.frameLandscape!==R){const Q=b.frameLandscape!==null&&R!==null&&b.frameLandscape!==R&&b.owed>0?1:0,be=Math.max(0,l-b.asked);G({asked:l,owed:b.owed+be-Q,frameLandscape:R,animate:be>0})}const M=h?b.owed:0,[P,ne]=y.useState(!1);let ie;e[10]!==M?(ie=()=>{if(M===0)return;const Y=setTimeout(()=>{G(kt),ne(!0)},Wt);return()=>clearTimeout(Y)},e[10]=M,e[11]=ie):ie=e[11];let q;e[12]!==M||e[13]!==l?(q=[M,l],e[12]=M,e[13]=l,e[14]=q):q=e[14],y.useEffect(ie,q);let oe,J;e[15]!==P?(J=()=>{if(!P)return;const Y=setTimeout(()=>ne(!1),$t);return()=>clearTimeout(Y)},oe=[P],e[15]=P,e[16]=oe,e[17]=J):(oe=e[16],J=e[17]),y.useEffect(J,oe);const j=o&&r?{width:o,height:r}:null,L=h?C??(j?Ae(j.width,j.height,a):null):j??C,re=L?L.width>L.height:!1,V=!h&&c&&!re,B=h?0:gt(a,V),X=h?a:0,Z=y.useRef(0);let w,ce;e[18]!==X?(w=()=>{Z.current=X},ce=[X],e[18]=X,e[19]=w,e[20]=ce):(w=e[19],ce=e[20]),y.useLayoutEffect(w,ce);const we=y.useRef(!1);let ee,K;e[21]!==V?(ee=()=>{we.current=V},K=[V],e[21]=V,e[22]=ee,e[23]=K):(ee=e[22],K=e[23]),y.useLayoutEffect(ee,K);const me=L?Math.min(1,Nt/Math.max(L.width,L.height)):.3,te=L?Math.round(L.width*me):324,ye=L?Math.round(L.height*me):720,de=V?ye:te,fe=V?te:ye,le=o&&r?Math.max(o,r):0,he=f==null?22:Math.round(h&&o&&le?f*o*Math.max(te,ye)/le:f*te),Ee=xt(C,j,a),ge=h?!0:Ee,ue=yt({ready:z,aspectAgrees:ge,frameIsAhead:T,rotating:u}),xe=mt(B,de,fe),se=`rotate(${B}deg)`,ae=ue?"visible":"hidden";let Re;e[24]!==xe||e[25]!==se||e[26]!==ae?(Re={position:"absolute",...xe,transform:se,transformOrigin:"center center",visibility:ae,cursor:"none"},e[24]=xe,e[25]=se,e[26]=ae,e[27]=Re):Re=e[27];const Se=Re,_e=M*90,Te=M!==0||P;let ve;return e[28]!==h||e[29]!==Se||e[30]!==fe||e[31]!==de||e[32]!==k||e[33]!==ge||e[34]!==ue||e[35]!==he||e[36]!==X||e[37]!==b.animate||e[38]!==_e||e[39]!==Te||e[40]!==B?(ve={surfaceHostRef:x,containerRef:U,decoderRef:A,videoSizeRef:_,needsCSSRotationRef:we,screenTurnRef:Z,screenTurn:X,bodyMode:h,decoderUnsupported:k,totalTurn:B,containerW:de,containerH:fe,screenRadius:he,frameMatchesScreen:ge,pictureVisible:ue,canvasStyle:Se,spinDeg:_e,spinAnimates:b.animate,spinning:Te},e[28]=h,e[29]=Se,e[30]=fe,e[31]=de,e[32]=k,e[33]=ge,e[34]=ue,e[35]=he,e[36]=X,e[37]=b.animate,e[38]=_e,e[39]=Te,e[40]=B,e[41]=ve):ve=e[41],ve}function kt(t){return{...t,owed:0,animate:!0}}function as(t){const e=pe.c(32),{screen:n,deviceReady:s,posturePending:i,surfaceHandlers:o,overlay:r}=t,{surfaceHostRef:a,containerRef:f,decoderUnsupported:c,containerW:u,containerH:d,screenRadius:g,frameMatchesScreen:l,pictureVisible:h,canvasStyle:x,spinDeg:U,spinAnimates:A}=n,z=u+24,O=d+24,k=U%180===90,H=A?"motion-safe:duration-300 motion-safe:ease-in-out":"",_=A?`motion-safe:transition-[width,height] ${H}`:void 0,C=k?O:z,N=k?z:O;let T;e[0]!==C||e[1]!==N?(T={width:C,height:N,position:"relative",flexShrink:0},e[0]=C,e[1]=N,e[2]=T):T=e[2];const F=A?`motion-safe:transition-transform ${H}`:void 0,I=`${g+12}px`,W=`translate(-50%, -50%) rotate(${U}deg)`;let E;e[3]!==I||e[4]!==W?(E={background:"#1c1c1e",borderRadius:I,padding:"12px",boxShadow:"0 8px 32px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06)",position:"absolute",top:"50%",left:"50%",transform:W,transformOrigin:"center center"},e[3]=I,e[4]=W,e[5]=E):E=e[5];const $=`${g}px`;let D;e[6]!==d||e[7]!==u||e[8]!==$?(D={width:u,height:d,backgroundColor:"#010101",borderRadius:$,overflow:"hidden"},e[6]=d,e[7]=u,e[8]=$,e[9]=D):D=e[9];let m;e[10]!==x||e[11]!==c||e[12]!==s||e[13]!==l||e[14]!==r||e[15]!==h||e[16]!==i||e[17]!==o||e[18]!==a?(m=!c&&S.jsxs(S.Fragment,{children:[S.jsx("div",{ref:a,style:x,...o}),!h&&S.jsx("div",{className:"absolute inset-0 animate-pulse bg-zinc-700"}),!h&&s&&S.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:S.jsx("span",{style:{color:"rgba(255,255,255,0.6)",fontSize:"0.875rem"},children:i||!l?"Changing posture…":"Waiting for stream…"})}),r]}),e[10]=x,e[11]=c,e[12]=s,e[13]=l,e[14]=r,e[15]=h,e[16]=i,e[17]=o,e[18]=a,e[19]=m):m=e[19];let p;e[20]!==f||e[21]!==D||e[22]!==m?(p=S.jsx("div",{ref:f,className:"relative",style:D,children:m}),e[20]=f,e[21]=D,e[22]=m,e[23]=p):p=e[23];let R;e[24]!==p||e[25]!==F||e[26]!==E?(R=S.jsx("div",{className:F,style:E,children:p}),e[24]=p,e[25]=F,e[26]=E,e[27]=R):R=e[27];let v;return e[28]!==_||e[29]!==R||e[30]!==T?(v=S.jsx("div",{className:_,style:T,children:R}),e[28]=_,e[29]=R,e[30]=T,e[31]=v):v=e[31],v}export{as as A,vt as C,bt as H,os as I,Nt as M,$t as S,is as a,Lt as b,Gt as c,Zt as d,es as e,Yt as f,Qt as g,rs as h,qt as i,Kt as j,Jt as k,Ot as l,Bt as m,ns as n,ts as o,Xt as p,Ue as q,ss as r,zt as s,Ae as t,jt as u};
@@ -1,25 +1,25 @@
1
- var Ve=l=>{throw TypeError(l)};var Re=(l,e,s)=>e.has(l)||Ve("Cannot "+s);var A=(l,e,s)=>(Re(l,e,"read from private field"),s?s.call(l):e.get(l)),fe=(l,e,s)=>e.has(l)?Ve("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,s),me=(l,e,s,a)=>(Re(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),ue=(l,e,s)=>(Re(l,e,"access private method"),s);import{r as o,c as xe,j as t}from"./vendor-react-DTSdA8m-.js";import{t as jt,w as yt,x as He,y as vt,A as tt,b as st,D as St,E as Nt,G as Ne,H as J,B as ie,L as ve,I as We,F as wt,J as Dt,S as _t,T as kt,K as Ct,M as At,N as Et,O as It,Q as pe,R as Rt,c as Je,U as Tt,V as Ft,W as Ot,X as $t,Y as Mt,q as Pt,Z as Lt,$ as Bt,a0 as zt}from"./index-2zL1a5_0.js";import{S as qt}from"./search-input-BK7cFT1m.js";import{S as ke,a as Ce,b as Ae,c as F,d as Ee,C as Kt}from"./select-BH7E2Q0r.js";import{D as lt,a as at,b as nt,c as rt,d as it}from"./dialog-CTc84wr4.js";import{T as _e}from"./tech-label-fz5PvoAL.js";import{P as Qt,T as Ut}from"./trash-CZ-V9h2G.js";import{B as Te}from"./badge-DM1m4CLq.js";import{A as Vt,a as Ht,b as Wt,c as Jt,d as Gt,e as Yt,f as Xt,g as Zt}from"./alert-dialog-nxQTqXgk.js";import{f as es,b as Oe,P as ts,S as ss,d as ls}from"./build-format-ofd2iIzf.js";import{P as as}from"./play-Dab2J3Tw.js";import{u as ns}from"./useFocusAfterSwap-BdItkQCu.js";import{u as rs,S as is}from"./useShownAfter-By1Yxysz.js";import{a as os,c as cs}from"./vendor-router-B1pQim9Z.js";import"./index-D17hSi50.js";var re,oe,$,Se,ae,ye,$e,et,ds=(et=class extends jt{constructor(e,s){super();fe(this,ae);fe(this,re);fe(this,oe);fe(this,$);fe(this,Se);me(this,re,e),this.setOptions(s),this.bindMethods(),ue(this,ae,ye).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var a;const s=this.options;this.options=A(this,re).defaultMutationOptions(e),yt(this.options,s)||A(this,re).getMutationCache().notify({type:"observerOptionsUpdated",mutation:A(this,$),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&He(s.mutationKey)!==He(this.options.mutationKey)?this.reset():((a=A(this,$))==null?void 0:a.state.status)==="pending"&&A(this,$).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&A(this,$)&&(A(this,$).addObserver(this),ue(this,ae,ye).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=A(this,$))==null||e.removeObserver(this)}onMutationUpdate(e){ue(this,ae,ye).call(this),ue(this,ae,$e).call(this,e)}getCurrentResult(){return A(this,oe)}reset(){var e;(e=A(this,$))==null||e.removeObserver(this),me(this,$,void 0),ue(this,ae,ye).call(this),ue(this,ae,$e).call(this)}mutate(e,s){var a;return me(this,Se,s),(a=A(this,$))==null||a.removeObserver(this),me(this,$,A(this,re).getMutationCache().build(A(this,re),this.options)),A(this,$).addObserver(this),A(this,$).execute(e)}},re=new WeakMap,oe=new WeakMap,$=new WeakMap,Se=new WeakMap,ae=new WeakSet,ye=function(){var s;const e=((s=A(this,$))==null?void 0:s.state)??vt();me(this,oe,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},$e=function(e){tt.batch(()=>{var a,c,b,f;const s=A(this,Se);if(s&&this.hasListeners()){const p=A(this,oe).variables,g=A(this,oe).context,u={client:A(this,re),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(a=s.onSuccess)==null||a.call(s,e.data,p,g,u)}catch(d){Promise.reject(d)}try{(c=s.onSettled)==null||c.call(s,e.data,null,p,g,u)}catch(d){Promise.reject(d)}}else if((e==null?void 0:e.type)==="error"){try{(b=s.onError)==null||b.call(s,e.error,p,g,u)}catch(d){Promise.reject(d)}try{(f=s.onSettled)==null||f.call(s,void 0,e.error,p,g,u)}catch(d){Promise.reject(d)}}}this.listeners.forEach(p=>{p(A(this,oe))})})},et);function Fe(l,e){const s=st(),[a]=o.useState(()=>new ds(s,l));o.useEffect(()=>{a.setOptions(l)},[a,l]);const c=o.useSyncExternalStore(o.useCallback(f=>a.subscribe(tt.batchCalls(f)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),b=o.useCallback((...f)=>{a.mutate(f[0],f[1]).catch(St)},[a]);if(c.error&&Nt(a.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:b,mutateAsync:c.mutate}}/**
2
- * @license lucide-react v1.59.0 - ISC
1
+ var Ve=l=>{throw TypeError(l)};var Re=(l,e,s)=>e.has(l)||Ve("Cannot "+s);var A=(l,e,s)=>(Re(l,e,"read from private field"),s?s.call(l):e.get(l)),fe=(l,e,s)=>e.has(l)?Ve("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,s),me=(l,e,s,a)=>(Re(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),ue=(l,e,s)=>(Re(l,e,"access private method"),s);import{r as o,c as xe,j as t}from"./vendor-react-DTSdA8m-.js";import{t as jt,w as yt,x as He,y as vt,A as tt,b as st,D as St,E as Nt,G as Ne,H as J,B as ie,L as ve,I as We,F as wt,J as Dt,S as _t,T as kt,K as Ct,M as At,N as Et,O as It,Q as pe,R as Rt,c as Je,U as Tt,V as Ft,W as Ot,X as $t,Y as Mt,q as Pt,Z as Lt,$ as Bt,a0 as zt}from"./index-CiJwpDAf.js";import{S as qt}from"./search-input-2MuvmbBR.js";import{S as ke,a as Ce,b as Ae,c as F,d as Ee,C as Kt}from"./select-7EkQtxVy.js";import{D as lt,a as at,b as nt,c as rt,d as it}from"./dialog-CrzZQwxn.js";import{T as _e}from"./tech-label-DpVGqU2Y.js";import{P as Qt,T as Ut}from"./trash-DFsQhdZ1.js";import{B as Te}from"./badge-Bjwwchrt.js";import{A as Vt,a as Ht,b as Wt,c as Jt,d as Gt,e as Yt,f as Xt,g as Zt}from"./alert-dialog-DPNbpxqG.js";import{f as es,b as Oe,P as ts,S as ss,d as ls}from"./build-format-ofd2iIzf.js";import{P as as}from"./play-BR_CdQzZ.js";import{u as ns}from"./useFocusAfterSwap-BdItkQCu.js";import{u as rs,S as is}from"./useShownAfter-By1Yxysz.js";import{a as os,c as cs}from"./vendor-router-B1pQim9Z.js";import"./index-D17hSi50.js";var re,oe,$,Se,ae,ye,$e,et,ds=(et=class extends jt{constructor(e,s){super();fe(this,ae);fe(this,re);fe(this,oe);fe(this,$);fe(this,Se);me(this,re,e),this.setOptions(s),this.bindMethods(),ue(this,ae,ye).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var a;const s=this.options;this.options=A(this,re).defaultMutationOptions(e),yt(this.options,s)||A(this,re).getMutationCache().notify({type:"observerOptionsUpdated",mutation:A(this,$),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&He(s.mutationKey)!==He(this.options.mutationKey)?this.reset():((a=A(this,$))==null?void 0:a.state.status)==="pending"&&A(this,$).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&A(this,$)&&(A(this,$).addObserver(this),ue(this,ae,ye).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=A(this,$))==null||e.removeObserver(this)}onMutationUpdate(e){ue(this,ae,ye).call(this),ue(this,ae,$e).call(this,e)}getCurrentResult(){return A(this,oe)}reset(){var e;(e=A(this,$))==null||e.removeObserver(this),me(this,$,void 0),ue(this,ae,ye).call(this),ue(this,ae,$e).call(this)}mutate(e,s){var a;return me(this,Se,s),(a=A(this,$))==null||a.removeObserver(this),me(this,$,A(this,re).getMutationCache().build(A(this,re),this.options)),A(this,$).addObserver(this),A(this,$).execute(e)}},re=new WeakMap,oe=new WeakMap,$=new WeakMap,Se=new WeakMap,ae=new WeakSet,ye=function(){var s;const e=((s=A(this,$))==null?void 0:s.state)??vt();me(this,oe,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},$e=function(e){tt.batch(()=>{var a,c,b,f;const s=A(this,Se);if(s&&this.hasListeners()){const p=A(this,oe).variables,g=A(this,oe).context,u={client:A(this,re),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(a=s.onSuccess)==null||a.call(s,e.data,p,g,u)}catch(d){Promise.reject(d)}try{(c=s.onSettled)==null||c.call(s,e.data,null,p,g,u)}catch(d){Promise.reject(d)}}else if((e==null?void 0:e.type)==="error"){try{(b=s.onError)==null||b.call(s,e.error,p,g,u)}catch(d){Promise.reject(d)}try{(f=s.onSettled)==null||f.call(s,void 0,e.error,p,g,u)}catch(d){Promise.reject(d)}}}this.listeners.forEach(p=>{p(A(this,oe))})})},et);function Fe(l,e){const s=st(),[a]=o.useState(()=>new ds(s,l));o.useEffect(()=>{a.setOptions(l)},[a,l]);const c=o.useSyncExternalStore(o.useCallback(f=>a.subscribe(tt.batchCalls(f)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),b=o.useCallback((...f)=>{a.mutate(f[0],f[1]).catch(St)},[a]);if(c.error&&Nt(a.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:b,mutateAsync:c.mutate}}/**
2
+ * @license lucide-react v1.61.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
6
  */const ot={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};ot.node;const us=Ne(ot);/**
7
- * @license lucide-react v1.59.0 - ISC
7
+ * @license lucide-react v1.61.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
11
  */const ct={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};ct.node;const hs=Ne(ct);/**
12
- * @license lucide-react v1.59.0 - ISC
12
+ * @license lucide-react v1.61.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */const dt={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};dt.node;const fs=Ne(dt);/**
17
- * @license lucide-react v1.59.0 - ISC
17
+ * @license lucide-react v1.61.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
21
  */const ut={name:"timer-off",size:24,node:[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]};ut.node;const ms=Ne(ut);/**
22
- * @license lucide-react v1.59.0 - ISC
22
+ * @license lucide-react v1.61.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
@@ -1,4 +1,4 @@
1
- import{r as y,j as e,c as Ve}from"./vendor-react-DTSdA8m-.js";import{a6 as ve,a8 as Ee,a2 as be,b as je,u as R,a as $,C as F,d as D,e as k,f as V,n as L,L as j,B as C,h as q,o as O,aF as ue,H as f,q as S,z as Me,R as Te,c as pe,l as Ge,I as N,F as P,S as fe,p as Re,g as $e,P as qe,aG as Le,_ as ye,s as E,i as Oe,j as Be,aH as He,Z as Ie}from"./index-2zL1a5_0.js";import{F as z}from"./field-hint-xptj_gfn.js";import{B as Qe}from"./badge-DM1m4CLq.js";import{P as ze}from"./build-format-ofd2iIzf.js";import{g as Ke,h as Ue,d as We,A as Xe,a as Je,b as Ye,e as Ze,c as er,f as rr}from"./alert-dialog-nxQTqXgk.js";import{S as ge}from"./slider-B4sPZi8m.js";import{P as he}from"./pencil-CEWs8Of9.js";import"./vendor-router-B1pQim9Z.js";import"./index-D17hSi50.js";var sr=Object.defineProperty,w=(a,i)=>sr(a,"name",{value:i,configurable:!0}),we="Progress",X=100,[ar,Cr]=Ee(we),[tr,or]=ar(we),Se=y.forwardRef(w(function(i,r){const{__scopeProgress:g,value:t=null,max:n,getValueLabel:p=Ne,...x}=i;(n||n===0)&&!K(n)&&console.error(Pe(`${n}`,"Progress"));const m=K(n)?n:X;t!==null&&!U(t,m)&&console.error(Ce(`${t}`,"Progress"));const h=U(t,m)?t:null,u=M(h)?p(h,m):void 0;return e.jsx(tr,{scope:g,value:h,max:m,children:e.jsx(ve.div,{"aria-valuemax":m,"aria-valuemin":0,"aria-valuenow":M(h)?h:void 0,"aria-valuetext":u,role:"progressbar","data-state":J(h,m),"data-value":h??void 0,"data-max":m,...x,ref:r})})},"Progress")),ir="ProgressIndicator",nr=y.forwardRef(w(function(i,r){const{__scopeProgress:g,...t}=i,n=or(ir,g);return e.jsx(ve.div,{"data-state":J(n.value,n.max),"data-value":n.value??void 0,"data-max":n.max,...t,ref:r})},"ProgressIndicator"));function Ne(a,i){return`${Math.round(a/i*100)}%`}w(Ne,"defaultGetValueLabel");function J(a,i){return a==null?"indeterminate":a===i?"complete":"loading"}w(J,"getProgressState");function M(a){return typeof a=="number"}w(M,"isNumber");function K(a){return M(a)&&!isNaN(a)&&a>0}w(K,"isValidMaxNumber");function U(a,i){return M(a)&&!isNaN(a)&&a<=i&&a>=0}w(U,"isValidValueNumber");function Pe(a,i){return`Invalid prop \`max\` of value \`${a}\` supplied to \`${i}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${X}\`.`}w(Pe,"getInvalidMaxError");function Ce(a,i){return`Invalid prop \`value\` of value \`${a}\` supplied to \`${i}\`. The \`value\` prop must be:
1
+ import{r as y,j as e,c as Ve}from"./vendor-react-DTSdA8m-.js";import{a6 as ve,a8 as Ee,a2 as be,b as je,u as R,a as $,C as F,d as D,e as k,f as V,n as L,L as j,B as C,h as q,o as O,aF as ue,H as f,q as S,z as Me,R as Te,c as pe,l as Ge,I as N,F as P,S as fe,p as Re,g as $e,P as qe,aG as Le,_ as ye,s as E,i as Oe,j as Be,aH as He,Z as Ie}from"./index-CiJwpDAf.js";import{F as z}from"./field-hint-CIJmSABE.js";import{B as Qe}from"./badge-Bjwwchrt.js";import{P as ze}from"./build-format-ofd2iIzf.js";import{g as Ke,h as Ue,d as We,A as Xe,a as Je,b as Ye,e as Ze,c as er,f as rr}from"./alert-dialog-DPNbpxqG.js";import{S as ge}from"./slider-ifEFgQFt.js";import{P as he}from"./pencil-CE5LnE8i.js";import"./vendor-router-B1pQim9Z.js";import"./index-D17hSi50.js";var sr=Object.defineProperty,w=(a,i)=>sr(a,"name",{value:i,configurable:!0}),we="Progress",X=100,[ar,Cr]=Ee(we),[tr,or]=ar(we),Se=y.forwardRef(w(function(i,r){const{__scopeProgress:g,value:t=null,max:n,getValueLabel:p=Ne,...x}=i;(n||n===0)&&!K(n)&&console.error(Pe(`${n}`,"Progress"));const m=K(n)?n:X;t!==null&&!U(t,m)&&console.error(Ce(`${t}`,"Progress"));const h=U(t,m)?t:null,u=M(h)?p(h,m):void 0;return e.jsx(tr,{scope:g,value:h,max:m,children:e.jsx(ve.div,{"aria-valuemax":m,"aria-valuemin":0,"aria-valuenow":M(h)?h:void 0,"aria-valuetext":u,role:"progressbar","data-state":J(h,m),"data-value":h??void 0,"data-max":m,...x,ref:r})})},"Progress")),ir="ProgressIndicator",nr=y.forwardRef(w(function(i,r){const{__scopeProgress:g,...t}=i,n=or(ir,g);return e.jsx(ve.div,{"data-state":J(n.value,n.max),"data-value":n.value??void 0,"data-max":n.max,...t,ref:r})},"ProgressIndicator"));function Ne(a,i){return`${Math.round(a/i*100)}%`}w(Ne,"defaultGetValueLabel");function J(a,i){return a==null?"indeterminate":a===i?"complete":"loading"}w(J,"getProgressState");function M(a){return typeof a=="number"}w(M,"isNumber");function K(a){return M(a)&&!isNaN(a)&&a>0}w(K,"isValidMaxNumber");function U(a,i){return M(a)&&!isNaN(a)&&a<=i&&a>=0}w(U,"isValidValueNumber");function Pe(a,i){return`Invalid prop \`max\` of value \`${a}\` supplied to \`${i}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${X}\`.`}w(Pe,"getInvalidMaxError");function Ce(a,i){return`Invalid prop \`value\` of value \`${a}\` supplied to \`${i}\`. The \`value\` prop must be:
2
2
  - a positive number
3
3
  - less than the value passed to \`max\` (or ${X} if no \`max\` prop is set)
4
4
  - \`null\` or \`undefined\` if the progress is indeterminate.
@@ -1 +1 @@
1
- import{r as F,j as e}from"./vendor-react-DTSdA8m-.js";import{u as M,a as W,l as K,b as Q,c as U,C as T,d as R,e as q,m as E,f as G,L as m,I as h,n as Y,p as z,F as u,S as V,g as J,P as X,B as Z,h as $,q as I,o as ee,s as v,i as ae,j as se,_ as re,v as te}from"./index-2zL1a5_0.js";import{F as ie}from"./field-hint-xptj_gfn.js";import{a as ne,c as oe,L as le}from"./vendor-router-B1pQim9Z.js";import{P as de}from"./pencil-CEWs8Of9.js";const ce=ee({displayName:v().optional(),avatar:re(File).nullable().optional(),password:v().min(ae,se),confirm:v()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ve(){var b,N,C,S,k,P;const o=ne(),[O]=oe(),i=O.get("token")??"",[x,_]=F.useState(null),g=F.useRef(null),{register:p,handleSubmit:A,control:j,setError:l,formState:{errors:a,isSubmitting:y,submitCount:L}}=M({shouldFocusError:!1,resolver:W(ce),defaultValues:{displayName:"",avatar:null}}),d=K({control:j,name:"displayName"})??"",B=Q(),f=U({queryKey:I.inviteToken(i),queryFn:()=>te(i),enabled:i!=="",staleTime:1/0}),w=!i||f.isError?"invalid":f.isPending?"loading":"valid",D=((b=f.data)==null?void 0:b.role)??"";async function H(t){var n;try{const s=new FormData;s.append("token",i),s.append("password",t.password),(n=t.displayName)!=null&&n.trim()&&s.append("display_name",t.displayName.trim()),t.avatar&&s.append("avatar",t.avatar);const r=await fetch("/api/v1/invitations/accept",{method:"POST",body:s});if(r.status===409){l("root",{type:"already-member",message:"This email already has an account. Sign in instead, or ask your admin for a password reset link."});return}if(!r.ok){const c=await r.json().catch(()=>({}));l("root",{message:c.error??"Failed to accept invitation"});return}B.removeQueries({queryKey:I.inviteToken(i)}),o("/app-center",{replace:!0})}catch{l("root",{message:"Network error. Please try again."})}}return w==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):w==="invalid"?e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(T,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(R,{children:[e.jsx(q,{children:"Invitation expired"}),e.jsx(E,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(T,{level:4,className:"w-full max-w-sm",children:[e.jsxs(R,{className:"text-center",children:[e.jsx(q,{children:"Set up your account"}),e.jsxs(E,{children:["You're joining as ",e.jsx("strong",{children:D})]})]}),e.jsx(G,{children:e.jsxs("form",{onSubmit:A(H),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(h,{id:"display-name",placeholder:"Your name",...p("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(Y,{name:"avatar",control:j,render:({field:t})=>{var n;return e.jsxs("div",{className:"relative w-14 h-14",children:[x?e.jsx("img",{src:x,alt:"Avatar preview",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const s=z(d);return{backgroundColor:s.bg,color:s.fg}})(),children:((n=d==null?void 0:d[0])==null?void 0:n.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":a.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":a.avatar?"avatar-error":void 0,onClick:()=>{var s;return(s=g.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(de,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:s=>{var c;const r=(c=s.target.files)==null?void 0:c[0];if(r){if(r.size>2*1024*1024){l("avatar",{message:"Max 2MB for avatar"});return}t.onChange(r),_(URL.createObjectURL(r))}}})]})}}),e.jsx(u,{assertive:!0,id:"avatar-error",message:(N=a.avatar)==null?void 0:N.message})]}),e.jsx(V,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),e.jsx(h,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.password,"aria-describedby":J("password-hint","password-error",!!a.password),...p("password")}),!a.password&&e.jsx(ie,{id:"password-hint",children:X}),e.jsx(u,{id:"password-error",message:(C=a.password)==null?void 0:C.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(h,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.confirm,"aria-describedby":a.confirm?"confirm-error":void 0,...p("confirm")}),e.jsx(u,{id:"confirm-error",message:(S=a.confirm)==null?void 0:S.message})]}),e.jsx(u,{assertive:!0,id:"invite-error",message:(k=a.root)==null?void 0:k.message}),((P=a.root)==null?void 0:P.type)==="already-member"&&e.jsx(le,{to:"/login",className:"text-sm text-center underline underline-offset-4",children:"Go to sign in"}),e.jsx(Z,{type:"submit",disabled:y,className:"w-full",children:y?"Creating account…":"Create account"}),e.jsx($,{errors:a,submitCount:L})]})})]})})}export{ve as Invite};
1
+ import{r as F,j as e}from"./vendor-react-DTSdA8m-.js";import{u as M,a as W,l as K,b as Q,c as U,C as T,d as R,e as q,m as E,f as G,L as m,I as h,n as Y,p as z,F as u,S as V,g as J,P as X,B as Z,h as $,q as I,o as ee,s as v,i as ae,j as se,_ as re,v as te}from"./index-CiJwpDAf.js";import{F as ie}from"./field-hint-CIJmSABE.js";import{a as ne,c as oe,L as le}from"./vendor-router-B1pQim9Z.js";import{P as de}from"./pencil-CE5LnE8i.js";const ce=ee({displayName:v().optional(),avatar:re(File).nullable().optional(),password:v().min(ae,se),confirm:v()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ve(){var b,N,C,S,k,P;const o=ne(),[O]=oe(),i=O.get("token")??"",[x,_]=F.useState(null),g=F.useRef(null),{register:p,handleSubmit:A,control:j,setError:l,formState:{errors:a,isSubmitting:y,submitCount:L}}=M({shouldFocusError:!1,resolver:W(ce),defaultValues:{displayName:"",avatar:null}}),d=K({control:j,name:"displayName"})??"",B=Q(),f=U({queryKey:I.inviteToken(i),queryFn:()=>te(i),enabled:i!=="",staleTime:1/0}),w=!i||f.isError?"invalid":f.isPending?"loading":"valid",D=((b=f.data)==null?void 0:b.role)??"";async function H(t){var n;try{const s=new FormData;s.append("token",i),s.append("password",t.password),(n=t.displayName)!=null&&n.trim()&&s.append("display_name",t.displayName.trim()),t.avatar&&s.append("avatar",t.avatar);const r=await fetch("/api/v1/invitations/accept",{method:"POST",body:s});if(r.status===409){l("root",{type:"already-member",message:"This email already has an account. Sign in instead, or ask your admin for a password reset link."});return}if(!r.ok){const c=await r.json().catch(()=>({}));l("root",{message:c.error??"Failed to accept invitation"});return}B.removeQueries({queryKey:I.inviteToken(i)}),o("/app-center",{replace:!0})}catch{l("root",{message:"Network error. Please try again."})}}return w==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):w==="invalid"?e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(T,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(R,{children:[e.jsx(q,{children:"Invitation expired"}),e.jsx(E,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(T,{level:4,className:"w-full max-w-sm",children:[e.jsxs(R,{className:"text-center",children:[e.jsx(q,{children:"Set up your account"}),e.jsxs(E,{children:["You're joining as ",e.jsx("strong",{children:D})]})]}),e.jsx(G,{children:e.jsxs("form",{onSubmit:A(H),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(h,{id:"display-name",placeholder:"Your name",...p("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(Y,{name:"avatar",control:j,render:({field:t})=>{var n;return e.jsxs("div",{className:"relative w-14 h-14",children:[x?e.jsx("img",{src:x,alt:"Avatar preview",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const s=z(d);return{backgroundColor:s.bg,color:s.fg}})(),children:((n=d==null?void 0:d[0])==null?void 0:n.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":a.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":a.avatar?"avatar-error":void 0,onClick:()=>{var s;return(s=g.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(de,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:s=>{var c;const r=(c=s.target.files)==null?void 0:c[0];if(r){if(r.size>2*1024*1024){l("avatar",{message:"Max 2MB for avatar"});return}t.onChange(r),_(URL.createObjectURL(r))}}})]})}}),e.jsx(u,{assertive:!0,id:"avatar-error",message:(N=a.avatar)==null?void 0:N.message})]}),e.jsx(V,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),e.jsx(h,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.password,"aria-describedby":J("password-hint","password-error",!!a.password),...p("password")}),!a.password&&e.jsx(ie,{id:"password-hint",children:X}),e.jsx(u,{id:"password-error",message:(C=a.password)==null?void 0:C.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(h,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!a.confirm,"aria-describedby":a.confirm?"confirm-error":void 0,...p("confirm")}),e.jsx(u,{id:"confirm-error",message:(S=a.confirm)==null?void 0:S.message})]}),e.jsx(u,{assertive:!0,id:"invite-error",message:(k=a.root)==null?void 0:k.message}),((P=a.root)==null?void 0:P.type)==="already-member"&&e.jsx(le,{to:"/login",className:"text-sm text-center underline underline-offset-4",children:"Go to sign in"}),e.jsx(Z,{type:"submit",disabled:y,className:"w-full",children:y?"Creating account…":"Create account"}),e.jsx($,{errors:a,submitCount:L})]})})]})})}export{ve as Invite};
@@ -1 +1 @@
1
- import{r as M,c as He,j as s}from"./vendor-react-DTSdA8m-.js";import{ak as Tt,c as bt,b as Ot,ay as Rt,az as Ct,q as Xe,aA as Dt,Q as xt}from"./index-2zL1a5_0.js";import{u as It}from"./useRelay-CES3I1Mt.js";import{u as Pt,S as Kt}from"./useShownAfter-By1Yxysz.js";import{c as Ft,a as Ht,T as Ut}from"./tabs-CYoB-S2t.js";import{R as Bt}from"./resource-health-oWJ8hy9X.js";import{t as qt,a as wt,b as Gt,c as Qt,d as Wt,e as $t,l as Xt,P as Vt,L as zt,G as Yt,A as Jt,m as St,f as Zt,g as es,h as ts,i as ss,B as ns,j as ls}from"./vendor-charts-BE7R_8yA.js";import"./vendor-router-B1pQim9Z.js";const os=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function as(){return M.useSyncExternalStore(os,is,rs)}function rs(){return!0}function is(){return document.visibilityState!=="hidden"}function cs(t,e){const o=He.c(4),[m,g]=M.useState(ds);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;g(Date.now());const h=setInterval(()=>g(Date.now()),t);return()=>clearInterval(h)},n=[t,e],o[0]=e,o[1]=t,o[2]=i,o[3]=n):(i=o[2],n=o[3]),M.useEffect(i,n),m}function ds(){return Date.now()}const pt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},us={"1h":Gt.every(10),"6h":wt,"24h":wt.every(3),"7d":qt};function fs(t,e,o){return us[o].range(new Date(t),new Date(e+1))}function ms(t,e){const o=new Date(t);return e==="7d"?`${o.getMonth()+1}/${o.getDate()}`:`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`}const hs=2e3;function xs(t){return Math.min(1e4,Math.max(1e3,pt[t]/hs))}const ps={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},gt=t=>Math.round(t*10)/10;function gs(t,e,o){let m;for(const i of t){const n=i.agentName===e?i.resources:void 0;n&&(!m||n.reportedAt>m.reportedAt)&&(m=n)}if(!m||o-m.reportedAt>Bt)return null;const g=i=>Number.isFinite(i)?gt(i):null;return{cpu:g(m.cpuPercent),mem:g(m.memUsedMB/m.memTotalMB*100)}}const Et={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},Lt={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Is(){const t=He.c(66);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=M.useState(e),[g,i]=M.useState(null),[n,h]=M.useState("24h"),R=as();let S;t[1]!==n?(S=xs(n),t[1]=n,t[2]=S):S=t[2];const x=cs(S,R),{setNode:v}=Tt();let p,j;t[3]!==v?(p=()=>(v(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>v(null)),j=[v],t[3]=v,t[4]=p,t[5]=j):(p=t[4],j=t[5]),M.useEffect(p,j);let C;t[6]===Symbol.for("react.memo_cache_sentinel")?(C=u=>{u.type==="agents:listed"&&m(u.sessions??[])},t[6]=C):C=t[6];const X=C,{send:$,connected:E}=It(X);let ce,de;t[7]!==E||t[8]!==$?(ce=()=>{if(!E)return;$({type:"agents:list"});const u=setInterval(()=>$({type:"agents:list"}),1e4);return()=>clearInterval(u)},de=[E,$],t[7]=E,t[8]=$,t[9]=ce,t[10]=de):(ce=t[9],de=t[10]),M.useEffect(ce,de);let se;t[11]===Symbol.for("react.memo_cache_sentinel")?(se={queryKey:Xe.agents,queryFn:Ct,refetchOnWindowFocus:!1},t[11]=se):se=t[11];const V=bt(se);let d,f,B,ne;t[12]!==V.data||t[13]!==o?(B=V.data??[],f=o.map(js).filter(Boolean),d=[...new Set([...f,...B])],ne=new Set(f),t[12]=V.data,t[13]=o,t[14]=d,t[15]=f,t[16]=B,t[17]=ne):(d=t[14],f=t[15],B=t[16],ne=t[17]);const b=ne,l=g??(V.isPending?null:B[0]??f[0]??null),q=Ot();let ee;t[18]!==n||t[19]!==l?(ee=l?Xe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=ee):ee=t[20];const te=ee;let D;t[21]!==te||t[22]!==n?(D=te??Xe.resourceHistory("",n),t[21]=te,t[22]=n,t[23]=D):D=t[23];let G;t[24]!==n||t[25]!==l?(G=u=>{const{signal:T}=u;return Dt(l,n,T)},t[24]=n,t[25]=l,t[26]=G):G=t[26];let z;t[27]!==D||t[28]!==G?(z={queryKey:D,queryFn:G,enabled:!1},t[27]=D,t[28]=G,t[29]=z):z=t[29];const I=bt(z),Q=I.refetch;let P,Y;t[30]!==q||t[31]!==n||t[32]!==Q||t[33]!==l||t[34]!==R?(P=()=>{if(!l||!R)return;const u=Xe.resourceHistory(l,n),T=ps[n],N=()=>{const H=q.getQueryState(u);(H==null?void 0:H.fetchStatus)==="fetching"&&H.data===void 0?q.cancelQueries({queryKey:u,exact:!0}).then(()=>Q()):Q({cancelRefetch:!0})},k=q.getQueryState(u),ae=Math.max((k==null?void 0:k.dataUpdatedAt)??0,(k==null?void 0:k.errorUpdatedAt)??0),re=(k==null?void 0:k.data)!==void 0&&ae>0?Math.max(0,T-(Date.now()-ae)):0;let ie;const Ue=()=>{N(),ie=setInterval(N,T)},Fe=re>0?setTimeout(Ue,re):void 0;return re===0&&Ue(),()=>{clearTimeout(Fe),clearInterval(ie),q.cancelQueries({queryKey:u,exact:!0})}},Y=[l,n,R,Q,q],t[30]=q,t[31]=n,t[32]=Q,t[33]=l,t[34]=R,t[35]=P,t[36]=Y):(P=t[35],Y=t[36]),M.useEffect(P,Y);const w=I.data!==void 0||I.isError,J=te!==null&&!w,c=Pt(J,Kt);let K;t[37]!==I.data?(K=I.data??[],t[37]=I.data,t[38]=K):K=t[38];let Z;t[39]!==K?(Z=K.map(vs),t[39]=K,t[40]=Z):Z=t[40];const W=Z;let le;t[41]!==x||t[42]!==l||t[43]!==o?(le=l?gs(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=le):le=t[44];const r=le;let y;t[45]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=y):y=t[45];let L;t[46]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx("h2",{id:"macs-heading",className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Macs"}),t[46]=L):L=t[46];let _;t[47]!==d||t[48]!==E||t[49]!==b||t[50]!==l?(_=d.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:E?"No agents yet.":"Connecting…"}):d.map(u=>{const T=b.has(u),N=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":N?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",N?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${T?"bg-emerald-400":"bg-muted-foreground/40"}`,"aria-hidden":"true"}),s.jsx("span",{className:"truncate min-w-0",children:u}),s.jsx("span",{className:"sr-only",children:T?"Online":"Offline"})]},u)}),t[47]=d,t[48]=E,t[49]=b,t[50]=l,t[51]=_):_=t[51];let A;t[52]!==_?(A=s.jsxs("aside",{"aria-labelledby":"macs-heading",className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[L,_]}),t[52]=_,t[53]=A):A=t[53];let F;t[54]!==W||t[55]!==(r==null?void 0:r.cpu)||t[56]!==(r==null?void 0:r.mem)||t[57]!==J||t[58]!==x||t[59]!==n||t[60]!==l||t[61]!==c?(F=s.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:l?s.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-base font-semibold",children:l}),s.jsx(Ft,{value:n,onValueChange:u=>h(u),children:s.jsx(Ht,{children:Object.keys(Lt).map(ys)})})]}),J?s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx("p",{className:"sr-only",children:"Loading…"}),s.jsxs("div",{className:c?"flex flex-col gap-6":"flex flex-col gap-6 invisible",children:[s.jsx(_t,{}),s.jsx(_t,{})]})]}):W.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No data yet for this range. Data is collected every minute while the agent is connected."}):s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(At,{title:"CPU %",color:"cpu",data:W,dataKey:"cpu",range:n,now:x,live:(r==null?void 0:r.cpu)??null}),s.jsx(At,{title:"RAM %",color:"mem",data:W,dataKey:"mem",range:n,now:x,live:(r==null?void 0:r.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Rt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=W,t[55]=r==null?void 0:r.cpu,t[56]=r==null?void 0:r.mem,t[57]=J,t[58]=x,t[59]=n,t[60]=l,t[61]=c,t[62]=F):F=t[62];let oe;return t[63]!==A||t[64]!==F?(oe=s.jsxs("div",{className:"flex h-full min-h-0",children:[y,A,F]}),t[63]=A,t[64]=F,t[65]=oe):oe=t[65],oe}function ys(t){return s.jsx(Ut,{value:t,children:Lt[t]},t)}function vs(t){return{time:t.recorded_at,cpu:gt(t.cpu_percent),mem:gt(t.mem_percent)}}function js(t){return t.agentName}const yt=t=>new Date(t.time).getTime(),Nt=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),Ve=t=>`${Math.round(t*10)/10}%`,bs=$t(yt).left,ws=$t(t=>t.t).left,U={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,Ss=20,Ns=40;function _t(){const t=He.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3","aria-hidden":!0,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xt,{className:"h-2.5 w-2.5 rounded-full"}),s.jsx(xt,{className:"h-5 w-12"})]}),s.jsx(xt,{className:"h-[220px] w-full"})]}),t[0]=e):e=t[0],e}function At(t){const e=He.c(18),{title:o,color:m,data:g,dataKey:i,range:n,now:h,live:R}=t,S=Et[m].color;let x;e[0]!==S?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:S}}),e[0]=S,e[1]=x):x=e[1];let v;e[2]!==o?(v=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=v):v=e[3];let p;e[4]!==x||e[5]!==v?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,v]}),e[4]=x,e[5]=v,e[6]=p):p=e[6];let j;e[7]!==g||e[8]!==i||e[9]!==S||e[10]!==R||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(Vt,{children:X=>{const{width:$,height:E}=X;return $>0&&E>0?s.jsx(ks,{width:$,height:E,data:g,dataKey:i,hex:S,range:n,now:h,live:R,label:o}):null}})}),e[7]=g,e[8]=i,e[9]=S,e[10]=R,e[11]=h,e[12]=n,e[13]=o,e[14]=j):j=e[14];let C;return e[15]!==p||e[16]!==j?(C=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3",children:[p,j]}),e[15]=p,e[16]=j,e[17]=C):C=e[17],C}function ks(t){const e=He.c(139),{width:o,height:m,data:g,dataKey:i,hex:n,range:h,now:R,live:S,label:x}=t,v=S===void 0?null:S,p=`chart-hint-${i}`,[j,C]=M.useState(null),[X,$]=M.useState(!1),[E,ce]=M.useState(null),[de,se]=M.useState(!1),V=de?E:null,d=o-U.left-U.right,f=m-U.top-U.bottom,B=R,ne=B-pt[h],b=Qt({domain:[ne,B],range:[0,Math.max(0,d)]}),l=Wt({domain:[0,100],range:[f,kt]}),q=d>0?Ss/d*pt[h]:0,ee=ne-q,te=B+q;let D;e[0]!==h||e[1]!==ee||e[2]!==te?(D=fs(ee,te,h),e[0]=h,e[1]=ee,e[2]=te,e[3]=D):D=e[3];const G=D,z=d>0?Math.min(.5,Ns/d):0,I=`fill-${i}`,Q=`plot-${i}`,P=`axis-fade-${i}`,Y=g[g.length-1],w=v!==null&&Y?{t:Math.max(B,yt(Y)+1),v,live:!0}:null;let J;e[4]!==i?(J=a=>({t:yt(a),v:a[i]}),e[4]=i,e[5]=J):J=e[5];const c=g.map(J);w&&c.push(w);const K=a=>Math.min(b(a),d),Z=w?K(w.t):0,W=w?l(w.v):0,le=Math.max(0,g.length-1),r=j===null?Math.max(0,c.length-1):j==="live"?w?c.length-1:le:Math.min(bs(g,j),le),y=X?c[r]:void 0,L=y?K(y.t):0,_=y?l(y.v):0,A=Et[i].label;let F;e[6]!==A?(F=a=>`${A}, ${Nt(a.t)}, ${a.live?"latest, ":""}${Ve(a.v)}`,e[6]=A,e[7]=F):F=e[7];const oe=F,u=a=>{const O=c[a];O&&(C(O.live?"live":O.t),$(!0),ce({now:a,text:oe(O)}))};let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>$(!1),e[8]=T):T=e[8];const N=T;let k,ae;e[9]!==X?(k=()=>{if(!X)return;const a=O=>{O.key==="Escape"&&$(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},ae=[X],e[9]=X,e[10]=k,e[11]=ae):(k=e[10],ae=e[11]),M.useEffect(k,ae);const re=a=>{if(c.length===0)return;const O=r,Ke=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,O-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(c.length-1,O+1):a.key==="Home"?0:a.key==="End"?c.length-1:null;Ke!==null&&(a.preventDefault(),u(Ke))},ie=a=>{const O=Xt(a);if(!O)return;const Ke=O.x-U.left,vt=ws(c,b.invert(Ke).getTime()),jt=[c[vt-1],c[vt],w].reduce((mt,ht)=>ht&&(!mt||Math.abs(K(ht.t)-Ke)<=Math.abs(K(mt.t)-Ke))?ht:mt,void 0);jt&&u(c.indexOf(jt))},Ue="group",Fe=w?`${x}, last ${h}. Now ${Ve(w.v)}.`:Y?`${x}, last ${h}. Latest ${Ve(Y[i])}.`:`${x}, last ${h}. No samples.`;let H;e[12]!==I||e[13]!==n?(H=s.jsx(zt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=H):H=e[14];const ze=Math.max(0,d),Ye=Math.max(0,f);let ue;e[15]!==ze||e[16]!==Ye?(ue=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=ue):ue=e[17];let fe;e[18]!==Q||e[19]!==ue?(fe=s.jsx("clipPath",{id:Q,children:ue}),e[18]=Q,e[19]=ue,e[20]=fe):fe=e[20];const Je=`${P}-grad`,Ze=Math.max(0,d);let Be;e[21]===Symbol.for("react.memo_cache_sentinel")?(Be=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=Be):Be=e[21];let me;e[22]!==z?(me=s.jsx("stop",{offset:z,stopColor:"white",stopOpacity:1}),e[22]=z,e[23]=me):me=e[23];const et=1-z;let he;e[24]!==et?(he=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=he):he=e[25];let qe;e[26]===Symbol.for("react.memo_cache_sentinel")?(qe=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=qe):qe=e[26];let xe;e[27]!==Je||e[28]!==Ze||e[29]!==me||e[30]!==he?(xe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[Be,me,he,qe]}),e[27]=Je,e[28]=Ze,e[29]=me,e[30]=he,e[31]=xe):xe=e[31];const tt=Math.max(0,d),st=Math.max(0,d),nt=`url(#${P}-grad)`;let pe;e[32]!==f||e[33]!==st||e[34]!==nt?(pe=s.jsx("rect",{x:0,y:f,width:st,height:U.bottom*2,fill:nt}),e[32]=f,e[33]=st,e[34]=nt,e[35]=pe):pe=e[35];let ge;e[36]!==P||e[37]!==f||e[38]!==tt||e[39]!==pe?(ge=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:f,width:tt,height:U.bottom*2,children:pe}),e[36]=P,e[37]=f,e[38]=tt,e[39]=pe,e[40]=ge):ge=e[40];let Ge;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ge=[0,25,50,75,100],e[41]=Ge):Ge=e[41];let ye;e[42]!==d||e[43]!==l?(ye=s.jsx(Yt,{scale:l,width:d,tickValues:Ge,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=d,e[43]=l,e[44]=ye):ye=e[44];const lt=`url(#${Q})`;let ve;e[45]!==b?(ve=a=>b(a.t),e[45]=b,e[46]=ve):ve=e[46];let je;e[47]!==l?(je=a=>l(a.v),e[47]=l,e[48]=je):je=e[48];const ot=`url(#${I})`;let be;e[49]!==c||e[50]!==ve||e[51]!==je||e[52]!==ot||e[53]!==l?(be=s.jsx(Jt,{data:c,x:ve,y:je,yScale:l,curve:St,fill:ot}),e[49]=c,e[50]=ve,e[51]=je,e[52]=ot,e[53]=l,e[54]=be):be=e[54];let we;e[55]!==b?(we=a=>b(a.t),e[55]=b,e[56]=we):we=e[56];let Se;e[57]!==l?(Se=a=>l(a.v),e[57]=l,e[58]=Se):Se=e[58];let Ne;e[59]!==n||e[60]!==c||e[61]!==we||e[62]!==Se?(Ne=s.jsx(Zt,{data:c,x:we,y:Se,curve:St,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=c,e[61]=we,e[62]=Se,e[63]=Ne):Ne=e[63];let ke;e[64]!==lt||e[65]!==be||e[66]!==Ne?(ke=s.jsxs("g",{clipPath:lt,children:[be,Ne]}),e[64]=lt,e[65]=be,e[66]=Ne,e[67]=ke):ke=e[67];const at=`url(#${P})`;let Me;e[68]!==h?(Me=a=>ms(+a,h),e[68]=h,e[69]=Me):Me=e[69];let _e;e[70]!==f||e[71]!==Me||e[72]!==G||e[73]!==b?(_e=s.jsx(es,{top:f,scale:b,tickValues:G,tickFormat:Me,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:As}),e[70]=f,e[71]=Me,e[72]=G,e[73]=b,e[74]=_e):_e=e[74];let Ae;e[75]!==at||e[76]!==_e?(Ae=s.jsx("g",{mask:at,children:_e}),e[75]=at,e[76]=_e,e[77]=Ae):Ae=e[77];let Qe;e[78]===Symbol.for("react.memo_cache_sentinel")?(Qe=[0,25,50,75,100],e[78]=Qe):Qe=e[78];let $e;e[79]!==l?($e=s.jsx(ts,{scale:l,tickValues:Qe,tickFormat:_s,hideAxisLine:!0,hideTicks:!0,tickLabelProps:Ms}),e[79]=l,e[80]=$e):$e=e[80];let Ee;e[81]!==Z||e[82]!==W||e[83]!==n||e[84]!==w?(Ee=w&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:Z,cy:W,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:Z,cy:W,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=Z,e[82]=W,e[83]=n,e[84]=w,e[85]=Ee):Ee=e[85];let Le;e[86]!==n||e[87]!==f||e[88]!==y||e[89]!==L||e[90]!==_?(Le=y&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${L}px)`},pointerEvents:"none",children:[s.jsx(ss,{from:{x:0,y:kt},to:{x:0,y:f},stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:0,cy:0,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5,style:{transition:"transform 0.25s ease-out",transform:`translateY(${_}px)`}})]}),e[86]=n,e[87]=f,e[88]=y,e[89]=L,e[90]=_,e[91]=Le):Le=e[91];const rt=Math.max(0,d)+Mt,it=Math.max(0,f),ct=`${x} samples`,dt=Math.max(0,c.length-1),ut=V?Math.min(V.now,Math.max(0,c.length-1)):r,ft=V?V.text:c[r]?oe(c[r]):void 0;let Te;e[92]!==r||e[93]!==u?(Te=()=>{se(!0),u(r)},e[92]=r,e[93]=u,e[94]=Te):Te=e[94];let Oe;e[95]!==N?(Oe=()=>{N(),se(!1)},e[95]=N,e[96]=Oe):Oe=e[96];let Re;e[97]!==re||e[98]!==ie||e[99]!==N||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Te||e[108]!==Oe?(Re=s.jsx(ns,{x:0,y:0,width:rt,height:it,fill:"transparent",tabIndex:0,role:"slider","aria-label":ct,"aria-valuemin":0,"aria-valuemax":dt,"aria-valuenow":ut,"aria-valuetext":ft,"aria-describedby":p,className:"outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",onFocus:Te,onBlur:Oe,onKeyDown:re,onMouseMove:ie,onMouseLeave:N,onTouchMove:ie,onTouchEnd:N,onTouchCancel:N}),e[97]=re,e[98]=ie,e[99]=N,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Te,e[108]=Oe,e[109]=Re):Re=e[109];let Ce;e[110]!==ye||e[111]!==ke||e[112]!==Ae||e[113]!==$e||e[114]!==Ee||e[115]!==Le||e[116]!==Re?(Ce=s.jsxs(ls,{left:U.left,top:U.top,children:[ye,ke,Ae,$e,Ee,Le,Re]}),e[110]=ye,e[111]=ke,e[112]=Ae,e[113]=$e,e[114]=Ee,e[115]=Le,e[116]=Re,e[117]=Ce):Ce=e[117];let De;e[118]!==m||e[119]!==Fe||e[120]!==H||e[121]!==fe||e[122]!==xe||e[123]!==ge||e[124]!==Ce||e[125]!==o?(De=s.jsxs("svg",{width:o,height:m,role:Ue,"aria-label":Fe,children:[H,fe,xe,ge,Ce]}),e[118]=m,e[119]=Fe,e[120]=H,e[121]=fe,e[122]=xe,e[123]=ge,e[124]=Ce,e[125]=o,e[126]=De):De=e[126];let Ie;e[127]!==p?(Ie=s.jsx("p",{id:p,className:"sr-only",children:"Use the arrow keys to read individual samples, and End for the latest value. Escape hides the reading."}),e[127]=p,e[128]=Ie):Ie=e[128];let Pe;e[129]!==d||e[130]!==A||e[131]!==y||e[132]!==L||e[133]!==_?(Pe=y&&s.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 whitespace-nowrap rounded-lg border bg-background px-3 py-2 text-xs text-foreground shadow-md",style:{transform:`translate(${L+U.left}px, ${_+U.top}px) translate(${L>d*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",Nt(y.t)]}),s.jsxs("p",{children:[A,": ",Ve(y.v)]})]}),e[129]=d,e[130]=A,e[131]=y,e[132]=L,e[133]=_,e[134]=Pe):Pe=e[134];let We;return e[135]!==De||e[136]!==Ie||e[137]!==Pe?(We=s.jsxs(s.Fragment,{children:[De,Ie,Pe]}),e[135]=De,e[136]=Ie,e[137]=Pe,e[138]=We):We=e[138],We}function Ms(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function _s(t){return`${t}%`}function As(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{ks as AreaChartInner,Is as MacResources};
1
+ import{r as M,c as He,j as s}from"./vendor-react-DTSdA8m-.js";import{ak as Tt,c as bt,b as Ot,ay as Rt,az as Ct,q as Xe,aA as Dt,Q as xt}from"./index-CiJwpDAf.js";import{u as It}from"./useRelay-CES3I1Mt.js";import{u as Pt,S as Kt}from"./useShownAfter-By1Yxysz.js";import{c as Ft,a as Ht,T as Ut}from"./tabs-SLpwFQLx.js";import{R as Bt}from"./resource-health-oWJ8hy9X.js";import{t as qt,a as wt,b as Gt,c as Qt,d as Wt,e as $t,l as Xt,P as Vt,L as zt,G as Yt,A as Jt,m as St,f as Zt,g as es,h as ts,i as ss,B as ns,j as ls}from"./vendor-charts-BE7R_8yA.js";import"./vendor-router-B1pQim9Z.js";const os=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function as(){return M.useSyncExternalStore(os,is,rs)}function rs(){return!0}function is(){return document.visibilityState!=="hidden"}function cs(t,e){const o=He.c(4),[m,g]=M.useState(ds);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;g(Date.now());const h=setInterval(()=>g(Date.now()),t);return()=>clearInterval(h)},n=[t,e],o[0]=e,o[1]=t,o[2]=i,o[3]=n):(i=o[2],n=o[3]),M.useEffect(i,n),m}function ds(){return Date.now()}const pt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},us={"1h":Gt.every(10),"6h":wt,"24h":wt.every(3),"7d":qt};function fs(t,e,o){return us[o].range(new Date(t),new Date(e+1))}function ms(t,e){const o=new Date(t);return e==="7d"?`${o.getMonth()+1}/${o.getDate()}`:`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`}const hs=2e3;function xs(t){return Math.min(1e4,Math.max(1e3,pt[t]/hs))}const ps={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},gt=t=>Math.round(t*10)/10;function gs(t,e,o){let m;for(const i of t){const n=i.agentName===e?i.resources:void 0;n&&(!m||n.reportedAt>m.reportedAt)&&(m=n)}if(!m||o-m.reportedAt>Bt)return null;const g=i=>Number.isFinite(i)?gt(i):null;return{cpu:g(m.cpuPercent),mem:g(m.memUsedMB/m.memTotalMB*100)}}const Et={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},Lt={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Is(){const t=He.c(66);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=M.useState(e),[g,i]=M.useState(null),[n,h]=M.useState("24h"),R=as();let S;t[1]!==n?(S=xs(n),t[1]=n,t[2]=S):S=t[2];const x=cs(S,R),{setNode:v}=Tt();let p,j;t[3]!==v?(p=()=>(v(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>v(null)),j=[v],t[3]=v,t[4]=p,t[5]=j):(p=t[4],j=t[5]),M.useEffect(p,j);let C;t[6]===Symbol.for("react.memo_cache_sentinel")?(C=u=>{u.type==="agents:listed"&&m(u.sessions??[])},t[6]=C):C=t[6];const X=C,{send:$,connected:E}=It(X);let ce,de;t[7]!==E||t[8]!==$?(ce=()=>{if(!E)return;$({type:"agents:list"});const u=setInterval(()=>$({type:"agents:list"}),1e4);return()=>clearInterval(u)},de=[E,$],t[7]=E,t[8]=$,t[9]=ce,t[10]=de):(ce=t[9],de=t[10]),M.useEffect(ce,de);let se;t[11]===Symbol.for("react.memo_cache_sentinel")?(se={queryKey:Xe.agents,queryFn:Ct,refetchOnWindowFocus:!1},t[11]=se):se=t[11];const V=bt(se);let d,f,B,ne;t[12]!==V.data||t[13]!==o?(B=V.data??[],f=o.map(js).filter(Boolean),d=[...new Set([...f,...B])],ne=new Set(f),t[12]=V.data,t[13]=o,t[14]=d,t[15]=f,t[16]=B,t[17]=ne):(d=t[14],f=t[15],B=t[16],ne=t[17]);const b=ne,l=g??(V.isPending?null:B[0]??f[0]??null),q=Ot();let ee;t[18]!==n||t[19]!==l?(ee=l?Xe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=ee):ee=t[20];const te=ee;let D;t[21]!==te||t[22]!==n?(D=te??Xe.resourceHistory("",n),t[21]=te,t[22]=n,t[23]=D):D=t[23];let G;t[24]!==n||t[25]!==l?(G=u=>{const{signal:T}=u;return Dt(l,n,T)},t[24]=n,t[25]=l,t[26]=G):G=t[26];let z;t[27]!==D||t[28]!==G?(z={queryKey:D,queryFn:G,enabled:!1},t[27]=D,t[28]=G,t[29]=z):z=t[29];const I=bt(z),Q=I.refetch;let P,Y;t[30]!==q||t[31]!==n||t[32]!==Q||t[33]!==l||t[34]!==R?(P=()=>{if(!l||!R)return;const u=Xe.resourceHistory(l,n),T=ps[n],N=()=>{const H=q.getQueryState(u);(H==null?void 0:H.fetchStatus)==="fetching"&&H.data===void 0?q.cancelQueries({queryKey:u,exact:!0}).then(()=>Q()):Q({cancelRefetch:!0})},k=q.getQueryState(u),ae=Math.max((k==null?void 0:k.dataUpdatedAt)??0,(k==null?void 0:k.errorUpdatedAt)??0),re=(k==null?void 0:k.data)!==void 0&&ae>0?Math.max(0,T-(Date.now()-ae)):0;let ie;const Ue=()=>{N(),ie=setInterval(N,T)},Fe=re>0?setTimeout(Ue,re):void 0;return re===0&&Ue(),()=>{clearTimeout(Fe),clearInterval(ie),q.cancelQueries({queryKey:u,exact:!0})}},Y=[l,n,R,Q,q],t[30]=q,t[31]=n,t[32]=Q,t[33]=l,t[34]=R,t[35]=P,t[36]=Y):(P=t[35],Y=t[36]),M.useEffect(P,Y);const w=I.data!==void 0||I.isError,J=te!==null&&!w,c=Pt(J,Kt);let K;t[37]!==I.data?(K=I.data??[],t[37]=I.data,t[38]=K):K=t[38];let Z;t[39]!==K?(Z=K.map(vs),t[39]=K,t[40]=Z):Z=t[40];const W=Z;let le;t[41]!==x||t[42]!==l||t[43]!==o?(le=l?gs(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=le):le=t[44];const r=le;let y;t[45]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=y):y=t[45];let L;t[46]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx("h2",{id:"macs-heading",className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Macs"}),t[46]=L):L=t[46];let _;t[47]!==d||t[48]!==E||t[49]!==b||t[50]!==l?(_=d.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:E?"No agents yet.":"Connecting…"}):d.map(u=>{const T=b.has(u),N=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":N?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",N?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${T?"bg-emerald-400":"bg-muted-foreground/40"}`,"aria-hidden":"true"}),s.jsx("span",{className:"truncate min-w-0",children:u}),s.jsx("span",{className:"sr-only",children:T?"Online":"Offline"})]},u)}),t[47]=d,t[48]=E,t[49]=b,t[50]=l,t[51]=_):_=t[51];let A;t[52]!==_?(A=s.jsxs("aside",{"aria-labelledby":"macs-heading",className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[L,_]}),t[52]=_,t[53]=A):A=t[53];let F;t[54]!==W||t[55]!==(r==null?void 0:r.cpu)||t[56]!==(r==null?void 0:r.mem)||t[57]!==J||t[58]!==x||t[59]!==n||t[60]!==l||t[61]!==c?(F=s.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:l?s.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-base font-semibold",children:l}),s.jsx(Ft,{value:n,onValueChange:u=>h(u),children:s.jsx(Ht,{children:Object.keys(Lt).map(ys)})})]}),J?s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx("p",{className:"sr-only",children:"Loading…"}),s.jsxs("div",{className:c?"flex flex-col gap-6":"flex flex-col gap-6 invisible",children:[s.jsx(_t,{}),s.jsx(_t,{})]})]}):W.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No data yet for this range. Data is collected every minute while the agent is connected."}):s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(At,{title:"CPU %",color:"cpu",data:W,dataKey:"cpu",range:n,now:x,live:(r==null?void 0:r.cpu)??null}),s.jsx(At,{title:"RAM %",color:"mem",data:W,dataKey:"mem",range:n,now:x,live:(r==null?void 0:r.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Rt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=W,t[55]=r==null?void 0:r.cpu,t[56]=r==null?void 0:r.mem,t[57]=J,t[58]=x,t[59]=n,t[60]=l,t[61]=c,t[62]=F):F=t[62];let oe;return t[63]!==A||t[64]!==F?(oe=s.jsxs("div",{className:"flex h-full min-h-0",children:[y,A,F]}),t[63]=A,t[64]=F,t[65]=oe):oe=t[65],oe}function ys(t){return s.jsx(Ut,{value:t,children:Lt[t]},t)}function vs(t){return{time:t.recorded_at,cpu:gt(t.cpu_percent),mem:gt(t.mem_percent)}}function js(t){return t.agentName}const yt=t=>new Date(t.time).getTime(),Nt=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),Ve=t=>`${Math.round(t*10)/10}%`,bs=$t(yt).left,ws=$t(t=>t.t).left,U={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,Ss=20,Ns=40;function _t(){const t=He.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3","aria-hidden":!0,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xt,{className:"h-2.5 w-2.5 rounded-full"}),s.jsx(xt,{className:"h-5 w-12"})]}),s.jsx(xt,{className:"h-[220px] w-full"})]}),t[0]=e):e=t[0],e}function At(t){const e=He.c(18),{title:o,color:m,data:g,dataKey:i,range:n,now:h,live:R}=t,S=Et[m].color;let x;e[0]!==S?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:S}}),e[0]=S,e[1]=x):x=e[1];let v;e[2]!==o?(v=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=v):v=e[3];let p;e[4]!==x||e[5]!==v?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,v]}),e[4]=x,e[5]=v,e[6]=p):p=e[6];let j;e[7]!==g||e[8]!==i||e[9]!==S||e[10]!==R||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(Vt,{children:X=>{const{width:$,height:E}=X;return $>0&&E>0?s.jsx(ks,{width:$,height:E,data:g,dataKey:i,hex:S,range:n,now:h,live:R,label:o}):null}})}),e[7]=g,e[8]=i,e[9]=S,e[10]=R,e[11]=h,e[12]=n,e[13]=o,e[14]=j):j=e[14];let C;return e[15]!==p||e[16]!==j?(C=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3",children:[p,j]}),e[15]=p,e[16]=j,e[17]=C):C=e[17],C}function ks(t){const e=He.c(139),{width:o,height:m,data:g,dataKey:i,hex:n,range:h,now:R,live:S,label:x}=t,v=S===void 0?null:S,p=`chart-hint-${i}`,[j,C]=M.useState(null),[X,$]=M.useState(!1),[E,ce]=M.useState(null),[de,se]=M.useState(!1),V=de?E:null,d=o-U.left-U.right,f=m-U.top-U.bottom,B=R,ne=B-pt[h],b=Qt({domain:[ne,B],range:[0,Math.max(0,d)]}),l=Wt({domain:[0,100],range:[f,kt]}),q=d>0?Ss/d*pt[h]:0,ee=ne-q,te=B+q;let D;e[0]!==h||e[1]!==ee||e[2]!==te?(D=fs(ee,te,h),e[0]=h,e[1]=ee,e[2]=te,e[3]=D):D=e[3];const G=D,z=d>0?Math.min(.5,Ns/d):0,I=`fill-${i}`,Q=`plot-${i}`,P=`axis-fade-${i}`,Y=g[g.length-1],w=v!==null&&Y?{t:Math.max(B,yt(Y)+1),v,live:!0}:null;let J;e[4]!==i?(J=a=>({t:yt(a),v:a[i]}),e[4]=i,e[5]=J):J=e[5];const c=g.map(J);w&&c.push(w);const K=a=>Math.min(b(a),d),Z=w?K(w.t):0,W=w?l(w.v):0,le=Math.max(0,g.length-1),r=j===null?Math.max(0,c.length-1):j==="live"?w?c.length-1:le:Math.min(bs(g,j),le),y=X?c[r]:void 0,L=y?K(y.t):0,_=y?l(y.v):0,A=Et[i].label;let F;e[6]!==A?(F=a=>`${A}, ${Nt(a.t)}, ${a.live?"latest, ":""}${Ve(a.v)}`,e[6]=A,e[7]=F):F=e[7];const oe=F,u=a=>{const O=c[a];O&&(C(O.live?"live":O.t),$(!0),ce({now:a,text:oe(O)}))};let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>$(!1),e[8]=T):T=e[8];const N=T;let k,ae;e[9]!==X?(k=()=>{if(!X)return;const a=O=>{O.key==="Escape"&&$(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},ae=[X],e[9]=X,e[10]=k,e[11]=ae):(k=e[10],ae=e[11]),M.useEffect(k,ae);const re=a=>{if(c.length===0)return;const O=r,Ke=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,O-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(c.length-1,O+1):a.key==="Home"?0:a.key==="End"?c.length-1:null;Ke!==null&&(a.preventDefault(),u(Ke))},ie=a=>{const O=Xt(a);if(!O)return;const Ke=O.x-U.left,vt=ws(c,b.invert(Ke).getTime()),jt=[c[vt-1],c[vt],w].reduce((mt,ht)=>ht&&(!mt||Math.abs(K(ht.t)-Ke)<=Math.abs(K(mt.t)-Ke))?ht:mt,void 0);jt&&u(c.indexOf(jt))},Ue="group",Fe=w?`${x}, last ${h}. Now ${Ve(w.v)}.`:Y?`${x}, last ${h}. Latest ${Ve(Y[i])}.`:`${x}, last ${h}. No samples.`;let H;e[12]!==I||e[13]!==n?(H=s.jsx(zt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=H):H=e[14];const ze=Math.max(0,d),Ye=Math.max(0,f);let ue;e[15]!==ze||e[16]!==Ye?(ue=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=ue):ue=e[17];let fe;e[18]!==Q||e[19]!==ue?(fe=s.jsx("clipPath",{id:Q,children:ue}),e[18]=Q,e[19]=ue,e[20]=fe):fe=e[20];const Je=`${P}-grad`,Ze=Math.max(0,d);let Be;e[21]===Symbol.for("react.memo_cache_sentinel")?(Be=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=Be):Be=e[21];let me;e[22]!==z?(me=s.jsx("stop",{offset:z,stopColor:"white",stopOpacity:1}),e[22]=z,e[23]=me):me=e[23];const et=1-z;let he;e[24]!==et?(he=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=he):he=e[25];let qe;e[26]===Symbol.for("react.memo_cache_sentinel")?(qe=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=qe):qe=e[26];let xe;e[27]!==Je||e[28]!==Ze||e[29]!==me||e[30]!==he?(xe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[Be,me,he,qe]}),e[27]=Je,e[28]=Ze,e[29]=me,e[30]=he,e[31]=xe):xe=e[31];const tt=Math.max(0,d),st=Math.max(0,d),nt=`url(#${P}-grad)`;let pe;e[32]!==f||e[33]!==st||e[34]!==nt?(pe=s.jsx("rect",{x:0,y:f,width:st,height:U.bottom*2,fill:nt}),e[32]=f,e[33]=st,e[34]=nt,e[35]=pe):pe=e[35];let ge;e[36]!==P||e[37]!==f||e[38]!==tt||e[39]!==pe?(ge=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:f,width:tt,height:U.bottom*2,children:pe}),e[36]=P,e[37]=f,e[38]=tt,e[39]=pe,e[40]=ge):ge=e[40];let Ge;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ge=[0,25,50,75,100],e[41]=Ge):Ge=e[41];let ye;e[42]!==d||e[43]!==l?(ye=s.jsx(Yt,{scale:l,width:d,tickValues:Ge,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=d,e[43]=l,e[44]=ye):ye=e[44];const lt=`url(#${Q})`;let ve;e[45]!==b?(ve=a=>b(a.t),e[45]=b,e[46]=ve):ve=e[46];let je;e[47]!==l?(je=a=>l(a.v),e[47]=l,e[48]=je):je=e[48];const ot=`url(#${I})`;let be;e[49]!==c||e[50]!==ve||e[51]!==je||e[52]!==ot||e[53]!==l?(be=s.jsx(Jt,{data:c,x:ve,y:je,yScale:l,curve:St,fill:ot}),e[49]=c,e[50]=ve,e[51]=je,e[52]=ot,e[53]=l,e[54]=be):be=e[54];let we;e[55]!==b?(we=a=>b(a.t),e[55]=b,e[56]=we):we=e[56];let Se;e[57]!==l?(Se=a=>l(a.v),e[57]=l,e[58]=Se):Se=e[58];let Ne;e[59]!==n||e[60]!==c||e[61]!==we||e[62]!==Se?(Ne=s.jsx(Zt,{data:c,x:we,y:Se,curve:St,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=c,e[61]=we,e[62]=Se,e[63]=Ne):Ne=e[63];let ke;e[64]!==lt||e[65]!==be||e[66]!==Ne?(ke=s.jsxs("g",{clipPath:lt,children:[be,Ne]}),e[64]=lt,e[65]=be,e[66]=Ne,e[67]=ke):ke=e[67];const at=`url(#${P})`;let Me;e[68]!==h?(Me=a=>ms(+a,h),e[68]=h,e[69]=Me):Me=e[69];let _e;e[70]!==f||e[71]!==Me||e[72]!==G||e[73]!==b?(_e=s.jsx(es,{top:f,scale:b,tickValues:G,tickFormat:Me,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:As}),e[70]=f,e[71]=Me,e[72]=G,e[73]=b,e[74]=_e):_e=e[74];let Ae;e[75]!==at||e[76]!==_e?(Ae=s.jsx("g",{mask:at,children:_e}),e[75]=at,e[76]=_e,e[77]=Ae):Ae=e[77];let Qe;e[78]===Symbol.for("react.memo_cache_sentinel")?(Qe=[0,25,50,75,100],e[78]=Qe):Qe=e[78];let $e;e[79]!==l?($e=s.jsx(ts,{scale:l,tickValues:Qe,tickFormat:_s,hideAxisLine:!0,hideTicks:!0,tickLabelProps:Ms}),e[79]=l,e[80]=$e):$e=e[80];let Ee;e[81]!==Z||e[82]!==W||e[83]!==n||e[84]!==w?(Ee=w&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:Z,cy:W,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:Z,cy:W,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=Z,e[82]=W,e[83]=n,e[84]=w,e[85]=Ee):Ee=e[85];let Le;e[86]!==n||e[87]!==f||e[88]!==y||e[89]!==L||e[90]!==_?(Le=y&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${L}px)`},pointerEvents:"none",children:[s.jsx(ss,{from:{x:0,y:kt},to:{x:0,y:f},stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:0,cy:0,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5,style:{transition:"transform 0.25s ease-out",transform:`translateY(${_}px)`}})]}),e[86]=n,e[87]=f,e[88]=y,e[89]=L,e[90]=_,e[91]=Le):Le=e[91];const rt=Math.max(0,d)+Mt,it=Math.max(0,f),ct=`${x} samples`,dt=Math.max(0,c.length-1),ut=V?Math.min(V.now,Math.max(0,c.length-1)):r,ft=V?V.text:c[r]?oe(c[r]):void 0;let Te;e[92]!==r||e[93]!==u?(Te=()=>{se(!0),u(r)},e[92]=r,e[93]=u,e[94]=Te):Te=e[94];let Oe;e[95]!==N?(Oe=()=>{N(),se(!1)},e[95]=N,e[96]=Oe):Oe=e[96];let Re;e[97]!==re||e[98]!==ie||e[99]!==N||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Te||e[108]!==Oe?(Re=s.jsx(ns,{x:0,y:0,width:rt,height:it,fill:"transparent",tabIndex:0,role:"slider","aria-label":ct,"aria-valuemin":0,"aria-valuemax":dt,"aria-valuenow":ut,"aria-valuetext":ft,"aria-describedby":p,className:"outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",onFocus:Te,onBlur:Oe,onKeyDown:re,onMouseMove:ie,onMouseLeave:N,onTouchMove:ie,onTouchEnd:N,onTouchCancel:N}),e[97]=re,e[98]=ie,e[99]=N,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Te,e[108]=Oe,e[109]=Re):Re=e[109];let Ce;e[110]!==ye||e[111]!==ke||e[112]!==Ae||e[113]!==$e||e[114]!==Ee||e[115]!==Le||e[116]!==Re?(Ce=s.jsxs(ls,{left:U.left,top:U.top,children:[ye,ke,Ae,$e,Ee,Le,Re]}),e[110]=ye,e[111]=ke,e[112]=Ae,e[113]=$e,e[114]=Ee,e[115]=Le,e[116]=Re,e[117]=Ce):Ce=e[117];let De;e[118]!==m||e[119]!==Fe||e[120]!==H||e[121]!==fe||e[122]!==xe||e[123]!==ge||e[124]!==Ce||e[125]!==o?(De=s.jsxs("svg",{width:o,height:m,role:Ue,"aria-label":Fe,children:[H,fe,xe,ge,Ce]}),e[118]=m,e[119]=Fe,e[120]=H,e[121]=fe,e[122]=xe,e[123]=ge,e[124]=Ce,e[125]=o,e[126]=De):De=e[126];let Ie;e[127]!==p?(Ie=s.jsx("p",{id:p,className:"sr-only",children:"Use the arrow keys to read individual samples, and End for the latest value. Escape hides the reading."}),e[127]=p,e[128]=Ie):Ie=e[128];let Pe;e[129]!==d||e[130]!==A||e[131]!==y||e[132]!==L||e[133]!==_?(Pe=y&&s.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 whitespace-nowrap rounded-lg border bg-background px-3 py-2 text-xs text-foreground shadow-md",style:{transform:`translate(${L+U.left}px, ${_+U.top}px) translate(${L>d*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",Nt(y.t)]}),s.jsxs("p",{children:[A,": ",Ve(y.v)]})]}),e[129]=d,e[130]=A,e[131]=y,e[132]=L,e[133]=_,e[134]=Pe):Pe=e[134];let We;return e[135]!==De||e[136]!==Ie||e[137]!==Pe?(We=s.jsxs(s.Fragment,{children:[De,Ie,Pe]}),e[135]=De,e[136]=Ie,e[137]=Pe,e[138]=We):We=e[138],We}function Ms(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function _s(t){return`${t}%`}function As(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{ks as AreaChartInner,Is as MacResources};