@tapflowio/relay 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RelayServer.d.ts +7 -1
- package/dist/RelayServer.d.ts.map +1 -1
- package/dist/RelayServer.js +22 -6
- package/dist/RelayServer.js.map +1 -1
- package/dist/api/auth.d.ts +1 -1
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +28 -8
- package/dist/api/auth.js.map +1 -1
- package/dist/api/invitations.d.ts +3 -1
- package/dist/api/invitations.d.ts.map +1 -1
- package/dist/api/invitations.js +16 -20
- package/dist/api/invitations.js.map +1 -1
- package/dist/api/passwordReset.d.ts +13 -2
- package/dist/api/passwordReset.d.ts.map +1 -1
- package/dist/api/passwordReset.js +45 -10
- package/dist/api/passwordReset.js.map +1 -1
- package/dist/api/team.d.ts.map +1 -1
- package/dist/api/team.js +9 -3
- package/dist/api/team.js.map +1 -1
- package/dist/api/tokens.d.ts.map +1 -1
- package/dist/api/tokens.js +7 -1
- package/dist/api/tokens.js.map +1 -1
- package/dist/lib/adminAccount.d.ts +0 -5
- package/dist/lib/adminAccount.d.ts.map +1 -1
- package/dist/lib/adminAccount.js +6 -7
- package/dist/lib/adminAccount.js.map +1 -1
- package/dist/lib/connectionAuth.d.ts +6 -5
- package/dist/lib/connectionAuth.d.ts.map +1 -1
- package/dist/lib/connectionAuth.js +4 -3
- package/dist/lib/connectionAuth.js.map +1 -1
- package/dist/lib/email.d.ts +16 -0
- package/dist/lib/email.d.ts.map +1 -0
- package/dist/lib/email.js +18 -0
- package/dist/lib/email.js.map +1 -0
- package/dist/middleware/auth.d.ts +20 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +33 -6
- package/dist/middleware/auth.js.map +1 -1
- package/dist/migrations/014_normalize_emails.sql +16 -0
- package/package.json +3 -3
- package/public/assets/{AppCenter-D_1rFI40.js → AppCenter-DZCsC2wa.js} +1 -1
- package/public/assets/AppCenter-DZCsC2wa.js.br +0 -0
- package/public/assets/AppCenter-DZCsC2wa.js.gz +0 -0
- package/public/assets/{Default-DF_X2_3I.js → Default-xD9Fmd5X.js} +1 -1
- package/public/assets/Default-xD9Fmd5X.js.br +0 -0
- package/public/assets/Default-xD9Fmd5X.js.gz +0 -0
- package/public/assets/Invite-29Erwv8j.js +1 -0
- package/public/assets/Invite-29Erwv8j.js.br +0 -0
- package/public/assets/Invite-29Erwv8j.js.gz +0 -0
- package/public/assets/{MacResources--1Enisxs.js → MacResources-B0DQ9ISE.js} +1 -1
- package/public/assets/MacResources-B0DQ9ISE.js.br +0 -0
- package/public/assets/MacResources-B0DQ9ISE.js.gz +0 -0
- package/public/assets/QASession-D-n6PXuD.js +150 -0
- package/public/assets/QASession-D-n6PXuD.js.br +0 -0
- package/public/assets/QASession-D-n6PXuD.js.gz +0 -0
- package/public/assets/{ResetPassword-B9miyXTP.js → ResetPassword-BnPIwTYH.js} +1 -1
- package/public/assets/ResetPassword-BnPIwTYH.js.br +0 -0
- package/public/assets/ResetPassword-BnPIwTYH.js.gz +0 -0
- package/public/assets/{Setup-CywZCqHU.js → Setup-DmUGFblg.js} +1 -1
- package/public/assets/Setup-DmUGFblg.js.br +0 -0
- package/public/assets/Setup-DmUGFblg.js.gz +0 -0
- package/public/assets/Team-BpvRgFfZ.js +6 -0
- package/public/assets/Team-BpvRgFfZ.js.br +0 -0
- package/public/assets/Team-BpvRgFfZ.js.gz +0 -0
- package/public/assets/Tokens-x6BtCcL7.js +1 -0
- package/public/assets/Tokens-x6BtCcL7.js.br +0 -0
- package/public/assets/Tokens-x6BtCcL7.js.gz +0 -0
- package/public/assets/{alert-dialog-CuPdBkxF.js → alert-dialog-C8wDimW-.js} +1 -1
- package/public/assets/alert-dialog-C8wDimW-.js.br +0 -0
- package/public/assets/alert-dialog-C8wDimW-.js.gz +0 -0
- package/public/assets/{badge-CSVsKOK_.js → badge-CWVbeuH3.js} +1 -1
- package/public/assets/badge-CWVbeuH3.js.br +0 -0
- package/public/assets/badge-CWVbeuH3.js.gz +0 -0
- package/public/assets/{build-format-l9BrlbZl.js → build-format-fzt-JrUX.js} +1 -1
- package/public/assets/build-format-fzt-JrUX.js.br +0 -0
- package/public/assets/build-format-fzt-JrUX.js.gz +0 -0
- package/public/assets/{dialog-B6jt7-2f.js → dialog-DQkbaw8h.js} +2 -2
- package/public/assets/dialog-DQkbaw8h.js.br +0 -0
- package/public/assets/dialog-DQkbaw8h.js.gz +0 -0
- package/public/assets/{index-Cm17I31a.js → index-C1Fo8g_c.js} +32 -32
- package/public/assets/index-C1Fo8g_c.js.br +0 -0
- package/public/assets/index-C1Fo8g_c.js.gz +0 -0
- package/public/assets/index-C2F1AgwB.css +1 -0
- package/public/assets/index-C2F1AgwB.css.br +0 -0
- package/public/assets/{index-D_P99bPX.css.gz → index-C2F1AgwB.css.gz} +0 -0
- package/public/assets/{list-view-Bp6pvsde.js → list-view-DxI397-H.js} +1 -1
- package/public/assets/list-view-DxI397-H.js.br +0 -0
- package/public/assets/list-view-DxI397-H.js.gz +0 -0
- package/public/assets/{pencil-g-WiK1F2.js → pencil-BJcOp3oN.js} +1 -1
- package/public/assets/pencil-BJcOp3oN.js.br +0 -0
- package/public/assets/pencil-BJcOp3oN.js.gz +0 -0
- package/public/assets/{resource-health-BbeyA8an.js → resource-health-Cq3gqqVd.js} +1 -1
- package/public/assets/resource-health-Cq3gqqVd.js.br +0 -0
- package/public/assets/resource-health-Cq3gqqVd.js.gz +0 -0
- package/public/assets/{trash-DHPg15P4.js → trash-DhBxh6H7.js} +1 -1
- package/public/assets/trash-DhBxh6H7.js.br +0 -0
- package/public/assets/trash-DhBxh6H7.js.gz +0 -0
- package/public/index.html +2 -2
- package/public/index.html.br +0 -0
- package/public/index.html.gz +0 -0
- package/public/assets/AppCenter-D_1rFI40.js.br +0 -0
- package/public/assets/AppCenter-D_1rFI40.js.gz +0 -0
- package/public/assets/Default-DF_X2_3I.js.br +0 -0
- package/public/assets/Default-DF_X2_3I.js.gz +0 -0
- package/public/assets/Invite-DETTWdYp.js +0 -1
- package/public/assets/Invite-DETTWdYp.js.br +0 -0
- package/public/assets/Invite-DETTWdYp.js.gz +0 -0
- package/public/assets/MacResources--1Enisxs.js.br +0 -0
- package/public/assets/MacResources--1Enisxs.js.gz +0 -0
- package/public/assets/QASession-BjoD9Toj.js +0 -150
- package/public/assets/QASession-BjoD9Toj.js.br +0 -0
- package/public/assets/QASession-BjoD9Toj.js.gz +0 -0
- package/public/assets/ResetPassword-B9miyXTP.js.br +0 -0
- package/public/assets/ResetPassword-B9miyXTP.js.gz +0 -0
- package/public/assets/Setup-CywZCqHU.js.br +0 -0
- package/public/assets/Setup-CywZCqHU.js.gz +0 -0
- package/public/assets/Team-CxdX_9mY.js +0 -6
- package/public/assets/Team-CxdX_9mY.js.br +0 -0
- package/public/assets/Team-CxdX_9mY.js.gz +0 -0
- package/public/assets/Tokens-BQnnawvG.js +0 -1
- package/public/assets/Tokens-BQnnawvG.js.br +0 -0
- package/public/assets/Tokens-BQnnawvG.js.gz +0 -0
- package/public/assets/alert-dialog-CuPdBkxF.js.br +0 -0
- package/public/assets/alert-dialog-CuPdBkxF.js.gz +0 -0
- package/public/assets/badge-CSVsKOK_.js.br +0 -0
- package/public/assets/badge-CSVsKOK_.js.gz +0 -0
- package/public/assets/build-format-l9BrlbZl.js.br +0 -0
- package/public/assets/build-format-l9BrlbZl.js.gz +0 -0
- package/public/assets/dialog-B6jt7-2f.js.br +0 -0
- package/public/assets/dialog-B6jt7-2f.js.gz +0 -0
- package/public/assets/index-Cm17I31a.js.br +0 -0
- package/public/assets/index-Cm17I31a.js.gz +0 -0
- package/public/assets/index-D_P99bPX.css +0 -1
- package/public/assets/index-D_P99bPX.css.br +0 -0
- package/public/assets/list-view-Bp6pvsde.js.br +0 -0
- package/public/assets/list-view-Bp6pvsde.js.gz +0 -0
- package/public/assets/pencil-g-WiK1F2.js.br +0 -0
- package/public/assets/pencil-g-WiK1F2.js.gz +0 -0
- package/public/assets/resource-health-BbeyA8an.js.br +0 -0
- package/public/assets/resource-health-BbeyA8an.js.gz +0 -0
- package/public/assets/trash-DHPg15P4.js.br +0 -0
- package/public/assets/trash-DHPg15P4.js.gz +0 -0
|
@@ -46,8 +46,8 @@ export function classifyConnection({ isLocal, hasCookieAuth, patScopes, patOwner
|
|
|
46
46
|
* Would this socket still be accepted, given what the database says now? Returns the close reason, or
|
|
47
47
|
* null when it would.
|
|
48
48
|
*
|
|
49
|
-
* **One predicate instead of one rule per event.** Removal, demotion, revocation, expiry and
|
|
50
|
-
*
|
|
49
|
+
* **One predicate instead of one rule per event.** Removal, demotion, revocation, expiry and a
|
|
50
|
+
* password change all reach an open socket through the same question, asked on
|
|
51
51
|
* the heartbeat and again right after any of those writes. A list of "which sockets does this event
|
|
52
52
|
* affect" is the design this replaced, and it had already missed expiry and the invitation path.
|
|
53
53
|
*
|
|
@@ -57,7 +57,8 @@ export function classifyConnection({ isLocal, hasCookieAuth, patScopes, patOwner
|
|
|
57
57
|
*/
|
|
58
58
|
export function revalidatePrincipal(principal, role, current, nowSeconds) {
|
|
59
59
|
if (principal.via === 'cookie') {
|
|
60
|
-
|
|
60
|
+
// A changed password ends the session the same way a removed member does (`passwordVersion`).
|
|
61
|
+
if (current.userPasswordVersion !== principal.pwv)
|
|
61
62
|
return WS_REJECT_REASON;
|
|
62
63
|
if (principal.jwtExp !== undefined && principal.jwtExp <= nowSeconds)
|
|
63
64
|
return WS_REJECT_REASON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionAuth.js","sourceRoot":"","sources":["../../src/lib/connectionAuth.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAA;AAChC,MAAM,UAAU,GAAG,OAAO,CAAA;AAE1B,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAC3B,2GAA2G,C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deliberately the same function as SQLite's `lower(trim(x))`**, not JavaScript's `trim()` and
|
|
6
|
+
* `toLowerCase()`. SQLite's `lower` folds ASCII only and its `trim` removes spaces only, and migration
|
|
7
|
+
* 014 normalizes the rows already stored with those. Were this function wider, an address with a
|
|
8
|
+
* non-ASCII capital or a tab would be rewritten one way by the migration and looked up another way
|
|
9
|
+
* here, and could never sign in again. `EMAIL_KEY_SQL` is the column side of the same comparison.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeEmail(email: string): string;
|
|
12
|
+
/** `users.email` / `invitations.email` in normalized form, for comparing with `normalizeEmail(input)`. */
|
|
13
|
+
export declare const EMAIL_KEY_SQL = "lower(trim(email))";
|
|
14
|
+
/** The domain of the placeholder address a member invited without an email is given. Mail to it reaches nobody. */
|
|
15
|
+
export declare const SYNTHETIC_EMAIL_DOMAIN = "@tapflow.local";
|
|
16
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,0GAA0G;AAC1G,eAAO,MAAM,aAAa,uBAAuB,CAAA;AAEjD,mHAAmH;AACnH,eAAO,MAAM,sBAAsB,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The form an email address is stored and compared in: surrounding spaces removed, ASCII letters
|
|
3
|
+
* lowercased.
|
|
4
|
+
*
|
|
5
|
+
* **Deliberately the same function as SQLite's `lower(trim(x))`**, not JavaScript's `trim()` and
|
|
6
|
+
* `toLowerCase()`. SQLite's `lower` folds ASCII only and its `trim` removes spaces only, and migration
|
|
7
|
+
* 014 normalizes the rows already stored with those. Were this function wider, an address with a
|
|
8
|
+
* non-ASCII capital or a tab would be rewritten one way by the migration and looked up another way
|
|
9
|
+
* here, and could never sign in again. `EMAIL_KEY_SQL` is the column side of the same comparison.
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeEmail(email) {
|
|
12
|
+
return email.replace(/^ +| +$/g, '').replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
13
|
+
}
|
|
14
|
+
/** `users.email` / `invitations.email` in normalized form, for comparing with `normalizeEmail(input)`. */
|
|
15
|
+
export const EMAIL_KEY_SQL = 'lower(trim(email))';
|
|
16
|
+
/** The domain of the placeholder address a member invited without an email is given. Mail to it reaches nobody. */
|
|
17
|
+
export const SYNTHETIC_EMAIL_DOMAIN = '@tapflow.local';
|
|
18
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AAChF,CAAC;AAED,0GAA0G;AAC1G,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAA;AAEjD,mHAAmH;AACnH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAA"}
|
|
@@ -4,13 +4,30 @@ export interface AuthContext {
|
|
|
4
4
|
email: string;
|
|
5
5
|
role: string;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Which password a session was issued under: a keyed digest of the stored hash, carried in the JWT as
|
|
9
|
+
* `pwv` and compared with the row on every check. Changing the password in any way — reset link,
|
|
10
|
+
* self-service change, anything added later — changes the hash and so ends every session issued before
|
|
11
|
+
* it, without each writer having to remember to. A per-user "changed at" column was the alternative,
|
|
12
|
+
* and it needed exactly that memory: the self-service path was missed on paper before any code existed.
|
|
13
|
+
*
|
|
14
|
+
* Keyed with the JWT secret so the claim reveals nothing about the hash. A cookie issued before this
|
|
15
|
+
* claim existed carries none and is refused, which signs everyone in once after the upgrade: accepting
|
|
16
|
+
* it would leave a reset unable to end those sessions for their remaining seven days.
|
|
17
|
+
*/
|
|
18
|
+
export declare function passwordVersion(passwordHash: string | null): string;
|
|
19
|
+
/** Signs a session for `payload.userId`, bound to that user's current password (see `passwordVersion`). */
|
|
7
20
|
export declare function signJwt(payload: AuthContext): string;
|
|
21
|
+
/** The `Set-Cookie` value for a new session. One place, so every issuing path sets the same attributes. */
|
|
22
|
+
export declare function sessionCookie(payload: AuthContext): string;
|
|
8
23
|
export declare function verifyJwtOrThrow(token: string): AuthContext;
|
|
9
24
|
export declare function verifyJwt(token: string): AuthContext | null;
|
|
10
25
|
/** A signed-in session: who the cookie names, as the users table describes them now. */
|
|
11
26
|
export interface SessionAuth extends AuthContext {
|
|
12
27
|
/** The JWT's `exp` (seconds since the epoch), so an open socket can be closed when it passes. */
|
|
13
28
|
exp?: number;
|
|
29
|
+
/** The password version the session was issued under, so an open socket can be closed when it changes. */
|
|
30
|
+
pwv: string;
|
|
14
31
|
}
|
|
15
32
|
/**
|
|
16
33
|
* The cookie's user, **checked against the users table on every call**.
|
|
@@ -18,7 +35,8 @@ export interface SessionAuth extends AuthContext {
|
|
|
18
35
|
* The JWT lives seven days and removing a member deletes their row, so a signature check alone kept a
|
|
19
36
|
* removed member signed in for up to a week on every cookie path: this function, `requireViewAuth`,
|
|
20
37
|
* `requireBuildAuth`, recordings, and the WebSocket handshake. This is the one place all of them pass,
|
|
21
|
-
* so the row check lives here
|
|
38
|
+
* so the row check lives here, and so does the password-version check that ends sessions on a password
|
|
39
|
+
* change. User ids are `AUTOINCREMENT`, so a removed id never comes back and "the
|
|
22
40
|
* row exists" is a sound test. `email` and `role` come from the row, never from the JWT.
|
|
23
41
|
*
|
|
24
42
|
* Only the JWT verification failure becomes `null`. A database error propagates: turning a transient
|
|
@@ -28,6 +46,7 @@ export declare function getAuth(req: http.IncomingMessage): SessionAuth | null;
|
|
|
28
46
|
export declare function findUser(userId: number): {
|
|
29
47
|
email: string;
|
|
30
48
|
role: string;
|
|
49
|
+
pwv: string;
|
|
31
50
|
} | null;
|
|
32
51
|
export declare function requireAuth(req: http.IncomingMessage, res: http.ServerResponse): AuthContext | null;
|
|
33
52
|
export declare function currentRole(res: http.ServerResponse, userId: number): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAOvB,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAID,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAOvB,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEnE;AAED,2GAA2G;AAC3G,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAWpD;AAED,2GAA2G;AAC3G,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAE1D;AAOD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAM3D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAM3D;AAED,wFAAwF;AACxF,MAAM,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C,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAGrD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,eAAe,CAC7B,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,GACvB,WAAW,GAAG,IAAI,CAgBpB;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,GACvB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAc3B"}
|
package/dist/middleware/auth.js
CHANGED
|
@@ -4,8 +4,34 @@ import { AuthError } from '@tapflowio/agent-core';
|
|
|
4
4
|
import { getDb } from '../db.js';
|
|
5
5
|
import { getJwtSecret } from '../lib/config.js';
|
|
6
6
|
const JWT_EXPIRES = '7d';
|
|
7
|
+
/**
|
|
8
|
+
* Which password a session was issued under: a keyed digest of the stored hash, carried in the JWT as
|
|
9
|
+
* `pwv` and compared with the row on every check. Changing the password in any way — reset link,
|
|
10
|
+
* self-service change, anything added later — changes the hash and so ends every session issued before
|
|
11
|
+
* it, without each writer having to remember to. A per-user "changed at" column was the alternative,
|
|
12
|
+
* and it needed exactly that memory: the self-service path was missed on paper before any code existed.
|
|
13
|
+
*
|
|
14
|
+
* Keyed with the JWT secret so the claim reveals nothing about the hash. A cookie issued before this
|
|
15
|
+
* claim existed carries none and is refused, which signs everyone in once after the upgrade: accepting
|
|
16
|
+
* it would leave a reset unable to end those sessions for their remaining seven days.
|
|
17
|
+
*/
|
|
18
|
+
export function passwordVersion(passwordHash) {
|
|
19
|
+
return crypto.createHmac('sha256', getJwtSecret()).update(passwordHash ?? '').digest('hex').slice(0, 16);
|
|
20
|
+
}
|
|
21
|
+
/** Signs a session for `payload.userId`, bound to that user's current password (see `passwordVersion`). */
|
|
7
22
|
export function signJwt(payload) {
|
|
8
|
-
|
|
23
|
+
const row = getDb().prepare('SELECT password_hash FROM users WHERE id = ?').get(payload.userId);
|
|
24
|
+
// Picked, not spread: a caller holding a `SessionAuth` would otherwise pass its `exp` along, and
|
|
25
|
+
// `jwt.sign` refuses an `exp` beside `expiresIn`.
|
|
26
|
+
const claims = {
|
|
27
|
+
userId: payload.userId, email: payload.email, role: payload.role,
|
|
28
|
+
pwv: passwordVersion(row?.password_hash ?? null),
|
|
29
|
+
};
|
|
30
|
+
return jwt.sign(claims, getJwtSecret(), { expiresIn: JWT_EXPIRES });
|
|
31
|
+
}
|
|
32
|
+
/** The `Set-Cookie` value for a new session. One place, so every issuing path sets the same attributes. */
|
|
33
|
+
export function sessionCookie(payload) {
|
|
34
|
+
return `tapflow_token=${signJwt(payload)}; HttpOnly; Path=/; SameSite=Lax; Max-Age=${7 * 24 * 3600}`;
|
|
9
35
|
}
|
|
10
36
|
export function verifyJwtOrThrow(token) {
|
|
11
37
|
try {
|
|
@@ -29,7 +55,8 @@ export function verifyJwt(token) {
|
|
|
29
55
|
* The JWT lives seven days and removing a member deletes their row, so a signature check alone kept a
|
|
30
56
|
* removed member signed in for up to a week on every cookie path: this function, `requireViewAuth`,
|
|
31
57
|
* `requireBuildAuth`, recordings, and the WebSocket handshake. This is the one place all of them pass,
|
|
32
|
-
* so the row check lives here
|
|
58
|
+
* so the row check lives here, and so does the password-version check that ends sessions on a password
|
|
59
|
+
* change. User ids are `AUTOINCREMENT`, so a removed id never comes back and "the
|
|
33
60
|
* row exists" is a sound test. `email` and `role` come from the row, never from the JWT.
|
|
34
61
|
*
|
|
35
62
|
* Only the JWT verification failure becomes `null`. A database error propagates: turning a transient
|
|
@@ -44,13 +71,13 @@ export function getAuth(req) {
|
|
|
44
71
|
if (!claims)
|
|
45
72
|
return null;
|
|
46
73
|
const user = findUser(claims.userId);
|
|
47
|
-
if (!user)
|
|
74
|
+
if (!user || claims.pwv !== user.pwv)
|
|
48
75
|
return null;
|
|
49
|
-
return { userId: claims.userId, email: user.email, role: user.role, exp: claims.exp };
|
|
76
|
+
return { userId: claims.userId, email: user.email, role: user.role, exp: claims.exp, pwv: user.pwv };
|
|
50
77
|
}
|
|
51
78
|
export function findUser(userId) {
|
|
52
|
-
const row = getDb().prepare('SELECT email, role FROM users WHERE id = ?').get(userId);
|
|
53
|
-
return row
|
|
79
|
+
const row = getDb().prepare('SELECT email, role, password_hash FROM users WHERE id = ?').get(userId);
|
|
80
|
+
return row ? { email: row.email, role: row.role, pwv: passwordVersion(row.password_hash) } : null;
|
|
54
81
|
}
|
|
55
82
|
export function requireAuth(req, res) {
|
|
56
83
|
const auth = getAuth(req);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAQ/C,MAAM,WAAW,GAAG,IAAI,CAAA;AAExB,MAAM,UAAU,OAAO,CAAC,OAAoB;IAC1C,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,YAAY,EA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AAE,CAAC;YACzC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAA;YAC1D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAA;YACxD,OAAO,IAAI,CAAA;QACb,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACnB,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;IACD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- Store email addresses in the form `normalizeEmail` (lib/email.ts) produces: spaces trimmed, ASCII
|
|
2
|
+
-- lowercased. Before this, `Alice@x.com` and `alice@x.com` could be two accounts, and login matched
|
|
3
|
+
-- case exactly.
|
|
4
|
+
--
|
|
5
|
+
-- A row whose normalized address another row already has, or would have, is left untouched: rewriting
|
|
6
|
+
-- it would violate `UNIQUE(email)`, abort this migration, and with it the relay's boot. The relay logs
|
|
7
|
+
-- those groups at startup so an Admin can remove the duplicate.
|
|
8
|
+
UPDATE users SET email = lower(trim(email))
|
|
9
|
+
WHERE email <> lower(trim(email))
|
|
10
|
+
AND NOT EXISTS (
|
|
11
|
+
SELECT 1 FROM users other
|
|
12
|
+
WHERE other.id <> users.id AND lower(trim(other.email)) = lower(trim(users.email))
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
UPDATE invitations SET email = lower(trim(email))
|
|
16
|
+
WHERE email IS NOT NULL AND email <> lower(trim(email));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapflowio/relay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "WebSocket relay server for tapflow — NAT traversal, session routing, JWT auth, bundled dashboard",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tapflow",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"nodemailer": "^9.1.1",
|
|
53
53
|
"ws": "^8.21.3",
|
|
54
54
|
"zod": "^4.6.5",
|
|
55
|
-
"@tapflowio/agent-core": "0.
|
|
56
|
-
"@tapflowio/protocol": "0.
|
|
55
|
+
"@tapflowio/agent-core": "0.26.0",
|
|
56
|
+
"@tapflowio/protocol": "0.26.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ue=l=>{throw TypeError(l)};var Ee=(l,e,s)=>e.has(l)||Ue("Cannot "+s);var k=(l,e,s)=>(Ee(l,e,"read from private field"),s?s.call(l):e.get(l)),fe=(l,e,s)=>e.has(l)?Ue("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,s),me=(l,e,s,a)=>(Ee(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),he=(l,e,s)=>(Ee(l,e,"access private method"),s);import{k as c,f as pe,j as t}from"./vendor-react-BlPSzrEe.js";import{z as xt,as as gt,ak as Ve,ac as bt,ao as et,aJ as tt,an as jt,at as yt,a2 as ve,av as J,B as re,L as ye,W as vt,I as He,F as St,Z as Nt,S as wt,G as Dt,T as kt,H as Ct,E as _t,f as At,ay as It,aI as We,aj as Et,Q as Ot,ar as Rt,ax as Ft,r as Tt,aq as $t,a7 as Mt,am as Pt,aa as Bt}from"./index-
|
|
1
|
+
var Ue=l=>{throw TypeError(l)};var Ee=(l,e,s)=>e.has(l)||Ue("Cannot "+s);var k=(l,e,s)=>(Ee(l,e,"read from private field"),s?s.call(l):e.get(l)),fe=(l,e,s)=>e.has(l)?Ue("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,s),me=(l,e,s,a)=>(Ee(l,e,"write to private field"),a?a.call(l,s):e.set(l,s),s),he=(l,e,s)=>(Ee(l,e,"access private method"),s);import{k as c,f as pe,j as t}from"./vendor-react-BlPSzrEe.js";import{z as xt,as as gt,ak as Ve,ac as bt,ao as et,aJ as tt,an as jt,at as yt,a2 as ve,av as J,B as re,L as ye,W as vt,I as He,F as St,Z as Nt,S as wt,G as Dt,T as kt,H as Ct,E as _t,f as At,ay as It,aI as We,aj as Et,Q as Ot,ar as Rt,ax as Ft,r as Tt,aq as $t,a7 as Mt,am as Pt,aa as Bt}from"./index-C1Fo8g_c.js";import{f as zt,d as Fe,S as Lt,P as qt,b as Qt,e as Kt}from"./build-format-fzt-JrUX.js";import{f as st,d as at,e as lt,i as ke,j as Ce,g as _e,h as F,S as Ae,a as nt,D as rt,C as Ut}from"./dialog-DQkbaw8h.js";import{P as Vt,T as Ht}from"./trash-DhBxh6H7.js";import{B as Oe}from"./badge-CWVbeuH3.js";import{f as Wt,g as Jt,d as Gt,b as Xt,c as Yt,e as Zt,a as es,A as ts}from"./alert-dialog-C8wDimW-.js";import{u as ss}from"./useFocusAfterSwap-BY3N9f9v.js";import{b as as,c as ls}from"./vendor-router-B_lVHrKl.js";var le,de,M,ne,se,je,Te,Ze,ns=(Ze=class extends xt{constructor(e,s){super();fe(this,se);fe(this,le);fe(this,de);fe(this,M);fe(this,ne);me(this,le,e),this.setOptions(s),this.bindMethods(),he(this,se,je).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=k(this,le).defaultMutationOptions(e),gt(this.options,s)||k(this,le).getMutationCache().notify({type:"observerOptionsUpdated",mutation:k(this,M),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Ve(s.mutationKey)!==Ve(this.options.mutationKey)?this.reset():((a=k(this,M))==null?void 0:a.state.status)==="pending"&&k(this,M).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&k(this,M)&&(k(this,M).addObserver(this),he(this,se,je).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=k(this,M))==null||e.removeObserver(this)}onMutationUpdate(e){he(this,se,je).call(this),he(this,se,Te).call(this,e)}getCurrentResult(){return k(this,de)}reset(){var e;(e=k(this,M))==null||e.removeObserver(this),me(this,M,void 0),he(this,se,je).call(this),he(this,se,Te).call(this)}mutate(e,s){var a;return me(this,ne,s),(a=k(this,M))==null||a.removeObserver(this),me(this,M,k(this,le).getMutationCache().build(k(this,le),this.options)),k(this,M).addObserver(this),k(this,M).execute(e)}},le=new WeakMap,de=new WeakMap,M=new WeakMap,ne=new WeakMap,se=new WeakSet,je=function(){var s;const e=((s=k(this,M))==null?void 0:s.state)??bt();me(this,de,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Te=function(e){et.batch(()=>{var s,a,i,u,f,j,b,m;if(k(this,ne)&&this.hasListeners()){const d=k(this,de).variables,y=k(this,de).context,p={client:k(this,le),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(a=(s=k(this,ne)).onSuccess)==null||a.call(s,e.data,d,y,p)}catch(r){Promise.reject(r)}try{(u=(i=k(this,ne)).onSettled)==null||u.call(i,e.data,null,d,y,p)}catch(r){Promise.reject(r)}}else if((e==null?void 0:e.type)==="error"){try{(j=(f=k(this,ne)).onError)==null||j.call(f,e.error,d,y,p)}catch(r){Promise.reject(r)}try{(m=(b=k(this,ne)).onSettled)==null||m.call(b,void 0,e.error,d,y,p)}catch(r){Promise.reject(r)}}}this.listeners.forEach(d=>{d(k(this,de))})})},Ze);function Re(l,e){const s=tt(),[a]=c.useState(()=>new ns(s,l));c.useEffect(()=>{a.setOptions(l)},[a,l]);const i=c.useSyncExternalStore(c.useCallback(f=>a.subscribe(et.batchCalls(f)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),u=c.useCallback((...f)=>{a.mutate(f[0],f[1]).catch(jt)},[a]);if(i.error&&yt(a.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:u,mutateAsync:i.mutate}}/**
|
|
2
2
|
* @license lucide-react v1.47.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as m,j as e}from"./vendor-react-BlPSzrEe.js";import{aO as ce,ay as me,aJ as ue,aI as $,aF as A,aw as k,aL as pe,C as y,c as b,d as N,a as S,L as c,I as u,F as p,S as Y,h as G,av as i,B as f,K as ge,W as fe,O as he,aq as g,ap as F,J as Z,au as h,ag as xe,a7 as je}from"./index-Cm17I31a.js";import{B as ve}from"./badge-CSVsKOK_.js";import{A as we,h as ye,c as be,f as Ne,g as Se,d as Pe,e as Ce,b as Ae,a as ke}from"./alert-dialog-CuPdBkxF.js";import{P as X}from"./pencil-g-WiK1F2.js";import"./vendor-router-B_lVHrKl.js";const Fe=F({teamName:h().min(1,"Team name is required"),logo:Z(File).nullable().optional()}),De=F({displayName:h().min(1,"Display name is required"),avatar:Z(File).nullable().optional()}),qe=F({currentPassword:h().min(1,"Enter your current password"),newPassword:h().min(8,"Password must be at least 8 characters"),confirmPassword:h()}).refine(x=>x.newPassword===x.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function _e(){var K,U,W,H,M,V,J;const{resolvedTheme:x}=ce(),I=x==="dark"?"/logo-dark.svg":"/logo.svg",{user:t}=me(),D=(t==null?void 0:t.role)==="Admin",q=(t==null?void 0:t.role)==="Admin"||(t==null?void 0:t.role)==="Developer"||(t==null?void 0:t.role)==="QA",j=ue(),P=$({queryKey:g.settings,queryFn:xe,enabled:D}),[ee,se]=m.useState(null),re=ee??((K=P.data)==null?void 0:K.logo_url)??null,T=m.useRef(null),d=A({resolver:k(Fe),defaultValues:{teamName:"",logo:null},values:P.data?{teamName:P.data.team_name,logo:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ae(s){const r=new FormData;r.append("team_name",s.teamName),s.logo&&r.append("logo",s.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update workspace");return}i.success("Workspace updated"),j.invalidateQueries({queryKey:g.settings})}catch{i.error("Failed to update workspace")}}const[te,oe]=m.useState(null),L=te??(t==null?void 0:t.avatarUrl)??null,Q=m.useRef(null),l=A({resolver:k(De),defaultValues:{displayName:"",avatar:null},values:t?{displayName:t.displayName??"",avatar:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ie(s){const r=new FormData;r.append("display_name",s.displayName),s.avatar&&r.append("avatar",s.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update profile");return}i.success("Profile updated"),j.invalidateQueries({queryKey:g.me})}catch{i.error("Failed to update profile")}}const o=A({resolver:k(qe)});async function ne(s){try{const r=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:s.currentPassword,newPassword:s.newPassword})});if(!r.ok){const a=await r.json();o.setError("root",{message:a.error??"Failed to change password"});return}o.reset(),i.success("Password changed")}catch{o.setError("root",{message:"Network error"})}}const C=$({queryKey:g.apps,queryFn:je,enabled:q}).data??[],[E,z]=m.useState({}),[O,R]=m.useState({}),[_,B]=m.useState({});async function le(s){B(r=>({...r,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"DELETE",credentials:"include"})).ok){i.error("Failed to delete app");return}j.invalidateQueries({queryKey:g.apps}),i.success("App deleted")}catch{i.error("Failed to delete app")}finally{B(r=>({...r,[s]:!1}))}}async function de(s){var r;R(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E[s]??((r=C.find(n=>n.id===s))==null?void 0:r.name)})})).ok){i.error("Failed to update app");return}i.success("App updated"),z(({[s]:n,...w})=>w),j.invalidateQueries({queryKey:g.apps})}catch{i.error("Failed to update app")}finally{R(a=>({...a,[s]:!1}))}}const v=pe({control:l.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),D&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Workspace"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:d.handleSubmit(ae),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team","aria-required":"true","aria-invalid":!!d.formState.errors.teamName,"aria-describedby":d.formState.errors.teamName?"teamName-error":void 0,...d.register("teamName")}),e.jsx(p,{id:"teamName-error",message:(U=d.formState.errors.teamName)==null?void 0:U.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(G,{name:"logo",control:d.control,render:({field:s})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:re??I,alt:"Workspace logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button","aria-label":"Change logo",onClick:()=>{var r;return(r=T.current)==null?void 0:r.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(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:T,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:r=>{var n;const a=(n=r.target.files)==null?void 0:n[0];if(a&&a.size>2*1024*1024){i.error("Image must be 2MB or less");return}a&&(s.onChange(a),se(URL.createObjectURL(a)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Profile"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:l.handleSubmit(ie),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name","aria-required":"true","aria-invalid":!!l.formState.errors.displayName,"aria-describedby":l.formState.errors.displayName?"displayName-error":void 0,...l.register("displayName")}),e.jsx(p,{id:"displayName-error",message:(W=l.formState.errors.displayName)==null?void 0:W.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(G,{name:"avatar",control:l.control,render:({field:s})=>{var r;return e.jsxs("div",{className:"relative w-14 h-14",children:[L?e.jsx("img",{src:L,alt:"Profile avatar",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 a=ge(v||(t==null?void 0:t.email)||"");return{backgroundColor:a.bg,color:a.fg}})(),children:((r=v==null?void 0:v[0])==null?void 0:r.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":"Change avatar",onClick:()=>{var a;return(a=Q.current)==null?void 0:a.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(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:Q,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var w;const n=(w=a.target.files)==null?void 0:w[0];if(n&&n.size>2*1024*1024){i.error("Image must be 2MB or less");return}n&&(s.onChange(n),oe(URL.createObjectURL(n)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:l.formState.isSubmitting,children:l.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Password"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:o.handleSubmit(ne),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password","aria-required":"true",autoComplete:"current-password","aria-invalid":!!o.formState.errors.currentPassword,"aria-describedby":o.formState.errors.currentPassword?"currentPassword-error":void 0,...o.register("currentPassword")}),e.jsx(p,{id:"currentPassword-error",message:(H=o.formState.errors.currentPassword)==null?void 0:H.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!o.formState.errors.newPassword,"aria-describedby":o.formState.errors.newPassword?"newPassword-error":void 0,...o.register("newPassword")}),e.jsx(p,{id:"newPassword-error",message:(M=o.formState.errors.newPassword)==null?void 0:M.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!o.formState.errors.confirmPassword,"aria-describedby":o.formState.errors.confirmPassword?"confirmPassword-error":void 0,...o.register("confirmPassword")}),e.jsx(p,{id:"confirmPassword-error",message:(V=o.formState.errors.confirmPassword)==null?void 0:V.message})]}),e.jsx(p,{assertive:!0,id:"default-error",message:(J=o.formState.errors.root)==null?void 0:J.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:o.formState.isSubmitting,children:o.formState.isSubmitting?"Saving…":"Change password"})})]})})]}),q&&C.length>0&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Apps"})}),e.jsx(S,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:C.map(s=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(c,{htmlFor:`app-${s.id}`,children:"App Name"}),e.jsx(u,{id:`app-${s.id}`,value:E[s.id]??s.name,onChange:r=>z(a=>({...a,[s.id]:r.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:s.bundle_id_key}),e.jsx(ve,{tone:s.platform==="ios"?"ios":s.platform==="android"?"android":void 0,variant:s.platform==="both"?"secondary":void 0,className:"capitalize",children:s.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(f,{size:"sm",variant:"outline",disabled:O[s.id],onClick:()=>de(s.id),children:O[s.id]?"Saving…":"Save"}),e.jsxs(we,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(f,{size:"sm",variant:"destructive",disabled:_[s.id],children:_[s.id]?"Deleting…":"Delete"})}),e.jsxs(be,{children:[e.jsxs(Ne,{children:[e.jsx(Se,{children:"Delete app?"}),e.jsxs(Pe,{children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(Ce,{children:[e.jsx(Ae,{className:"w-24",children:"Cancel"}),e.jsx(ke,{className:fe(he({variant:"destructive"}),"w-24"),onClick:()=>le(s.id),children:"Delete"})]})]})]})]})]})]},s.id))})})]})]})}export{_e as DefaultSettings};
|
|
1
|
+
import{k as m,j as e}from"./vendor-react-BlPSzrEe.js";import{aO as ce,ay as me,aJ as ue,aI as $,aF as A,aw as k,aL as pe,C as y,c as b,d as N,a as S,L as c,I as u,F as p,S as Y,h as G,av as i,B as f,K as ge,W as fe,O as he,aq as g,ap as F,J as Z,au as h,ag as xe,a7 as je}from"./index-C1Fo8g_c.js";import{B as ve}from"./badge-CWVbeuH3.js";import{A as we,h as ye,c as be,f as Ne,g as Se,d as Pe,e as Ce,b as Ae,a as ke}from"./alert-dialog-C8wDimW-.js";import{P as X}from"./pencil-BJcOp3oN.js";import"./vendor-router-B_lVHrKl.js";const Fe=F({teamName:h().min(1,"Team name is required"),logo:Z(File).nullable().optional()}),De=F({displayName:h().min(1,"Display name is required"),avatar:Z(File).nullable().optional()}),qe=F({currentPassword:h().min(1,"Enter your current password"),newPassword:h().min(8,"Password must be at least 8 characters"),confirmPassword:h()}).refine(x=>x.newPassword===x.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function _e(){var K,U,W,H,M,V,J;const{resolvedTheme:x}=ce(),I=x==="dark"?"/logo-dark.svg":"/logo.svg",{user:t}=me(),D=(t==null?void 0:t.role)==="Admin",q=(t==null?void 0:t.role)==="Admin"||(t==null?void 0:t.role)==="Developer"||(t==null?void 0:t.role)==="QA",j=ue(),P=$({queryKey:g.settings,queryFn:xe,enabled:D}),[ee,se]=m.useState(null),re=ee??((K=P.data)==null?void 0:K.logo_url)??null,T=m.useRef(null),d=A({resolver:k(Fe),defaultValues:{teamName:"",logo:null},values:P.data?{teamName:P.data.team_name,logo:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ae(s){const r=new FormData;r.append("team_name",s.teamName),s.logo&&r.append("logo",s.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update workspace");return}i.success("Workspace updated"),j.invalidateQueries({queryKey:g.settings})}catch{i.error("Failed to update workspace")}}const[te,oe]=m.useState(null),L=te??(t==null?void 0:t.avatarUrl)??null,Q=m.useRef(null),l=A({resolver:k(De),defaultValues:{displayName:"",avatar:null},values:t?{displayName:t.displayName??"",avatar:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ie(s){const r=new FormData;r.append("display_name",s.displayName),s.avatar&&r.append("avatar",s.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update profile");return}i.success("Profile updated"),j.invalidateQueries({queryKey:g.me})}catch{i.error("Failed to update profile")}}const o=A({resolver:k(qe)});async function ne(s){try{const r=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:s.currentPassword,newPassword:s.newPassword})});if(!r.ok){const a=await r.json();o.setError("root",{message:a.error??"Failed to change password"});return}o.reset(),i.success("Password changed")}catch{o.setError("root",{message:"Network error"})}}const C=$({queryKey:g.apps,queryFn:je,enabled:q}).data??[],[E,z]=m.useState({}),[O,R]=m.useState({}),[_,B]=m.useState({});async function le(s){B(r=>({...r,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"DELETE",credentials:"include"})).ok){i.error("Failed to delete app");return}j.invalidateQueries({queryKey:g.apps}),i.success("App deleted")}catch{i.error("Failed to delete app")}finally{B(r=>({...r,[s]:!1}))}}async function de(s){var r;R(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E[s]??((r=C.find(n=>n.id===s))==null?void 0:r.name)})})).ok){i.error("Failed to update app");return}i.success("App updated"),z(({[s]:n,...w})=>w),j.invalidateQueries({queryKey:g.apps})}catch{i.error("Failed to update app")}finally{R(a=>({...a,[s]:!1}))}}const v=pe({control:l.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),D&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Workspace"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:d.handleSubmit(ae),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team","aria-required":"true","aria-invalid":!!d.formState.errors.teamName,"aria-describedby":d.formState.errors.teamName?"teamName-error":void 0,...d.register("teamName")}),e.jsx(p,{id:"teamName-error",message:(U=d.formState.errors.teamName)==null?void 0:U.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(G,{name:"logo",control:d.control,render:({field:s})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:re??I,alt:"Workspace logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button","aria-label":"Change logo",onClick:()=>{var r;return(r=T.current)==null?void 0:r.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(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:T,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:r=>{var n;const a=(n=r.target.files)==null?void 0:n[0];if(a&&a.size>2*1024*1024){i.error("Image must be 2MB or less");return}a&&(s.onChange(a),se(URL.createObjectURL(a)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Profile"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:l.handleSubmit(ie),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name","aria-required":"true","aria-invalid":!!l.formState.errors.displayName,"aria-describedby":l.formState.errors.displayName?"displayName-error":void 0,...l.register("displayName")}),e.jsx(p,{id:"displayName-error",message:(W=l.formState.errors.displayName)==null?void 0:W.message})]}),e.jsx(Y,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(G,{name:"avatar",control:l.control,render:({field:s})=>{var r;return e.jsxs("div",{className:"relative w-14 h-14",children:[L?e.jsx("img",{src:L,alt:"Profile avatar",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 a=ge(v||(t==null?void 0:t.email)||"");return{backgroundColor:a.bg,color:a.fg}})(),children:((r=v==null?void 0:v[0])==null?void 0:r.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":"Change avatar",onClick:()=>{var a;return(a=Q.current)==null?void 0:a.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(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:Q,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var w;const n=(w=a.target.files)==null?void 0:w[0];if(n&&n.size>2*1024*1024){i.error("Image must be 2MB or less");return}n&&(s.onChange(n),oe(URL.createObjectURL(n)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:l.formState.isSubmitting,children:l.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Password"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:o.handleSubmit(ne),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password","aria-required":"true",autoComplete:"current-password","aria-invalid":!!o.formState.errors.currentPassword,"aria-describedby":o.formState.errors.currentPassword?"currentPassword-error":void 0,...o.register("currentPassword")}),e.jsx(p,{id:"currentPassword-error",message:(H=o.formState.errors.currentPassword)==null?void 0:H.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!o.formState.errors.newPassword,"aria-describedby":o.formState.errors.newPassword?"newPassword-error":void 0,...o.register("newPassword")}),e.jsx(p,{id:"newPassword-error",message:(M=o.formState.errors.newPassword)==null?void 0:M.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!o.formState.errors.confirmPassword,"aria-describedby":o.formState.errors.confirmPassword?"confirmPassword-error":void 0,...o.register("confirmPassword")}),e.jsx(p,{id:"confirmPassword-error",message:(V=o.formState.errors.confirmPassword)==null?void 0:V.message})]}),e.jsx(p,{assertive:!0,id:"default-error",message:(J=o.formState.errors.root)==null?void 0:J.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:o.formState.isSubmitting,children:o.formState.isSubmitting?"Saving…":"Change password"})})]})})]}),q&&C.length>0&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Apps"})}),e.jsx(S,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:C.map(s=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(c,{htmlFor:`app-${s.id}`,children:"App Name"}),e.jsx(u,{id:`app-${s.id}`,value:E[s.id]??s.name,onChange:r=>z(a=>({...a,[s.id]:r.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:s.bundle_id_key}),e.jsx(ve,{tone:s.platform==="ios"?"ios":s.platform==="android"?"android":void 0,variant:s.platform==="both"?"secondary":void 0,className:"capitalize",children:s.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(f,{size:"sm",variant:"outline",disabled:O[s.id],onClick:()=>de(s.id),children:O[s.id]?"Saving…":"Save"}),e.jsxs(we,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(f,{size:"sm",variant:"destructive",disabled:_[s.id],children:_[s.id]?"Deleting…":"Delete"})}),e.jsxs(be,{children:[e.jsxs(Ne,{children:[e.jsx(Se,{children:"Delete app?"}),e.jsxs(Pe,{children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(Ce,{children:[e.jsx(Ae,{className:"w-24",children:"Cancel"}),e.jsx(ke,{className:fe(he({variant:"destructive"}),"w-24"),onClick:()=>le(s.id),children:"Delete"})]})]})]})]})]})]},s.id))})})]})]})}export{_e as DefaultSettings};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as F,j as e}from"./vendor-react-BlPSzrEe.js";import{aF as U,aw as D,aL as J,aJ as O,aI as Y,C as q,c as I,d as L,b as T,a as _,L as m,I as f,h as z,K as G,F as u,S as H,B as V,aq as R,ap as W,au as v,J as X,aM as Z}from"./index-C1Fo8g_c.js";import{b as $,c as ee,L as ae}from"./vendor-router-B_lVHrKl.js";import{P as se}from"./pencil-BJcOp3oN.js";const re=W({displayName:v().optional(),avatar:X(File).nullable().optional(),password:v().min(8,"Password must be at least 8 characters"),confirm:v()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function le(){var b,N,C,k,P,S;const o=$(),[E]=ee(),i=E.get("token")??"",[x,A]=F.useState(null),g=F.useRef(null),{register:p,handleSubmit:B,control:j,setError:l,formState:{errors:s,isSubmitting:y}}=U({resolver:D(re),defaultValues:{displayName:"",avatar:null}}),d=J({control:j,name:"displayName"})??"",K=O(),h=Y({queryKey:R.inviteToken(i),queryFn:()=>Z(i),enabled:i!=="",staleTime:1/0}),w=!i||h.isError?"invalid":h.isPending?"loading":"valid",M=((b=h.data)==null?void 0:b.role)??"";async function Q(t){var n;try{const a=new FormData;a.append("token",i),a.append("password",t.password),(n=t.displayName)!=null&&n.trim()&&a.append("display_name",t.displayName.trim()),t.avatar&&a.append("avatar",t.avatar);const r=await fetch("/api/v1/invitations/accept",{method:"POST",body:a});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}K.removeQueries({queryKey:R.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:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(q,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(I,{children:[e.jsx(L,{children:"Invitation expired"}),e.jsx(T,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(q,{level:4,className:"w-full max-w-sm",children:[e.jsxs(I,{className:"text-center",children:[e.jsx(L,{children:"Set up your account"}),e.jsxs(T,{children:["You're joining as ",e.jsx("strong",{children:M})]})]}),e.jsx(_,{children:e.jsxs("form",{onSubmit:B(Q),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(f,{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(z,{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 a=G(d);return{backgroundColor:a.bg,color:a.fg}})(),children:((n=d==null?void 0:d[0])==null?void 0:n.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":s.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":s.avatar?"avatar-error":void 0,onClick:()=>{var a;return(a=g.current)==null?void 0:a.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(se,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:a=>{var c;const r=(c=a.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),A(URL.createObjectURL(r))}}})]})}}),e.jsx(u,{assertive:!0,id:"avatar-error",message:(N=s.avatar)==null?void 0:N.message})]}),e.jsx(H,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),e.jsx(f,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,...p("password")}),e.jsx(u,{id:"password-error",message:(C=s.password)==null?void 0:C.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(f,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.confirm,"aria-describedby":s.confirm?"confirm-error":void 0,...p("confirm")}),e.jsx(u,{id:"confirm-error",message:(k=s.confirm)==null?void 0:k.message})]}),e.jsx(u,{assertive:!0,id:"invite-error",message:(P=s.root)==null?void 0:P.message}),((S=s.root)==null?void 0:S.type)==="already-member"&&e.jsx(ae,{to:"/login",className:"text-sm text-center underline underline-offset-4",children:"Go to sign in"}),e.jsx(V,{type:"submit",disabled:y,className:"w-full",children:y?"Creating account…":"Create account"})]})})]})})}export{le as Invite};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{az as Lt,aI as bt,aJ as Et,M as Tt,ad as Rt,aq as Qe,af as Ot}from"./index-Cm17I31a.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-BbeyA8an.js";import{t as Ft,i as jt,j as Ht,h as Ut,g as Bt,f as _t,l as qt,P as Gt,e as Qt,G as Wt,A as Xt,m as wt,d as Vt,a as zt,b as Yt,L as Jt,B as Zt,c as es}from"./vendor-charts-BykzUV2D.js";import"./vendor-router-B_lVHrKl.js";const ts=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function ss(){return N.useSyncExternalStore(ts,ls,ns)}function ns(){return!0}function ls(){return document.visibilityState!=="hidden"}function os(t,e){const o=Xe.c(4),[m,y]=N.useState(as);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;y(Date.now());const h=setInterval(()=>y(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]),N.useEffect(i,n),m}function as(){return Date.now()}const xt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},rs={"1h":Ht.every(10),"6h":jt,"24h":jt.every(3),"7d":Ft};function is(t,e,o){return rs[o].range(new Date(t),new Date(e+1))}function cs(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 ds=2e3;function us(t){return Math.min(1e4,Math.max(1e3,xt[t]/ds))}const fs={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},pt=t=>Math.round(t*10)/10;function ms(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>Ct)return null;const y=i=>Number.isFinite(i)?pt(i):null;return{cpu:y(m.cpuPercent),mem:y(m.memUsedMB/m.memTotalMB*100)}}const $t={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},At={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Ls(){const t=Xe.c(65);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=N.useState(e),[y,i]=N.useState(null),[n,h]=N.useState("24h"),O=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,O),{setNode:b}=Lt();let p,j;t[3]!==b?(p=()=>(b(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>b(null)),j=[b],t[3]=b,t[4]=p,t[5]=j):(p=t[4],j=t[5]),N.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 Q=C,{send:E,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==E?(ie=()=>{if(!T)return;E({type:"agents:list"});const u=setInterval(()=>E({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,E],t[7]=T,t[8]=E,t[9]=ie,t[10]=ce):(ie=t[9],ce=t[10]),N.useEffect(ie,ce);let le;t[11]===Symbol.for("react.memo_cache_sentinel")?(le={queryKey:Qe.agents,queryFn:Rt,refetchOnWindowFocus:!1},t[11]=le):le=t[11];const W=bt(le);let c,d,F,oe;t[12]!==W.data||t[13]!==o?(F=W.data??[],d=o.map(ps).filter(Boolean),c=[...new Set([...d,...F])],oe=new Set(d),t[12]=W.data,t[13]=o,t[14]=c,t[15]=d,t[16]=F,t[17]=oe):(c=t[14],d=t[15],F=t[16],oe=t[17]);const w=oe,l=y??(W.isPending?null:F[0]??d[0]??null),H=Et();let Z;t[18]!==n||t[19]!==l?(Z=l?Qe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=Z):Z=t[20];const ee=Z;let D;t[21]!==ee||t[22]!==n?(D=ee??Qe.resourceHistory("",n),t[21]=ee,t[22]=n,t[23]=D):D=t[23];let U;t[24]!==n||t[25]!==l?(U=u=>{const{signal:L}=u;return Ot(l,n,L)},t[24]=n,t[25]=l,t[26]=U):U=t[26];let X;t[27]!==D||t[28]!==U?(X={queryKey:D,queryFn:U,enabled:!1},t[27]=D,t[28]=U,t[29]=X):X=t[29];const I=bt(X),B=I.refetch;let P,V;t[30]!==H||t[31]!==n||t[32]!==B||t[33]!==l||t[34]!==O?(P=()=>{if(!l||!O)return;const u=Qe.resourceHistory(l,n),L=fs[n],G=()=>{const ne=H.getQueryState(u);(ne==null?void 0:ne.fetchStatus)==="fetching"&&ne.data===void 0?H.cancelQueries({queryKey:u,exact:!0}).then(()=>B()):B({cancelRefetch:!0})},g=H.getQueryState(u),ae=Math.max((g==null?void 0:g.dataUpdatedAt)??0,(g==null?void 0:g.errorUpdatedAt)??0),se=(g==null?void 0:g.data)!==void 0&&ae>0?Math.max(0,L-(Date.now()-ae)):0;let de;const re=()=>{G(),de=setInterval(G,L)},Ve=se>0?setTimeout(re,se):void 0;return se===0&&re(),()=>{clearTimeout(Ve),clearInterval(de),H.cancelQueries({queryKey:u,exact:!0})}},V=[l,n,O,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=O,t[35]=P,t[36]=V):(P=t[35],V=t[36]),N.useEffect(P,V);const S=I.data!==void 0||I.isError,te=ee!==null&&!S;let r;t[37]!==I.data?(r=I.data??[],t[37]=I.data,t[38]=r):r=t[38];let z;t[39]!==r?(z=r.map(xs),t[39]=r,t[40]=z):z=t[40];const q=z;let Y;t[41]!==x||t[42]!==l||t[43]!==o?(Y=l?ms(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=Y):Y=t[44];const f=Y;let _;t[45]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=_):_=t[45];let v;t[46]===Symbol.for("react.memo_cache_sentinel")?(v=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]=v):v=t[46];let M;t[47]!==c||t[48]!==T||t[49]!==w||t[50]!==l?(M=c.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:T?"No agents yet.":"Connecting…"}):c.map(u=>{const L=w.has(u),G=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":G?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",G?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${L?"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:L?"Online":"Offline"})]},u)}),t[47]=c,t[48]=T,t[49]=w,t[50]=l,t[51]=M):M=t[51];let $;t[52]!==M?($=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:[v,M]}),t[52]=M,t[53]=$):$=t[53];let A;t[54]!==q||t[55]!==(f==null?void 0:f.cpu)||t[56]!==(f==null?void 0:f.mem)||t[57]!==te||t[58]!==x||t[59]!==n||t[60]!==l?(A=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(It,{value:n,onValueChange:u=>h(u),children:s.jsx(Pt,{children:Object.keys(At).map(hs)})})]}),te?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading…"}):q.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(Nt,{title:"CPU %",color:"cpu",data:q,dataKey:"cpu",range:n,now:x,live:(f==null?void 0:f.cpu)??null}),s.jsx(Nt,{title:"RAM %",color:"mem",data:q,dataKey:"mem",range:n,now:x,live:(f==null?void 0:f.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Tt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=q,t[55]=f==null?void 0:f.cpu,t[56]=f==null?void 0:f.mem,t[57]=te,t[58]=x,t[59]=n,t[60]=l,t[61]=A):A=t[61];let J;return t[62]!==$||t[63]!==A?(J=s.jsxs("div",{className:"flex h-full min-h-0",children:[_,$,A]}),t[62]=$,t[63]=A,t[64]=J):J=t[64],J}function hs(t){return s.jsx(Kt,{value:t,children:At[t]},t)}function xs(t){return{time:t.recorded_at,cpu:pt(t.cpu_percent),mem:pt(t.mem_percent)}}function ps(t){return t.agentName}const gt=t=>new Date(t.time).getTime(),St=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),We=t=>`${Math.round(t*10)/10}%`,gs=_t(gt).left,ys=_t(t=>t.t).left,K={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,vs=20,bs=40;function Nt(t){const e=Xe.c(18),{title:o,color:m,data:y,dataKey:i,range:n,now:h,live:O}=t,k=$t[m].color;let x;e[0]!==k?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:k}}),e[0]=k,e[1]=x):x=e[1];let b;e[2]!==o?(b=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=b):b=e[3];let p;e[4]!==x||e[5]!==b?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[4]=x,e[5]=b,e[6]=p):p=e[6];let j;e[7]!==y||e[8]!==i||e[9]!==k||e[10]!==O||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(Gt,{children:Q=>{const{width:E,height:T}=Q;return E>0&&T>0?s.jsx(js,{width:E,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:O,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=O,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 js(t){const e=Xe.c(139),{width:o,height:m,data:y,dataKey:i,hex:n,range:h,now:O,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,E]=N.useState(!1),[T,ie]=N.useState(null),[ce,le]=N.useState(!1),W=ce?T:null,c=o-K.left-K.right,d=m-K.top-K.bottom,F=O,oe=F-xt[h],w=Ut({domain:[oe,F],range:[0,Math.max(0,c)]}),l=Bt({domain:[0,100],range:[d,kt]}),H=c>0?vs/c*xt[h]:0,Z=oe-H,ee=F+H;let D;e[0]!==h||e[1]!==Z||e[2]!==ee?(D=is(Z,ee,h),e[0]=h,e[1]=Z,e[2]=ee,e[3]=D):D=e[3];const U=D,X=c>0?Math.min(.5,bs/c):0,I=`fill-${i}`,B=`plot-${i}`,P=`axis-fade-${i}`,V=y[y.length-1],S=b!==null&&V?{t:Math.max(F,gt(V)+1),v:b,live:!0}:null;let te;e[4]!==i?(te=a=>({t:gt(a),v:a[i]}),e[4]=i,e[5]=te):te=e[5];const r=y.map(te);S&&r.push(S);const z=a=>Math.min(w(a),c),q=S?z(S.t):0,Y=S?l(S.v):0,f=Math.max(0,y.length-1),_=j===null?Math.max(0,r.length-1):j==="live"?S?r.length-1:f:Math.min(gs(y,j),f),v=Q?r[_]:void 0,M=v?z(v.t):0,$=v?l(v.v):0,A=$t[i].label;let J;e[6]!==A?(J=a=>`${A}, ${St(a.t)}, ${a.live?"latest, ":""}${We(a.v)}`,e[6]=A,e[7]=J):J=e[7];const u=J,L=a=>{const R=r[a];R&&(C(R.live?"live":R.t),E(!0),ie({now:a,text:u(R)}))};let G;e[8]===Symbol.for("react.memo_cache_sentinel")?(G=()=>E(!1),e[8]=G):G=e[8];const g=G;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=R=>{R.key==="Escape"&&E(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},se=[Q],e[9]=Q,e[10]=ae,e[11]=se):(ae=e[10],se=e[11]),N.useEffect(ae,se);const de=a=>{if(r.length===0)return;const R=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,R-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,R+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),L(Fe))},re=a=>{const R=qt(a);if(!R)return;const Fe=R.x-K.left,yt=ys(r,w.invert(Fe).getTime()),vt=[r[yt-1],r[yt],S].reduce((mt,ht)=>ht&&(!mt||Math.abs(z(ht.t)-Fe)<=Math.abs(z(mt.t)-Fe))?ht:mt,void 0);vt&&L(r.indexOf(vt))},Ve="group",ne=S?`${x}, last ${h}. Now ${We(S.v)}.`:V?`${x}, last ${h}. Latest ${We(V[i])}.`:`${x}, last ${h}. No samples.`;let ue;e[12]!==I||e[13]!==n?(ue=s.jsx(Qt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=ue):ue=e[14];const ze=Math.max(0,c),Ye=Math.max(0,d);let fe;e[15]!==ze||e[16]!==Ye?(fe=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=fe):fe=e[17];let me;e[18]!==B||e[19]!==fe?(me=s.jsx("clipPath",{id:B,children:fe}),e[18]=B,e[19]=fe,e[20]=me):me=e[20];const Je=`${P}-grad`,Ze=Math.max(0,c);let He;e[21]===Symbol.for("react.memo_cache_sentinel")?(He=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=He):He=e[21];let he;e[22]!==X?(he=s.jsx("stop",{offset:X,stopColor:"white",stopOpacity:1}),e[22]=X,e[23]=he):he=e[23];const et=1-X;let xe;e[24]!==et?(xe=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=xe):xe=e[25];let Ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=Ue):Ue=e[26];let pe;e[27]!==Je||e[28]!==Ze||e[29]!==he||e[30]!==xe?(pe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[He,he,xe,Ue]}),e[27]=Je,e[28]=Ze,e[29]=he,e[30]=xe,e[31]=pe):pe=e[31];const tt=Math.max(0,c),st=Math.max(0,c),nt=`url(#${P}-grad)`;let ge;e[32]!==d||e[33]!==st||e[34]!==nt?(ge=s.jsx("rect",{x:0,y:d,width:st,height:K.bottom*2,fill:nt}),e[32]=d,e[33]=st,e[34]=nt,e[35]=ge):ge=e[35];let ye;e[36]!==P||e[37]!==d||e[38]!==tt||e[39]!==ge?(ye=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:d,width:tt,height:K.bottom*2,children:ge}),e[36]=P,e[37]=d,e[38]=tt,e[39]=ge,e[40]=ye):ye=e[40];let Be;e[41]===Symbol.for("react.memo_cache_sentinel")?(Be=[0,25,50,75,100],e[41]=Be):Be=e[41];let ve;e[42]!==c||e[43]!==l?(ve=s.jsx(Wt,{scale:l,width:c,tickValues:Be,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=c,e[43]=l,e[44]=ve):ve=e[44];const lt=`url(#${B})`;let be;e[45]!==w?(be=a=>w(a.t),e[45]=w,e[46]=be):be=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 we;e[49]!==r||e[50]!==be||e[51]!==je||e[52]!==ot||e[53]!==l?(we=s.jsx(Xt,{data:r,x:be,y:je,yScale:l,curve:wt,fill:ot}),e[49]=r,e[50]=be,e[51]=je,e[52]=ot,e[53]=l,e[54]=we):we=e[54];let Se;e[55]!==w?(Se=a=>w(a.t),e[55]=w,e[56]=Se):Se=e[56];let ke;e[57]!==l?(ke=a=>l(a.v),e[57]=l,e[58]=ke):ke=e[58];let Me;e[59]!==n||e[60]!==r||e[61]!==Se||e[62]!==ke?(Me=s.jsx(Vt,{data:r,x:Se,y:ke,curve:wt,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=r,e[61]=Se,e[62]=ke,e[63]=Me):Me=e[63];let Ne;e[64]!==lt||e[65]!==we||e[66]!==Me?(Ne=s.jsxs("g",{clipPath:lt,children:[we,Me]}),e[64]=lt,e[65]=we,e[66]=Me,e[67]=Ne):Ne=e[67];const at=`url(#${P})`;let _e;e[68]!==h?(_e=a=>cs(+a,h),e[68]=h,e[69]=_e):_e=e[69];let $e;e[70]!==d||e[71]!==_e||e[72]!==U||e[73]!==w?($e=s.jsx(zt,{top:d,scale:w,tickValues:U,tickFormat:_e,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:ks}),e[70]=d,e[71]=_e,e[72]=U,e[73]=w,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 Le;e[79]!==l?(Le=s.jsx(Yt,{scale:l,tickValues:qe,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Le):Le=e[80];let Ee;e[81]!==q||e[82]!==Y||e[83]!==n||e[84]!==S?(Ee=S&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:q,cy:Y,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:q,cy:Y,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=q,e[82]=Y,e[83]=n,e[84]=S,e[85]=Ee):Ee=e[85];let Te;e[86]!==n||e[87]!==d||e[88]!==v||e[89]!==M||e[90]!==$?(Te=v&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${M}px)`},pointerEvents:"none",children:[s.jsx(Jt,{from:{x:0,y:kt},to:{x:0,y:d},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]=d,e[88]=v,e[89]=M,e[90]=$,e[91]=Te):Te=e[91];const rt=Math.max(0,c)+Mt,it=Math.max(0,d),ct=`${x} samples`,dt=Math.max(0,r.length-1),ut=W?Math.min(W.now,Math.max(0,r.length-1)):_,ft=W?W.text:r[_]?u(r[_]):void 0;let Re;e[92]!==_||e[93]!==L?(Re=()=>{le(!0),L(_)},e[92]=_,e[93]=L,e[94]=Re):Re=e[94];let Oe;e[95]!==g?(Oe=()=>{g(),le(!1)},e[95]=g,e[96]=Oe):Oe=e[96];let Ce;e[97]!==de||e[98]!==re||e[99]!==g||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Re||e[108]!==Oe?(Ce=s.jsx(Zt,{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:Re,onBlur:Oe,onKeyDown:de,onMouseMove:re,onMouseLeave:g,onTouchMove:re,onTouchEnd:g,onTouchCancel:g}),e[97]=de,e[98]=re,e[99]=g,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Re,e[108]=Oe,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Le||e[114]!==Ee||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Le,Ee,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Le,e[114]=Ee,e[115]=Te,e[116]=Ce,e[117]=De):De=e[117];let Ie;e[118]!==m||e[119]!==ne||e[120]!==ue||e[121]!==me||e[122]!==pe||e[123]!==ye||e[124]!==De||e[125]!==o?(Ie=s.jsxs("svg",{width:o,height:m,role:Ve,"aria-label":ne,children:[ue,me,pe,ye,De]}),e[118]=m,e[119]=ne,e[120]=ue,e[121]=me,e[122]=pe,e[123]=ye,e[124]=De,e[125]=o,e[126]=Ie):Ie=e[126];let Pe;e[127]!==p?(Pe=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]=Pe):Pe=e[128];let Ke;e[129]!==c||e[130]!==A||e[131]!==v||e[132]!==M||e[133]!==$?(Ke=v&&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(${M+K.left}px, ${$+K.top}px) translate(${M>c*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",St(v.t)]}),s.jsxs("p",{children:[A,": ",We(v.v)]})]}),e[129]=c,e[130]=A,e[131]=v,e[132]=M,e[133]=$,e[134]=Ke):Ke=e[134];let Ge;return e[135]!==Ie||e[136]!==Pe||e[137]!==Ke?(Ge=s.jsxs(s.Fragment,{children:[Ie,Pe,Ke]}),e[135]=Ie,e[136]=Pe,e[137]=Ke,e[138]=Ge):Ge=e[138],Ge}function ws(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function Ss(t){return`${t}%`}function ks(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{js as AreaChartInner,Ls as MacResources};
|
|
1
|
+
import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{az as Lt,aI as bt,aJ as Et,M as Tt,ad as Rt,aq as Qe,af as Ot}from"./index-C1Fo8g_c.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-Cq3gqqVd.js";import{t as Ft,i as jt,j as Ht,h as Ut,g as Bt,f as _t,l as qt,P as Gt,e as Qt,G as Wt,A as Xt,m as wt,d as Vt,a as zt,b as Yt,L as Jt,B as Zt,c as es}from"./vendor-charts-BykzUV2D.js";import"./vendor-router-B_lVHrKl.js";const ts=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function ss(){return N.useSyncExternalStore(ts,ls,ns)}function ns(){return!0}function ls(){return document.visibilityState!=="hidden"}function os(t,e){const o=Xe.c(4),[m,y]=N.useState(as);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;y(Date.now());const h=setInterval(()=>y(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]),N.useEffect(i,n),m}function as(){return Date.now()}const xt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},rs={"1h":Ht.every(10),"6h":jt,"24h":jt.every(3),"7d":Ft};function is(t,e,o){return rs[o].range(new Date(t),new Date(e+1))}function cs(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 ds=2e3;function us(t){return Math.min(1e4,Math.max(1e3,xt[t]/ds))}const fs={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},pt=t=>Math.round(t*10)/10;function ms(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>Ct)return null;const y=i=>Number.isFinite(i)?pt(i):null;return{cpu:y(m.cpuPercent),mem:y(m.memUsedMB/m.memTotalMB*100)}}const $t={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},At={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Ls(){const t=Xe.c(65);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=N.useState(e),[y,i]=N.useState(null),[n,h]=N.useState("24h"),O=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,O),{setNode:b}=Lt();let p,j;t[3]!==b?(p=()=>(b(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>b(null)),j=[b],t[3]=b,t[4]=p,t[5]=j):(p=t[4],j=t[5]),N.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 Q=C,{send:E,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==E?(ie=()=>{if(!T)return;E({type:"agents:list"});const u=setInterval(()=>E({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,E],t[7]=T,t[8]=E,t[9]=ie,t[10]=ce):(ie=t[9],ce=t[10]),N.useEffect(ie,ce);let le;t[11]===Symbol.for("react.memo_cache_sentinel")?(le={queryKey:Qe.agents,queryFn:Rt,refetchOnWindowFocus:!1},t[11]=le):le=t[11];const W=bt(le);let c,d,F,oe;t[12]!==W.data||t[13]!==o?(F=W.data??[],d=o.map(ps).filter(Boolean),c=[...new Set([...d,...F])],oe=new Set(d),t[12]=W.data,t[13]=o,t[14]=c,t[15]=d,t[16]=F,t[17]=oe):(c=t[14],d=t[15],F=t[16],oe=t[17]);const w=oe,l=y??(W.isPending?null:F[0]??d[0]??null),H=Et();let Z;t[18]!==n||t[19]!==l?(Z=l?Qe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=Z):Z=t[20];const ee=Z;let D;t[21]!==ee||t[22]!==n?(D=ee??Qe.resourceHistory("",n),t[21]=ee,t[22]=n,t[23]=D):D=t[23];let U;t[24]!==n||t[25]!==l?(U=u=>{const{signal:L}=u;return Ot(l,n,L)},t[24]=n,t[25]=l,t[26]=U):U=t[26];let X;t[27]!==D||t[28]!==U?(X={queryKey:D,queryFn:U,enabled:!1},t[27]=D,t[28]=U,t[29]=X):X=t[29];const I=bt(X),B=I.refetch;let P,V;t[30]!==H||t[31]!==n||t[32]!==B||t[33]!==l||t[34]!==O?(P=()=>{if(!l||!O)return;const u=Qe.resourceHistory(l,n),L=fs[n],G=()=>{const ne=H.getQueryState(u);(ne==null?void 0:ne.fetchStatus)==="fetching"&&ne.data===void 0?H.cancelQueries({queryKey:u,exact:!0}).then(()=>B()):B({cancelRefetch:!0})},g=H.getQueryState(u),ae=Math.max((g==null?void 0:g.dataUpdatedAt)??0,(g==null?void 0:g.errorUpdatedAt)??0),se=(g==null?void 0:g.data)!==void 0&&ae>0?Math.max(0,L-(Date.now()-ae)):0;let de;const re=()=>{G(),de=setInterval(G,L)},Ve=se>0?setTimeout(re,se):void 0;return se===0&&re(),()=>{clearTimeout(Ve),clearInterval(de),H.cancelQueries({queryKey:u,exact:!0})}},V=[l,n,O,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=O,t[35]=P,t[36]=V):(P=t[35],V=t[36]),N.useEffect(P,V);const S=I.data!==void 0||I.isError,te=ee!==null&&!S;let r;t[37]!==I.data?(r=I.data??[],t[37]=I.data,t[38]=r):r=t[38];let z;t[39]!==r?(z=r.map(xs),t[39]=r,t[40]=z):z=t[40];const q=z;let Y;t[41]!==x||t[42]!==l||t[43]!==o?(Y=l?ms(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=Y):Y=t[44];const f=Y;let _;t[45]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=_):_=t[45];let v;t[46]===Symbol.for("react.memo_cache_sentinel")?(v=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]=v):v=t[46];let M;t[47]!==c||t[48]!==T||t[49]!==w||t[50]!==l?(M=c.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:T?"No agents yet.":"Connecting…"}):c.map(u=>{const L=w.has(u),G=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":G?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",G?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${L?"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:L?"Online":"Offline"})]},u)}),t[47]=c,t[48]=T,t[49]=w,t[50]=l,t[51]=M):M=t[51];let $;t[52]!==M?($=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:[v,M]}),t[52]=M,t[53]=$):$=t[53];let A;t[54]!==q||t[55]!==(f==null?void 0:f.cpu)||t[56]!==(f==null?void 0:f.mem)||t[57]!==te||t[58]!==x||t[59]!==n||t[60]!==l?(A=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(It,{value:n,onValueChange:u=>h(u),children:s.jsx(Pt,{children:Object.keys(At).map(hs)})})]}),te?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading…"}):q.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(Nt,{title:"CPU %",color:"cpu",data:q,dataKey:"cpu",range:n,now:x,live:(f==null?void 0:f.cpu)??null}),s.jsx(Nt,{title:"RAM %",color:"mem",data:q,dataKey:"mem",range:n,now:x,live:(f==null?void 0:f.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Tt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=q,t[55]=f==null?void 0:f.cpu,t[56]=f==null?void 0:f.mem,t[57]=te,t[58]=x,t[59]=n,t[60]=l,t[61]=A):A=t[61];let J;return t[62]!==$||t[63]!==A?(J=s.jsxs("div",{className:"flex h-full min-h-0",children:[_,$,A]}),t[62]=$,t[63]=A,t[64]=J):J=t[64],J}function hs(t){return s.jsx(Kt,{value:t,children:At[t]},t)}function xs(t){return{time:t.recorded_at,cpu:pt(t.cpu_percent),mem:pt(t.mem_percent)}}function ps(t){return t.agentName}const gt=t=>new Date(t.time).getTime(),St=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),We=t=>`${Math.round(t*10)/10}%`,gs=_t(gt).left,ys=_t(t=>t.t).left,K={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,vs=20,bs=40;function Nt(t){const e=Xe.c(18),{title:o,color:m,data:y,dataKey:i,range:n,now:h,live:O}=t,k=$t[m].color;let x;e[0]!==k?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:k}}),e[0]=k,e[1]=x):x=e[1];let b;e[2]!==o?(b=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=b):b=e[3];let p;e[4]!==x||e[5]!==b?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[4]=x,e[5]=b,e[6]=p):p=e[6];let j;e[7]!==y||e[8]!==i||e[9]!==k||e[10]!==O||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(Gt,{children:Q=>{const{width:E,height:T}=Q;return E>0&&T>0?s.jsx(js,{width:E,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:O,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=O,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 js(t){const e=Xe.c(139),{width:o,height:m,data:y,dataKey:i,hex:n,range:h,now:O,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,E]=N.useState(!1),[T,ie]=N.useState(null),[ce,le]=N.useState(!1),W=ce?T:null,c=o-K.left-K.right,d=m-K.top-K.bottom,F=O,oe=F-xt[h],w=Ut({domain:[oe,F],range:[0,Math.max(0,c)]}),l=Bt({domain:[0,100],range:[d,kt]}),H=c>0?vs/c*xt[h]:0,Z=oe-H,ee=F+H;let D;e[0]!==h||e[1]!==Z||e[2]!==ee?(D=is(Z,ee,h),e[0]=h,e[1]=Z,e[2]=ee,e[3]=D):D=e[3];const U=D,X=c>0?Math.min(.5,bs/c):0,I=`fill-${i}`,B=`plot-${i}`,P=`axis-fade-${i}`,V=y[y.length-1],S=b!==null&&V?{t:Math.max(F,gt(V)+1),v:b,live:!0}:null;let te;e[4]!==i?(te=a=>({t:gt(a),v:a[i]}),e[4]=i,e[5]=te):te=e[5];const r=y.map(te);S&&r.push(S);const z=a=>Math.min(w(a),c),q=S?z(S.t):0,Y=S?l(S.v):0,f=Math.max(0,y.length-1),_=j===null?Math.max(0,r.length-1):j==="live"?S?r.length-1:f:Math.min(gs(y,j),f),v=Q?r[_]:void 0,M=v?z(v.t):0,$=v?l(v.v):0,A=$t[i].label;let J;e[6]!==A?(J=a=>`${A}, ${St(a.t)}, ${a.live?"latest, ":""}${We(a.v)}`,e[6]=A,e[7]=J):J=e[7];const u=J,L=a=>{const R=r[a];R&&(C(R.live?"live":R.t),E(!0),ie({now:a,text:u(R)}))};let G;e[8]===Symbol.for("react.memo_cache_sentinel")?(G=()=>E(!1),e[8]=G):G=e[8];const g=G;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=R=>{R.key==="Escape"&&E(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},se=[Q],e[9]=Q,e[10]=ae,e[11]=se):(ae=e[10],se=e[11]),N.useEffect(ae,se);const de=a=>{if(r.length===0)return;const R=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,R-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,R+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),L(Fe))},re=a=>{const R=qt(a);if(!R)return;const Fe=R.x-K.left,yt=ys(r,w.invert(Fe).getTime()),vt=[r[yt-1],r[yt],S].reduce((mt,ht)=>ht&&(!mt||Math.abs(z(ht.t)-Fe)<=Math.abs(z(mt.t)-Fe))?ht:mt,void 0);vt&&L(r.indexOf(vt))},Ve="group",ne=S?`${x}, last ${h}. Now ${We(S.v)}.`:V?`${x}, last ${h}. Latest ${We(V[i])}.`:`${x}, last ${h}. No samples.`;let ue;e[12]!==I||e[13]!==n?(ue=s.jsx(Qt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=ue):ue=e[14];const ze=Math.max(0,c),Ye=Math.max(0,d);let fe;e[15]!==ze||e[16]!==Ye?(fe=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=fe):fe=e[17];let me;e[18]!==B||e[19]!==fe?(me=s.jsx("clipPath",{id:B,children:fe}),e[18]=B,e[19]=fe,e[20]=me):me=e[20];const Je=`${P}-grad`,Ze=Math.max(0,c);let He;e[21]===Symbol.for("react.memo_cache_sentinel")?(He=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=He):He=e[21];let he;e[22]!==X?(he=s.jsx("stop",{offset:X,stopColor:"white",stopOpacity:1}),e[22]=X,e[23]=he):he=e[23];const et=1-X;let xe;e[24]!==et?(xe=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=xe):xe=e[25];let Ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=Ue):Ue=e[26];let pe;e[27]!==Je||e[28]!==Ze||e[29]!==he||e[30]!==xe?(pe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[He,he,xe,Ue]}),e[27]=Je,e[28]=Ze,e[29]=he,e[30]=xe,e[31]=pe):pe=e[31];const tt=Math.max(0,c),st=Math.max(0,c),nt=`url(#${P}-grad)`;let ge;e[32]!==d||e[33]!==st||e[34]!==nt?(ge=s.jsx("rect",{x:0,y:d,width:st,height:K.bottom*2,fill:nt}),e[32]=d,e[33]=st,e[34]=nt,e[35]=ge):ge=e[35];let ye;e[36]!==P||e[37]!==d||e[38]!==tt||e[39]!==ge?(ye=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:d,width:tt,height:K.bottom*2,children:ge}),e[36]=P,e[37]=d,e[38]=tt,e[39]=ge,e[40]=ye):ye=e[40];let Be;e[41]===Symbol.for("react.memo_cache_sentinel")?(Be=[0,25,50,75,100],e[41]=Be):Be=e[41];let ve;e[42]!==c||e[43]!==l?(ve=s.jsx(Wt,{scale:l,width:c,tickValues:Be,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=c,e[43]=l,e[44]=ve):ve=e[44];const lt=`url(#${B})`;let be;e[45]!==w?(be=a=>w(a.t),e[45]=w,e[46]=be):be=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 we;e[49]!==r||e[50]!==be||e[51]!==je||e[52]!==ot||e[53]!==l?(we=s.jsx(Xt,{data:r,x:be,y:je,yScale:l,curve:wt,fill:ot}),e[49]=r,e[50]=be,e[51]=je,e[52]=ot,e[53]=l,e[54]=we):we=e[54];let Se;e[55]!==w?(Se=a=>w(a.t),e[55]=w,e[56]=Se):Se=e[56];let ke;e[57]!==l?(ke=a=>l(a.v),e[57]=l,e[58]=ke):ke=e[58];let Me;e[59]!==n||e[60]!==r||e[61]!==Se||e[62]!==ke?(Me=s.jsx(Vt,{data:r,x:Se,y:ke,curve:wt,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=r,e[61]=Se,e[62]=ke,e[63]=Me):Me=e[63];let Ne;e[64]!==lt||e[65]!==we||e[66]!==Me?(Ne=s.jsxs("g",{clipPath:lt,children:[we,Me]}),e[64]=lt,e[65]=we,e[66]=Me,e[67]=Ne):Ne=e[67];const at=`url(#${P})`;let _e;e[68]!==h?(_e=a=>cs(+a,h),e[68]=h,e[69]=_e):_e=e[69];let $e;e[70]!==d||e[71]!==_e||e[72]!==U||e[73]!==w?($e=s.jsx(zt,{top:d,scale:w,tickValues:U,tickFormat:_e,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:ks}),e[70]=d,e[71]=_e,e[72]=U,e[73]=w,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 Le;e[79]!==l?(Le=s.jsx(Yt,{scale:l,tickValues:qe,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Le):Le=e[80];let Ee;e[81]!==q||e[82]!==Y||e[83]!==n||e[84]!==S?(Ee=S&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:q,cy:Y,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:q,cy:Y,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=q,e[82]=Y,e[83]=n,e[84]=S,e[85]=Ee):Ee=e[85];let Te;e[86]!==n||e[87]!==d||e[88]!==v||e[89]!==M||e[90]!==$?(Te=v&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${M}px)`},pointerEvents:"none",children:[s.jsx(Jt,{from:{x:0,y:kt},to:{x:0,y:d},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]=d,e[88]=v,e[89]=M,e[90]=$,e[91]=Te):Te=e[91];const rt=Math.max(0,c)+Mt,it=Math.max(0,d),ct=`${x} samples`,dt=Math.max(0,r.length-1),ut=W?Math.min(W.now,Math.max(0,r.length-1)):_,ft=W?W.text:r[_]?u(r[_]):void 0;let Re;e[92]!==_||e[93]!==L?(Re=()=>{le(!0),L(_)},e[92]=_,e[93]=L,e[94]=Re):Re=e[94];let Oe;e[95]!==g?(Oe=()=>{g(),le(!1)},e[95]=g,e[96]=Oe):Oe=e[96];let Ce;e[97]!==de||e[98]!==re||e[99]!==g||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Re||e[108]!==Oe?(Ce=s.jsx(Zt,{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:Re,onBlur:Oe,onKeyDown:de,onMouseMove:re,onMouseLeave:g,onTouchMove:re,onTouchEnd:g,onTouchCancel:g}),e[97]=de,e[98]=re,e[99]=g,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Re,e[108]=Oe,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Le||e[114]!==Ee||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Le,Ee,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Le,e[114]=Ee,e[115]=Te,e[116]=Ce,e[117]=De):De=e[117];let Ie;e[118]!==m||e[119]!==ne||e[120]!==ue||e[121]!==me||e[122]!==pe||e[123]!==ye||e[124]!==De||e[125]!==o?(Ie=s.jsxs("svg",{width:o,height:m,role:Ve,"aria-label":ne,children:[ue,me,pe,ye,De]}),e[118]=m,e[119]=ne,e[120]=ue,e[121]=me,e[122]=pe,e[123]=ye,e[124]=De,e[125]=o,e[126]=Ie):Ie=e[126];let Pe;e[127]!==p?(Pe=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]=Pe):Pe=e[128];let Ke;e[129]!==c||e[130]!==A||e[131]!==v||e[132]!==M||e[133]!==$?(Ke=v&&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(${M+K.left}px, ${$+K.top}px) translate(${M>c*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",St(v.t)]}),s.jsxs("p",{children:[A,": ",We(v.v)]})]}),e[129]=c,e[130]=A,e[131]=v,e[132]=M,e[133]=$,e[134]=Ke):Ke=e[134];let Ge;return e[135]!==Ie||e[136]!==Pe||e[137]!==Ke?(Ge=s.jsxs(s.Fragment,{children:[Ie,Pe,Ke]}),e[135]=Ie,e[136]=Pe,e[137]=Ke,e[138]=Ge):Ge=e[138],Ge}function ws(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function Ss(t){return`${t}%`}function ks(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{js as AreaChartInner,Ls as MacResources};
|
|
Binary file
|
|
Binary file
|