hopwire 0.2.0 → 0.3.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/account.js +180 -35
- package/dist/agent/redact.js +17 -8
- package/dist/bin.js +136 -6
- package/dist/cli.js +116 -69
- package/dist/commands/doctor.js +19 -14
- package/dist/commands/http.js +3 -2
- package/dist/commands/init.js +10 -7
- package/dist/commands/login.js +47 -8
- package/dist/commands/up.js +3 -2
- package/dist/commands/watch.js +3 -3
- package/dist/config.js +7 -2
- package/dist/inspector/assets/{index-CIOfyIbK.js → index-CdyIIKdA.js} +1 -1
- package/dist/inspector/index.html +1 -1
- package/dist/live.js +226 -0
- package/dist/main.js +14 -3
- package/dist/output.js +19 -0
- package/dist/p2p.js +59 -1
- package/dist/relay.js +1 -1
- package/dist/serve.js +1 -0
- package/dist/shortcuts.js +217 -0
- package/dist/terminal.js +619 -0
- package/dist/version.js +12 -0
- package/dist/webhook.js +91 -0
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -18,7 +18,7 @@ export async function init(options) {
|
|
|
18
18
|
if (await present(options.file)) {
|
|
19
19
|
throw exists(options.shown);
|
|
20
20
|
}
|
|
21
|
-
const answers = options.flags === null ? await interview(options) : await fromFlags(options.flags, options
|
|
21
|
+
const answers = options.flags === null ? await interview(options) : await fromFlags(options.flags, storeOf(options));
|
|
22
22
|
const text = renderConfig(answers);
|
|
23
23
|
// The parser of hopwire up decides; a refusal here is a fault of init and ends with its sentence
|
|
24
24
|
parseConfig(text, options.shown);
|
|
@@ -55,18 +55,21 @@ async function present(file) {
|
|
|
55
55
|
throw new HopwireError(`${file} cannot be checked (${errorCode(error)}); check the permissions of its directory.`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
function storeOf(options) {
|
|
59
|
+
return { dataDir: options.dataDir, profile: options.profile ?? null };
|
|
60
|
+
}
|
|
58
61
|
/** What the account gives a public service: its edge and its control plane. Null when the machine cannot have one. */
|
|
59
|
-
async function accountUrls(
|
|
60
|
-
const account = await readAccount(
|
|
62
|
+
async function accountUrls(store) {
|
|
63
|
+
const account = await readAccount(store);
|
|
61
64
|
if (account === null) {
|
|
62
65
|
return 'logged-out';
|
|
63
66
|
}
|
|
64
|
-
const edgeUrl = await boundEdge(
|
|
67
|
+
const edgeUrl = await boundEdge(store);
|
|
65
68
|
return edgeUrl === null ? 'no-edge' : { edgeUrl, controlPlaneUrl: account.controlPlaneUrl };
|
|
66
69
|
}
|
|
67
70
|
const NO_EDGE = 'The account on this machine names no edge yet; run hopwire login again (or start hopwire http <port> --public once), then hopwire init again.';
|
|
68
71
|
// --- The flags ---
|
|
69
|
-
async function fromFlags(flags,
|
|
72
|
+
async function fromFlags(flags, store) {
|
|
70
73
|
if (flags.services.length === 0) {
|
|
71
74
|
throw new UsageError('hopwire init --yes needs at least one --service name=port, for example --service web=3000');
|
|
72
75
|
}
|
|
@@ -126,7 +129,7 @@ async function fromFlags(flags, dataDir) {
|
|
|
126
129
|
let edgeUrl = null;
|
|
127
130
|
let controlPlaneUrl = null;
|
|
128
131
|
if (flags.public.length > 0 || flags.team) {
|
|
129
|
-
const urls = await accountUrls(
|
|
132
|
+
const urls = await accountUrls(store);
|
|
130
133
|
if (urls === 'logged-out') {
|
|
131
134
|
throw new HopwireError(flags.public.length > 0
|
|
132
135
|
? '--public needs an account: run hopwire login first; nothing was written.'
|
|
@@ -182,7 +185,7 @@ async function interview(options) {
|
|
|
182
185
|
}
|
|
183
186
|
};
|
|
184
187
|
// Read once, before the first question: whether a service can be public at all
|
|
185
|
-
const urls = await accountUrls(options
|
|
188
|
+
const urls = await accountUrls(storeOf(options));
|
|
186
189
|
const detected = await detectPort(options.cwd);
|
|
187
190
|
const services = [];
|
|
188
191
|
let toldAboutPublic = false;
|
package/dist/commands/login.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_CONTROL_PLANE_URL, accountFile, isApiToken, readControlPlaneUrl, removeAccount, writeAccount, } from '../account.js';
|
|
1
|
+
import { DEFAULT_CONTROL_PLANE_URL, DEFAULT_PROFILE, accountFile, isApiToken, listProfiles, profileName, readControlPlaneUrl, removeAccount, useProfile, writeAccount, } from '../account.js';
|
|
2
2
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
3
3
|
import { HopwireError, TemporaryError } from '../errors.js';
|
|
4
4
|
import { LOGIN_NEXT, printable } from '../output.js';
|
|
@@ -11,7 +11,8 @@ import { LOGIN_NEXT, printable } from '../output.js';
|
|
|
11
11
|
* is stored unless the control plane accepted the token. The token is never printed.
|
|
12
12
|
*/
|
|
13
13
|
export async function login(options) {
|
|
14
|
-
const
|
|
14
|
+
const ref = { dataDir: options.dataDir, profile: options.profile ?? null };
|
|
15
|
+
const controlPlaneUrl = options.apiUrl ?? (await storedUrl(ref)) ?? new URL(DEFAULT_CONTROL_PLANE_URL);
|
|
15
16
|
const fromEnv = (options.token ?? '').trim();
|
|
16
17
|
const apiToken = fromEnv ||
|
|
17
18
|
(options.paste
|
|
@@ -27,7 +28,11 @@ export async function login(options) {
|
|
|
27
28
|
apiToken,
|
|
28
29
|
}).me(options.signal);
|
|
29
30
|
// The account is bound to the edge its control plane names: public tunnels need no HOPWIRE_EDGE_URL
|
|
30
|
-
await
|
|
31
|
+
const profile = await profileName(ref).catch(() => options.profile ?? DEFAULT_PROFILE);
|
|
32
|
+
await writeAccount({ dataDir: options.dataDir, profile }, { apiToken, controlPlaneUrl }, edgeUrl, {
|
|
33
|
+
organisation: organisation?.name ?? null,
|
|
34
|
+
plan,
|
|
35
|
+
});
|
|
31
36
|
// The address comes from another machine: nothing of it reaches the terminal as an escape sequence
|
|
32
37
|
options.print(`Logged in ${printable(email)} at ${controlPlaneUrl.origin}`);
|
|
33
38
|
if (organisation !== null) {
|
|
@@ -37,6 +42,7 @@ export async function login(options) {
|
|
|
37
42
|
options.print(`Edge ${edgeUrl.origin} (public tunnels of this account go there)`);
|
|
38
43
|
}
|
|
39
44
|
options.print(`Token stored in ${accountFile(options.dataDir)} (readable for this user only)`);
|
|
45
|
+
options.print(`Profile ${profile} (current; hopwire profiles lists them, hopwire login --profile <name> adds one)`);
|
|
40
46
|
for (const line of LOGIN_NEXT) {
|
|
41
47
|
options.print(line);
|
|
42
48
|
}
|
|
@@ -48,16 +54,49 @@ export async function login(options) {
|
|
|
48
54
|
*/
|
|
49
55
|
export async function logout(options) {
|
|
50
56
|
const file = accountFile(options.dataDir);
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
const ref = { dataDir: options.dataDir, profile: options.profile ?? null };
|
|
58
|
+
// A machine that was never logged in, or a damaged file, has no profiles to name; a damaged file goes as a whole
|
|
59
|
+
const known = (await listProfiles(options.dataDir).catch(() => [])).length > 0;
|
|
60
|
+
const of = known ? ` of profile ${await profileName(ref)}` : '';
|
|
61
|
+
if (await removeAccount(ref)) {
|
|
62
|
+
options.print(`Logged out the token${of} was removed from ${file}; it stays valid until you revoke it on the API tokens page of the control plane`);
|
|
53
63
|
}
|
|
54
64
|
else {
|
|
55
|
-
options.print(`Logged out no token was stored in ${file}`);
|
|
65
|
+
options.print(`Logged out no token${of} was stored in ${file}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* `hopwire profiles`: the logins of this data directory, one line each, with the organisation and plan the control
|
|
70
|
+
* plane named at login. Nothing is contacted; the token is never printed.
|
|
71
|
+
*/
|
|
72
|
+
export async function profiles(options) {
|
|
73
|
+
const found = await listProfiles(options.dataDir);
|
|
74
|
+
if (found.length === 0) {
|
|
75
|
+
options.print('No profiles yet: hopwire login stores the first one (named default; --profile <name> names it)');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const width = Math.max(...found.map((profile) => profile.name.length));
|
|
79
|
+
for (const profile of found) {
|
|
80
|
+
const organisation = profile.organisation === null
|
|
81
|
+
? 'organisation not known'
|
|
82
|
+
: `${profile.organisation}${profile.plan === null ? '' : ` (${profile.plan} plan)`}`;
|
|
83
|
+
const state = profile.loggedIn ? '' : ', logged out';
|
|
84
|
+
// Names of organisations come from another machine: nothing of them reaches the terminal as an escape sequence
|
|
85
|
+
options.print(printable(`${profile.current ? '*' : ' '} ${profile.name.padEnd(width)} ${organisation} at ${profile.controlPlaneUrl.origin}${state}`));
|
|
86
|
+
}
|
|
87
|
+
options.print('');
|
|
88
|
+
options.print('* is the current profile; hopwire use <name> switches, --profile <name> picks one for one command');
|
|
89
|
+
}
|
|
90
|
+
/** `hopwire use <name>`: makes a profile the current one. Nothing is contacted. */
|
|
91
|
+
export async function use(options) {
|
|
92
|
+
if (!(await useProfile(options.dataDir, options.name))) {
|
|
93
|
+
throw new HopwireError(`There is no profile "${options.name}" on this machine; run hopwire login --profile ${options.name} to create it, or hopwire profiles to list the ones there are.`);
|
|
56
94
|
}
|
|
95
|
+
options.print(`Profile ${options.name} is now the current one`);
|
|
57
96
|
}
|
|
58
97
|
/** The control plane of an earlier login, logged out since or not; a damaged file counts as none, the login replaces it. */
|
|
59
|
-
async function storedUrl(
|
|
60
|
-
return readControlPlaneUrl(
|
|
98
|
+
async function storedUrl(ref) {
|
|
99
|
+
return readControlPlaneUrl(ref).catch((error) => {
|
|
61
100
|
if (error instanceof HopwireError) {
|
|
62
101
|
return null;
|
|
63
102
|
}
|
package/dist/commands/up.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { LOCAL_ENTRY_DEFAULT_PORT, RANDOM_SUBDOMAIN_BYTES, randomSubdomain } from '@hopwire/protocol';
|
|
4
4
|
import { HopwireError } from '../errors.js';
|
|
5
|
-
import { MODE_LOCAL, MODE_P2P, MODE_P2P_TEAM, relayLine, MODE_PUBLIC, MODE_PUBLIC_P2P, MODE_PUBLIC_P2P_TEAM, AGENTS_ALLOWED_LINE, agentLine, agentOffLine,
|
|
5
|
+
import { MODE_LOCAL, MODE_P2P, MODE_P2P_TEAM, relayLine, MODE_PUBLIC, MODE_PUBLIC_P2P, MODE_PUBLIC_P2P_TEAM, AGENTS_ALLOWED_LINE, agentLine, agentOffLine, exchangeSink, formatPeerEvent, formatLogNotice, logLines, formatRelayEvent, formatTeamEvent, formatUsage, shareNotice, tunnelGuide, mainPublicUrl, publicUrlText, } from '../output.js';
|
|
6
6
|
import { startServing } from '../serve.js';
|
|
7
7
|
import { formatBridgeEvent } from './http.js';
|
|
8
8
|
/**
|
|
@@ -53,6 +53,7 @@ export async function startUp(options) {
|
|
|
53
53
|
onTeamEvent: (event, organisation) => options.print(formatTeamEvent(event, organisation)),
|
|
54
54
|
relay: options.relay,
|
|
55
55
|
onRelayEvent: (event) => options.print(formatRelayEvent(event)),
|
|
56
|
+
onPeerEvent: (event) => options.print(formatPeerEvent(event)),
|
|
56
57
|
bootstrap: options.bootstrap,
|
|
57
58
|
inspectorFiles: options.inspectorFiles,
|
|
58
59
|
agent: options.agent,
|
|
@@ -63,7 +64,7 @@ export async function startUp(options) {
|
|
|
63
64
|
signal: options.signal,
|
|
64
65
|
listenOption: 'a free port',
|
|
65
66
|
inspectOption: 'inspector.port in hopwire.yaml',
|
|
66
|
-
onExchange: (exchange) => options.print(
|
|
67
|
+
onExchange: (exchange) => exchangeSink(options.print, options.exchange)(exchange, label(exchange.serviceName)),
|
|
67
68
|
onLogError: (name) => options.print(`${label(name)}Could not write to the traffic log; the request was still forwarded`),
|
|
68
69
|
onBridgeEvent: (name, event) => options.print(several ? `${formatBridgeEvent(event)} (service ${name})` : formatBridgeEvent(event)),
|
|
69
70
|
});
|
package/dist/commands/watch.js
CHANGED
|
@@ -7,7 +7,7 @@ import { startInspectorServer } from '../inspector-server.js';
|
|
|
7
7
|
import { createInterceptor } from '../interceptor.js';
|
|
8
8
|
import { InFlightExchanges, followLogFile } from '../log-follow.js';
|
|
9
9
|
import { REMOTE_LOG_BUDGET_BYTES } from '../log.js';
|
|
10
|
-
import { MODE_P2P, MODE_P2P_RELAYED, MODE_P2P_TEAM,
|
|
10
|
+
import { MODE_P2P, MODE_P2P_RELAYED, MODE_P2P_TEAM, exchangeSink, formatLogNotice, logLines, printable, relayedLine, shortKey, watchAgentLine, watchGuide, } from '../output.js';
|
|
11
11
|
import { INSPECTOR_FILES } from '../serve.js';
|
|
12
12
|
import { Supervisor, unlessAborted } from '../supervisor.js';
|
|
13
13
|
/**
|
|
@@ -114,7 +114,7 @@ export async function startWatch(options) {
|
|
|
114
114
|
serviceName,
|
|
115
115
|
log: own,
|
|
116
116
|
inFlight,
|
|
117
|
-
onExchange: (exchange) => options.print(
|
|
117
|
+
onExchange: (exchange) => exchangeSink(options.print, options.exchange)(exchange),
|
|
118
118
|
onLogError: () => options.print('Could not write to the traffic log; the replay was still sent'),
|
|
119
119
|
});
|
|
120
120
|
interceptors.set(serviceName, interceptor);
|
|
@@ -162,7 +162,7 @@ export async function startWatch(options) {
|
|
|
162
162
|
}
|
|
163
163
|
// Stopped at the last step: nothing is reported as running
|
|
164
164
|
proceed();
|
|
165
|
-
const stopPrinting = remote.subscribe((_index, exchange) => options.print(
|
|
165
|
+
const stopPrinting = remote.subscribe((_index, exchange) => exchangeSink(options.print, options.exchange)(exchange));
|
|
166
166
|
supervisor.add('servers', async () => stopPrinting());
|
|
167
167
|
void remote.exhausted.then(() => options.print(`Watching stopped: this run has downloaded ${REMOTE_LOG_BUDGET_BYTES / (1024 * 1024)} MB of the log; new exchanges are no longer fetched until hopwire watch is started again`));
|
|
168
168
|
options.print(joined.relayed ? MODE_P2P_RELAYED : organisation === null ? MODE_P2P : MODE_P2P_TEAM);
|
package/dist/config.js
CHANGED
|
@@ -157,9 +157,14 @@ function validate(value, ordered) {
|
|
|
157
157
|
team = boolean(p2p.team, ['p2p', 'team']);
|
|
158
158
|
allowAgents = boolean(p2p.allowAgents, ['p2p', 'allowAgents']);
|
|
159
159
|
relay = boolean(p2p.relay, ['p2p', 'relay']);
|
|
160
|
-
if (relay && !
|
|
161
|
-
throw new Problem(['p2p', 'relay'], '
|
|
160
|
+
if (relay && !share) {
|
|
161
|
+
throw new Problem(['p2p', 'relay'], 'only works together with p2p.share: true; it lets teammates without a direct connection reach the shared services and the shared log.');
|
|
162
162
|
}
|
|
163
|
+
if (relay && p2p.allow !== undefined) {
|
|
164
|
+
throw new Problem(['p2p', 'allow'], 'cannot be combined with p2p.relay: the relay of the edge (Team plan) only pairs machines of one organisation, so p2p.relay shares with your team; remove p2p.allow.');
|
|
165
|
+
}
|
|
166
|
+
// The relay only pairs machines of one organisation, so p2p.relay turns on p2p.team
|
|
167
|
+
team = team || relay;
|
|
163
168
|
if (allowAgents && !share) {
|
|
164
169
|
throw new Problem(['p2p', 'allowAgents'], 'needs p2p.share: true; it lets the coding agents of teammates who watch the shared log read it.');
|
|
165
170
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
`))),e[ho]=fo(i);let a=r||i.props&&i.props.type===`number`;Xa(e,t?`change`:`input`,t=>{t.target.composing||e[ho](_o(e.value,n,a))}),(n||a)&&Xa(e,`change`,()=>{e.value=_o(e.value,n,a)}),t||(Xa(e,`compositionstart`,po),Xa(e,`compositionend`,mo),Xa(e,`change`,mo))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[go];delete e[go],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[ho](_o(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[ho]=fo(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?de(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},yo={created(e,{value:t},n){e.checked=Ee(t,n.props.value),e[ho]=fo(n),Xa(e,`change`,()=>{e[ho](Co(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[ho]=fo(r),t!==n&&(e.checked=Ee(t,r.props.value))}},bo={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Xa(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?de(Co(e)):Co(e)),r=e.multiple,i=r?p(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?d(i)?t.slice():t:i];try{e[ho](i)}finally{Cn(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[ho]=fo(r)},mounted(e,{value:t,modifiers:{number:n}}){So(e,t,n)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[ho]=fo(n)},updated(e,{value:t,modifiers:{number:n}}){let r=e._pendingValue;e._pendingValue=void 0,r&&r[0]===e.multiple&&xo(t,r[1],r[0])||So(e,t,n)}};function xo(e,t,n){if(!n||d(e))return Ee(e,t);if(p(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function So(e,t,n=!1){let r=e.multiple,i=d(t);if(!r||i||p(t)){for(let a=0,o=e.options.length;a<o;a++){let o=e.options[a],s=Co(o);if(r){if(i){let e=typeof s;o.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(s)):De(t,s)>-1}else o.selected=t.has(s)||n&&typeof s==`string`&&t.has(de(s))}else if(Ee(Co(o),t)){e.selectedIndex!==a&&(e.selectedIndex=a);return}}!r&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Co(e){return`_value`in e?e._value:e.value}var wo=[`ctrl`,`shift`,`alt`,`meta`],To={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>wo.some(n=>e[`${n}Key`]&&!t.includes(n))},Eo=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=To[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Do=s({patchProp:co},Na),Oo;function ko(){return Oo||=Ti(Do)}var Ao=((...e)=>{let t=ko().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Mo(e);if(!r)return;let i=t._component;h(i)||i.render||i.template||(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,jo(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function jo(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function Mo(e){return g(e)?document.querySelector(e):e}var No=`296 62 430 108`,Po=`300 62 124 110`,Fo=4.5,Io=[`M336.89 111.56C337.43 111.4 339.26 111.03 340.5 110.5C341.74 109.97 343.04 108.72 345.17 108C347.29 107.28 351.42 105.97 354.67 105.67C357.92 105.37 363.86 105.65 366.83 106C369.81 106.35 372.7 107.42 374.5 108C376.3 108.58 377.61 109.56 378.83 109.83C380.06 110.11 381.87 110.21 382.67 109.83C383.47 109.46 383.87 108.21 384.17 107.33C384.47 106.46 384.64 104.72 384.67 104C384.69 103.28 385.33 103.22 384.33 102.5C383.33 101.78 379.93 100.34 378 99.17C376.07 97.99 373.1 95.97 371.5 94.67C369.9 93.37 368.68 92.3 367.33 90.5C365.98 88.7 363.4 84.77 362.5 82.67C361.6 80.57 361.46 77.5 361.33 76.5C361.21 75.5 361.09 76.08 361.67 76C362.24 75.92 363.79 75.72 365.17 76C366.54 76.28 368.93 76.98 370.83 77.83C372.73 78.68 375.86 80.32 377.83 81.67C379.81 83.02 382.35 85.21 384 86.83C385.65 88.46 387.58 90.85 388.83 92.5C390.08 94.15 390.43 96.71 392.33 97.83C394.23 98.96 399.38 99.22 401.5 100C403.63 100.78 405.18 101.95 406.5 103C407.82 104.05 409.23 105.58 410.33 107C411.43 108.42 413.33 110.95 413.83 112.5C414.33 114.05 414.09 116.13 413.67 117.33C413.24 118.53 411.93 119.78 411 120.5C410.07 121.22 408.73 121.87 407.5 122.17C406.27 122.47 404.31 122.28 402.83 122.5C401.36 122.72 399.81 122.4 397.67 123.67C395.52 124.93 389.89 129.84 388.52 130.93`,`M388.52 130.93C389.84 131.32 394.31 131.96 397.33 133.5C400.35 135.04 406.67 139.69 408.67 141.17C410.67 142.64 410.32 142.58 410.67 143.33C411.02 144.08 411.02 145.44 411 146.17C410.98 146.89 411 147.67 410.5 148.17C410 148.67 408.54 149.4 407.67 149.5C406.79 149.6 407.19 150.08 404.67 148.83C402.14 147.58 394.86 142.99 390.83 141.17C386.81 139.34 381.46 137.54 377.83 136.67C374.21 135.79 369.24 135.46 366.67 135.33C364.09 135.21 361.57 135.76 360.67 135.83`,`M331 120.88C330.77 122.84 330.2 131.76 329.5 134C328.8 136.24 327.63 135.48 326.33 135.83C325.03 136.18 321.88 136.16 320.83 136.33C319.78 136.51 320.86 134.7 319.33 137C317.81 139.3 312.07 149.12 310.67 151.67C309.27 154.22 310.05 153.32 310 154C309.95 154.68 310.08 155.59 310.33 156.17C310.58 156.74 311.19 157.51 311.67 157.83C312.14 158.16 312.85 158.31 313.5 158.33C314.15 158.36 315.43 158.22 316 158C316.57 157.78 316.58 157.86 317.33 156.83C318.08 155.81 319.82 152.74 321 151.17C322.18 149.59 323.29 147.16 325.17 146.33C327.04 145.51 331.23 146.02 333.5 145.67C335.77 145.32 338.76 144.53 340.33 144C341.91 143.47 342.95 142.82 344 142.17C345.05 141.52 346.18 140.94 347.33 139.67C348.48 138.39 350.72 135.57 351.67 133.67C352.62 131.77 353.34 128.4 353.67 127C353.99 125.6 353.81 124.73 353.83 124.33`,`M336.89 111.56C336.46 111.1 334.91 109.08 334 108.5C333.09 107.92 331.81 107.72 330.83 107.67C329.86 107.62 328.45 107.67 327.5 108.17C326.55 108.67 325.05 110.03 324.5 111C323.95 111.97 323.81 113.67 323.83 114.67C323.86 115.67 324.24 116.89 324.67 117.67C325.09 118.44 325.72 119.35 326.67 119.83C327.62 120.31 330.35 120.72 331 120.88`,`M336.89 111.56C336.73 112.02 336.52 113.42 335.83 114.67C335.15 115.91 333.06 118.9 332.33 119.83C331.61 120.76 331.2 120.72 331 120.88`],Lo=`M454.72 144L447.01 144L447.01 94.02L454.72 94.02L454.72 115.44L475.72 115.44L475.72 94.02L483.43 94.02L483.43 144L475.72 144L475.72 122.44L454.72 122.44L454.72 144M510.56 145Q505.27 145 501.17 142.82Q497.06 140.64 494.71 136.57Q492.35 132.50 492.35 126.94L492.35 125.86Q492.35 120.30 494.71 116.26Q497.06 112.23 501.17 110.01Q505.27 107.80 510.56 107.80Q515.84 107.80 519.98 110.01Q524.12 112.23 526.48 116.26Q528.84 120.30 528.84 125.86L528.84 126.94Q528.84 132.50 526.48 136.57Q524.12 140.64 519.98 142.82Q515.84 145 510.56 145M510.56 138.43Q515.41 138.43 518.45 135.32Q521.48 132.22 521.48 126.72L521.48 126.08Q521.48 120.58 518.48 117.47Q515.48 114.37 510.56 114.37Q505.77 114.37 502.74 117.47Q499.71 120.58 499.71 126.08L499.71 126.72Q499.71 132.22 502.74 135.32Q505.77 138.43 510.56 138.43M545.33 158.28L537.98 158.28L537.98 108.80L545.19 108.80L545.19 113.87L546.33 113.87Q547.69 111.51 550.44 109.66Q553.18 107.80 558.32 107.80Q562.75 107.80 566.43 109.94Q570.11 112.08 572.35 116.12Q574.60 120.15 574.60 125.86L574.60 126.94Q574.60 132.65 572.39 136.68Q570.18 140.72 566.46 142.86Q562.75 145 558.32 145Q554.90 145 552.54 144.14Q550.19 143.29 548.76 141.97Q547.33 140.64 546.47 139.22L545.33 139.22L545.33 158.28M556.18 138.57Q561.04 138.57 564.11 135.50Q567.18 132.43 567.18 126.72L567.18 126.08Q567.18 120.44 564.07 117.37Q560.97 114.30 556.18 114.30Q551.47 114.30 548.36 117.37Q545.26 120.44 545.26 126.08L545.26 126.72Q545.26 132.43 548.36 135.50Q551.47 138.57 556.18 138.57M599.52 144L587.17 144L581.17 108.80L588.53 108.80L592.95 139.07L594.10 139.07L600.24 108.80L612.16 108.80L618.23 139.07L619.37 139.07L623.80 108.80L631.15 108.80L625.16 144L612.80 144L606.73 113.80L605.59 113.80L599.52 144M647.22 144L639.86 144L639.86 108.80L647.22 108.80L647.22 144M643.58 104.02Q641.43 104.02 639.97 102.62Q638.51 101.23 638.51 99.02Q638.51 96.80 639.97 95.41Q641.43 94.02 643.58 94.02Q645.79 94.02 647.22 95.41Q648.65 96.80 648.65 99.02Q648.65 101.23 647.22 102.62Q645.79 104.02 643.58 104.02M665.50 144L658.14 144L658.14 108.80L665.35 108.80L665.35 112.94L666.50 112.94Q667.35 110.73 669.24 109.69Q671.14 108.66 673.92 108.66L678.13 108.66L678.13 115.30L673.64 115.30Q670.07 115.30 667.78 117.26Q665.50 119.22 665.50 123.29L665.50 144M700.63 145Q695.27 145 691.27 142.75Q687.27 140.50 685.02 136.40Q682.77 132.29 682.77 126.86L682.77 126.01Q682.77 120.51 684.99 116.40Q687.20 112.30 691.16 110.05Q695.13 107.80 700.34 107.80Q705.41 107.80 709.23 110.05Q713.05 112.30 715.19 116.30Q717.33 120.30 717.33 125.65L717.33 128.43L690.27 128.43Q690.41 133.08 693.38 135.82Q696.34 138.57 700.77 138.57Q704.91 138.57 707.02 136.72Q709.12 134.86 710.26 132.43L716.33 135.57Q715.33 137.57 713.44 139.79Q711.55 142 708.48 143.50Q705.41 145 700.63 145M690.34 122.79L709.84 122.79Q709.55 118.80 706.98 116.55Q704.41 114.30 700.27 114.30Q696.13 114.30 693.52 116.55Q690.91 118.80 690.34 122.79`,Ro=[`id`],zo=[`id`],Bo=[`fill`],Vo=[`mask`],Ho={class:`hwx-wire`},Uo=[`cx`],Wo={class:`hwx-hop`},Go=[`stroke-width`],Ko=[`d`],qo=z({__name:`HopLoader`,props:{active:{type:Boolean}},setup(e){let t=Array.from({length:9},(e,t)=>-128+t*64),n=Qn(),r=Qn();return(i,a)=>(W(),G(`svg`,{viewBox:`0 0 256 150`,"aria-hidden":`true`,focusable:`false`,class:E([`block h-auto`,e.active?`hwx-run`:void 0])},[q(`defs`,null,[q(`linearGradient`,{id:P(r),x1:`0`,x2:`1`,y1:`0`,y2:`0`},[...a[0]||=[q(`stop`,{offset:`0`,"stop-color":`#000`},null,-1),q(`stop`,{offset:`.22`,"stop-color":`#fff`},null,-1),q(`stop`,{offset:`.78`,"stop-color":`#fff`},null,-1),q(`stop`,{offset:`1`,"stop-color":`#000`},null,-1)]],8,Ro),q(`mask`,{id:P(n),maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`256`,height:`150`},[q(`rect`,{width:`256`,height:`150`,fill:`url(#${P(r)})`},null,8,Bo)],8,zo)]),q(`g`,{mask:`url(#${P(n)})`},[q(`g`,Ho,[a[1]||=q(`line`,{class:`stroke-muted`,x1:`-192`,y1:`122`,x2:`448`,y2:`122`,"stroke-width":`1.5`},null,-1),(W(!0),G(U,null,B(P(t),e=>(W(),G(`circle`,{key:e,class:`fill-ground stroke-muted`,cx:e,cy:`122`,r:`3.4`,"stroke-width":`1.5`},null,8,Uo))),128))]),a[2]||=q(`circle`,{class:`hwx-lit1 fill-hop-green`,cx:`128`,cy:`122`,r:`4.6`},null,-1),a[3]||=q(`circle`,{class:`hwx-lit2 fill-hop-green`,cx:`64`,cy:`122`,r:`4.6`},null,-1),a[4]||=q(`circle`,{class:`hwx-lit3 fill-hop-green`,cx:`0`,cy:`122`,r:`4.6`},null,-1)],8,Vo),a[5]||=q(`circle`,{class:`hwx-ring stroke-green-text`,cx:`128`,cy:`122`,r:`5`,fill:`none`,"stroke-width":`1.5`},null,-1),q(`g`,Wo,[q(`g`,{transform:`translate(-132.64 10.80) scale(0.72)`,class:`stroke-mark`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(e,t)=>(W(),G(`path`,{key:t,d:e},null,8,Ko))),128))],8,Go)])],2))}}),Jo={class:`flex h-full flex-col items-center justify-center gap-4 p-8 text-center`,role:`status`},Yo={class:`text-sm text-muted`},Xo=z({__name:`ConnectingState`,props:{connecting:{type:Boolean}},setup(e){return(t,n)=>(W(),G(`div`,Jo,[J(qo,{class:`w-44`,active:e.connecting},null,8,[`active`]),q(`p`,Yo,D(e.connecting?`Connecting to the tunnel`:`Not connected to the tunnel`),1)]))}}),Zo={connecting:`Connecting`,live:`Live`,reconnecting:`Reconnecting`,closed:`Disconnected`};function Qo(e,t){return e?`closed`:t?`reconnecting`:`connecting`}function $o(e){return e===`connecting`||e===`reconnecting`}function es(){let e=N(!1),t;async function n(n){try{await navigator.clipboard.writeText(n)}catch{return}e.value=!0,clearTimeout(t),t=setTimeout(()=>{e.value=!1},1500)}return gr(()=>clearTimeout(t)),{copied:e,copy:n}}var ts=[`aria-label`],ns={"aria-live":`polite`},rs=z({__name:`CopyButton`,props:{text:{},label:{}},setup(e){let{copied:t,copy:n}=es();return(r,i)=>(W(),G(`button`,{type:`button`,class:`shrink-0 cursor-pointer rounded-sm px-1.5 py-0.5 text-xs font-medium text-tag-fg transition-colors duration-150 ease-out hover:bg-ink/8 hover:text-ink`,"aria-label":e.label,onClick:i[0]||=t=>P(n)(e.text)},[q(`span`,ns,D(P(t)?`Copied`:`Copy`),1)],8,ts))}}),is={class:`flex h-full items-center justify-center overflow-y-auto p-8`},as={class:`w-full max-w-2xl`},os={key:0,class:`mt-2 text-sm text-muted`},ss={class:`mt-4 flex items-start gap-2 rounded-md border border-hairline bg-well p-3`},cs={class:`min-w-0 flex-1 text-xs leading-5 break-all text-ink`},ls={class:`mt-4 text-sm text-muted`},us={class:`font-mono text-xs text-ink`},ds={class:`font-mono text-xs text-ink`},fs={key:2,class:`mt-2 text-sm text-muted`},ps=z({__name:`EmptyState`,props:{status:{},stream:{}},setup(e){let t=e,n=Q(()=>t.status?.services.find(e=>e.entryUrl!==null)??null),r=Q(()=>n.value===null?null:`curl -X POST ${n.value.entryUrl}/hello -H 'content-type: application/json' -d '{"hello":"hopwire"}'`);return(t,i)=>(W(),G(`div`,is,[q(`div`,as,[J(qo,{class:`mb-6 w-44`,active:P($o)(e.stream)},null,8,[`active`]),i[5]||=q(`h2`,{class:`text-subheading`},`No requests yet`,-1),e.status?.watching?(W(),G(`p`,os,` This inspector follows a shared traffic log. Requests show up here as soon as your teammate's tunnel receives them. `)):n.value&&r.value?(W(),G(U,{key:1},[i[4]||=q(`p`,{class:`mt-2 text-sm text-muted`},` Send a request to the entry point and it appears here right away, no reload needed: `,-1),q(`div`,ss,[q(`code`,cs,[i[0]||=q(`span`,{class:`text-muted select-none`},`$ `,-1),Y(D(r.value),1)]),J(rs,{text:r.value,label:`Copy curl command`},null,8,[`text`])]),q(`p`,ls,[i[1]||=Y(` Everything sent to `,-1),q(`span`,us,D(n.value.entryUrl),1),i[2]||=Y(` is forwarded to `,-1),q(`span`,ds,D(n.value.target),1),i[3]||=Y(` and recorded in the traffic log. Point your webhook sender or client at the entry point instead of the service. `,-1)])],64)):(W(),G(`p`,fs,`Waiting for the tunnel.`))])]))}});function ms(e){return e.response.status===101}var hs=[[/^(emergency|alert|critical|crit|error|err|fatal)$/i,`error`],[/^(warning|warn)$/i,`warning`],[/^(notice|info)$/i,`info`],[/^(debug|trace)$/i,`debug`]];function gs(e){let t=e.slice(0,2048).split(`
|
|
3
3
|
`,1)[0]??``,n=/\.(EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG):/.exec(t)?.[1]??/"(?:level|level_name|severity)"\s*:\s*"([A-Za-z]+)"/.exec(t)?.[1]??/^\S*\s*\[?\b(FATAL|ERROR|ERR|WARN|WARNING|INFO|DEBUG|TRACE)\b\]?/.exec(t.replace(/^\[[^\]]*\]\s*/,``))?.[1];if(n===void 0)return null;for(let[e,t]of hs)if(e.test(n))return t;return null}var _s=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}},vs=`api/`;async function ys(e,t){let n;try{n=await fetch(e,t)}catch{throw new _s(0,`unreachable`,`The tunnel does not answer. Is it still running?`)}if(!n.ok){let e=await n.json().catch(()=>null);throw new _s(n.status,typeof e?.error==`string`?e.error:`unknown`,typeof e?.message==`string`?e.message:`The inspector answered ${n.status}.`)}return await n.json()}function bs(){return ys(`${vs}status`)}function xs(e){let t=new URLSearchParams({origin:e.origin,limit:String(e.limit)});return e.before!==void 0&&t.set(`before`,String(e.before)),ys(`${vs}exchanges?${t.toString()}`)}async function Ss(e,t){let n=[],r=null;for(;;){let i=new URLSearchParams({origin:e});r!==null&&i.set(`after`,String(r));let a=await ys(`${vs}ws-messages/${encodeURIComponent(t)}?${i.toString()}`);n.push(...a.blocks);let o=a.blocks.at(-1);if(!a.more||o===void 0)return n;r=o.seq}}function Cs(e){let t=new URLSearchParams;return e.exchangeId!==void 0&&t.set(`exchangeId`,e.exchangeId),e.origin!==void 0&&t.set(`origin`,e.origin),e.limit!==void 0&&t.set(`limit`,String(e.limit)),ys(`${vs}log-entries?${t.toString()}`)}function ws(e,t){let n=new URLSearchParams({origin:e.origin,index:String(e.index)});return ys(`${vs}replay/${encodeURIComponent(e.exchange.id)}?${n.toString()}`,{method:`POST`,...t===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(t)}})}function Ts(e){return e>=200&&e<300?`success`:e>=300&&e<400?`info`:e>=400&&e<500?`warning`:e>=500&&e<600?`danger`:`neutral`}var Es={success:`bg-ok-bg text-ok-fg`,info:`bg-info-bg text-info-fg`,warning:`bg-warn-bg text-warn-fg`,danger:`bg-err-bg text-err-fg`,neutral:`bg-tag-bg text-tag-fg`},Ds={local:`local`,replay:`replay`,p2p_peer:`peer`,public_edge:`public`};function Os(e){return Ds[e]}function ks(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`}function As(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} kB`:`${(e/1048576).toFixed(1)} MB`}function js(e,t){return t?`Binary body; the log keeps its first ${As(e)}. It is not shown.`:`Binary body of ${As(e)}. It is not shown, but it is replayed as captured.`}function Ms(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function Ns(e){return e.length<=20?e:`${e.slice(0,10)}...${e.slice(-6)}`}function Ps(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Fs(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function Is(e){return Fs(new TextEncoder().encode(e))}function Ls(e,t){let n=new TextDecoder(`utf-8`,{fatal:!0});for(let r=0;r<=(t?3:0)&&r<e.length;r++)try{let t=n.decode(e.subarray(0,e.length-r));return t.includes(`\0`)?null:t}catch{}return null}function Rs(e){let t=e.trim();if(t===``)return null;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}}function zs(e,t=!1){if(e===``)return{kind:`empty`};let n=Ps(e),r=Ls(n,t);if(r===null)return{kind:`binary`,bytes:n.length};let i=Rs(r);return i!==null&&/^\s*[[{]/.test(r)?{kind:`json`,text:r,formatted:i,bytes:n.length}:{kind:`text`,text:r,bytes:n.length}}function Bs(e,t){return`${e}:${t}`}function Vs(e,t){let n=new Map;for(let r of[...e,...t])n.set(r.seq,r);return[...n.values()].sort((e,t)=>e.seq-t.seq)}function Hs(e){return{messages:e.flatMap(e=>e.messages).map((e,t)=>({...e,position:t})),close:e.find(e=>e.close!==void 0)?.close??null}}function Us(e){if(!e.binary){let t=zs(e.dataBase64,e.truncated);if(t.kind===`json`)return{kind:`json`,text:t.text,formatted:t.formatted};if(t.kind===`text`)return{kind:`text`,text:t.text};if(t.kind===`empty`)return{kind:`text`,text:``}}let t=Ps(e.dataBase64);return{kind:`binary`,hex:Array.from(t.subarray(0,256),e=>e.toString(16).padStart(2,`0`)).join(` `),more:t.length>256}}function Ws(e,t){let n=t.text.trim().toLowerCase();return e.filter(e=>{if(t.direction!==``&&e.direction!==t.direction)return!1;if(n===``)return!0;let r=Us(e);return r.kind!==`binary`&&r.text.toLowerCase().includes(n)})}function Gs(e){switch(e){case`client`:return`the client`;case`service`:return`the service`;case`hopwire`:return`Hopwire`}return e}function Ks(e){return e.some(e=>e.direction===`in`&&e.truncated)?`A client message was captured only in part. Use Edit & Replay to replace or remove it.`:null}var qs=0;function Js(e=``){return qs+=1,{key:qs,binary:!1,text:e,dataBase64:``,length:0,truncated:!1}}function Ys(e,t,n){return{path:e,headers:t.map(([e,t])=>({name:e,value:t})),messages:n.filter(e=>e.direction===`in`).map(e=>{qs+=1;let t=e.binary?null:Us(e),n=t!==null&&t.kind!==`binary`;return{key:qs,binary:!n,text:n?t.text:``,dataBase64:e.dataBase64,atMs:e.atMs,length:e.length,truncated:e.truncated}}),timing:`recorded`}}var Xs=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Zs(e){if(!/^\/\S*$/.test(e.path))return`The path must start with / and must not contain spaces.`;for(let t of e.headers)if(t.name.trim()!==``||t.value.trim()!==``){if(!Xs.test(t.name.trim()))return`"${t.name}" is not a valid header name.`;if(/[\r\n]/.test(t.value))return`The value of ${t.name.trim()} must be a single line.`}return e.messages.some(e=>e.binary&&e.truncated)?`A binary message was captured only in part and cannot be sent. Remove it to replay the rest.`:null}function Qs(e){let t=e.messages.map(e=>({binary:e.binary,dataBase64:e.binary?e.dataBase64:Is(e.text),...e.atMs===void 0?{}:{atMs:e.atMs}}));return{path:e.path,headers:e.headers.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.value.trim()]),messages:t,timing:e.timing}}var $s=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`,`OPTIONS`],ec=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function tc(e){let{request:t}=e,n=zs(t.bodyBase64,t.bodyTruncated);return{method:t.method.toUpperCase(),path:t.path,headers:t.headers.map(([e,t])=>({name:e,value:t})),body:n.kind===`json`||n.kind===`text`?n.text:``,bodyEditable:n.kind!==`binary`}}function nc(e,t){if(!ec.test(e.method.trim()))return`Enter a method such as GET or POST.`;if(!/^\/\S*$/.test(e.path))return`The path must start with / and must not contain spaces.`;for(let t of e.headers)if(t.name.trim()!==``||t.value.trim()!==``){if(!ec.test(t.name.trim()))return`"${t.name}" is not a valid header name.`;if(/[\r\n]/.test(t.value))return`The value of ${t.name.trim()} must be a single line.`}return!e.bodyEditable&&t.request.bodyTruncated?`The stored body is binary and was truncated, so this request cannot be replayed.`:null}function rc(e){let t=e.headers.filter(e=>e.name.trim()!==``).map(e=>[e.name.trim(),e.value.trim()]);return{method:e.method.trim().toUpperCase(),path:e.path,headers:t,...e.bodyEditable?{bodyBase64:Is(e.body)}:{}}}function ic(e,t){return e===null?`The inspector is not connected to the tunnel.`:e.watching?e.replayTarget===null?`Replay is off because this watch has no replay target. Start hopwire watch with --replay-target <url>.`:null:e.services.some(e=>e.name===t.serviceName)?null:`The service "${t.serviceName}" is not part of this tunnel, so there is nothing to replay to.`}function ac(e,t,n=[]){let r=ic(e,t);if(r!==null)return{replay:r,editAndReplay:r};if(ms(t))return{replay:Ks(n),editAndReplay:null};let{request:i}=t;if(!i.bodyTruncated)return{replay:null,editAndReplay:null};if(zs(i.bodyBase64,!0).kind===`binary`){let e=`The stored body is binary and was truncated, so this request cannot be replayed.`;return{replay:e,editAndReplay:e}}return{replay:`The stored body was truncated. Use Edit & Replay to supply the body.`,editAndReplay:null}}function oc(e,t){return e===null?null:e.watching?e.replayTarget:e.services.find(e=>e.name===t.serviceName)?.target??null}function sc(e){return e.replayTarget===null?e.watching?{text:`none: start hopwire watch with --replay-target <url>`,missing:!0}:e.services.length>1?{text:`the local target of each service`,missing:!1}:{text:`none`,missing:!0}:{text:e.replayTarget,missing:!1}}var cc=2e3;function lc(e){return e.flatMap(({origin:e,block:t})=>t.entries.map(n=>({key:`${e}:${t.serviceName}:${t.source}:${t.seq}:${n.readAt}:${n.length}:${n.text.slice(0,200)}`,origin:e,serviceName:t.serviceName,source:t.source,entry:n,level:gs(n.text)})))}function uc(e,t,n=cc){let r=new Map(e.map(e=>[e.key,e])),i=!1;for(let e of t)r.has(e.key)||(r.set(e.key,e),i=!0);if(!i)return e;let a=[...r.values()].sort((e,t)=>e.entry.readAt-t.entry.readAt);return a.length>n?a.slice(a.length-n):a}function dc(e){return e.reduce((e,{block:t})=>({entries:e.entries+(t.omitted?.entries??0),bytes:e.bytes+(t.omitted?.bytes??0)}),{entries:0,bytes:0})}function fc(e,t,n){return e.filter(e=>e.origin===t&&e.entry.exchangeIds.includes(n))}function pc(e,t){let n=t.text.trim().toLowerCase();return e.filter(e=>(t.source===``||e.source===t.source)&&(t.level===``||e.level===t.level)&&(n===``||e.entry.text.toLowerCase().includes(n)))}var mc=/^\s*(#\d+\s|at\s)/,hc=/[/\\](vendor|node_modules|site-packages)[/\\]/;function gc(e){return e.split(`
|
|
4
4
|
`).map(e=>({text:e,appFrame:mc.test(e)&&!hc.test(e)}))}var _c={error:`Error`,warning:`Warning`,info:`Info`,debug:`Debug`},vc={class:`space-y-2`,"aria-live":`polite`},yc=[`onClick`],bc={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted`},xc={class:`font-mono text-tag-fg`},Sc={class:`tabular-nums`},Cc={key:1,class:`rounded-full bg-info-bg px-2 py-0.5 text-info-fg`},wc={key:2,class:`text-warn-fg`},Tc={key:3,class:`text-warn-fg`},Ec={key:4},Dc={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Oc={class:`mt-2 max-h-80 overflow-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap text-muted`},kc=z({__name:`LogEntryList`,props:{items:{},exchangeId:{default:null},selectable:{type:Boolean,default:!1}},emits:[`select`],setup(e,{emit:t}){let n=t,r={error:`bg-err-bg text-err-fg`,warning:`bg-warn-bg text-warn-fg`,info:`bg-info-bg text-info-fg`,debug:`bg-tag-bg text-tag-fg`};function i(e,t){return e.entry.exchangeIds.filter(e=>e!==t).length}return(t,a)=>(W(),G(`ol`,vc,[(W(!0),G(U,null,B(e.items,t=>(W(),G(`li`,{key:t.key,class:E([`rounded-sm border border-hairline bg-surface p-3`,e.selectable&&t.entry.exchangeIds.length>0?`cursor-pointer hover:border-line-strong`:``]),onClick:r=>e.selectable&&t.entry.exchangeIds.length>0&&n(`select`,t)},[q(`div`,bc,[t.level?(W(),G(`span`,{key:0,class:E([`rounded-sm px-1.5 py-0.5 font-medium`,r[t.level]])},D(P(_c)[t.level]),3)):X(``,!0),q(`span`,xc,D(t.source),1),q(`span`,Sc,D(P(Ms)(t.entry.readAt)),1),t.origin===`remote`?(W(),G(`span`,Cc,` watching `)):X(``,!0),t.entry.ambiguous&&e.exchangeId!==null?(W(),G(`span`,wc,` also linked to `+D(i(t,e.exchangeId))+` other `+D(i(t,e.exchangeId)===1?`request`:`requests`),1)):t.entry.ambiguous?(W(),G(`span`,Tc,` logged while `+D(t.entry.exchangeIds.length)+` requests were in flight `,1)):e.selectable&&t.entry.exchangeIds.length===0?(W(),G(`span`,Ec,`not linked to a request`)):X(``,!0)]),t.entry.truncated?(W(),G(`p`,Dc,` Truncated: the log keeps the first `+D(P(As)(16384))+` of this entry of `+D(P(As)(t.entry.length))+`. `,1)):X(``,!0),q(`pre`,Oc,[(W(!0),G(U,null,B(P(gc)(t.entry.text),(e,t)=>(W(),G(`span`,{key:t,class:E(e.appFrame||t===0?`text-ink`:``)},D(e.text)+D(`
|
|
5
|
-
`),3))),128))])],10,yc))),128))]))}}),Ac={class:`space-y-6`},jc={key:0,class:`mt-2 text-sm text-muted`},Mc={key:1,class:`mt-2 w-full table-fixed border-collapse text-left font-mono text-xs`},Nc={scope:`row`,class:`w-2/5 py-1.5 pr-3 font-normal break-words text-muted`},Pc={class:`py-1.5 break-all text-ink`},Fc={class:`flex items-center gap-3`},Ic={key:0,class:`text-xs text-muted`},Lc={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Rc={key:1,class:`mt-2 text-sm text-muted`},zc={key:2,class:`mt-2 text-sm text-muted`},Bc={key:3,class:`mt-2 max-h-[60vh] overflow-auto rounded-sm border border-hairline bg-surface p-3 font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Vc=z({__name:`MessageView`,props:{headers:{},bodyBase64:{},bodyTruncated:{type:Boolean}},setup(e){let t=e,n=Q(()=>zs(t.bodyBase64,t.bodyTruncated)),r=Q(()=>n.value.kind===`json`?n.value.formatted:n.value.kind===`text`?n.value.text:null),i=Q(()=>{switch(n.value.kind){case`empty`:return``;case`json`:return`JSON, ${As(n.value.bytes)}`;case`text`:return`Text, ${As(n.value.bytes)}`;case`binary`:return`Binary, ${As(n.value.bytes)}`}return``});return(t,a)=>(W(),G(`div`,Ac,[q(`section`,null,[a[1]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),e.headers.length===0?(W(),G(`p`,jc,`No headers.`)):(W(),G(`table`,Mc,[a[0]||=q(`thead`,{class:`sr-only`},[q(`tr`,null,[q(`th`,{scope:`col`},`Name`),q(`th`,{scope:`col`},`Value`)])],-1),q(`tbody`,null,[(W(!0),G(U,null,B(e.headers,(e,t)=>(W(),G(`tr`,{key:t,class:`border-b border-hairline align-top`},[q(`th`,Nc,D(e[0]),1),q(`td`,Pc,D(e[1]),1)]))),128))])]))]),q(`section`,null,[q(`div`,Fc,[a[2]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Body`,-1),i.value?(W(),G(`span`,Ic,D(i.value),1)):X(``,!0),r.value===null?X(``,!0):(W(),K(rs,{key:1,class:`ml-auto`,text:r.value,label:`Copy body`},null,8,[`text`]))]),e.bodyTruncated?(W(),G(`p`,Lc,` Truncated: the log keeps only the first `+D(P(As)(n.value.kind===`empty`?0:n.value.bytes))+` of this body. The full body was forwarded. `,1)):X(``,!0),n.value.kind===`empty`?(W(),G(`p`,Rc,`No body.`)):n.value.kind===`binary`?(W(),G(`p`,zc,D(P(js)(n.value.bytes,e.bodyTruncated)),1)):(W(),G(`pre`,Bc,D(r.value),1))])]))}}),Hc={class:`inline-flex shrink-0 rounded-sm bg-tag-bg px-1.5 py-0.5 font-mono text-xs font-medium text-tag-fg`},Uc=z({__name:`MethodBadge`,props:{method:{}},setup(e){return(t,n)=>(W(),G(`span`,Hc,D(e.method),1))}}),Wc=[`viewBox`],Gc=[`stroke-width`],Kc=[`d`],qc=z({__name:`MarkLoader`,setup(e){return(e,t)=>(W(),G(`svg`,{viewBox:P(Po),"aria-hidden":`true`,focusable:`false`,class:`block w-auto shrink-0`},[q(`g`,{class:`stroke-current`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(e,t)=>(W(),G(`path`,{key:t,d:e,pathLength:`1`,class:E(`hwl hwl-${t+1}`)},null,10,Kc))),128))],8,Gc)],8,Wc))}}),Jc=[`type`,`disabled`,`aria-busy`],$=z({__name:`UiButton`,props:{variant:{default:`secondary`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){let t={primary:`border border-transparent bg-hop-green text-on-green hover:bg-ink hover:text-ground disabled:hover:bg-hop-green disabled:hover:text-on-green`,secondary:`border border-line-strong text-ink hover:border-ink disabled:hover:border-line-strong`,quiet:`border border-transparent text-muted hover:bg-ink/8 hover:text-ink disabled:hover:bg-transparent disabled:hover:text-muted`};return(n,r)=>(W(),G(`button`,{type:e.type,disabled:e.disabled||e.loading,"aria-busy":e.loading?`true`:void 0,class:E([`inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors duration-150 ease-out disabled:cursor-not-allowed disabled:opacity-60`,t[e.variant]])},[e.loading?(W(),K(qc,{key:0,class:`h-4`})):X(``,!0),Cr(n.$slots,`default`)],10,Jc))}}),Yc={class:`flex gap-3`},Xc={class:`w-32 shrink-0`},Zc=[`value`],Qc={class:`min-w-0 flex-1`},$c={class:`mt-1.5 space-y-1.5`},el=[`onUpdate:modelValue`,`aria-label`],tl=[`onUpdate:modelValue`,`aria-label`],nl={class:`mt-2 flex items-center gap-3`},rl={class:`flex items-center gap-3`},il={key:0,class:`mt-1.5 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},al={key:2,class:`mt-1.5 text-sm text-muted`},ol={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},sl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},cl={class:`flex items-center gap-3`},ll={key:0,class:`truncate text-xs text-muted`},ul={class:`font-mono`},dl=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,fl=z({__name:`ReplayEditor`,props:{exchange:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(tc(n.exchange)),a=N(null),o=Q(()=>{let e=n.exchange.request.method.toUpperCase();return $s.includes(e)?[...$s]:[...$s,e]}),s=Q(()=>i.bodyEditable&&Rs(i.body)!==null);function c(){i.body=Rs(i.body)??i.body}function l(){i.headers.push({name:``,value:``})}function u(e){i.headers.splice(e,1)}function d(){a.value=nc(i,n.exchange),a.value===null&&r(`send`,rc(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,Yc,[q(`div`,Xc,[n[4]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-method`},` Method `,-1),R(q(`select`,{id:`replay-method`,"onUpdate:modelValue":n[0]||=e=>i.method=e,class:E([`mt-1.5`,dl])},[(W(!0),G(U,null,B(o.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Zc))),128))],512),[[bo,i.method]])]),q(`div`,Qc,[n[5]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-path`},`Path`,-1),R(q(`input`,{id:`replay-path`,"onUpdate:modelValue":n[1]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,dl])},null,512),[[vo,i.path]])])]),q(`fieldset`,null,[n[9]||=q(`legend`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),q(`ul`,$c,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,dl])},null,8,el),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,dl])},null,8,tl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>u(t)},{default:L(()=>[...n[6]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,nl,[J($,{onClick:l},{default:L(()=>[...n[7]||=[Y(`Add header`,-1)]]),_:1}),n[8]||=q(`span`,{class:`text-xs text-muted`},`Content-Length is set to match the body.`,-1)])]),q(`div`,null,[q(`div`,rl,[n[11]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-body`},`Body`,-1),s.value?(W(),K($,{key:0,class:`ml-auto`,variant:`quiet`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Format JSON`,-1)]]),_:1})):X(``,!0)]),e.exchange.request.bodyTruncated&&i.bodyEditable?(W(),G(`p`,il,` The log holds only the first part of this body. What you send is exactly the text below. `)):X(``,!0),i.bodyEditable?R((W(),G(`textarea`,{key:1,id:`replay-body`,"onUpdate:modelValue":n[2]||=e=>i.body=e,rows:`12`,spellcheck:`false`,class:E([`mt-1.5 leading-5`,dl])},null,512)),[[vo,i.body]]):(W(),G(`p`,al,` The body is binary and cannot be edited here. It is sent as captured. `))]),q(`div`,ol,[a.value||e.error?(W(),G(`p`,sl,D(a.value??e.error),1)):X(``,!0),q(`div`,cl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[12]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,ll,[n[13]||=Y(` Goes to `,-1),q(`span`,ul,D(e.target),1)])):X(``,!0)])])],32))}}),pl=z({__name:`StatusBadge`,props:{status:{}},setup(e){let t=e,n=Q(()=>Es[Ts(t.status)]);return(t,r)=>(W(),G(`span`,{class:E([`inline-flex shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-xs font-medium tabular-nums`,n.value])},D(e.status),3))}}),ml={class:`space-y-3`,"aria-label":`WebSocket messages`},hl={class:`flex gap-2`},gl=[`value`],_l={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},vl={key:1,class:`text-sm text-muted`},yl={key:2,class:`text-sm text-muted`},bl={key:3,class:`text-sm text-muted`},xl={class:`space-y-2`,"aria-live":`polite`},Sl=[`aria-label`],Cl={class:`flex items-center gap-3 text-xs text-muted`},wl={class:`tabular-nums`},Tl={class:`tabular-nums`},El={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Dl={class:`mt-2 max-h-80 overflow-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Ol={key:4,class:`space-y-1 rounded-sm border border-hairline px-3 py-2 text-sm text-muted`,"aria-label":`Close of the WebSocket`},kl={key:0,class:`text-warn-fg`},Al={key:5,class:`text-xs text-muted`},jl=z({__name:`WsMessages`,props:{blocks:{},failure:{}},setup(e){let t=e,n=N(``),r=N(``),i=Q(()=>Hs(t.blocks??[])),a=Q(()=>Ws(i.value.messages,{text:n.value,direction:r.value}).map(e=>({message:e,view:Us(e)}))),o=Q(()=>n.value.trim()!==``||r.value!==``),s=Q(()=>{let e=i.value.close;if(e===null)return``;let t=e.reason===``?``:` and reason "${e.reason}"`;return`Closed by ${Gs(e.by)} with code ${e.code}${t}.`}),c=[{value:``,label:`Both directions`},{value:`in`,label:`Client to service`},{value:`out`,label:`Service to client`}];return(t,l)=>(W(),G(`section`,ml,[q(`div`,hl,[l[2]||=q(`label`,{class:`sr-only`,for:`ws-filter`},`Filter messages`,-1),R(q(`input`,{id:`ws-filter`,"onUpdate:modelValue":l[0]||=e=>n.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,n.value]]),l[3]||=q(`label`,{class:`sr-only`,for:`ws-direction`},`Filter by direction`,-1),R(q(`select`,{id:`ws-direction`,"onUpdate:modelValue":l[1]||=e=>r.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[(W(),G(U,null,B(c,e=>q(`option`,{key:e.value,value:e.value},D(e.label),9,gl)),64))],512),[[bo,r.value]])]),e.failure?(W(),G(`p`,_l,D(e.failure),1)):e.blocks===null?(W(),G(`p`,vl,`Loading messages.`)):i.value.messages.length===0&&i.value.close===null?(W(),G(`p`,yl,` No messages yet. New ones appear here as they pass. `)):a.value.length===0&&o.value?(W(),G(`p`,bl,`No message matches the filter.`)):X(``,!0),q(`ol`,xl,[(W(!0),G(U,null,B(a.value,({message:e,view:t})=>(W(),G(`li`,{key:e.position,class:`rounded-sm border border-hairline bg-surface p-3`,"aria-label":`Message ${e.position+1}, ${e.direction===`in`?`client to service`:`service to client`}`},[q(`div`,Cl,[q(`span`,{class:E([`font-mono font-medium`,e.direction===`in`?`text-cyan-text`:`text-green-text`]),"aria-hidden":`true`},D(e.direction===`in`?`Client → service`:`Service → client`),3),q(`span`,wl,`+`+D(e.atMs)+` ms`,1),q(`span`,Tl,D(P(As)(e.length)),1),q(`span`,null,D(t.kind===`json`?`JSON`:t.kind===`text`?`Text`:`Binary`),1),t.kind===`binary`?(W(),K(rs,{key:0,class:`ml-auto`,text:e.dataBase64,label:`Copy message as Base64`},null,8,[`text`])):(W(),K(rs,{key:1,class:`ml-auto`,text:t.kind===`json`?t.formatted:t.text,label:`Copy message`},null,8,[`text`]))]),e.truncated?(W(),G(`p`,El,` Truncated: the log keeps the first `+D(P(As)(65536))+` of this message of `+D(P(As)(e.length))+`. The full message was carried. `,1)):X(``,!0),q(`pre`,Dl,D(t.kind===`json`?t.formatted:t.kind===`text`?t.text:`${t.hex}${t.more?` ...`:``}`),1)],8,Sl))),128))]),i.value.close?(W(),G(`div`,Ol,[q(`p`,null,D(s.value),1),i.value.close.omittedMessages>0?(W(),G(`p`,kl,D(i.value.close.omittedMessages)+` `+D(i.value.close.omittedMessages===1?`message was`:`messages were`)+` not captured: the log keeps up to 2 MB or 10,000 messages per WebSocket. Every message was carried in full. `,1)):X(``,!0)])):e.blocks===null?X(``,!0):(W(),G(`p`,Al,`Open. New messages appear here as they pass.`))]))}}),Ml={class:`mt-1.5 space-y-1.5`},Nl=[`onUpdate:modelValue`,`aria-label`],Pl=[`onUpdate:modelValue`,`aria-label`],Fl={class:`mt-2 flex items-center gap-3`},Il={key:0,class:`mt-1.5 text-sm text-muted`},Ll={class:`mt-1.5 space-y-2`},Rl={class:`flex items-center gap-2 text-xs text-muted`},zl={class:`font-medium text-ink`},Bl={key:0,class:`tabular-nums`},Vl={key:1},Hl={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Ul={key:1,class:`mt-2 text-sm text-muted`},Wl=[`onUpdate:modelValue`,`aria-label`],Gl={class:`mt-1.5 space-y-1.5 text-sm text-ink`},Kl={class:`flex items-center gap-2`},ql={class:`flex items-center gap-2`},Jl={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},Yl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Xl={class:`flex items-center gap-3`},Zl={key:0,class:`truncate text-xs text-muted`},Ql={class:`font-mono`},$l=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,eu=`text-xs font-medium tracking-wider text-muted uppercase`,tu=z({__name:`WsReplayEditor`,props:{exchange:{},messages:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(Ys(n.exchange.request.path,n.exchange.request.headers,n.messages)),a=N(null);function o(){i.headers.push({name:``,value:``})}function s(e){i.headers.splice(e,1)}function c(){i.messages.push(Js())}function l(e){i.messages.splice(e,1)}function u(e,t){let[n]=i.messages.splice(e,1);n!==void 0&&i.messages.splice(e+t,0,n)}function d(){a.value=Zs(i),a.value===null&&r(`send`,Qs(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay the WebSocket`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,null,[q(`label`,{class:E(eu),for:`ws-replay-path`},`Path`),R(q(`input`,{id:`ws-replay-path`,"onUpdate:modelValue":n[0]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,$l])},null,512),[[vo,i.path]])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Headers`),q(`ul`,Ml,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,$l])},null,8,Nl),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,$l])},null,8,Pl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>s(t)},{default:L(()=>[...n[4]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,Fl,[J($,{onClick:o},{default:L(()=>[...n[5]||=[Y(`Add header`,-1)]]),_:1}),n[6]||=q(`span`,{class:`text-xs text-muted`},`The handshake headers of the WebSocket are made anew.`,-1)])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Messages from the client`),i.messages.length===0?(W(),G(`p`,Il,` No messages. The WebSocket opens, waits 5 s for the service and closes. `)):X(``,!0),q(`ol`,Ll,[(W(!0),G(U,null,B(i.messages,(e,t)=>(W(),G(`li`,{key:e.key,class:`rounded-sm border border-hairline bg-surface p-3`},[q(`div`,Rl,[q(`span`,zl,D(t+1),1),q(`span`,null,D(e.binary?`Binary`:`Text`),1),e.atMs===void 0?(W(),G(`span`,Vl,`Added`)):(W(),G(`span`,Bl,`+`+D(e.atMs)+` ms`,1)),J($,{class:`ml-auto`,variant:`quiet`,disabled:t===0,"aria-label":`Move message ${t+1} up`,onClick:e=>u(t,-1)},{default:L(()=>[...n[7]||=[Y(` Up `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,disabled:t===i.messages.length-1,"aria-label":`Move message ${t+1} down`,onClick:e=>u(t,1)},{default:L(()=>[...n[8]||=[Y(` Down `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,"aria-label":`Remove message ${t+1}`,onClick:e=>l(t)},{default:L(()=>[...n[9]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]),e.truncated?(W(),G(`p`,Hl,[e.binary?(W(),G(U,{key:0},[Y(` Captured only in part (`+D(P(As)(e.length))+` in full), so it cannot be sent. Remove it to replay the rest. `,1)],64)):(W(),G(U,{key:1},[Y(` The log holds only the first part of this message. What you send is exactly the text below. `)],64))])):X(``,!0),e.binary&&!e.truncated?(W(),G(`p`,Ul,` Binary, `+D(P(As)(e.length))+`. It cannot be edited here and is sent as captured. `,1)):e.binary?X(``,!0):R((W(),G(`textarea`,{key:2,"onUpdate:modelValue":t=>e.text=t,rows:`3`,spellcheck:`false`,class:E([`mt-2 leading-5`,$l]),"aria-label":`Text of message ${t+1}`},null,8,Wl)),[[vo,e.text]])]))),128))]),J($,{class:`mt-2`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Add text message`,-1)]]),_:1})]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Timing`),q(`div`,Gl,[q(`label`,Kl,[R(q(`input`,{"onUpdate:modelValue":n[1]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`recorded`},null,512),[[yo,i.timing]]),n[11]||=Y(` As recorded: the gaps between the messages, each at most 5 s `,-1)]),q(`label`,ql,[R(q(`input`,{"onUpdate:modelValue":n[2]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`fast`},null,512),[[yo,i.timing]]),n[12]||=Y(` Fast: one message after the other `,-1)])]),n[13]||=q(`p`,{class:`mt-1.5 text-xs text-muted`},` After the last message the WebSocket stays open 5 s for the answers, then it is closed with 1000. `,-1)]),q(`div`,Jl,[a.value||e.error?(W(),G(`p`,Yl,D(a.value??e.error),1)):X(``,!0),q(`div`,Xl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[14]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,Zl,[n[15]||=Y(` Goes to `,-1),q(`span`,Ql,D(e.target),1)])):X(``,!0)])])],32))}}),nu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Request details`},ru={class:`border-b border-hairline p-4`},iu={class:`flex items-start gap-2`},au={class:`min-w-0 flex-1 font-mono text-sm leading-5 font-normal break-all text-ink`},ou={class:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted`},su={class:`flex gap-1`},cu={class:`text-tag-fg tabular-nums`},lu={class:`flex gap-1`},uu={class:`text-tag-fg tabular-nums`},du={class:`flex gap-1`},fu={class:`text-tag-fg`},pu={class:`flex gap-1`},mu={class:`text-tag-fg`},hu={key:0,class:`flex gap-1`},gu={key:1,class:`flex gap-1`},_u={key:1,class:`font-mono text-tag-fg`},vu={key:0,class:`mt-3 flex flex-wrap items-center gap-2`},yu={key:0,class:`truncate text-xs text-muted`},bu={class:`font-mono`},xu={key:1,class:`mt-2 text-sm text-warn-fg`,role:`note`},Su={key:2,class:`mt-2 rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Cu={key:0,class:`min-h-0 flex-1 overflow-y-auto`},wu={class:`flex gap-1 border-b border-hairline px-4`,role:`tablist`,"aria-label":`Message`},Tu=[`id`,`aria-selected`,`onClick`],Eu=[`aria-labelledby`],Du=z({__name:`ExchangeDetail`,props:{record:{},status:{},originalLoaded:{type:Boolean},replay:{},wsBlocks:{default:null},wsFailure:{default:null},logs:{default:()=>[]}},emits:[`select`,`load-messages`,`load-logs`],setup(e,{emit:t}){let n=e,r=t,i=N(`request`),a=N(!1),o=N(!1),s=N(null),c=Q(()=>n.record.exchange),l=Q(()=>ms(c.value)),u=Q(()=>[`request`,`response`,...l.value?[`messages`]:[],...n.logs.length>0?[`logs`]:[]]),d=N(!1);function f(e){return e===`logs`?`Logs ${n.logs.length}`:e}function p(e){i.value=e,d.value=!0}let m=Q(()=>Hs(n.wsBlocks??[]).messages),h=Q(()=>oc(n.status,c.value)),g=Q(()=>{let e=ac(n.status,c.value,m.value);if(l.value&&n.wsBlocks===null&&e.replay===null){let t=`The messages of this WebSocket are still loading.`;return{replay:t,editAndReplay:e.editAndReplay??t}}return e}),_=Q(()=>g.value.replay);Vn(()=>[c.value.id,n.record.origin],()=>{a.value=!1,s.value=null,d.value=!1,u.value.includes(i.value)||(i.value=`request`),l.value&&r(`load-messages`,n.record),r(`load-logs`,n.record)},{immediate:!0}),Vn(()=>[c.value.id,n.logs.length>0],([,e])=>{e&&!d.value&&c.value.response.status>=500?i.value=`logs`:!e&&i.value===`logs`&&(i.value=`request`)},{immediate:!0});async function v(e){o.value=!0,s.value=null;try{let t=await n.replay(n.record,e);a.value=!1,i.value=l.value&&ms(t)?`messages`:`response`,r(`select`,t.id)}catch(e){s.value=e instanceof _s?e.message:`The replay could not be sent.`}finally{o.value=!1}}function y(){s.value=null,a.value=!0}return(t,n)=>(W(),G(`article`,nu,[q(`header`,ru,[q(`div`,iu,[J(Uc,{method:c.value.request.method},null,8,[`method`]),q(`h2`,au,D(c.value.request.path),1),J(pl,{status:c.value.response.status},null,8,[`status`])]),q(`dl`,ou,[q(`div`,su,[n[4]||=q(`dt`,null,`Time`,-1),q(`dd`,cu,D(P(Ms)(c.value.timestamp)),1)]),q(`div`,lu,[n[5]||=q(`dt`,null,`Duration`,-1),q(`dd`,uu,D(P(ks)(c.value.response.durationMs)),1)]),q(`div`,du,[n[6]||=q(`dt`,null,`Source`,-1),q(`dd`,fu,D(P(Os)(c.value.source)),1)]),q(`div`,pu,[n[7]||=q(`dt`,null,`Service`,-1),q(`dd`,mu,D(c.value.serviceName),1)]),e.record.origin===`remote`?(W(),G(`div`,hu,[...n[8]||=[q(`dt`,null,`Origin`,-1),q(`dd`,{class:`text-tag-fg`},`remote log`,-1)]])):X(``,!0),c.value.replayOf?(W(),G(`div`,gu,[n[9]||=q(`dt`,null,`Replay of`,-1),q(`dd`,null,[e.originalLoaded?(W(),G(`button`,{key:0,type:`button`,class:`cursor-pointer rounded-sm font-mono text-ink underline decoration-line-strong underline-offset-2 transition-colors duration-150 ease-out hover:decoration-ink`,onClick:n[0]||=e=>r(`select`,c.value.replayOf)},D(c.value.replayOf.slice(0,8)),1)):(W(),G(`span`,_u,D(c.value.replayOf.slice(0,8)),1))])])):X(``,!0)]),a.value?X(``,!0):(W(),G(`div`,vu,[J($,{variant:`primary`,loading:o.value,disabled:_.value!==null,onClick:n[1]||=e=>v()},{default:L(()=>[Y(D(o.value?`Sending`:`Replay`),1)]),_:1},8,[`loading`,`disabled`]),J($,{disabled:o.value||g.value.editAndReplay!==null,onClick:y},{default:L(()=>[...n[10]||=[Y(` Edit & Replay `,-1)]]),_:1},8,[`disabled`]),h.value&&_.value===null?(W(),G(`span`,yu,[n[11]||=Y(` Goes to `,-1),q(`span`,bu,D(h.value),1)])):X(``,!0)])),!a.value&&_.value?(W(),G(`p`,xu,D(_.value),1)):X(``,!0),!a.value&&s.value?(W(),G(`p`,Su,D(s.value),1)):X(``,!0)]),a.value?(W(),G(`div`,Cu,[l.value?(W(),K(tu,{key:`ws-${c.value.id}`,exchange:c.value,messages:m.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[2]||=e=>a.value=!1},null,8,[`exchange`,`messages`,`target`,`sending`,`error`])):(W(),K(fl,{key:c.value.id,exchange:c.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[3]||=e=>a.value=!1},null,8,[`exchange`,`target`,`sending`,`error`]))])):(W(),G(U,{key:1},[q(`div`,wu,[(W(!0),G(U,null,B(u.value,e=>(W(),G(`button`,{id:`tab-${e}`,key:e,type:`button`,role:`tab`,"aria-selected":i.value===e,"aria-controls":`message-panel`,class:E([`-mb-px cursor-pointer border-b-2 px-3 py-2 text-sm font-medium capitalize transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,i.value===e?`border-ink text-ink`:`border-transparent text-muted hover:text-ink`]),onClick:t=>p(e)},D(f(e)),11,Tu))),128))]),q(`div`,{id:`message-panel`,class:`min-h-0 flex-1 overflow-y-auto p-4`,role:`tabpanel`,"aria-labelledby":`tab-${i.value}`},[i.value===`request`?(W(),K(Vc,{key:0,headers:c.value.request.headers,"body-base64":c.value.request.bodyBase64,"body-truncated":c.value.request.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`])):i.value===`messages`?(W(),K(jl,{key:1,blocks:e.wsBlocks,failure:e.wsFailure},null,8,[`blocks`,`failure`])):i.value===`logs`?(W(),K(kc,{key:2,items:e.logs,"exchange-id":c.value.id},null,8,[`items`,`exchange-id`])):(W(),K(Vc,{key:3,headers:c.value.response.headers,"body-base64":c.value.response.bodyBase64,"body-truncated":c.value.response.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`]))],8,Eu)],64))]))}});function Ou(e){return`${e.origin}:${e.index}`}function ku(e,t){let n=new Map;for(let t of e)n.set(Ou(t),t);for(let e of t)n.set(Ou(e),e);return[...n.values()].sort((e,t)=>t.exchange.timestamp-e.exchange.timestamp||t.index-e.index)}function Au(e,t){let n=t.text.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(({exchange:e})=>{if(t.service!==``&&e.serviceName!==t.service)return!1;let r=`${e.request.method} ${e.request.path} ${e.response.status} ${e.serviceName} ${e.source}${ms(e)?` ws`:``}`.toLowerCase();return n.every(e=>r.includes(e))})}function ju(e,t){return[...new Set([...t,...e.map(e=>e.exchange.serviceName)])].sort()}function Mu(e){return e?[`remote`,`own`]:[`own`]}function Nu(e,t){return e.reduce((e,n)=>n.origin===t&&(e===null||n.index<e)?n.index:e,null)}function Pu(e){let t=[];for(let n of[`remote`,`own`]){let r=Nu(e,n);r!==null&&r>0&&t.push({origin:n,before:r})}return t}var Fu={class:`flex h-full min-h-0 flex-col`},Iu={class:`flex gap-2 border-b border-hairline p-2`},Lu=[`value`],Ru={key:0,class:`p-4 text-sm text-muted`},zu={class:`min-h-0 flex-1 overflow-y-auto`,"aria-label":`Requests, newest first`},Bu=[`aria-current`,`onClick`],Vu={class:`flex items-center gap-2`},Hu=[`title`],Uu={class:`mt-1 flex items-center gap-2 text-xs text-muted`},Wu={class:`tabular-nums`},Gu={class:`tabular-nums`},Ku={key:0,class:`rounded-sm bg-tag-bg px-1.5 py-px font-medium text-tag-fg`,title:`WebSocket handshake; its messages are in the Messages tab`},qu={key:1,class:`rounded-sm bg-info-bg px-1.5 py-px font-medium text-info-fg`},Ju={key:2,class:`truncate`},Yu={key:0,class:`p-2 text-center`},Xu=z({__name:`ExchangeList`,props:{records:{},services:{},selectedKey:{},hasOlder:{type:Boolean},loadingOlder:{type:Boolean}},emits:[`select`,`load-older`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=Q(()=>n.services.length>1),s=Q(()=>Au(n.records,{text:i.value,service:a.value})),c=Q(()=>i.value.trim()!==``||a.value!==``);return(t,n)=>(W(),G(`div`,Fu,[q(`div`,Iu,[n[5]||=q(`label`,{class:`sr-only`,for:`traffic-filter`},`Filter requests`,-1),R(q(`input`,{id:`traffic-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by method, path or status`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),o.value?(W(),G(U,{key:0},[n[4]||=q(`label`,{class:`sr-only`,for:`traffic-service`},`Filter by service`,-1),R(q(`select`,{id:`traffic-service`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[3]||=q(`option`,{value:``},`All services`,-1),(W(!0),G(U,null,B(e.services,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Lu))),128))],512),[[bo,a.value]])],64)):X(``,!0)]),s.value.length===0?(W(),G(`p`,Ru,D(c.value?`No request matches the filter.`:`No requests yet.`),1)):X(``,!0),q(`ul`,zu,[(W(!0),G(U,null,B(s.value,t=>(W(),G(`li`,{key:P(Ou)(t)},[q(`button`,{type:`button`,class:E([`block w-full cursor-pointer border-b border-l-2 border-b-hairline px-3 py-2 text-left transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,P(Ou)(t)===e.selectedKey?`border-l-ink bg-surface`:`border-l-transparent hover:bg-surface/60`]),"aria-current":P(Ou)(t)===e.selectedKey?`true`:void 0,onClick:e=>r(`select`,P(Ou)(t))},[q(`span`,Vu,[J(Uc,{method:t.exchange.request.method},null,8,[`method`]),q(`span`,{class:`min-w-0 flex-1 truncate font-mono text-sm text-ink`,title:t.exchange.request.path},D(t.exchange.request.path),9,Hu),J(pl,{status:t.exchange.response.status},null,8,[`status`])]),q(`span`,Uu,[q(`span`,Wu,D(P(Ms)(t.exchange.timestamp)),1),q(`span`,Gu,D(P(ks)(t.exchange.response.durationMs)),1),q(`span`,{class:E([`rounded-sm px-1.5 py-px font-medium`,t.exchange.source===`replay`?`bg-warn-bg text-warn-fg`:`bg-tag-bg text-tag-fg`])},D(P(Os)(t.exchange.source)),3),P(ms)(t.exchange)?(W(),G(`span`,Ku,` ws `)):X(``,!0),t.origin===`remote`?(W(),G(`span`,qu,` remote `)):X(``,!0),o.value?(W(),G(`span`,Ju,D(t.exchange.serviceName),1)):X(``,!0)])],10,Bu)]))),128)),e.hasOlder?(W(),G(`li`,Yu,[J($,{variant:`quiet`,loading:e.loadingOlder,onClick:n[2]||=e=>r(`load-older`)},{default:L(()=>[Y(D(e.loadingOlder?`Loading`:`Load older requests`),1)]),_:1},8,[`loading`])])):X(``,!0)])]))}}),Zu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Application logs`},Qu={class:`flex flex-wrap gap-2 border-b border-hairline px-4 py-2`},$u=[`value`],ed=[`value`],td={key:0,class:`rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},nd={key:1,class:`text-sm text-muted`},rd={key:2,class:`text-sm text-muted`},id=z({__name:`LogPane`,props:{items:{},omitted:{}},emits:[`select`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=N(``),s=Q(()=>[...new Set(n.items.map(e=>e.source))].sort()),c=Q(()=>pc(n.items,{text:i.value,source:a.value,level:o.value})),l=Q(()=>i.value.trim()!==``||a.value!==``||o.value!==``),u=[`error`,`warning`,`info`,`debug`],d=N(null),f=!0;function p(){let e=d.value;e!==null&&(f=e.scrollHeight-e.scrollTop-e.clientHeight<40)}async function m(){await Cn(),f&&d.value!==null&&(d.value.scrollTop=d.value.scrollHeight)}return pr(m),Vn(()=>c.value.length,m),(t,n)=>(W(),G(`section`,Zu,[q(`div`,Qu,[n[6]||=q(`label`,{class:`sr-only`,for:`log-filter`},`Filter log entries`,-1),R(q(`input`,{id:`log-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),n[7]||=q(`label`,{class:`sr-only`,for:`log-source`},`Filter by file`,-1),R(q(`select`,{id:`log-source`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[4]||=q(`option`,{value:``},`All files`,-1),(W(!0),G(U,null,B(s.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,$u))),128))],512),[[bo,a.value]]),n[8]||=q(`label`,{class:`sr-only`,for:`log-level`},`Filter by level`,-1),R(q(`select`,{id:`log-level`,"onUpdate:modelValue":n[2]||=e=>o.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[5]||=q(`option`,{value:``},`All levels`,-1),(W(),G(U,null,B(u,e=>q(`option`,{key:e,value:e},D(P(_c)[e]),9,ed)),64))],512),[[bo,o.value]])]),q(`div`,{ref_key:`scroller`,ref:d,class:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,onScroll:p},[e.omitted.entries>0?(W(),G(`p`,td,D(e.omitted.entries)+` `+D(e.omitted.entries===1?`entry was`:`entries were`)+` (`+D(P(As)(e.omitted.bytes))+`) not captured: a log file is captured up to 200 entries per second and 10 MB per run. `,1)):X(``,!0),e.items.length===0?(W(),G(`p`,nd,` No log entries yet. Start the tunnel with --log <path> (or logs: in hopwire.yaml) and new entries of the file appear here as they are written. `)):c.value.length===0&&l.value?(W(),G(`p`,rd,`No entry matches the filter.`)):X(``,!0),J(kc,{items:c.value,selectable:``,onSelect:n[3]||=e=>r(`select`,e)},null,8,[`items`])],544)]))}}),ad=`hopwire-inspector-theme`;function od(){try{return localStorage.getItem(ad)===`light`?`light`:`dark`}catch{return`dark`}}var sd=N(od());Vn(sd,e=>{document.documentElement.classList.toggle(`dark`,e===`dark`);try{localStorage.setItem(ad,e)}catch{}},{immediate:!0});function cd(){function e(){sd.value=sd.value===`dark`?`light`:`dark`}return{theme:sd,toggleTheme:e}}var ld=[`viewBox`],ud=[`stroke-width`],dd=[`d`,`pathLength`],fd=[`d`],pd=z({__name:`BrandLogo`,props:{animated:{type:Boolean,default:!1}},setup(e){return(t,n)=>(W(),G(`svg`,{viewBox:P(No),role:`img`,"aria-label":`Hopwire`,class:`block w-auto`},[q(`g`,{class:`stroke-mark`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(t,n)=>(W(),G(`path`,{key:n,d:t,pathLength:e.animated?1:void 0,class:E(e.animated?`hwd-s hwd-s${n+1}`:void 0)},null,10,dd))),128))],8,ud),q(`g`,{class:E(e.animated?`hwd-w`:void 0)},[q(`path`,{class:`fill-ink`,d:P(Lo)},null,8,fd)],2)],8,ld))}}),md={class:`flex flex-wrap items-center gap-x-5 gap-y-2 border-b border-hairline bg-surface px-4 py-2.5 text-sm`},hd={class:`flex items-center gap-2.5 font-normal`},gd={key:0,class:`inline-flex items-center gap-1.5 rounded-full bg-tag-bg px-2 py-0.5 text-xs font-medium text-tag-fg`},_d={key:1,class:`rounded-full bg-info-bg px-2 py-0.5 text-xs font-medium text-info-fg`},vd={key:2,class:`order-last flex w-full min-w-0 flex-wrap items-center gap-x-5 gap-y-1 lg:order-none lg:w-auto lg:flex-1`},yd={class:`truncate font-mono text-xs text-ink`},bd={key:0,class:`flex items-center gap-1.5`},xd=[`title`],Sd={class:`flex items-center gap-1.5`},Cd=[`title`],wd={class:`flex min-w-0 items-center gap-1.5`},Td={key:0,class:`truncate font-mono text-xs text-ink`},Ed={class:`ml-auto flex items-center gap-3`},Dd={class:`flex items-center gap-1.5 text-xs text-tag-fg`,role:`status`},Od=z({__name:`StatusBar`,props:{status:{},stream:{},logCount:{default:0},logsOpen:{type:Boolean,default:!1}},emits:[`toggle-logs`],setup(e,{emit:t}){let n=e,r=t,{theme:i,toggleTheme:a}=cd(),o=Q(()=>n.status===null?null:sc(n.status));return(t,n)=>(W(),G(`header`,md,[q(`h1`,hd,[J(pd,{class:`h-6`}),n[1]||=q(`span`,{class:`text-muted`},`Inspector`,-1)]),e.status?(W(),G(`span`,gd,[q(`span`,{class:E([`size-2 rounded-full border-[1.5px]`,e.status.mode===`public`?`border-link-blue bg-link-blue`:`border-cyan-text bg-wire-cyan`]),"aria-hidden":`true`},null,2),Y(` `+D(e.status.mode===`public`?`Public mode`:`Private mode`),1)])):X(``,!0),e.status?.watching?(W(),G(`span`,_d,` Watching a shared log `)):X(``,!0),e.status?(W(),G(`dl`,vd,[(W(!0),G(U,null,B(e.status.publicUrls,e=>(W(),G(`div`,{key:e,class:`flex min-w-0 items-center gap-1.5`},[n[2]||=q(`dt`,{class:`text-muted`},`Public URL`,-1),q(`dd`,yd,D(e),1),J(rs,{text:e,label:`Copy public URL`},null,8,[`text`])]))),128)),e.status.peerKey?(W(),G(`div`,bd,[n[3]||=q(`dt`,{class:`text-muted`},`Peer key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.peerKey},D(P(Ns)(e.status.peerKey)),9,xd),J(rs,{text:e.status.peerKey,label:`Copy peer key`},null,8,[`text`])])):X(``,!0),q(`div`,Sd,[n[4]||=q(`dt`,{class:`text-muted`},`Log key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.logKey},D(P(Ns)(e.status.logKey)),9,Cd),J(rs,{text:e.status.logKey,label:`Copy log key`},null,8,[`text`])]),q(`div`,wd,[n[5]||=q(`dt`,{class:`text-muted`},`Replay target`,-1),e.status.replayTarget?(W(),G(`dd`,Td,D(e.status.replayTarget),1)):o.value?(W(),G(`dd`,{key:1,class:E([`text-xs`,o.value.missing?`text-warn-fg`:`text-tag-fg`])},D(o.value.text),3)):X(``,!0)])])):X(``,!0),q(`div`,Ed,[q(`span`,Dd,[P($o)(e.stream)?(W(),K(qc,{key:0,class:`h-3.5`})):(W(),G(`span`,{key:1,class:E([`size-2 rounded-full`,e.stream===`live`?`bg-hop-green`:`border-[1.5px] border-muted`]),"aria-hidden":`true`},null,2)),Y(` `+D(P(Zo)[e.stream]),1)]),e.logCount>0||e.logsOpen?(W(),K($,{key:0,variant:`quiet`,"aria-pressed":e.logsOpen,"aria-controls":`log-pane`,onClick:n[0]||=e=>r(`toggle-logs`)},{default:L(()=>[Y(D(e.logsOpen?`Hide logs`:`Logs ${e.logCount}`),1)]),_:1},8,[`aria-pressed`])):X(``,!0),J($,{variant:`quiet`,"aria-label":`Switch to ${P(i)===`dark`?`light`:`dark`} mode`,onClick:P(a)},{default:L(()=>[Y(D(P(i)===`dark`?`Light`:`Dark`),1)]),_:1},8,[`aria-label`,`onClick`])])]))}}),kd=100;function Ad(){let e=N(null),t=$t([]),n=N(`connecting`),r=N(!1),i=N(!1),a=N(null),o=null,s=!1,c=$t(new Map),l=$t(new Map),u=$t([]),d=N({entries:0,bytes:0});function f(e){u.value=uc(u.value,lc(e));let t=dc(e);t.entries>0&&(d.value={entries:d.value.entries+t.entries,bytes:d.value.bytes+t.bytes})}async function p(e){try{let t=await Cs({exchangeId:e.exchange.id,origin:e.origin});u.value=uc(u.value,lc(t.blocks))}catch{}}async function m(){try{let e=await Cs({limit:500});u.value=uc(u.value,lc(e.blocks))}catch{}}function h(e,t){let n=new Map(c.value);n.set(e,t),c.value=n}async function g(e){let t=Bs(e.origin,e.exchange.id);c.value.has(t)||h(t,[]);try{let n=await Ss(e.origin,e.exchange.id);if(h(t,Vs(c.value.get(t)??[],n)),l.value.has(t)){let e=new Map(l.value);e.delete(t),l.value=e}}catch(e){let n=new Map(l.value);n.set(t,e instanceof _s?e.message:`The messages could not be loaded.`),l.value=n}}let _=Q(()=>Pu(t.value).length>0),v=Q(()=>a.value??(n.value===`closed`?`The connection to the tunnel is closed. Reload the page to connect again.`:null)),y=Q(()=>!r.value&&v.value===null);async function b(){r.value||(a.value=null);try{let n=await bs(),i=(await Promise.all(Mu(n.watching).map(e=>xs({origin:e,limit:kd})))).flat(),o=e.value===null||e.value.logKey===n.logKey;e.value=n,t.value=ku(o?t.value:[],i),r.value=!0,a.value=null,o||(c.value=new Map,u.value=[],d.value={entries:0,bytes:0}),m();for(let e of c.value.keys()){let n=t.value.find(t=>Bs(t.origin,t.exchange.id)===e);n!==void 0&&g(n)}}catch(e){a.value=e instanceof _s?e.message:`The traffic could not be loaded.`}}function x(){let e=new EventSource(`${vs}stream`);o=e,e.addEventListener(`open`,()=>{s=!0,n.value=`live`,b()}),e.addEventListener(`exchange`,e=>{let n=JSON.parse(e.data);t.value=ku(t.value,[n])}),e.addEventListener(`ws_messages`,e=>{let{origin:t,block:n}=JSON.parse(e.data),r=Bs(t,n.exchangeId),i=c.value.get(r);i!==void 0&&h(r,Vs(i,[n]))}),e.addEventListener(`log_entries`,e=>{f([JSON.parse(e.data)])}),e.addEventListener(`error`,()=>{n.value=Qo(e.readyState===EventSource.CLOSED,s)})}function ee(){o?.close(),o=null,n.value=`closed`}async function S(){let e=Pu(t.value);if(!(e.length===0||i.value)){i.value=!0;try{let n=await Promise.all(e.map(e=>xs({...e,limit:kd})));t.value=ku(t.value,n.flat())}catch(e){a.value=e instanceof _s?e.message:`Older requests could not be loaded.`}finally{i.value=!1}}}async function C(e,n){let r=await ws(e,n);return t.value.some(e=>e.exchange.id===r.id)||await b(),r}return{status:e,records:t,stream:n,connecting:y,loaded:r,loadingOlder:i,problem:v,hasOlder:_,start:x,stop:ee,loadOlder:S,replay:C,wsSessions:c,wsFailures:l,loadWsMessages:g,logs:u,logsOmitted:d,loadExchangeLogs:p}}function jd(){let e=Ad();return gr(e.stop),e}var Md={class:`flex h-dvh flex-col bg-ground text-ink`},Nd={key:0,class:`border-b border-hairline bg-err-bg px-4 py-2 text-sm text-err-fg`,role:`alert`},Pd={class:`min-h-0 flex-1`},Fd={key:2,class:`flex h-full min-h-0 flex-col md:flex-row`},Id={class:`h-2/5 min-h-0 shrink-0 border-b border-hairline md:h-full md:w-2/5 md:max-w-xl md:min-w-80 md:border-r md:border-b-0`,"aria-label":`Traffic`},Ld={class:`min-h-0 min-w-0 flex-1`},Rd={key:1,class:`flex h-full items-center justify-center p-8 text-sm text-muted`},zd={key:1,id:`log-pane`,class:`h-2/5 min-h-0 shrink-0 border-t border-hairline`};Ao(z({__name:`App`,setup(e){let{status:t,records:n,stream:r,connecting:i,loaded:a,loadingOlder:o,problem:s,hasOlder:c,start:l,loadOlder:u,replay:d,wsSessions:f,wsFailures:p,loadWsMessages:m,logs:h,logsOmitted:g,loadExchangeLogs:_}=jd(),v=N(!1),y=N(null),b=Q(()=>n.value.find(e=>Ou(e)===y.value)??null);function x(e){let t=n.value.find(t=>t.exchange.id===e);y.value=t===void 0?null:Ou(t)}let ee=Q(()=>ju(n.value,(t.value?.services??[]).map(e=>e.name))),S=Q(()=>b.value===null?null:Bs(b.value.origin,b.value.exchange.id)),C=Q(()=>S.value===null?null:f.value.get(S.value)??null),te=Q(()=>S.value===null?null:p.value.get(S.value)??null),ne=Q(()=>b.value===null?[]:fc(h.value,b.value.origin,b.value.exchange.id));function re(e){let t=n.value.find(t=>t.origin===e.origin&&e.entry.exchangeIds.includes(t.exchange.id));t!==void 0&&(y.value=Ou(t))}let ie=Q(()=>{let e=b.value?.exchange.replayOf;return e!==void 0&&n.value.some(t=>t.exchange.id===e)});return pr(l),(e,l)=>(W(),G(`div`,Md,[J(Od,{status:P(t),stream:P(r),"log-count":P(h).length,"logs-open":v.value,onToggleLogs:l[0]||=e=>v.value=!v.value},null,8,[`status`,`stream`,`log-count`,`logs-open`]),P(s)?(W(),G(`p`,Nd,D(P(s)),1)):X(``,!0),q(`main`,Pd,[P(a)?P(n).length===0?(W(),K(ps,{key:1,status:P(t),stream:P(r)},null,8,[`status`,`stream`])):(W(),G(`div`,Fd,[q(`section`,Id,[J(Xu,{records:P(n),services:ee.value,"selected-key":y.value,"has-older":P(c),"loading-older":P(o),onSelect:l[1]||=e=>y.value=e,onLoadOlder:P(u)},null,8,[`records`,`services`,`selected-key`,`has-older`,`loading-older`,`onLoadOlder`])]),q(`section`,Ld,[b.value?(W(),K(Du,{key:0,record:b.value,status:P(t),"original-loaded":ie.value,replay:P(d),"ws-blocks":C.value,"ws-failure":te.value,logs:ne.value,onSelect:x,onLoadMessages:P(m),onLoadLogs:P(_)},null,8,[`record`,`status`,`original-loaded`,`replay`,`ws-blocks`,`ws-failure`,`logs`,`onLoadMessages`,`onLoadLogs`])):(W(),G(`div`,Rd,` Select a request to see its headers and body. `))])])):(W(),K(Xo,{key:0,connecting:P(i)},null,8,[`connecting`]))]),v.value?(W(),G(`div`,zd,[J(id,{items:P(h),omitted:P(g),onSelect:re},null,8,[`items`,`omitted`])])):X(``,!0)]))}})).mount(`#app`);
|
|
5
|
+
`),3))),128))])],10,yc))),128))]))}}),Ac={class:`space-y-6`},jc={key:0,class:`mt-2 text-sm text-muted`},Mc={key:1,class:`mt-2 w-full table-fixed border-collapse text-left font-mono text-xs`},Nc={scope:`row`,class:`w-2/5 py-1.5 pr-3 font-normal break-words text-muted`},Pc={class:`py-1.5 break-all text-ink`},Fc={class:`flex items-center gap-3`},Ic={key:0,class:`text-xs text-muted`},Lc={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Rc={key:1,class:`mt-2 text-sm text-muted`},zc={key:2,class:`mt-2 text-sm text-muted`},Bc={key:3,class:`mt-2 max-h-[60vh] overflow-auto rounded-sm border border-hairline bg-surface p-3 font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Vc=z({__name:`MessageView`,props:{headers:{},bodyBase64:{},bodyTruncated:{type:Boolean}},setup(e){let t=e,n=Q(()=>zs(t.bodyBase64,t.bodyTruncated)),r=Q(()=>n.value.kind===`json`?n.value.formatted:n.value.kind===`text`?n.value.text:null),i=Q(()=>{switch(n.value.kind){case`empty`:return``;case`json`:return`JSON, ${As(n.value.bytes)}`;case`text`:return`Text, ${As(n.value.bytes)}`;case`binary`:return`Binary, ${As(n.value.bytes)}`}return``});return(t,a)=>(W(),G(`div`,Ac,[q(`section`,null,[a[1]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),e.headers.length===0?(W(),G(`p`,jc,`No headers.`)):(W(),G(`table`,Mc,[a[0]||=q(`thead`,{class:`sr-only`},[q(`tr`,null,[q(`th`,{scope:`col`},`Name`),q(`th`,{scope:`col`},`Value`)])],-1),q(`tbody`,null,[(W(!0),G(U,null,B(e.headers,(e,t)=>(W(),G(`tr`,{key:t,class:`border-b border-hairline align-top`},[q(`th`,Nc,D(e[0]),1),q(`td`,Pc,D(e[1]),1)]))),128))])]))]),q(`section`,null,[q(`div`,Fc,[a[2]||=q(`h3`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Body`,-1),i.value?(W(),G(`span`,Ic,D(i.value),1)):X(``,!0),r.value===null?X(``,!0):(W(),K(rs,{key:1,class:`ml-auto`,text:r.value,label:`Copy body`},null,8,[`text`]))]),e.bodyTruncated?(W(),G(`p`,Lc,` Truncated: the log keeps only the first `+D(P(As)(n.value.kind===`empty`?0:n.value.bytes))+` of this body. The full body was forwarded. `,1)):X(``,!0),n.value.kind===`empty`?(W(),G(`p`,Rc,`No body.`)):n.value.kind===`binary`?(W(),G(`p`,zc,D(P(js)(n.value.bytes,e.bodyTruncated)),1)):(W(),G(`pre`,Bc,D(r.value),1))])]))}}),Hc={class:`inline-flex shrink-0 rounded-sm bg-tag-bg px-1.5 py-0.5 font-mono text-xs font-medium text-tag-fg`},Uc=z({__name:`MethodBadge`,props:{method:{}},setup(e){return(t,n)=>(W(),G(`span`,Hc,D(e.method),1))}}),Wc=[`viewBox`],Gc=[`stroke-width`],Kc=[`d`],qc=z({__name:`MarkLoader`,setup(e){return(e,t)=>(W(),G(`svg`,{viewBox:P(Po),"aria-hidden":`true`,focusable:`false`,class:`block w-auto shrink-0`},[q(`g`,{class:`stroke-current`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(e,t)=>(W(),G(`path`,{key:t,d:e,pathLength:`1`,class:E(`hwl hwl-${t+1}`)},null,10,Kc))),128))],8,Gc)],8,Wc))}}),Jc=[`type`,`disabled`,`aria-busy`],$=z({__name:`UiButton`,props:{variant:{default:`secondary`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},setup(e){let t={primary:`border border-transparent bg-hop-green text-on-green hover:bg-ink hover:text-ground disabled:hover:bg-hop-green disabled:hover:text-on-green`,secondary:`border border-line-strong text-ink hover:border-ink disabled:hover:border-line-strong`,quiet:`border border-transparent text-muted hover:bg-ink/8 hover:text-ink disabled:hover:bg-transparent disabled:hover:text-muted`};return(n,r)=>(W(),G(`button`,{type:e.type,disabled:e.disabled||e.loading,"aria-busy":e.loading?`true`:void 0,class:E([`inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors duration-150 ease-out disabled:cursor-not-allowed disabled:opacity-60`,t[e.variant]])},[e.loading?(W(),K(qc,{key:0,class:`h-4`})):X(``,!0),Cr(n.$slots,`default`)],10,Jc))}}),Yc={class:`flex gap-3`},Xc={class:`w-32 shrink-0`},Zc=[`value`],Qc={class:`min-w-0 flex-1`},$c={class:`mt-1.5 space-y-1.5`},el=[`onUpdate:modelValue`,`aria-label`],tl=[`onUpdate:modelValue`,`aria-label`],nl={class:`mt-2 flex items-center gap-3`},rl={class:`flex items-center gap-3`},il={key:0,class:`mt-1.5 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},al={key:2,class:`mt-1.5 text-sm text-muted`},ol={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},sl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},cl={class:`flex items-center gap-3`},ll={key:0,class:`truncate text-xs text-muted`},ul={class:`font-mono`},dl=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,fl=z({__name:`ReplayEditor`,props:{exchange:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(tc(n.exchange)),a=N(null),o=Q(()=>{let e=n.exchange.request.method.toUpperCase();return $s.includes(e)?[...$s]:[...$s,e]}),s=Q(()=>i.bodyEditable&&Rs(i.body)!==null);function c(){i.body=Rs(i.body)??i.body}function l(){i.headers.push({name:``,value:``})}function u(e){i.headers.splice(e,1)}function d(){a.value=nc(i,n.exchange),a.value===null&&r(`send`,rc(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,Yc,[q(`div`,Xc,[n[4]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-method`},` Method `,-1),R(q(`select`,{id:`replay-method`,"onUpdate:modelValue":n[0]||=e=>i.method=e,class:E([`mt-1.5`,dl])},[(W(!0),G(U,null,B(o.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Zc))),128))],512),[[bo,i.method]])]),q(`div`,Qc,[n[5]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-path`},`Path`,-1),R(q(`input`,{id:`replay-path`,"onUpdate:modelValue":n[1]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,dl])},null,512),[[vo,i.path]])])]),q(`fieldset`,null,[n[9]||=q(`legend`,{class:`text-xs font-medium tracking-wider text-muted uppercase`},`Headers`,-1),q(`ul`,$c,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,dl])},null,8,el),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,dl])},null,8,tl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>u(t)},{default:L(()=>[...n[6]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,nl,[J($,{onClick:l},{default:L(()=>[...n[7]||=[Y(`Add header`,-1)]]),_:1}),n[8]||=q(`span`,{class:`text-xs text-muted`},`Content-Length is set to match the body.`,-1)])]),q(`div`,null,[q(`div`,rl,[n[11]||=q(`label`,{class:`text-xs font-medium tracking-wider text-muted uppercase`,for:`replay-body`},`Body`,-1),s.value?(W(),K($,{key:0,class:`ml-auto`,variant:`quiet`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Format JSON`,-1)]]),_:1})):X(``,!0)]),e.exchange.request.bodyTruncated&&i.bodyEditable?(W(),G(`p`,il,` The log holds only the first part of this body. What you send is exactly the text below. `)):X(``,!0),i.bodyEditable?R((W(),G(`textarea`,{key:1,id:`replay-body`,"onUpdate:modelValue":n[2]||=e=>i.body=e,rows:`12`,spellcheck:`false`,class:E([`mt-1.5 leading-5`,dl])},null,512)),[[vo,i.body]]):(W(),G(`p`,al,` The body is binary and cannot be edited here. It is sent as captured. `))]),q(`div`,ol,[a.value||e.error?(W(),G(`p`,sl,D(a.value??e.error),1)):X(``,!0),q(`div`,cl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[12]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,ll,[n[13]||=Y(` Goes to `,-1),q(`span`,ul,D(e.target),1)])):X(``,!0)])])],32))}}),pl=z({__name:`StatusBadge`,props:{status:{}},setup(e){let t=e,n=Q(()=>Es[Ts(t.status)]);return(t,r)=>(W(),G(`span`,{class:E([`inline-flex shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-xs font-medium tabular-nums`,n.value])},D(e.status),3))}}),ml={class:`space-y-3`,"aria-label":`WebSocket messages`},hl={class:`flex gap-2`},gl=[`value`],_l={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},vl={key:1,class:`text-sm text-muted`},yl={key:2,class:`text-sm text-muted`},bl={key:3,class:`text-sm text-muted`},xl={class:`space-y-2`,"aria-live":`polite`},Sl=[`aria-label`],Cl={class:`flex items-center gap-3 text-xs text-muted`},wl={class:`tabular-nums`},Tl={class:`tabular-nums`},El={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Dl={class:`mt-2 max-h-80 overflow-auto font-mono text-xs leading-5 break-words whitespace-pre-wrap text-ink`},Ol={key:4,class:`space-y-1 rounded-sm border border-hairline px-3 py-2 text-sm text-muted`,"aria-label":`Close of the WebSocket`},kl={key:0,class:`text-warn-fg`},Al={key:5,class:`text-xs text-muted`},jl=z({__name:`WsMessages`,props:{blocks:{},failure:{}},setup(e){let t=e,n=N(``),r=N(``),i=Q(()=>Hs(t.blocks??[])),a=Q(()=>Ws(i.value.messages,{text:n.value,direction:r.value}).map(e=>({message:e,view:Us(e)}))),o=Q(()=>n.value.trim()!==``||r.value!==``),s=Q(()=>{let e=i.value.close;if(e===null)return``;let t=e.reason===``?``:` and reason "${e.reason}"`;return`Closed by ${Gs(e.by)} with code ${e.code}${t}.`}),c=[{value:``,label:`Both directions`},{value:`in`,label:`Client to service`},{value:`out`,label:`Service to client`}];return(t,l)=>(W(),G(`section`,ml,[q(`div`,hl,[l[2]||=q(`label`,{class:`sr-only`,for:`ws-filter`},`Filter messages`,-1),R(q(`input`,{id:`ws-filter`,"onUpdate:modelValue":l[0]||=e=>n.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,n.value]]),l[3]||=q(`label`,{class:`sr-only`,for:`ws-direction`},`Filter by direction`,-1),R(q(`select`,{id:`ws-direction`,"onUpdate:modelValue":l[1]||=e=>r.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[(W(),G(U,null,B(c,e=>q(`option`,{key:e.value,value:e.value},D(e.label),9,gl)),64))],512),[[bo,r.value]])]),e.failure?(W(),G(`p`,_l,D(e.failure),1)):e.blocks===null?(W(),G(`p`,vl,`Loading messages.`)):i.value.messages.length===0&&i.value.close===null?(W(),G(`p`,yl,` No messages yet. New ones appear here as they pass. `)):a.value.length===0&&o.value?(W(),G(`p`,bl,`No message matches the filter.`)):X(``,!0),q(`ol`,xl,[(W(!0),G(U,null,B(a.value,({message:e,view:t})=>(W(),G(`li`,{key:e.position,class:`rounded-sm border border-hairline bg-surface p-3`,"aria-label":`Message ${e.position+1}, ${e.direction===`in`?`client to service`:`service to client`}`},[q(`div`,Cl,[q(`span`,{class:E([`font-mono font-medium`,e.direction===`in`?`text-cyan-text`:`text-green-text`]),"aria-hidden":`true`},D(e.direction===`in`?`Client → service`:`Service → client`),3),q(`span`,wl,`+`+D(e.atMs)+` ms`,1),q(`span`,Tl,D(P(As)(e.length)),1),q(`span`,null,D(t.kind===`json`?`JSON`:t.kind===`text`?`Text`:`Binary`),1),t.kind===`binary`?(W(),K(rs,{key:0,class:`ml-auto`,text:e.dataBase64,label:`Copy message as Base64`},null,8,[`text`])):(W(),K(rs,{key:1,class:`ml-auto`,text:t.kind===`json`?t.formatted:t.text,label:`Copy message`},null,8,[`text`]))]),e.truncated?(W(),G(`p`,El,` Truncated: the log keeps the first `+D(P(As)(65536))+` of this message of `+D(P(As)(e.length))+`. The full message was carried. `,1)):X(``,!0),q(`pre`,Dl,D(t.kind===`json`?t.formatted:t.kind===`text`?t.text:`${t.hex}${t.more?` ...`:``}`),1)],8,Sl))),128))]),i.value.close?(W(),G(`div`,Ol,[q(`p`,null,D(s.value),1),i.value.close.omittedMessages>0?(W(),G(`p`,kl,D(i.value.close.omittedMessages)+` `+D(i.value.close.omittedMessages===1?`message was`:`messages were`)+` not captured: the log keeps up to 2 MB or 10,000 messages per WebSocket. Every message was carried in full. `,1)):X(``,!0)])):e.blocks===null?X(``,!0):(W(),G(`p`,Al,`Open. New messages appear here as they pass.`))]))}}),Ml={class:`mt-1.5 space-y-1.5`},Nl=[`onUpdate:modelValue`,`aria-label`],Pl=[`onUpdate:modelValue`,`aria-label`],Fl={class:`mt-2 flex items-center gap-3`},Il={key:0,class:`mt-1.5 text-sm text-muted`},Ll={class:`mt-1.5 space-y-2`},Rl={class:`flex items-center gap-2 text-xs text-muted`},zl={class:`font-medium text-ink`},Bl={key:0,class:`tabular-nums`},Vl={key:1},Hl={key:0,class:`mt-2 rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},Ul={key:1,class:`mt-2 text-sm text-muted`},Wl=[`onUpdate:modelValue`,`aria-label`],Gl={class:`mt-1.5 space-y-1.5 text-sm text-ink`},Kl={class:`flex items-center gap-2`},ql={class:`flex items-center gap-2`},Jl={class:`sticky bottom-0 -mx-4 space-y-3 border-t border-hairline bg-ground px-4 py-3`},Yl={key:0,class:`rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Xl={class:`flex items-center gap-3`},Zl={key:0,class:`truncate text-xs text-muted`},Ql={class:`font-mono`},$l=`w-full rounded-sm border border-line-strong bg-well px-2.5 py-1.5 font-mono text-xs text-ink placeholder:text-muted`,eu=`text-xs font-medium tracking-wider text-muted uppercase`,tu=z({__name:`WsReplayEditor`,props:{exchange:{},messages:{},target:{},sending:{type:Boolean},error:{}},emits:[`send`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=Ht(Ys(n.exchange.request.path,n.exchange.request.headers,n.messages)),a=N(null);function o(){i.headers.push({name:``,value:``})}function s(e){i.headers.splice(e,1)}function c(){i.messages.push(Js())}function l(e){i.messages.splice(e,1)}function u(e,t){let[n]=i.messages.splice(e,1);n!==void 0&&i.messages.splice(e+t,0,n)}function d(){a.value=Zs(i),a.value===null&&r(`send`,Qs(i))}return(t,n)=>(W(),G(`form`,{class:`space-y-6 px-4 pt-4`,"aria-label":`Edit and replay the WebSocket`,novalidate:``,onSubmit:Eo(d,[`prevent`])},[q(`div`,null,[q(`label`,{class:E(eu),for:`ws-replay-path`},`Path`),R(q(`input`,{id:`ws-replay-path`,"onUpdate:modelValue":n[0]||=e=>i.path=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:E([`mt-1.5`,$l])},null,512),[[vo,i.path]])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Headers`),q(`ul`,Ml,[(W(!0),G(U,null,B(i.headers,(e,t)=>(W(),G(`li`,{key:t,class:`flex gap-1.5`},[R(q(`input`,{"onUpdate:modelValue":t=>e.name=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Name`,"aria-label":`Header ${t+1} name`,class:E([`basis-2/5`,$l])},null,8,Nl),[[vo,e.name]]),R(q(`input`,{"onUpdate:modelValue":t=>e.value=t,type:`text`,autocomplete:`off`,spellcheck:`false`,placeholder:`Value`,"aria-label":`Header ${t+1} value`,class:E([`basis-3/5`,$l])},null,8,Pl),[[vo,e.value]]),J($,{variant:`quiet`,"aria-label":`Remove header ${e.name||t+1}`,onClick:e=>s(t)},{default:L(()=>[...n[4]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]))),128))]),q(`div`,Fl,[J($,{onClick:o},{default:L(()=>[...n[5]||=[Y(`Add header`,-1)]]),_:1}),n[6]||=q(`span`,{class:`text-xs text-muted`},`The handshake headers of the WebSocket are made anew.`,-1)])]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Messages from the client`),i.messages.length===0?(W(),G(`p`,Il,` No messages. The WebSocket opens, waits 5 s for the service and closes. `)):X(``,!0),q(`ol`,Ll,[(W(!0),G(U,null,B(i.messages,(e,t)=>(W(),G(`li`,{key:e.key,class:`rounded-sm border border-hairline bg-surface p-3`},[q(`div`,Rl,[q(`span`,zl,D(t+1),1),q(`span`,null,D(e.binary?`Binary`:`Text`),1),e.atMs===void 0?(W(),G(`span`,Vl,`Added`)):(W(),G(`span`,Bl,`+`+D(e.atMs)+` ms`,1)),J($,{class:`ml-auto`,variant:`quiet`,disabled:t===0,"aria-label":`Move message ${t+1} up`,onClick:e=>u(t,-1)},{default:L(()=>[...n[7]||=[Y(` Up `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,disabled:t===i.messages.length-1,"aria-label":`Move message ${t+1} down`,onClick:e=>u(t,1)},{default:L(()=>[...n[8]||=[Y(` Down `,-1)]]),_:1},8,[`disabled`,`aria-label`,`onClick`]),J($,{variant:`quiet`,"aria-label":`Remove message ${t+1}`,onClick:e=>l(t)},{default:L(()=>[...n[9]||=[Y(` Remove `,-1)]]),_:1},8,[`aria-label`,`onClick`])]),e.truncated?(W(),G(`p`,Hl,[e.binary?(W(),G(U,{key:0},[Y(` Captured only in part (`+D(P(As)(e.length))+` in full), so it cannot be sent. Remove it to replay the rest. `,1)],64)):(W(),G(U,{key:1},[Y(` The log holds only the first part of this message. What you send is exactly the text below. `)],64))])):X(``,!0),e.binary&&!e.truncated?(W(),G(`p`,Ul,` Binary, `+D(P(As)(e.length))+`. It cannot be edited here and is sent as captured. `,1)):e.binary?X(``,!0):R((W(),G(`textarea`,{key:2,"onUpdate:modelValue":t=>e.text=t,rows:`3`,spellcheck:`false`,class:E([`mt-2 leading-5`,$l]),"aria-label":`Text of message ${t+1}`},null,8,Wl)),[[vo,e.text]])]))),128))]),J($,{class:`mt-2`,onClick:c},{default:L(()=>[...n[10]||=[Y(`Add text message`,-1)]]),_:1})]),q(`fieldset`,null,[q(`legend`,{class:E(eu)},`Timing`),q(`div`,Gl,[q(`label`,Kl,[R(q(`input`,{"onUpdate:modelValue":n[1]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`recorded`},null,512),[[yo,i.timing]]),n[11]||=Y(` As recorded: the gaps between the messages, each at most 5 s `,-1)]),q(`label`,ql,[R(q(`input`,{"onUpdate:modelValue":n[2]||=e=>i.timing=e,type:`radio`,name:`ws-timing`,value:`fast`},null,512),[[yo,i.timing]]),n[12]||=Y(` Fast: one message after the other `,-1)])]),n[13]||=q(`p`,{class:`mt-1.5 text-xs text-muted`},` After the last message the WebSocket stays open 5 s for the answers, then it is closed with 1000. `,-1)]),q(`div`,Jl,[a.value||e.error?(W(),G(`p`,Yl,D(a.value??e.error),1)):X(``,!0),q(`div`,Xl,[J($,{type:`submit`,variant:`primary`,loading:e.sending},{default:L(()=>[Y(D(e.sending?`Sending`:`Send replay`),1)]),_:1},8,[`loading`]),J($,{disabled:e.sending,onClick:n[3]||=e=>r(`cancel`)},{default:L(()=>[...n[14]||=[Y(`Cancel`,-1)]]),_:1},8,[`disabled`]),e.target?(W(),G(`span`,Zl,[n[15]||=Y(` Goes to `,-1),q(`span`,Ql,D(e.target),1)])):X(``,!0)])])],32))}}),nu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Request details`},ru={class:`border-b border-hairline p-4`},iu={class:`flex items-start gap-2`},au={class:`min-w-0 flex-1 font-mono text-sm leading-5 font-normal break-all text-ink`},ou={class:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted`},su={class:`flex gap-1`},cu={class:`text-tag-fg tabular-nums`},lu={class:`flex gap-1`},uu={class:`text-tag-fg tabular-nums`},du={class:`flex gap-1`},fu={class:`text-tag-fg`},pu={class:`flex gap-1`},mu={class:`text-tag-fg`},hu={key:0,class:`flex gap-1`},gu={key:1,class:`flex gap-1`},_u={key:1,class:`font-mono text-tag-fg`},vu={key:0,class:`mt-3 flex flex-wrap items-center gap-2`},yu={key:0,class:`truncate text-xs text-muted`},bu={class:`font-mono`},xu={key:1,class:`mt-2 text-sm text-warn-fg`,role:`note`},Su={key:2,class:`mt-2 rounded-sm bg-err-bg px-3 py-2 text-sm text-err-fg`,role:`alert`},Cu={key:0,class:`min-h-0 flex-1 overflow-y-auto`},wu={class:`flex gap-1 border-b border-hairline px-4`,role:`tablist`,"aria-label":`Message`},Tu=[`id`,`aria-selected`,`onClick`],Eu=[`aria-labelledby`],Du=z({__name:`ExchangeDetail`,props:{record:{},status:{},originalLoaded:{type:Boolean},replay:{},wsBlocks:{default:null},wsFailure:{default:null},logs:{default:()=>[]}},emits:[`select`,`load-messages`,`load-logs`],setup(e,{emit:t}){let n=e,r=t,i=N(`request`),a=N(!1),o=N(!1),s=N(null),c=Q(()=>n.record.exchange),l=Q(()=>ms(c.value)),u=Q(()=>[`request`,`response`,...l.value?[`messages`]:[],...n.logs.length>0?[`logs`]:[]]),d=N(!1);function f(e){return e===`logs`?`Logs ${n.logs.length}`:e}function p(e){i.value=e,d.value=!0}let m=Q(()=>Hs(n.wsBlocks??[]).messages),h=Q(()=>oc(n.status,c.value)),g=Q(()=>{let e=ac(n.status,c.value,m.value);if(l.value&&n.wsBlocks===null&&e.replay===null){let t=`The messages of this WebSocket are still loading.`;return{replay:t,editAndReplay:e.editAndReplay??t}}return e}),_=Q(()=>g.value.replay);Vn(()=>[c.value.id,n.record.origin],()=>{a.value=!1,s.value=null,d.value=!1,u.value.includes(i.value)||(i.value=`request`),l.value&&r(`load-messages`,n.record),r(`load-logs`,n.record)},{immediate:!0}),Vn(()=>[c.value.id,n.logs.length>0],([,e])=>{e&&!d.value&&c.value.response.status>=500?i.value=`logs`:!e&&i.value===`logs`&&(i.value=`request`)},{immediate:!0});async function v(e){o.value=!0,s.value=null;try{let t=await n.replay(n.record,e);a.value=!1,i.value=l.value&&ms(t)?`messages`:`response`,r(`select`,t.id)}catch(e){s.value=e instanceof _s?e.message:`The replay could not be sent.`}finally{o.value=!1}}function y(){s.value=null,a.value=!0}return(t,n)=>(W(),G(`article`,nu,[q(`header`,ru,[q(`div`,iu,[J(Uc,{method:c.value.request.method},null,8,[`method`]),q(`h2`,au,D(c.value.request.path),1),J(pl,{status:c.value.response.status},null,8,[`status`])]),q(`dl`,ou,[q(`div`,su,[n[4]||=q(`dt`,null,`Time`,-1),q(`dd`,cu,D(P(Ms)(c.value.timestamp)),1)]),q(`div`,lu,[n[5]||=q(`dt`,null,`Duration`,-1),q(`dd`,uu,D(P(ks)(c.value.response.durationMs)),1)]),q(`div`,du,[n[6]||=q(`dt`,null,`Source`,-1),q(`dd`,fu,D(P(Os)(c.value.source)),1)]),q(`div`,pu,[n[7]||=q(`dt`,null,`Service`,-1),q(`dd`,mu,D(c.value.serviceName),1)]),e.record.origin===`remote`?(W(),G(`div`,hu,[...n[8]||=[q(`dt`,null,`Origin`,-1),q(`dd`,{class:`text-tag-fg`},`remote log`,-1)]])):X(``,!0),c.value.replayOf?(W(),G(`div`,gu,[n[9]||=q(`dt`,null,`Replay of`,-1),q(`dd`,null,[e.originalLoaded?(W(),G(`button`,{key:0,type:`button`,class:`cursor-pointer rounded-sm font-mono text-ink underline decoration-line-strong underline-offset-2 transition-colors duration-150 ease-out hover:decoration-ink`,onClick:n[0]||=e=>r(`select`,c.value.replayOf)},D(c.value.replayOf.slice(0,8)),1)):(W(),G(`span`,_u,D(c.value.replayOf.slice(0,8)),1))])])):X(``,!0)]),a.value?X(``,!0):(W(),G(`div`,vu,[J($,{variant:`primary`,loading:o.value,disabled:_.value!==null,onClick:n[1]||=e=>v()},{default:L(()=>[Y(D(o.value?`Sending`:`Replay`),1)]),_:1},8,[`loading`,`disabled`]),J($,{disabled:o.value||g.value.editAndReplay!==null,onClick:y},{default:L(()=>[...n[10]||=[Y(` Edit & Replay `,-1)]]),_:1},8,[`disabled`]),h.value&&_.value===null?(W(),G(`span`,yu,[n[11]||=Y(` Goes to `,-1),q(`span`,bu,D(h.value),1)])):X(``,!0)])),!a.value&&_.value?(W(),G(`p`,xu,D(_.value),1)):X(``,!0),!a.value&&s.value?(W(),G(`p`,Su,D(s.value),1)):X(``,!0)]),a.value?(W(),G(`div`,Cu,[l.value?(W(),K(tu,{key:`ws-${c.value.id}`,exchange:c.value,messages:m.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[2]||=e=>a.value=!1},null,8,[`exchange`,`messages`,`target`,`sending`,`error`])):(W(),K(fl,{key:c.value.id,exchange:c.value,target:h.value,sending:o.value,error:s.value,onSend:v,onCancel:n[3]||=e=>a.value=!1},null,8,[`exchange`,`target`,`sending`,`error`]))])):(W(),G(U,{key:1},[q(`div`,wu,[(W(!0),G(U,null,B(u.value,e=>(W(),G(`button`,{id:`tab-${e}`,key:e,type:`button`,role:`tab`,"aria-selected":i.value===e,"aria-controls":`message-panel`,class:E([`-mb-px cursor-pointer border-b-2 px-3 py-2 text-sm font-medium capitalize transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,i.value===e?`border-ink text-ink`:`border-transparent text-muted hover:text-ink`]),onClick:t=>p(e)},D(f(e)),11,Tu))),128))]),q(`div`,{id:`message-panel`,class:`min-h-0 flex-1 overflow-y-auto p-4`,role:`tabpanel`,"aria-labelledby":`tab-${i.value}`},[i.value===`request`?(W(),K(Vc,{key:0,headers:c.value.request.headers,"body-base64":c.value.request.bodyBase64,"body-truncated":c.value.request.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`])):i.value===`messages`?(W(),K(jl,{key:1,blocks:e.wsBlocks,failure:e.wsFailure},null,8,[`blocks`,`failure`])):i.value===`logs`?(W(),K(kc,{key:2,items:e.logs,"exchange-id":c.value.id},null,8,[`items`,`exchange-id`])):(W(),K(Vc,{key:3,headers:c.value.response.headers,"body-base64":c.value.response.bodyBase64,"body-truncated":c.value.response.bodyTruncated},null,8,[`headers`,`body-base64`,`body-truncated`]))],8,Eu)],64))]))}});function Ou(e){return`${e.origin}:${e.index}`}function ku(e,t){let n=new Map;for(let t of e)n.set(Ou(t),t);for(let e of t)n.set(Ou(e),e);return[...n.values()].sort((e,t)=>t.exchange.timestamp-e.exchange.timestamp||t.index-e.index)}function Au(e,t){let n=t.text.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(({exchange:e})=>{if(t.service!==``&&e.serviceName!==t.service)return!1;let r=`${e.request.method} ${e.request.path} ${e.response.status} ${e.serviceName} ${e.source}${ms(e)?` ws`:``}`.toLowerCase();return n.every(e=>r.includes(e))})}function ju(e,t){return[...new Set([...t,...e.map(e=>e.exchange.serviceName)])].sort()}function Mu(e){return e?[`remote`,`own`]:[`own`]}function Nu(e,t){return e.reduce((e,n)=>n.origin===t&&(e===null||n.index<e)?n.index:e,null)}function Pu(e){let t=[];for(let n of[`remote`,`own`]){let r=Nu(e,n);r!==null&&r>0&&t.push({origin:n,before:r})}return t}var Fu={class:`flex h-full min-h-0 flex-col`},Iu={class:`flex gap-2 border-b border-hairline p-2`},Lu=[`value`],Ru={key:0,class:`p-4 text-sm text-muted`},zu={class:`min-h-0 flex-1 overflow-y-auto`,"aria-label":`Requests, newest first`},Bu=[`aria-current`,`onClick`],Vu={class:`flex items-center gap-2`},Hu=[`title`],Uu={class:`mt-1 flex items-center gap-2 text-xs text-muted`},Wu={class:`tabular-nums`},Gu={class:`tabular-nums`},Ku={key:0,class:`rounded-sm bg-tag-bg px-1.5 py-px font-medium text-tag-fg`,title:`WebSocket handshake; its messages are in the Messages tab`},qu={key:1,class:`rounded-sm bg-info-bg px-1.5 py-px font-medium text-info-fg`},Ju={key:2,class:`truncate`},Yu={key:0,class:`p-2 text-center`},Xu=z({__name:`ExchangeList`,props:{records:{},services:{},selectedKey:{},hasOlder:{type:Boolean},loadingOlder:{type:Boolean}},emits:[`select`,`load-older`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=Q(()=>n.services.length>1),s=Q(()=>Au(n.records,{text:i.value,service:a.value})),c=Q(()=>i.value.trim()!==``||a.value!==``);return(t,n)=>(W(),G(`div`,Fu,[q(`div`,Iu,[n[5]||=q(`label`,{class:`sr-only`,for:`traffic-filter`},`Filter requests`,-1),R(q(`input`,{id:`traffic-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by method, path or status`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),o.value?(W(),G(U,{key:0},[n[4]||=q(`label`,{class:`sr-only`,for:`traffic-service`},`Filter by service`,-1),R(q(`select`,{id:`traffic-service`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[3]||=q(`option`,{value:``},`All services`,-1),(W(!0),G(U,null,B(e.services,e=>(W(),G(`option`,{key:e,value:e},D(e),9,Lu))),128))],512),[[bo,a.value]])],64)):X(``,!0)]),s.value.length===0?(W(),G(`p`,Ru,D(c.value?`No request matches the filter.`:`No requests yet.`),1)):X(``,!0),q(`ul`,zu,[(W(!0),G(U,null,B(s.value,t=>(W(),G(`li`,{key:P(Ou)(t)},[q(`button`,{type:`button`,class:E([`block w-full cursor-pointer border-b border-l-2 border-b-hairline px-3 py-2 text-left transition-colors duration-150 ease-out focus-visible:-outline-offset-2`,P(Ou)(t)===e.selectedKey?`border-l-ink bg-surface`:`border-l-transparent hover:bg-surface/60`]),"aria-current":P(Ou)(t)===e.selectedKey?`true`:void 0,onClick:e=>r(`select`,P(Ou)(t))},[q(`span`,Vu,[J(Uc,{method:t.exchange.request.method},null,8,[`method`]),q(`span`,{class:`min-w-0 flex-1 truncate font-mono text-sm text-ink`,title:t.exchange.request.path},D(t.exchange.request.path),9,Hu),J(pl,{status:t.exchange.response.status},null,8,[`status`])]),q(`span`,Uu,[q(`span`,Wu,D(P(Ms)(t.exchange.timestamp)),1),q(`span`,Gu,D(P(ks)(t.exchange.response.durationMs)),1),q(`span`,{class:E([`rounded-sm px-1.5 py-px font-medium`,t.exchange.source===`replay`?`bg-warn-bg text-warn-fg`:`bg-tag-bg text-tag-fg`])},D(P(Os)(t.exchange.source)),3),P(ms)(t.exchange)?(W(),G(`span`,Ku,` ws `)):X(``,!0),t.origin===`remote`?(W(),G(`span`,qu,` remote `)):X(``,!0),o.value?(W(),G(`span`,Ju,D(t.exchange.serviceName),1)):X(``,!0)])],10,Bu)]))),128)),e.hasOlder?(W(),G(`li`,Yu,[J($,{variant:`quiet`,loading:e.loadingOlder,onClick:n[2]||=e=>r(`load-older`)},{default:L(()=>[Y(D(e.loadingOlder?`Loading`:`Load older requests`),1)]),_:1},8,[`loading`])])):X(``,!0)])]))}}),Zu={class:`flex h-full min-h-0 flex-col`,"aria-label":`Application logs`},Qu={class:`flex flex-wrap gap-2 border-b border-hairline px-4 py-2`},$u=[`value`],ed=[`value`],td={key:0,class:`rounded-sm bg-warn-bg px-3 py-2 text-sm text-warn-fg`,role:`note`},nd={key:1,class:`text-sm text-muted`},rd={key:2,class:`text-sm text-muted`},id=z({__name:`LogPane`,props:{items:{},omitted:{}},emits:[`select`],setup(e,{emit:t}){let n=e,r=t,i=N(``),a=N(``),o=N(``),s=Q(()=>[...new Set(n.items.map(e=>e.source))].sort()),c=Q(()=>pc(n.items,{text:i.value,source:a.value,level:o.value})),l=Q(()=>i.value.trim()!==``||a.value!==``||o.value!==``),u=[`error`,`warning`,`info`,`debug`],d=N(null),f=!0;function p(){let e=d.value;e!==null&&(f=e.scrollHeight-e.scrollTop-e.clientHeight<40)}async function m(){await Cn(),f&&d.value!==null&&(d.value.scrollTop=d.value.scrollHeight)}return pr(m),Vn(()=>c.value.length,m),(t,n)=>(W(),G(`section`,Zu,[q(`div`,Qu,[n[6]||=q(`label`,{class:`sr-only`,for:`log-filter`},`Filter log entries`,-1),R(q(`input`,{id:`log-filter`,"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`search`,placeholder:`Filter by text`,autocomplete:`off`,spellcheck:`false`,class:`min-w-0 flex-1 rounded-sm border border-line-strong bg-well px-2.5 py-1.5 text-sm text-ink placeholder:text-muted`},null,512),[[vo,i.value]]),n[7]||=q(`label`,{class:`sr-only`,for:`log-source`},`Filter by file`,-1),R(q(`select`,{id:`log-source`,"onUpdate:modelValue":n[1]||=e=>a.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[4]||=q(`option`,{value:``},`All files`,-1),(W(!0),G(U,null,B(s.value,e=>(W(),G(`option`,{key:e,value:e},D(e),9,$u))),128))],512),[[bo,a.value]]),n[8]||=q(`label`,{class:`sr-only`,for:`log-level`},`Filter by level`,-1),R(q(`select`,{id:`log-level`,"onUpdate:modelValue":n[2]||=e=>o.value=e,class:`rounded-sm border border-line-strong bg-well px-2 py-1.5 text-sm text-ink`},[n[5]||=q(`option`,{value:``},`All levels`,-1),(W(),G(U,null,B(u,e=>q(`option`,{key:e,value:e},D(P(_c)[e]),9,ed)),64))],512),[[bo,o.value]])]),q(`div`,{ref_key:`scroller`,ref:d,class:`min-h-0 flex-1 space-y-3 overflow-y-auto p-4`,onScroll:p},[e.omitted.entries>0?(W(),G(`p`,td,D(e.omitted.entries)+` `+D(e.omitted.entries===1?`entry was`:`entries were`)+` (`+D(P(As)(e.omitted.bytes))+`) not captured: a log file is captured up to 200 entries per second and 10 MB per run. `,1)):X(``,!0),e.items.length===0?(W(),G(`p`,nd,` No log entries yet. Start the tunnel with --log <path> (or logs: in hopwire.yaml) and new entries of the file appear here as they are written. `)):c.value.length===0&&l.value?(W(),G(`p`,rd,`No entry matches the filter.`)):X(``,!0),J(kc,{items:c.value,selectable:``,onSelect:n[3]||=e=>r(`select`,e)},null,8,[`items`])],544)]))}}),ad=`hopwire-inspector-theme`;function od(){try{return localStorage.getItem(ad)===`light`?`light`:`dark`}catch{return`dark`}}var sd=N(od());Vn(sd,e=>{document.documentElement.classList.toggle(`dark`,e===`dark`);try{localStorage.setItem(ad,e)}catch{}},{immediate:!0});function cd(){function e(){sd.value=sd.value===`dark`?`light`:`dark`}return{theme:sd,toggleTheme:e}}var ld=[`viewBox`],ud=[`stroke-width`],dd=[`d`,`pathLength`],fd=[`d`],pd=z({__name:`BrandLogo`,props:{animated:{type:Boolean,default:!1}},setup(e){return(t,n)=>(W(),G(`svg`,{viewBox:P(No),role:`img`,"aria-label":`Hopwire`,class:`block w-auto`},[q(`g`,{class:`stroke-mark`,fill:`none`,"stroke-width":P(Fo),"stroke-linecap":`round`,"stroke-linejoin":`round`},[(W(!0),G(U,null,B(P(Io),(t,n)=>(W(),G(`path`,{key:n,d:t,pathLength:e.animated?1:void 0,class:E(e.animated?`hwd-s hwd-s${n+1}`:void 0)},null,10,dd))),128))],8,ud),q(`g`,{class:E(e.animated?`hwd-w`:void 0)},[q(`path`,{class:`fill-ink`,d:P(Lo)},null,8,fd)],2)],8,ld))}}),md={class:`flex flex-wrap items-center gap-x-5 gap-y-2 border-b border-hairline bg-surface px-4 py-2.5 text-sm`},hd={class:`flex items-center gap-2.5 font-normal`},gd={key:0,class:`inline-flex items-center gap-1.5 rounded-full bg-tag-bg px-2 py-0.5 text-xs font-medium text-tag-fg`},_d={key:1,class:`rounded-full bg-info-bg px-2 py-0.5 text-xs font-medium text-info-fg`},vd={key:2,class:`order-last flex w-full min-w-0 flex-wrap items-center gap-x-5 gap-y-1 lg:order-none lg:w-auto lg:flex-1`},yd={class:`truncate font-mono text-xs text-ink`},bd={key:0,class:`flex items-center gap-1.5`},xd=[`title`],Sd={class:`flex items-center gap-1.5`},Cd=[`title`],wd={class:`flex min-w-0 items-center gap-1.5`},Td={key:0,class:`truncate font-mono text-xs text-ink`},Ed={class:`ml-auto flex items-center gap-3`},Dd={class:`flex items-center gap-1.5 text-xs text-tag-fg`,role:`status`},Od=z({__name:`StatusBar`,props:{status:{},stream:{},logCount:{default:0},logsOpen:{type:Boolean,default:!1}},emits:[`toggle-logs`],setup(e,{emit:t}){let n=e,r=t,{theme:i,toggleTheme:a}=cd(),o=Q(()=>n.status===null?null:sc(n.status));return(t,n)=>(W(),G(`header`,md,[q(`h1`,hd,[J(pd,{class:`h-6`}),n[1]||=q(`span`,{class:`text-muted`},`Inspector`,-1)]),e.status?(W(),G(`span`,gd,[q(`span`,{class:E([`size-2 rounded-full border-[1.5px]`,e.status.mode===`public`?`border-link-blue bg-link-blue`:`border-cyan-text bg-wire-cyan`]),"aria-hidden":`true`},null,2),Y(` `+D(e.status.mode===`public`?`Public mode`:`Private mode`),1)])):X(``,!0),e.status?.watching?(W(),G(`span`,_d,` Watching a shared log `)):X(``,!0),e.status?(W(),G(`dl`,vd,[(W(!0),G(U,null,B(e.status.publicUrls,e=>(W(),G(`div`,{key:e,class:`flex min-w-0 items-center gap-1.5`},[n[2]||=q(`dt`,{class:`text-muted`},`Public URL`,-1),q(`dd`,yd,D(e),1),J(rs,{text:e,label:`Copy public URL`},null,8,[`text`])]))),128)),e.status.peerKey?(W(),G(`div`,bd,[n[3]||=q(`dt`,{class:`text-muted`},`Peer key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.peerKey},D(P(Ns)(e.status.peerKey)),9,xd),J(rs,{text:e.status.peerKey,label:`Copy peer key`},null,8,[`text`])])):X(``,!0),q(`div`,Sd,[n[4]||=q(`dt`,{class:`text-muted`},`Log key`,-1),q(`dd`,{class:`font-mono text-xs text-ink`,title:e.status.logKey},D(P(Ns)(e.status.logKey)),9,Cd),J(rs,{text:e.status.logKey,label:`Copy log key`},null,8,[`text`])]),q(`div`,wd,[n[5]||=q(`dt`,{class:`text-muted`},`Replay target`,-1),e.status.replayTarget?(W(),G(`dd`,Td,D(e.status.replayTarget),1)):o.value?(W(),G(`dd`,{key:1,class:E([`text-xs`,o.value.missing?`text-warn-fg`:`text-tag-fg`])},D(o.value.text),3)):X(``,!0)])])):X(``,!0),q(`div`,Ed,[q(`span`,Dd,[P($o)(e.stream)?(W(),K(qc,{key:0,class:`h-3.5`})):(W(),G(`span`,{key:1,class:E([`size-2 rounded-full`,e.stream===`live`?`bg-hop-green`:`border-[1.5px] border-muted`]),"aria-hidden":`true`},null,2)),Y(` `+D(P(Zo)[e.stream]),1)]),e.logCount>0||e.logsOpen?(W(),K($,{key:0,variant:`quiet`,"aria-pressed":e.logsOpen,"aria-controls":`log-pane`,onClick:n[0]||=e=>r(`toggle-logs`)},{default:L(()=>[Y(D(e.logsOpen?`Hide logs`:`Logs ${e.logCount}`),1)]),_:1},8,[`aria-pressed`])):X(``,!0),J($,{variant:`quiet`,"aria-label":`Switch to ${P(i)===`dark`?`light`:`dark`} mode`,onClick:P(a)},{default:L(()=>[Y(D(P(i)===`dark`?`Light`:`Dark`),1)]),_:1},8,[`aria-label`,`onClick`])])]))}}),kd=100;function Ad(){let e=N(null),t=$t([]),n=N(`connecting`),r=N(!1),i=N(!1),a=N(null),o=null,s=!1,c=$t(new Map),l=$t(new Map),u=$t([]),d=N({entries:0,bytes:0});function f(e){u.value=uc(u.value,lc(e));let t=dc(e);t.entries>0&&(d.value={entries:d.value.entries+t.entries,bytes:d.value.bytes+t.bytes})}async function p(e){try{let t=await Cs({exchangeId:e.exchange.id,origin:e.origin});u.value=uc(u.value,lc(t.blocks))}catch{}}async function m(){try{let e=await Cs({limit:500});u.value=uc(u.value,lc(e.blocks))}catch{}}function h(e,t){let n=new Map(c.value);n.set(e,t),c.value=n}async function g(e){let t=Bs(e.origin,e.exchange.id);c.value.has(t)||h(t,[]);try{let n=await Ss(e.origin,e.exchange.id);if(h(t,Vs(c.value.get(t)??[],n)),l.value.has(t)){let e=new Map(l.value);e.delete(t),l.value=e}}catch(e){let n=new Map(l.value);n.set(t,e instanceof _s?e.message:`The messages could not be loaded.`),l.value=n}}let _=Q(()=>Pu(t.value).length>0),v=Q(()=>a.value??(n.value===`closed`?`The connection to the tunnel is closed. Reload the page to connect again.`:null)),y=Q(()=>!r.value&&v.value===null);async function b(){r.value||(a.value=null);try{let n=await bs(),i=(await Promise.all(Mu(n.watching).map(e=>xs({origin:e,limit:kd})))).flat(),o=e.value===null||e.value.logKey===n.logKey;e.value=n,t.value=ku(o?t.value:[],i),r.value=!0,a.value=null,o||(c.value=new Map,u.value=[],d.value={entries:0,bytes:0}),m();for(let e of c.value.keys()){let n=t.value.find(t=>Bs(t.origin,t.exchange.id)===e);n!==void 0&&g(n)}}catch(e){a.value=e instanceof _s?e.message:`The traffic could not be loaded.`}}function x(){let e=new EventSource(`${vs}stream`);o=e,e.addEventListener(`open`,()=>{s=!0,n.value=`live`,b()}),e.addEventListener(`exchange`,e=>{let n=JSON.parse(e.data);t.value=ku(t.value,[n])}),e.addEventListener(`ws_messages`,e=>{let{origin:t,block:n}=JSON.parse(e.data),r=Bs(t,n.exchangeId),i=c.value.get(r);i!==void 0&&h(r,Vs(i,[n]))}),e.addEventListener(`log_entries`,e=>{f([JSON.parse(e.data)])}),e.addEventListener(`error`,()=>{n.value=Qo(e.readyState===EventSource.CLOSED,s)})}function ee(){o?.close(),o=null,n.value=`closed`}async function S(){let e=Pu(t.value);if(!(e.length===0||i.value)){i.value=!0;try{let n=await Promise.all(e.map(e=>xs({...e,limit:kd})));t.value=ku(t.value,n.flat())}catch(e){a.value=e instanceof _s?e.message:`Older requests could not be loaded.`}finally{i.value=!1}}}async function C(e,n){let r=await ws(e,n);return t.value.some(e=>e.exchange.id===r.id)||await b(),r}return{status:e,records:t,stream:n,connecting:y,loaded:r,loadingOlder:i,problem:v,hasOlder:_,start:x,stop:ee,loadOlder:S,replay:C,wsSessions:c,wsFailures:l,loadWsMessages:g,logs:u,logsOmitted:d,loadExchangeLogs:p}}function jd(){let e=Ad();return gr(e.stop),e}function Md(e){let t=/^#exchange=([^&]+)$/.exec(e);if(t?.[1]===void 0)return null;try{return decodeURIComponent(t[1])}catch{return null}}var Nd={class:`flex h-dvh flex-col bg-ground text-ink`},Pd={key:0,class:`border-b border-hairline bg-err-bg px-4 py-2 text-sm text-err-fg`,role:`alert`},Fd={class:`min-h-0 flex-1`},Id={key:2,class:`flex h-full min-h-0 flex-col md:flex-row`},Ld={class:`h-2/5 min-h-0 shrink-0 border-b border-hairline md:h-full md:w-2/5 md:max-w-xl md:min-w-80 md:border-r md:border-b-0`,"aria-label":`Traffic`},Rd={class:`min-h-0 min-w-0 flex-1`},zd={key:1,class:`flex h-full items-center justify-center p-8 text-sm text-muted`},Bd={key:1,id:`log-pane`,class:`h-2/5 min-h-0 shrink-0 border-t border-hairline`};Ao(z({__name:`App`,setup(e){let{status:t,records:n,stream:r,connecting:i,loaded:a,loadingOlder:o,problem:s,hasOlder:c,start:l,loadOlder:u,replay:d,wsSessions:f,wsFailures:p,loadWsMessages:m,logs:h,logsOmitted:g,loadExchangeLogs:_}=jd(),v=N(!1),y=N(null),b=Q(()=>n.value.find(e=>Ou(e)===y.value)??null);function x(e){let t=n.value.find(t=>t.exchange.id===e);y.value=t===void 0?null:Ou(t)}let ee=Q(()=>ju(n.value,(t.value?.services??[]).map(e=>e.name))),S=Q(()=>b.value===null?null:Bs(b.value.origin,b.value.exchange.id)),C=Q(()=>S.value===null?null:f.value.get(S.value)??null),te=Q(()=>S.value===null?null:p.value.get(S.value)??null),ne=Q(()=>b.value===null?[]:fc(h.value,b.value.origin,b.value.exchange.id));function re(e){let t=n.value.find(t=>t.origin===e.origin&&e.entry.exchangeIds.includes(t.exchange.id));t!==void 0&&(y.value=Ou(t))}let ie=Q(()=>{let e=b.value?.exchange.replayOf;return e!==void 0&&n.value.some(t=>t.exchange.id===e)}),w=N(Md(window.location.hash));Vn([n,w],()=>{let e=w.value;e!==null&&n.value.some(t=>t.exchange.id===e)&&(x(e),w.value=null)},{immediate:!0});let ae=()=>{w.value=Md(window.location.hash)};return pr(()=>{window.addEventListener(`hashchange`,ae),l()}),gr(()=>window.removeEventListener(`hashchange`,ae)),(e,l)=>(W(),G(`div`,Nd,[J(Od,{status:P(t),stream:P(r),"log-count":P(h).length,"logs-open":v.value,onToggleLogs:l[0]||=e=>v.value=!v.value},null,8,[`status`,`stream`,`log-count`,`logs-open`]),P(s)?(W(),G(`p`,Pd,D(P(s)),1)):X(``,!0),q(`main`,Fd,[P(a)?P(n).length===0?(W(),K(ps,{key:1,status:P(t),stream:P(r)},null,8,[`status`,`stream`])):(W(),G(`div`,Id,[q(`section`,Ld,[J(Xu,{records:P(n),services:ee.value,"selected-key":y.value,"has-older":P(c),"loading-older":P(o),onSelect:l[1]||=e=>y.value=e,onLoadOlder:P(u)},null,8,[`records`,`services`,`selected-key`,`has-older`,`loading-older`,`onLoadOlder`])]),q(`section`,Rd,[b.value?(W(),K(Du,{key:0,record:b.value,status:P(t),"original-loaded":ie.value,replay:P(d),"ws-blocks":C.value,"ws-failure":te.value,logs:ne.value,onSelect:x,onLoadMessages:P(m),onLoadLogs:P(_)},null,8,[`record`,`status`,`original-loaded`,`replay`,`ws-blocks`,`ws-failure`,`logs`,`onLoadMessages`,`onLoadLogs`])):(W(),G(`div`,zd,` Select a request to see its headers and body. `))])])):(W(),K(Xo,{key:0,connecting:P(i)},null,8,[`connecting`]))]),v.value?(W(),G(`div`,Bd,[J(id,{items:P(h),omitted:P(g),onSelect:re},null,8,[`items`,`omitted`])])):X(``,!0)]))}})).mount(`#app`);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="referrer" content="no-referrer" />
|
|
8
8
|
<title>Hopwire Inspector</title>
|
|
9
9
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
10
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
+
<script type="module" crossorigin src="./assets/index-CdyIIKdA.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/index-Du4-DCNN.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body class="bg-ground font-sans text-ink antialiased">
|