@yunuseon/kayra 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/skills/kayra-rollout/SKILL.md +3 -2
- package/ansible/playbooks/edge.yml +5 -0
- package/ansible/playbooks/nas.yml +9 -1
- package/ansible/playbooks/platform.yml +8 -2
- package/ansible/roles/app/tasks/main.yml +11 -3
- package/ansible/roles/kayra-version/defaults/main.yml +5 -0
- package/ansible/roles/kayra-version/tasks/main.yml +18 -0
- package/ansible/roles/platform/tasks/main.yml +6 -4
- package/cli/dist/browser/assets/index-C4HCL022.js +7 -0
- package/cli/dist/browser/index.html +1 -1
- package/cli/dist/clients/cli/status.js +28 -7
- package/cli/dist/clients/wire/schemas.js +2 -1
- package/cli/dist/clients/wire/status.js +7 -1
- package/cli/dist/core/adapters/network.js +20 -1
- package/cli/dist/core/fleet/brand.js +5 -0
- package/cli/dist/core/fleet/parse.js +10 -1
- package/cli/dist/core/fleet/settings.js +18 -3
- package/cli/dist/core/operations/dispatch.js +3 -3
- package/cli/dist/core/recipes/doctor.js +3 -3
- package/cli/dist/core/recipes/host.js +8 -3
- package/cli/dist/core/status/look.js +33 -13
- package/cli/dist/core/status/model.js +2 -0
- package/cli/dist/deployer/brand.js +5 -0
- package/cli/dist/deployer/build/builder.js +5 -0
- package/cli/dist/deployer/build/bundle.js +5 -0
- package/cli/dist/deployer/build/compose.js +21 -8
- package/cli/dist/deployer/build/routes.js +128 -0
- package/cli/dist/deployer/deployer.js +10 -4
- package/cli/dist/deployer/runs/run.js +14 -7
- package/package.json +1 -1
- package/schema/app.json +64 -8
- package/scripts/local/app-check.sh +12 -9
- package/scripts/local/app-manifests.sh +11 -6
- package/scripts/local/verify.sh +22 -11
- package/scripts/platform/compose-policy.sh +37 -40
- package/cli/dist/browser/assets/index-hcyM6f6T.js +0 -7
- package/compose/traefik/dynamic/ratelimit.yml +0 -21
package/scripts/local/verify.sh
CHANGED
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
# browser to the login, not a 403 from rules Authelia never loaded
|
|
10
10
|
# - every certificate is a real one (Let's Encrypt or mkcert), never
|
|
11
11
|
# Traefik's default
|
|
12
|
-
# - an unsigned webhook is refused; every app
|
|
12
|
+
# - an unsigned webhook is refused; every app route answers, not 5xx
|
|
13
13
|
# On the server (one SSH call):
|
|
14
14
|
# - every app in server.yml is registered, and nothing else
|
|
15
15
|
# - every app's containers run, none unhealthy; its last run did not fail
|
|
16
16
|
# - every platform container runs, none unhealthy; no alert is open
|
|
17
|
+
# - which kayra set it up (/opt/kayra/version): one that is not this kayra
|
|
18
|
+
# (KAYRA_VERSION, the fleet's pin) is noted, not failed — it still works,
|
|
19
|
+
# and every server runs the last release until its rollout reaches it
|
|
17
20
|
#
|
|
18
21
|
# Certificates and routes can lag a fresh deploy (ACME, DNS-01's minute), so
|
|
19
22
|
# the probes retry for VERIFY_WAIT seconds (default 150) before failing.
|
|
@@ -23,6 +26,7 @@ set -euo pipefail
|
|
|
23
26
|
|
|
24
27
|
KAYRA_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
25
28
|
FLEET_ROOT="${FLEET_ROOT:?the directory of the fleet (servers/), set by kayra}"
|
|
29
|
+
pin="${KAYRA_VERSION:?the kayra that runs, set by kayra}"
|
|
26
30
|
name="${1:?Usage: verify.sh <server>}"
|
|
27
31
|
dir="${FLEET_ROOT}/servers/${name}"
|
|
28
32
|
wait="${VERIFY_WAIT:-150}"
|
|
@@ -30,6 +34,7 @@ failed=0
|
|
|
30
34
|
|
|
31
35
|
fail() { echo " ✗ $*"; failed=1; }
|
|
32
36
|
pass() { echo " ✓ $*"; }
|
|
37
|
+
note() { echo " ! $*"; }
|
|
33
38
|
|
|
34
39
|
domain="$(yq -r '.domain' "${dir}/server.yml")"
|
|
35
40
|
inventory="${dir}/inventory.ini"
|
|
@@ -42,12 +47,12 @@ key="$(field ansible_ssh_private_key_file)"
|
|
|
42
47
|
registered_wanted="$(yq -r '.apps // [] | .[].name' "${dir}/server.yml")"
|
|
43
48
|
|
|
44
49
|
# ── From outside ────────────────────────────────────────────────────────────
|
|
45
|
-
# "<status> <redirect> <verify result> <issuer CN>" for a host, pinned to the server.
|
|
50
|
+
# "<status> <redirect> <verify result> <issuer CN>" for a host (and path), pinned to the server.
|
|
46
51
|
probe() {
|
|
47
|
-
local host="$1" method="${2:-GET}" result issuer
|
|
52
|
+
local host="$1" method="${2:-GET}" path="${3:-/}" result issuer
|
|
48
53
|
result="$(curl -s -o /dev/null -m 10 -X "$method" -H 'Accept: text/html' \
|
|
49
54
|
--resolve "${host}:443:${address}" -w '%{http_code} %{redirect_url} %{ssl_verify_result}' \
|
|
50
|
-
"https://${host}
|
|
55
|
+
"https://${host}${path}" 2>/dev/null || echo "000 - -")"
|
|
51
56
|
issuer="$(openssl s_client -connect "${address}:443" -servername "$host" </dev/null 2>/dev/null \
|
|
52
57
|
| openssl x509 -noout -issuer 2>/dev/null | sed -n 's/.*CN *= *//p')"
|
|
53
58
|
echo "${result} ${issuer:-none}"
|
|
@@ -55,10 +60,10 @@ probe() {
|
|
|
55
60
|
|
|
56
61
|
# Probes until `test` accepts the answer or VERIFY_WAIT runs out; prints the last answer.
|
|
57
62
|
until_ok() {
|
|
58
|
-
local host="$1" method="$2" test="$3" deadline answer
|
|
63
|
+
local host="$1" method="$2" test="$3" path="${4:-/}" deadline answer
|
|
59
64
|
deadline=$(( $(date +%s) + wait ))
|
|
60
65
|
while :; do
|
|
61
|
-
answer="$(probe "$host" "$method")"
|
|
66
|
+
answer="$(probe "$host" "$method" "$path")"
|
|
62
67
|
if "$test" "$answer"; then echo "$answer"; return 0; fi
|
|
63
68
|
[ "$(date +%s)" -lt "$deadline" ] || { echo "$answer"; return 1; }
|
|
64
69
|
sleep 10
|
|
@@ -74,8 +79,8 @@ refused() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 401 ]; }
|
|
|
74
79
|
describe() { echo "HTTP $(cut -d' ' -f1 <<< "$1"), certificate by $(cut -d' ' -f4- <<< "$1") (verify $(cut -d' ' -f3 <<< "$1"))"; }
|
|
75
80
|
|
|
76
81
|
check() {
|
|
77
|
-
local label="$1" host="$2" method="$3" test="$4" answer
|
|
78
|
-
if answer="$(until_ok "$host" "$method" "$test")"; then pass "$label"; else fail "${label}: $(describe "$answer")"; fi
|
|
82
|
+
local label="$1" host="$2" method="$3" test="$4" path="${5:-/}" answer
|
|
83
|
+
if answer="$(until_ok "$host" "$method" "$test" "$path")"; then pass "$label"; else fail "${label}: $(describe "$answer")"; fi
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
check "auth.${domain} answers" "auth.${domain}" GET answers
|
|
@@ -91,9 +96,9 @@ if [ -n "$first_app" ]; then
|
|
|
91
96
|
}
|
|
92
97
|
code="$(hook)"
|
|
93
98
|
[ "$code" = 401 ] && pass "an unsigned webhook is refused" || fail "an unsigned webhook to /hook/${first_app}: HTTP ${code}, not 401"
|
|
94
|
-
while
|
|
95
|
-
[ -z "$sub" ] || check "${sub}.${domain} answers" "${sub}.${domain}" GET not_5xx
|
|
96
|
-
done < <(bash "${KAYRA_ROOT}/scripts/local/app-manifests.sh" --
|
|
99
|
+
while read -r sub path; do
|
|
100
|
+
[ -z "$sub" ] || check "${sub}.${domain}${path%/} answers" "${sub}.${domain}" GET not_5xx "$path"
|
|
101
|
+
done < <(bash "${KAYRA_ROOT}/scripts/local/app-manifests.sh" --routes "$name")
|
|
97
102
|
fi
|
|
98
103
|
|
|
99
104
|
# ── On the server ───────────────────────────────────────────────────────────
|
|
@@ -102,6 +107,7 @@ facts="$(ssh -p "${port:-22}" -i "$key" -o StrictHostKeyChecking=no -o UserKnown
|
|
|
102
107
|
cd /opt/platform
|
|
103
108
|
echo "registered $(ls apps 2>/dev/null | sed -n "s/\.json$//p" | sort | tr "\n" " ")"
|
|
104
109
|
echo "alerts $(ls alerts 2>/dev/null | tr "\n" " ")"
|
|
110
|
+
echo "kayra $(cat /opt/kayra/version 2>/dev/null || true)"
|
|
105
111
|
docker compose ps -a --format "{{.Service}}|{{.State}}|{{.Health}}" | sed "s/^/platform /"
|
|
106
112
|
for app in $(ls apps 2>/dev/null | sed -n "s/\.json$//p"); do
|
|
107
113
|
docker ps -a --filter "label=com.docker.compose.project=$app" --format "{{.Names}}|{{.State}}|{{.Status}}" | sed "s/^/container $app /"
|
|
@@ -116,6 +122,11 @@ have="$(xargs <<< "$have")"
|
|
|
116
122
|
[ "$wanted" = "$have" ] && pass "registered: ${have:-no apps}" \
|
|
117
123
|
|| fail "registered: ${have:-nothing}; server.yml says ${wanted:-no apps} (kayra apps ${name})"
|
|
118
124
|
|
|
125
|
+
running="$(sed -n 's/^kayra //p' <<< "$facts" | xargs)"
|
|
126
|
+
if [ "$running" = "$pin" ]; then pass "set up by kayra ${pin}, the fleet's pin"
|
|
127
|
+
elif [ -z "$running" ]; then note "set up by a kayra that recorded no version; the fleet pins ${pin} (kayra deploy ${name})"
|
|
128
|
+
else note "set up by kayra ${running}; the fleet pins ${pin} (kayra deploy ${name})"; fi
|
|
129
|
+
|
|
119
130
|
alerts="$(sed -n 's/^alerts //p' <<< "$facts" | xargs)"
|
|
120
131
|
[ -z "$alerts" ] && pass "no alert is open" || fail "open alerts: ${alerts}"
|
|
121
132
|
|
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# =============================================================================
|
|
3
|
-
# compose-policy.sh <app> <allowed-host>... < config.json
|
|
3
|
+
# compose-policy.sh <app> <domain> <routes> <allowed-host>... < config.json
|
|
4
4
|
#
|
|
5
5
|
# The platform's admission check, run by the deployer before every
|
|
6
6
|
# `docker compose up`. Input is `docker compose config --no-env-resolution
|
|
7
|
-
# --format json
|
|
8
|
-
# defaults cannot hide anything. Env files stay
|
|
9
|
-
# deployer would read them from its own filesystem,
|
|
10
|
-
# included. Prints one line per violation and exits 1 if
|
|
7
|
+
# --format json` of the app's own compose files: the fully resolved config, so
|
|
8
|
+
# variables, overlays and defaults cannot hide anything. Env files stay
|
|
9
|
+
# unresolved on purpose: the deployer would read them from its own filesystem,
|
|
10
|
+
# platform secrets included. Prints one line per violation and exits 1 if
|
|
11
|
+
# there is any.
|
|
11
12
|
#
|
|
12
13
|
# An allow-list: a service key the platform has not thought about is refused,
|
|
13
14
|
# rather than a new Compose feature quietly opening a hole. Modelled on
|
|
14
15
|
# Kubernetes' Pod Security "restricted" profile, adapted to what matters on a
|
|
15
16
|
# shared Docker host: an app must not reach the host, other apps, or the
|
|
16
|
-
# platform, must
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
17
|
+
# platform, and must declare how much memory it may take. Running as root
|
|
18
|
+
# inside the container is allowed (unlike restricted): without capabilities or
|
|
19
|
+
# host access it gets nothing a non-root user would not.
|
|
20
|
+
#
|
|
21
|
+
# Routing is the platform's: the app's routes (app.yml `routes`, as JSON) are
|
|
22
|
+
# checked here against its config, each to one of its services on one of its
|
|
23
|
+
# registered hosts, and the deployer writes the Traefik labels and the
|
|
24
|
+
# platform network from them after admission. So an app's own files carry
|
|
25
|
+
# neither: no `traefik.*` label, no `platform-*` network.
|
|
20
26
|
# =============================================================================
|
|
21
27
|
set -euo pipefail
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
usage="Usage: compose-policy.sh <app> <domain> <routes> <allowed-host>... < config.json"
|
|
30
|
+
app="${1:?$usage}"
|
|
31
|
+
domain="${2:?$usage}"
|
|
32
|
+
routes="${3:?$usage}"
|
|
33
|
+
shift 3
|
|
34
|
+
hosts=$(printf '%s\n' "$@" | jq -R 'select(. != "")' | jq -s .)
|
|
26
35
|
|
|
27
|
-
jq -r --arg app "$app" --argjson hosts "$hosts" '
|
|
36
|
+
jq -r --arg app "$app" --arg domain "$domain" --argjson routes "$routes" --argjson hosts "$hosts" '
|
|
28
37
|
def own($name): $name | startswith($app + "_");
|
|
38
|
+
def platform($name): $name | startswith("platform-");
|
|
29
39
|
def registry_ref: test("^(localhost|registry):5000/");
|
|
30
40
|
def allowed: ["image", "command", "entrypoint", "environment", "labels",
|
|
31
41
|
"networks", "volumes", "tmpfs", "healthcheck", "depends_on", "restart",
|
|
@@ -42,43 +52,30 @@ jq -r --arg app "$app" --argjson hosts "$hosts" '
|
|
|
42
52
|
(if ($s.mem_limit // $s.deploy.resources.limits.memory) == null
|
|
43
53
|
then "no memory limit (set mem_limit)" else empty end),
|
|
44
54
|
($s.networks // {} | to_entries[] | .key as $net | .value // {} |
|
|
45
|
-
(keys - ["aliases"] | .[] | "networks.\($net).\(.) is not allowed"),
|
|
46
|
-
(select($root.networks[$net].name == "platform-public") | .aliases // [] | .[]
|
|
47
|
-
| select(startswith($app + "-") | not)
|
|
48
|
-
| "alias \(.) on platform-public must start with \($app)-")),
|
|
55
|
+
(keys - ["aliases"] | .[] | "networks.\($net).\(.) is not allowed")),
|
|
49
56
|
($s.volumes // [] | .[] | select(.type != "volume" and .type != "tmpfs")
|
|
50
57
|
| "\(.type) mount \(.source // "") -> \(.target) (named volumes only)"),
|
|
51
58
|
(if ($s.image // "") | registry_ref and (test("^[^/]+/" + $app + "/") | not)
|
|
52
59
|
then "image \($s.image) is outside the \($app)/ namespace" else empty end),
|
|
53
|
-
($s.labels // {} |
|
|
54
|
-
|
|
55
|
-
(select(.key | test("^traefik\\.http\\.(routers|services|middlewares)\\."))
|
|
56
|
-
| (.key | split(".")[3]) as $name
|
|
57
|
-
| select($name | startswith($app + "-") | not)
|
|
58
|
-
| "\(.key): Traefik names must start with \($app)-"),
|
|
59
|
-
(select(.value | test("@internal")) | "\(.key) references an @internal service"),
|
|
60
|
-
(select(.key | test("^traefik\\.http\\.routers\\.[^.]+\\.middlewares$"))
|
|
61
|
-
| select(.value | split(",") | map(gsub("\\s"; "")) | index("authelia@file"))
|
|
62
|
-
| "\(.key): authelia@file is the platform'"'"'s login; apps bring their own"),
|
|
63
|
-
(select(.key | test("^traefik\\.http\\.routers\\.[^.]+\\.rule$")) | .key as $k | .value as $rule |
|
|
64
|
-
([$rule | scan("Host\\(`([^`]*)`\\)") | .[0]]) as $claimed |
|
|
65
|
-
if ($rule | test("HostRegexp|HostSNI")) then "\($k): only Host() rules are allowed"
|
|
66
|
-
elif ($claimed | length) == 0 then "\($k): rule must name a Host()"
|
|
67
|
-
else ($claimed[] | select(. as $h | $hosts | index($h) | not)
|
|
68
|
-
| "\($k): host \(.) is not one of this app'"'"'s")
|
|
69
|
-
end)
|
|
70
|
-
)
|
|
60
|
+
($s.labels // {} | keys[] | select(ascii_downcase | startswith("traefik."))
|
|
61
|
+
| "label \(.): Traefik labels are the platform'"'"'s; declare routes in app.yml")
|
|
71
62
|
) | "service \($svc): \(.)"
|
|
72
63
|
),
|
|
73
64
|
(.networks // {} | to_entries[] | .value as $n |
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
|
|
65
|
+
if platform(.key) or platform($n.name // "")
|
|
66
|
+
then "network \(.key): platform networks are the platform'"'"'s; it attaches routed services itself"
|
|
67
|
+
elif own($n.name // "") | not
|
|
68
|
+
then "network \(.key): \($n.name // "?") is not the app'"'"'s own"
|
|
69
|
+
else empty end),
|
|
78
70
|
(.volumes // {} | to_entries[] | .value as $v |
|
|
79
71
|
(select($v.external) | "volume \(.key): external volumes are not allowed"),
|
|
80
72
|
(select(($v.driver_opts // {}) | length > 0) | "volume \(.key): driver_opts are not allowed"),
|
|
81
73
|
(select(own($v.name // "") | not) | "volume \(.key): \($v.name) belongs to another project")),
|
|
82
74
|
(.secrets // {}, .configs // {} | to_entries[] | select(.value.file)
|
|
83
|
-
| "\(.key): file-backed secrets/configs read the host filesystem")
|
|
75
|
+
| "\(.key): file-backed secrets/configs read the host filesystem"),
|
|
76
|
+
($routes | to_entries[] | .value as $r | "route \($r.host)\($r.path // "")" as $route |
|
|
77
|
+
(select($root.services[$r.service] == null)
|
|
78
|
+
| "\($route): no service \($r.service) in the compose files"),
|
|
79
|
+
(select($hosts | index("\($r.host).\($domain)") | not)
|
|
80
|
+
| "\($route): \($r.host).\($domain) is not one of this app'"'"'s hosts (kayra apps registers new ones)"))
|
|
84
81
|
' | { violations=$(cat); [ -z "$violations" ] || { echo "$violations"; exit 1; }; }
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function ee(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function te(e,t){this.props=e,this.context=t}function C(e,t){if(t==null)return e.__?C(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?C(e):null}function w(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=y({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),se(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??C(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,le(i,o,a),n.__e=n.__=null,o.__e!=r&&T(o)}}function T(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),T(e)}function E(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!D.__r++||a!=t.debounceRendering)&&((a=t.debounceRendering)||o)(D)}function D(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,w(e)}finally{i.length=D.__r=0}}function ne(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,ee=t.length;for(c=O(n,t,y,c,ee),d=0;d<ee;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=se(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&fe(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=re(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function O(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):v(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ie(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=C(s)),pe(s,s));return r}function re(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=re(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=C(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ie(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ae(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function k(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ae(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ae(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[u]=r[u]:(n[u]=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function oe(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[l]==null)n[l]=f++;else if(n[l]<r[u])return;return r(t.event?t.event(n):n)}}}function se(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,b,x,w,T,E,D,O,re,ie,ae,k=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=n.__e=r.__e]),(d=t.__b)&&d(n);n:if(typeof k==`function`){f=s.length;try{if(w=n.props,T=k.prototype&&k.prototype.render,E=(d=k.contextType)&&i[d.__c],D=d?E?E.props.value:d.__:i,r.__c?x=(p=n.__c=r.__c).__=p.__E:(T?n.__c=p=new k(w,D):(n.__c=p=new te(w,D),p.constructor=k,p.render=me),E&&E.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),T&&p.__s==null&&(p.__s=p.state),T&&k.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,k.getDerivedStateFromProps(w,p.__s))),h=p.props,_=p.state,p.__v=n,m)T&&k.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),T&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(T&&k.getDerivedStateFromProps==null&&w!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(w,D),n.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(w,p.__s,D)){n.__v!=r.__v&&(p.props=w,p.state=p.__s,p.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),g.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=C(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(w,p.__s,D),T&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,b)})}if(p.context=D,p.props=w,p.__P=e,p.__e=!1,O=t.__r,re=0,T)p.state=p.__s,p.__d=!1,O&&O(n),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,O&&O(n),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++re<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),T&&!m&&p.getSnapshotBeforeUpdate!=null&&(b=p.getSnapshotBeforeUpdate(h,_)),ie=d!=null&&d.type===S&&d.key==null?ue(d.props.children):d,c=ne(e,v(ie)?ie:[ie],n,r,i,a,o,s,c,l,u),p.base=n.__e,n.__u&=-161,p.__h.length&&s.push(p),x&&(p.__E=p.__=null)}catch(e){if(s.length=f,n.__v=null,l||o!=null){if(e.then){for(n.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),n.__e=c}else if(o!=null)for(ae=o.length;ae--;)ee(o[ae])}else n.__e=r.__e;n.__k??=r.__k||[],e.then||ce(n),t.__e(e,n,r)}}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=de(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function ce(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ce))}function le(e,n,r){for(var i=0;i<r.length;i++)fe(r[i],r[++i],r[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function ue(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ue):e.constructor===void 0?y({},e):null}function de(n,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,b=i.props||h,x=r.props,S=r.type;if(S==`svg`?o=`http://www.w3.org/2000/svg`:S==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!S&&(S?g.localName==S:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(S==null)return document.createTextNode(x);n=document.createElementNS(o,S,x.is&&x),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(S==null)b===x||l&&n.data==x||(n.data=x);else{if(s=S==`textarea`&&x.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(b={},d=0;d<n.attributes.length;d++)b[(g=n.attributes[d]).name]=g.value;for(d in b)g=b[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in x||d==`value`&&`defaultValue`in x||d==`checked`&&`defaultChecked`in x||k(n,d,null,g,o);for(d in x)g=x[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||b[d]===g||k(n,d,g,b[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),r.__k=[];else if(p&&(n.innerHTML=``),ne(r.type==`template`?n.content:n,v(m)?m:[m],r,i,a,S==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&C(i,0),l,u),s!=null)for(d=s.length;d--;)ee(s[d]);l&&S!=`textarea`||(d=`value`,S==`progress`&&_==null?n.removeAttribute(`value`):_!=null&&(_!==n[d]||S==`progress`&&!_||S==`option`&&_!=b[d])&&k(n,d,_,b[d],o),d=`checked`,y!=null&&y!=n[d]&&k(n,d,y,b[d],o))}return n}function fe(e,n,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&n==null||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,r)}}function pe(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||fe(i,null,n)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){t.__e(e,n)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&pe(i[a],n,r||typeof e.type!=`function`);r||ee(e.__e),e.__c=e.__=e.__e=void 0}function me(e,t,n){return this.constructor(e,n)}function he(n,r,i){var a,o,s,c;r==document&&(r=document.documentElement),t.__&&t.__(n,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],se(r,n=(!a&&i||r).__k=b(S,null,[n]),o||h,h,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?e.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),le(s,n,c),n.props.children=null}e=g.slice,t={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},n=0,r=function(e){return e!=null&&e.constructor===void 0},te.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),E(this))},te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),E(this))},te.prototype.render=S,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},D.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=oe(!1),m=oe(!0);var ge,A,_e,ve,ye=0,be=[],j=t,xe=j.__b,Se=j.__r,Ce=j.diffed,we=j.__c,Te=j.unmount,Ee=j.__;function De(e,t){j.__h&&j.__h(A,e,ye||t),ye=0;var n=A.__H||(A.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function M(e){return ye=1,Oe(Le,e)}function Oe(e,t,n){var r=De(ge++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Le(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=A,!A.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};A.__f=!0;var a=A.shouldComponentUpdate,o=A.componentWillUpdate;A.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},A.shouldComponentUpdate=i}return r.__N||r.__}function N(e,t){var n=De(ge++,3);!j.__s&&Ie(n.__H,t)&&(n.__=e,n.u=t,A.__H.__h.push(n))}function ke(e){return ye=5,Ae(function(){return{current:e}},[])}function Ae(e,t){var n=De(ge++,7);return Ie(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function je(){for(var e;e=be.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Pe),t.__h.some(Fe),t.__h=[]}catch(n){t.__h=[],j.__e(n,e.__v)}}}j.__b=function(e){A=null,xe&&xe(e)},j.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ee&&Ee(e,t)},j.__r=function(e){Se&&Se(e),ge=0;var t=(A=e.__c).__H;t&&(_e===A?(t.__h=[],A.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Pe),t.__h.some(Fe),t.__h=[],ge=0)),_e=A},j.diffed=function(e){Ce&&Ce(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(be.push(t)!==1&&ve===j.requestAnimationFrame||((ve=j.requestAnimationFrame)||Ne)(je)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),_e=A=null},j.__c=function(e,t){t.some(function(e){try{e.__h.some(Pe),e.__h=e.__h.filter(function(e){return!e.__||Fe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],j.__e(n,e.__v)}}),we&&we(e,t)},j.unmount=function(e){Te&&Te(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Pe(e)}catch(e){t=e}}),n.__H=void 0,t&&j.__e(t,n.__v))};var Me=typeof requestAnimationFrame==`function`;function Ne(e){var t,n=function(){clearTimeout(r),Me&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Me&&(t=requestAnimationFrame(n))}function Pe(e){var t=A,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),A=t}function Fe(e){var t=A;e.__c=e.__(),A=t}function Ie(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Le(e,t){return typeof t==`function`?t(e):t}var Re=Symbol.for(`preact-signals`);function ze(){if(F>1)F--;else{var e,t=!1;for((function(){var e=qe;for(qe=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();Ue!==void 0;){var n=Ue;for(Ue=void 0,We++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Xe(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(We=0,F--,t)throw e}}function Be(e){if(F>0)return e();Ke=++Ge,F++;try{return e()}finally{ze()}}var Ve,P=void 0;function He(e){var t=P,n=Ve;P=void 0,Ve=void 0;try{return e()}finally{P=t,Ve=n}}var Ue=void 0,F=0,We=0,Ge=0,Ke=0,qe=void 0,Je=0;function Ye(e){if(P!==void 0){var t=e.n;if(t===void 0||t.t!==P)return t={i:0,S:e,p:P.s,n:void 0,t:P,e:void 0,x:void 0,r:t},P.s!==void 0&&(P.s.n=t),P.s=t,e.n=t,32&P.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=P.s,t.n=void 0,P.s.n=t,P.s=t),t}}function I(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}I.prototype.brand=Re,I.prototype.h=function(){return!0},I.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?He(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},I.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&He(function(){var e;(e=t.Z)==null||e.call(t)}))}},I.prototype.subscribe=function(e){var t=this;return rt(function(){var n=t.value;He(function(){return e(n)})},{name:`sub`})},I.prototype.valueOf=function(){return this.value},I.prototype.toString=function(){return this.value+``},I.prototype.toJSON=function(){return this.value},I.prototype.peek=function(){var e=this;return He(function(){return e.value})},Object.defineProperty(I.prototype,"value",{get:function(){var e=Ye(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(We>100)throw Error(`Cycle detected`);(function(e){F!==0&&We===0&&e.l!==Ke&&(e.l=Ke,qe={S:e,v:e.v,i:e.i,o:qe})})(this),this.v=e,this.i++,Je++,F++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ze()}}}});function L(e,t){return new I(e,t)}function Xe(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ze(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Qe(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function R(e,t){I.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Je-1,this.f=4}R.prototype=new I,R.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Je))return!0;if(this.g=Je,this.f|=1,this.i>0&&!Xe(this))return this.f&=-2,!0;var e=P;try{Ze(this),P=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return P=e,Qe(this),this.f&=-2,!0},R.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}I.prototype.S.call(this,e)},R.prototype.U=function(e){if(this.t!==void 0&&(I.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},R.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(R.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Ye(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function $e(e,t){return new R(e,t)}function et(e){var t=e.m;if(e.m=void 0,typeof t==`function`){F++;var n=P;P=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,tt(e),t}finally{P=n,ze()}}}function tt(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,et(e)}function nt(e){if(P!==this)throw Error(`Out-of-order effect`);Qe(this),P=e,this.f&=-2,8&this.f&&tt(this),ze()}function z(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Ve&&Ve.push(this)}z.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},z.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,et(this),Ze(this),F++;var e=P;return P=this,nt.bind(this,e)},z.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ue,Ue=this)},z.prototype.d=function(){this.f|=8,1&this.f||tt(this)},z.prototype.dispose=function(){this.d()};function rt(e,t){var n=new z(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var it,at,ot=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,st=[];rt(function(){it=this.N})();function B(e,n){t[e]=n.bind(null,t[e]||function(){})}function ct(e){if(at){var t=at;at=void 0,t()}at=e&&e.S()}function lt(e){var t=this,n=e.data,i=dt(n);i.name=`ReactiveDom`,i.value=n;var a=Ae(function(){for(var e=t,n=t.__v;n=n.__;)if(n.__c){n.__c.__$f|=4;break}var a=$e(function(){var e=i.value.value;return e===0?0:!0===e?``:e||``}),o=$e(function(){return!Array.isArray(a.value)&&!r(a.value)}),s=rt(function(){if(this.N=mt,o.value){var t=a.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),c=t.__$u.d;return t.__$u.d=function(){s(),c.call(this)},[o,a]},[]),o=a[0],s=a[1];return o.value?s.peek():s.value}lt.displayName=`ReactiveTextNode`,Object.defineProperties(I.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:lt},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),B(`__b`,function(e,t){if(ct(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof I&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),B(`__r`,function(e,t){if(e(t),t.type!==S){ct();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return rt(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;ot&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),ct(n)}}),B(`__e`,function(e,t,n,r){ct(),e(t,n,r)}),B(`diffed`,function(e,t){ct();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=ut(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function ut(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=L(n);return{o:function(e,t){a.value=e,r=t},d:rt(function(){this.N=mt;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}B(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),B(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),te.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function dt(e,t){return Ae(function(){return L(e,t)},[])}var ft=function(e){queueMicrotask(function(){queueMicrotask(e)})};function pt(){Be(function(){for(var e;e=st.shift();)it.call(e)})}function mt(){st.push(this)===1&&(t.requestAnimationFrame||ft)(pt)}var V=e=>e,ht={up:{label:`Up`,icon:`↑`},provision:{label:`Provision`,icon:`+`},deploy:{label:`Deploy`,icon:`↑`},setup:{label:`Setup`,icon:`⚙`},plan:{label:`Plan`,icon:`≡`},verify:{label:`Verify`,icon:`✓`},apps:{label:`Register apps`,icon:`▦`},hosts:{label:`Local hosts`,icon:`⌂`},ssh:{label:`SSH terminal`,icon:`>_`},"ssh.exec":{label:`SSH command`,icon:`>`},down:{label:`Destroy`,icon:`×`},adopt:{label:`Adopt`,icon:`+`},"backup.test":{label:`Test backup`,icon:`✓`},"app.check":{label:`Check app repository`,icon:`✓`},"app.purge":{label:`Purge app data`,icon:`×`},"app.runs":{label:`App runs`,icon:`≡`},"app.log":{label:`App log`,icon:`≡`},"app.deploy":{label:`Deploy app`,icon:`↑`},"app.releases":{label:`App releases`,icon:`≡`},"app.rollback":{label:`Roll back app`,icon:`↶`},job:{label:`Run job`,icon:`▶`},status:{label:`Status`,icon:`●`},validate:{label:`Validate`,icon:`✓`},doctor:{label:`Doctor`,icon:`✓`},certs:{label:`Local certificates`,icon:`◇`},version:{label:`Version`,icon:`i`}},gt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),_t=e=>gt(e)?e:V({}),vt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):V([]),yt=e=>Object.freeze(Object.entries(_t(e.properties)).map(([t,n])=>{let r=_t(n);return{name:t,type:r.type,required:vt(e.required).includes(t),description:typeof r.description==`string`?r.description:``,choices:vt(r.enum),default:r.default,minLength:typeof r.minLength==`number`?r.minLength:void 0,pattern:typeof r.pattern==`string`?r.pattern:void 0,supported:r.type===`string`||r.type===`boolean`||r.type===`array`&&_t(r.items).type===`string`}})),bt=e=>typeof e==`boolean`||typeof e==`string`?e:Array.isArray(e)?vt(e).join(`
|
|
2
|
-
`):V(``),xt=(e,t)=>Object.freeze(Object.fromEntries(yt(e).map(e=>[e.name,bt(t[e.name]??e.default)]))),St=(e,t)=>Object.freeze(Object.fromEntries(yt(e).flatMap(e=>{let n=t[e.name];return e.type===`boolean`?V([[e.name,n===!0]]):V(typeof n!=`string`||n===``?[]:[[e.name,e.type===`array`?n.split(/\r?\n/):n]])}))),Ct=(e,t)=>Object.freeze(e.filter(e=>e.scope===`app`&&t.kind===`platform`||e.scope===`server`&&(t.commands.some(t=>t===e.name)||e.name===`ssh`||e.name===`ssh.exec`||e.name===`hosts`&&t.target===`multipass`))),wt=(e,t)=>{let n=t.toLowerCase().replace(/\s+/g,``);if(n===``)return V(0);let r=e.toLowerCase(),i=Array.from(n).reduce((e,t)=>{if(e===void 0)return;let n=r.indexOf(t,e.at);return n===-1?void 0:{at:n+1,gaps:e.gaps+(e.first===-1?0:n-e.at),first:e.first===-1?n:e.first}},{at:0,gaps:0,first:-1});return i===void 0?void 0:i.gaps*2+i.first+(r.startsWith(n)?-10:0)},Tt=(e,t)=>Object.freeze(e.flatMap(e=>{let n=wt(`${e.label} ${e.hint}`,t);return Object.freeze(n===void 0?[]:[{choice:e,scored:n}])}).toSorted((e,t)=>e.scored-t.scored).map(e=>e.choice)),Et=e=>e,Dt=async(e,t)=>e.ok?V({ok:!0,value:Et(await t(e))}):V({ok:!1,failure:{status:e.status,message:(await e.text()).trim()}}),Ot=async e=>{try{return await e()}catch{return V({ok:!1,failure:{status:0,message:`Cannot reach kayra. Check that kayra serve is still running.`}})}},kt=e=>Ot(()=>fetch(e).then(e=>Dt(e,e=>e.json()))),H=(e,t)=>Ot(async()=>Dt(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),async e=>e.status===204?void 0:e.json())),At=(e,t)=>H(`/api/operations/${e.name}/preview`,{input:e.input,options:t}),jt=(e,t,n)=>H(`/api/operations/${e.name}`,{input:e.input,options:t,...n===void 0?{}:{confirm:n}}),Mt=(e,t={})=>H(`/api/operations/${e}`,{input:t}),Nt=(e,t)=>H(`/api/runs/${encodeURIComponent(e)}/answers`,{text:t}),Pt=e=>H(`/api/runs/${encodeURIComponent(e)}/cancel`,{}),Ft=(e,t)=>H(`/api/sessions/${encodeURIComponent(e)}/input`,{text:t}),It=e=>Ot(async()=>Dt(await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`}),()=>Promise.resolve(void 0))),Lt=()=>kt(`/api/runs`),Rt=(e,t,n,r,i)=>{let a=new AbortController;return(async()=>{let n=await fetch(e,{signal:a.signal,...r===void 0?{}:{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}});if(!n.ok){i?.({status:n.status,message:(await n.text()).trim()});return}if(n.body===null)throw Error(`No stream`);let o=n.body.getReader(),s=new TextDecoder,c={text:``},l=async()=>{let e=await o.read();if(e.done)return;let n=(c.text+s.decode(e.value,{stream:!0})).split(`
|
|
3
|
-
|
|
4
|
-
`);c.text=n.pop()??``,n.forEach(e=>{e.startsWith(`data: `)&&t(Et(JSON.parse(e.slice(6))))}),await l()};await l()})().catch(()=>{a.signal.aborted||i?.({status:0,message:`The connection to kayra was interrupted.`})}).finally(n),()=>{a.abort()}},zt=/^[A-Za-z0-9._-]+$/,Bt=e=>{let t=e.split(`/`).filter(e=>e!==``).map(decodeURIComponent);if(!t.every(e=>zt.test(e)))return V({page:`missing`,path:e});let[n,r,i,a]=t;return n===void 0?V({page:`fleet`}):n===`runs`&&r===void 0?V({page:`runs`}):n===`runs`&&r!==void 0&&i===void 0?V({page:`run`,id:r}):n===`sessions`&&r!==void 0&&i===void 0?V({page:`session`,id:r}):n===`validate`&&r===void 0?V({page:`validate`}):n===`servers`&&r!==void 0&&i===void 0?V({page:`server`,server:r}):n===`servers`&&r!==void 0&&i===`apps`&&a!==void 0&&t.length===4?V({page:`app`,server:r,app:a}):V({page:`missing`,path:e})},Vt=e=>{switch(e.page){case`fleet`:return`/`;case`server`:return`/servers/${encodeURIComponent(e.server)}`;case`app`:return`/servers/${encodeURIComponent(e.server)}/apps/${encodeURIComponent(e.app)}`;case`runs`:return`/runs`;case`run`:return`/runs/${encodeURIComponent(e.id)}`;case`session`:return`/sessions/${encodeURIComponent(e.id)}`;case`validate`:return`/validate`;case`missing`:return e.path}},Ht=L(Bt(location.pathname)),Ut=e=>{history.pushState(null,``,Vt(e)),Ht.value=e,scrollTo({top:0})};addEventListener(`popstate`,()=>{Ht.value=Bt(location.pathname)});var U=L({state:`loading`}),Wt=L({state:`loading`}),Gt=async()=>{let e=await kt(`/api/operations`);Wt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},W=L({value:void 0,live:!1}),Kt=L({state:`loading`}),qt=async()=>{let e=await kt(`/api/fleet`);U.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Jt=()=>{W.value={value:W.value.value,live:!0},Rt(`/api/operations/status`,e=>{W.value={value:e,live:!0}},()=>{W.value={value:W.value.value,live:!1}},{input:{}})},Yt=async()=>{Kt.value={state:`loading`};let e=await Mt(`validate`);Kt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Xt=0;Array.isArray;function G(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}var Zt=(e,t)=>{if(typeof e==`string`)return e;let n=e.tone===void 0?void 0:`tone-${e.tone}`;return e.href===void 0?G(`span`,{class:n,children:e.text},t):G(`a`,{class:n,href:e.href,target:`_blank`,rel:`noreferrer`,children:e.text},t)},Qt=({text:e})=>G(S,{children:(typeof e==`string`?[e]:e).map(Zt)}),$t=({lines:e})=>G(`div`,{class:`lines`,children:e.map((e,t)=>G(`div`,{children:G(Qt,{text:e})},t))}),K=({tone:e,label:t})=>G(`span`,{class:`dot dot-${e}`,title:t,"aria-label":t,role:t===void 0?void 0:`img`}),q=({children:e,tone:t})=>G(`span`,{class:`pill${t===void 0?``:` pill-${t}`}`,children:e}),J=({label:e,cell:t})=>t===void 0?null:G(`div`,{class:`fact`,children:[G(`dt`,{children:e}),G(`dd`,{title:t.title,children:[G(K,{tone:t.tone}),G(`span`,{class:t.tone===`waiting`?`tone-muted`:`tone-${t.tone}`,children:t.text})]})]}),Y=({failure:e})=>G(`div`,{class:`problem`,role:`alert`,children:[G(`strong`,{children:e.status===0?`Connection problem`:`kayra answered ${String(e.status)}`}),G(`pre`,{children:e.message})]}),X=({what:e})=>G(`div`,{class:`waiting`,children:[G(`span`,{class:`spinner`,"aria-hidden":`true`}),` `,e]}),Z=({title:e,sub:t,children:n})=>G(`header`,{class:`page-header`,children:[G(`div`,{children:[G(`h1`,{children:e}),t===void 0?null:G(`div`,{class:`sub`,children:t})]}),n===void 0?null:G(`div`,{class:`actions`,children:n})]}),en=({initial:e,choose:t,close:n})=>{let[r,i]=M(e===``?`.`:e),[a,o]=M(void 0);return N(()=>{let e={current:!1};return o(void 0),kt(`/api/directories?path=${encodeURIComponent(r)}`).then(t=>{e.current||o(t)}),()=>{e.current=!0}},[r]),G(`section`,{class:`directory-picker`,"aria-label":`Choose a local directory`,children:[G(`div`,{class:`buttons`,children:[G(`strong`,{children:`Choose a local directory`}),G(`button`,{type:`button`,class:`button small`,onClick:n,children:`Close picker`})]}),a===void 0?G(X,{what:`Reading directories`}):a.ok?G(S,{children:[G(`code`,{class:`directory-path`,children:a.value.path}),G(`ul`,{class:`directory-list`,children:[a.value.parent===a.value.path?null:G(`li`,{children:G(`button`,{type:`button`,onClick:()=>{i(a.value.parent)},children:`↑ Parent directory`})}),a.value.directories.map(e=>G(`li`,{children:G(`button`,{type:`button`,onClick:()=>{i(e.path)},children:[`▸ `,e.name]})},e.path))]}),G(`button`,{type:`button`,class:`button`,onClick:()=>{t(a.value.path)},children:`Use this directory`})]}):G(Y,{failure:a.failure})]})},tn=L(void 0),nn=(e,t={})=>{tn.value={name:e,input:t}},rn=e=>{nn(e.name,Object.fromEntries(Object.entries(e).filter(([e])=>e!==`name`)))},Q=()=>{tn.value=void 0},an=({step:e})=>G(`li`,{class:`plan-step`,children:[G(`span`,{class:`plan-index`,children:e.index+1}),G(`div`,{children:[G(`div`,{class:`plan-title`,children:[G(q,{tone:e.kind===`guard`?`warn`:e.kind===`confirm`?`bad`:`active`,children:e.kind}),` `,e.title]}),e.command===void 0?null:G(`code`,{class:`plan-command`,children:e.command})]})]}),on=({field:e,value:t,change:n,server:r})=>{let[i,a]=M(!1),o=U.value,s=o.state===`ready`?o.value.servers:[],c=typeof t==`string`?t:``,l=`operation-${e.name}`;return e.type===`boolean`?G(`label`,{class:`toggle`,children:[G(`input`,{type:`checkbox`,checked:t===!0,onChange:e=>{n(e.currentTarget.checked)}}),e.description||e.name]}):G(`div`,{class:`operation-field`,children:[G(`label`,{for:l,children:[e.name,e.required?``:` (optional)`]}),e.name===`server`||e.choices.length>0?G(`select`,{id:l,required:e.required,value:c,onChange:e=>{n(e.currentTarget.value)},children:[G(`option`,{value:``,children:e.required?`Choose…`:`All servers`}),(e.name===`server`?s.map(e=>e.name):e.choices).map(e=>G(`option`,{value:e,children:e},e))]}):e.type===`array`?G(`textarea`,{id:l,rows:3,value:c,required:e.required,placeholder:`One item per line`,onInput:e=>{n(e.currentTarget.value)}}):G(`div`,{class:`inline`,children:[G(`input`,{id:l,value:c,required:e.required,minLength:e.minLength,pattern:e.pattern,list:e.name===`app`?`operation-apps`:void 0,spellcheck:!1,onInput:e=>{n(e.currentTarget.value)}}),e.name===`dir`?G(`button`,{type:`button`,class:`button`,onClick:()=>{a(!i)},children:`Browse…`}):null]}),e.name===`app`?G(`datalist`,{id:`operation-apps`,children:s.find(e=>e.name===r)?.apps.map(e=>G(`option`,{value:e},e))}):null,e.description===``?null:G(`span`,{class:`hint`,children:e.description}),e.type===`array`?G(`span`,{class:`hint`,children:[`One `,e.name===`command`?`argument`:`item`,` per line. Spaces within a line are preserved.`]}):null,i?G(en,{initial:c,close:()=>{a(!1)},choose:e=>{n(e),a(!1)}}):null]})},sn=({info:e,seed:t,options:n,submit:r})=>{let[i,a]=M(()=>xt(e.input,t.input)),[o,s]=M(n.verbose??!1),[c,l]=M(n.dryRun??!1),u=e.kind===`plan`||e.kind===`session`,d=yt(e.input),f=d.some(e=>!e.supported);return G(`form`,{onSubmit:t=>{t.preventDefault(),r({draft:{name:e.name,input:St(e.input,i)},options:{verbose:o,dryRun:c}})},children:[G(`div`,{class:`sheet-body operation-fields`,children:[d.map(e=>G(on,{field:e,value:i[e.name]??``,server:i.server,change:t=>{a({...i,[e.name]:t})}},e.name)),f?G(`p`,{role:`alert`,children:`This operation has an unsupported input. Update the UI before running it.`}):null,u?G(`fieldset`,{class:`run-options`,children:[G(`legend`,{children:`Run options`}),G(`label`,{class:`toggle`,children:[G(`input`,{type:`checkbox`,checked:o,onChange:e=>{s(e.currentTarget.checked)}}),`Verbose output`]}),G(`label`,{class:`toggle`,children:[G(`input`,{type:`checkbox`,checked:c,onChange:e=>{l(e.currentTarget.checked)}}),`Dry run — preview only`]})]}):null]}),G(`div`,{class:`sheet-foot buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:Q,children:`Cancel`}),G(`button`,{type:`submit`,class:`button primary`,disabled:f,children:u?`Preview plan`:`Run query`})]})]})},cn=e=>{let t=U.value,n=t.state===`ready`?t.value.servers.find(t=>t.name===e.input.server):void 0;return n?.target===`multipass`?void 0:n?.name},ln=({prepared:e,back:t})=>{let{draft:n,options:r}=e,[i,a]=M(void 0),[o,s]=M(``),[c,l]=M(void 0);if(N(()=>{At(n,r).then(a)},[e]),i===void 0)return G(`div`,{class:`sheet-body`,children:G(X,{what:`Planning`})});if(!i.ok)return G(`div`,{class:`sheet-body`,children:[G(Y,{failure:i.failure}),G(`button`,{class:`button`,onClick:t,children:`Edit inputs`})]});let{invocation:u,steps:d,changes:f}=i.value,p=f&&!r.dryRun?cn(n):void 0,m=p===void 0||o===p,h=async()=>{l(`starting`);let e=await jt(n,r,p===void 0?void 0:o);e.ok?(Q(),Ut(`session`in e.value?{page:`session`,id:e.value.session}:{page:`run`,id:e.value.run})):l(e.failure)};return G(S,{children:[G(`div`,{class:`sheet-body`,children:[G(`code`,{class:`command`,children:u.command}),G(`p`,{class:`sub`,children:[d.length,` steps · `,f?`changes things`:`reads only`,r.verbose?` · verbose`:``,r.dryRun?` · preview only`:``]}),G(`ol`,{class:`plan`,children:d.map(e=>G(an,{step:e},e.index))})]}),G(`form`,{class:`sheet-foot`,onSubmit:e=>{e.preventDefault(),m&&!r.dryRun&&h()},children:[p===void 0?null:G(`label`,{class:`confirm`,children:[G(`span`,{children:[`This changes `,G(`strong`,{children:p}),`, a real server. Type its name to go on:`]}),G(`input`,{value:o,onInput:e=>{s(e.currentTarget.value)},placeholder:p,autoComplete:`off`,spellcheck:!1})]}),c===void 0||c===`starting`?null:G(Y,{failure:c}),G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:t,disabled:c===`starting`,children:`Edit inputs`}),r.dryRun?G(`button`,{type:`button`,class:`button primary`,onClick:Q,children:`Done`}):G(`button`,{type:`submit`,class:p===void 0?`button primary`:`button danger`,disabled:!m||c===`starting`,children:c===`starting`?`Starting…`:n.name===`ssh`?`Open terminal`:`Run`})]})]})]})},un=({prepared:e,info:t,back:n})=>{let[r,i]=M(void 0),[a,o]=M(t.kind===`stream`);return N(()=>{let n={current:!0};return t.kind===`stream`?Rt(`/api/operations/${t.name}`,e=>{i({ok:!0,value:e})},()=>{o(!1)},{input:e.draft.input},e=>{i({ok:!1,failure:e})}):(Mt(t.name,e.draft.input).then(e=>{n.current&&i(e)}),()=>{n.current=!1})},[e]),G(S,{children:[G(`div`,{class:`sheet-body`,children:[r===void 0?G(X,{what:`Asking kayra`}):r.ok?G(`pre`,{class:`query-result`,children:typeof r.value==`string`?r.value:JSON.stringify(r.value,null,2)}):G(Y,{failure:r.failure}),a?G(X,{what:`Receiving updates`}):null]}),G(`div`,{class:`sheet-foot buttons`,children:[G(`button`,{class:`button`,onClick:n,children:`Edit inputs`}),G(`button`,{class:`button`,onClick:Q,children:`Close`})]})]})},dn=({draft:e,info:t})=>{let[n,r]=M(void 0),[i,a]=M({draft:e,options:{}}),o=()=>{n!==void 0&&a(n),r(void 0)};return G(S,{children:[G(`div`,{class:`sheet-head`,children:[G(`h2`,{id:`operation-title`,children:[ht[t.name].icon,` `,ht[t.name].label]}),G(`p`,{class:`sub`,children:t.summary})]}),n===void 0?G(sn,{info:t,seed:i.draft,options:i.options,submit:r}):t.kind===`plan`||t.kind===`session`?G(ln,{prepared:n,back:o}):G(un,{prepared:n,info:t,back:o})]})},fn=()=>{let e=tn.value,t=ke(null),n=e!==void 0;if(N(()=>{if(!n)return;let e=document.activeElement;t.current?.focus();let r=e=>{if(e.key===`Escape`&&Q(),e.key===`Tab`){let n=t.current?.querySelectorAll(`button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled)`),r=n?.[0],i=n?.[n.length-1];r===void 0?e.preventDefault():e.shiftKey&&(document.activeElement===r||document.activeElement===t.current)?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())}};return addEventListener(`keydown`,r),()=>{removeEventListener(`keydown`,r),e instanceof HTMLElement&&e.focus()}},[n]),e===void 0)return null;let r=Wt.value,i=r.state===`ready`?r.value.find(t=>t.name===e.name):void 0;return G(`div`,{class:`overlay`,onClick:Q,children:G(`div`,{ref:t,tabIndex:-1,class:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`operation-title`,onClick:e=>{e.stopPropagation()},children:r.state===`loading`?G(X,{what:`Reading operations`}):r.state===`failed`?G(Y,{failure:r.failure}):i===void 0?G(`p`,{role:`alert`,children:`Operation unavailable.`}):G(dn,{draft:e,info:i},JSON.stringify(e))})})},$=L(!1),pn=()=>{let e=U.value,t=e.state===`ready`?e.value.servers:[],n=Wt.value.state===`ready`?Wt.value.value:[];return V([{label:`Fleet`,hint:`every server`,go:{page:`fleet`}},{label:`Runs`,hint:`what ran from here`,go:{page:`runs`}},{label:`Validate`,hint:`the fleet beyond its schemas`,go:{page:`validate`}},...n.map(e=>V({label:`${e.name} · ${ht[e.name].label}`,hint:e.summary,run:{name:e.name,input:{}}})),...t.flatMap(e=>V([{label:e.name,hint:`${e.kind} on ${e.target}`,go:{page:`server`,server:e.name}},...e.apps.map(t=>V({label:`${e.name}/${t}`,hint:`app`,go:{page:`app`,server:e.name,app:t}})),...Ct(n,e).map(t=>V({label:`${t.name} ${e.name}`,hint:t.summary,run:{name:t.name,input:{server:e.name}}}))]))])},mn=e=>{$.value=!1,`go`in e?Ut(e.go):nn(e.run.name,e.run.input)},hn=()=>{let[e,t]=M(``),[n,r]=M(0),i=ke(null),a=$.value;if(N(()=>{a&&i.current?.focus()},[a]),N(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),$.value=!$.value,t(``),r(0)):e.key===`Escape`&&($.value=!1)};return addEventListener(`keydown`,e),()=>{removeEventListener(`keydown`,e)}},[]),!$.value)return null;let o=Tt(pn(),e).slice(0,12);return G(`div`,{class:`overlay`,onClick:()=>{$.value=!1},children:G(`div`,{class:`palette`,role:`dialog`,"aria-modal":`true`,onClick:e=>{e.stopPropagation()},children:[G(`input`,{ref:i,value:e,placeholder:`Go to, or run…`,spellcheck:!1,onInput:e=>{t(e.currentTarget.value),r(0)},onKeyDown:e=>{if(e.key===`ArrowDown`)r(Math.min(n+1,o.length-1));else if(e.key===`ArrowUp`)r(Math.max(n-1,0));else if(e.key===`Enter`){let e=o[n];e!==void 0&&mn(e)}else return;e.preventDefault()}}),G(`ul`,{children:o.map((e,t)=>G(`li`,{class:t===n?`selected`:void 0,onMouseEnter:()=>{r(t)},onClick:()=>{mn(e)},children:[G(`span`,{children:e.label}),G(`span`,{class:`hint`,children:e.hint})]},e.label))})]})})},gn=()=>{$.value=!0},_n=e=>e===null?``:` · ${String(e)} ms`,vn={pending:`asking`,open:`open`,answered:`answered`,refused:`refused`,"no-answer":`no answer`,unreachable:`unreachable`,"unknown-host":`unknown host`,"bad-certificate":`bad certificate`,failed:`failed`,skipped:`not asked`},yn=e=>{let{state:t,address:n,reason:r}=e.machine;switch(t){case`pending`:return V({text:`asking OpenTofu`,tone:`waiting`});case`found`:return V({text:n??`an address OpenTofu does not give`,tone:n===null?`warn`:`strong`});case`not-provisioned`:return V({text:`not provisioned`,tone:`muted`});case`no-machine`:return V({text:`no machine in its state`,tone:`muted`});case`unreadable`:return V({text:`state unreadable`,tone:`bad`,...r===null?{}:{title:r}})}},bn=e=>{let{state:t,error:n}=e.ssh;switch(t){case`pending`:return V({text:`connecting`,tone:`waiting`});case`open`:return V({text:`port ${String(e.ssh.port)} open${_n(e.ssh.ms)}`,tone:`ok`});case`refused`:return V({text:`off (refused)`,tone:`warn`,title:`Nothing listens: SSH may be on only on demand.`});case`skipped`:return V({text:`not asked`,tone:`muted`});case`answered`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return V({text:vn[t],tone:`bad`,...n===null?{}:{title:n}})}},xn=e=>{let{https:t}=e;if(t!==null)switch(t.state){case`pending`:return V({text:`asking`,tone:`waiting`});case`answered`:return V({text:`HTTP ${String(t.status??`?`)}${_n(t.ms)}`,tone:t.status!==null&&t.status<400?`ok`:`bad`});case`skipped`:return V({text:`not asked`,tone:`muted`});case`open`:case`refused`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return V({text:vn[t.state],tone:`bad`,...t.error===null?{}:{title:t.error}})}},Sn=e=>{if(e===void 0)return V(`waiting`);let t=[yn(e),bn(e),xn(e)].flatMap(e=>Object.freeze(e===void 0?[]:[e.tone]));return t.includes(`waiting`)?V(`waiting`):t.includes(`bad`)?V(`bad`):t.includes(`warn`)?V(`warn`):t.includes(`ok`)?V(`ok`):V(`muted`)},Cn=({to:e,children:t,class:n})=>G(`a`,{href:Vt(e),class:n,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),Ut(e))},children:t}),wn=(e,t)=>Vt(e)===Vt(t),Tn=({to:e,label:t})=>G(Cn,{to:e,class:wn(Ht.value,e)?`nav-item current`:`nav-item`,children:t}),En=()=>{let e=U.value;if(e.state!==`ready`)return null;let t=Ht.value;return G(`nav`,{class:`servers`,"aria-label":`Servers`,children:[G(`div`,{class:`nav-title`,children:`Servers`}),e.value.servers.map(e=>G(Cn,{to:{page:`server`,server:e.name},class:`server`in t&&t.server===e.name?`nav-item current`:`nav-item`,children:[G(K,{tone:Sn(W.value.value?.servers.find(t=>t.name===e.name))}),G(`span`,{children:e.name}),G(`span`,{class:`nav-meta`,children:e.kind})]},e.name))]})},Dn=({children:e})=>{let t=U.value;return G(`div`,{class:`shell`,children:[G(`aside`,{class:`sidebar`,children:[G(Cn,{to:{page:`fleet`},class:`brand`,children:[G(`span`,{class:`logo`,"aria-hidden":`true`,children:`k`}),G(`span`,{children:[G(`strong`,{children:`kayra`}),G(`span`,{class:`brand-sub`,children:t.state===`ready`?t.value.fleet:`…`})]})]}),G(`nav`,{"aria-label":`Pages`,children:[G(Tn,{to:{page:`fleet`},label:`Fleet`}),G(Tn,{to:{page:`runs`},label:`Runs`}),G(Tn,{to:{page:`validate`},label:`Validate`})]}),G(En,{}),G(`div`,{class:`sidebar-foot`,children:t.state===`ready`?`kayra ${t.value.version}`:``})]}),G(`main`,{class:`main`,children:e})]})},On=e=>{let t=Math.max(0,e)/1e3;if(t<10)return`${(Math.floor(t*10)/10).toFixed(1)}s`;if(t<60)return`${String(Math.floor(t))}s`;let n=Math.floor(t/60);return n<60?`${String(n)}m${String(Math.floor(t%60)).padStart(2,`0`)}s`:`${String(Math.floor(n/60))}h${String(n%60).padStart(2,`0`)}m`},kn=e=>{let t=Math.floor(Math.max(0,e)/1e3);if(t<10)return`just now`;if(t<60)return`${String(t)}s ago`;let n=Math.floor(t/60);if(n<60)return`${String(n)}m ago`;let r=Math.floor(n/60);return r<48?`${String(r)}h ago`:`${String(Math.floor(r/24))}d ago`},An=e=>Date.parse(e),jn=(e,t)=>{let[n,r]=M(void 0),i=()=>{r(void 0),e().then(r)};return N(i,[t]),V([n,i])},Mn=e=>e===`success`?`ok`:e===`failure`?`bad`:`waiting`,Nn=({server:e,app:t,open:n})=>{let[r]=jn(()=>Mt(`app.runs`,{server:e,app:t}),`${e}/${t}`);if(r===void 0)return G(X,{what:`Asking the deployer`});if(!r.ok)return G(Y,{failure:r.failure});let i=Date.now(),{live:a,runs:o}=r.value;return G(S,{children:[G(`p`,{class:`sub`,children:a===void 0?`Not deployed yet.`:`Live: ${a.sha.slice(0,7)} since ${kn(i-Date.parse(a.time))}`}),G(`table`,{class:`table`,children:[G(`thead`,{children:G(`tr`,{children:[G(`th`,{}),G(`th`,{children:`Commit`}),G(`th`,{children:`Why`}),G(`th`,{children:`What`}),G(`th`,{class:`right`,children:`When`}),G(`th`,{class:`right`,children:`Took`})]})}),G(`tbody`,{children:o.map(e=>G(`tr`,{class:`clickable`,onClick:()=>{n(e.id)},children:[G(`td`,{class:`narrow`,children:G(K,{tone:Mn(e.state),label:e.state})}),G(`td`,{children:G(`code`,{children:e.sha?.slice(0,7)??``})}),G(`td`,{children:e.why}),G(`td`,{children:e.what}),G(`td`,{class:`right tone-muted`,children:kn(i-Date.parse(e.started))}),G(`td`,{class:`right tone-muted`,children:e.finished===void 0?``:On(Date.parse(e.finished)-Date.parse(e.started))})]},e.id))})]})]})},Pn=({server:e,app:t})=>{let[n]=jn(()=>Mt(`app.releases`,{server:e,app:t}),`${e}/${t}`);if(n===void 0)return G(X,{what:`Asking the deployer`});if(!n.ok)return G(Y,{failure:n.failure});let r=Date.now();return G(`ul`,{class:`releases`,children:n.value.releases.map(n=>G(`li`,{children:[G(`code`,{children:n.sha.slice(0,12)}),G(`span`,{class:`tone-muted`,children:kn(r-Date.parse(n.time))}),n.live?G(q,{tone:`ok`,children:`live`}):G(`button`,{class:`button small`,onClick:()=>{rn({name:`app.rollback`,server:e,app:t,sha:n.sha})},children:`Roll back to it`})]},n.sha))})},Fn=e=>{if(/\b(error|failed|fatal|refused)\b/i.test(e))return V(`tone-bad`);if(/\bwarn(ing)?\b/i.test(e))return V(`tone-warn`)},In=({server:e,app:t,run:n})=>{let[r]=jn(()=>Mt(`app.log`,{server:e,app:t,...n===void 0?{}:{run:n}}),`${e}/${t}/${n??``}`);return r===void 0?G(X,{what:`Fetching the log`}):r.ok?G(`pre`,{class:`log`,children:r.value.split(`
|
|
5
|
-
`).map((e,t)=>G(`div`,{class:Fn(e),children:e===``?` `:e},t))}):G(Y,{failure:r.failure})},Ln=({server:e,app:t})=>{let[n,r]=M(`runs`),[i,a]=M(void 0),[o,s]=M(``);return G(S,{children:[G(Z,{title:t,sub:`on ${e}`,children:G(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),rn({name:`app.deploy`,server:e,app:t,...o.trim()===``?{}:{ref:o.trim()}})},children:[G(`input`,{value:o,onInput:e=>{s(e.currentTarget.value)},placeholder:`its ref`,spellcheck:!1,"aria-label":`Branch, tag or commit`}),G(`button`,{type:`submit`,class:`button primary`,children:`Deploy`})]})}),G(`nav`,{class:`tabs`,role:`tablist`,children:[`runs`,`releases`,`log`].map(e=>G(`button`,{role:`tab`,"aria-selected":n===e,class:n===e?`tab current`:`tab`,onClick:()=>{r(e)},children:[e,e===`log`&&i!==void 0?` · ${i}`:``]},e))}),G(`section`,{class:`card`,children:n===`runs`?G(Nn,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?G(Pn,{server:e,app:t}):G(In,{server:e,app:t,run:i})}),G(`p`,{class:`tone-muted small`,children:[`Purging an app's data is irreversible:`,` `,G(`button`,{class:`link danger-link`,onClick:()=>{rn({name:`app.purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},Rn=({server:e})=>{let t=Wt.value;return t.state===`loading`?G(X,{what:`Reading operations`}):t.state===`failed`?G(Y,{failure:t.failure}):G(`div`,{class:`action-grid`,children:(e===void 0?t.value.filter(e=>e.scope===`fleet`||e.scope===`repo`):Ct(t.value,e)).map(t=>G(`button`,{class:`action${t.effect===`destroys`?` danger`:``}`,onClick:()=>{nn(t.name,e===void 0?{}:{server:e.name})},children:[G(`strong`,{children:[G(`span`,{"aria-hidden":`true`,children:ht[t.name].icon}),` `,ht[t.name].label]}),G(`span`,{children:t.summary})]},t.name))})},zn=({facts:e,seen:t})=>G(Cn,{to:{page:`server`,server:e.name},class:`card server-card`,children:[G(`div`,{class:`card-head`,children:[G(K,{tone:Sn(t)}),G(`h2`,{children:e.name}),G(q,{children:e.kind}),G(q,{tone:e.target===`multipass`?`muted`:e.target===`hetzner`?`accent`:`active`,children:e.target})]}),G(`div`,{class:`domain`,children:e.domain}),t===void 0?G(X,{what:`asking`}):G(`dl`,{class:`facts`,children:[G(J,{label:`Address`,cell:yn(t)}),G(J,{label:`SSH`,cell:bn(t)}),G(J,{label:`Login`,cell:xn(t)})]}),e.apps.length===0?null:G(`div`,{class:`chips`,children:e.apps.map(e=>G(q,{children:e},e))})]}),Bn=()=>{let e=U.value;if(e.state===`loading`)return G(X,{what:`Reading the fleet`});if(e.state===`failed`)return G(Y,{failure:e.failure});let{value:t,live:n}=W.value,{servers:r}=e.value,i=r.filter(e=>Sn(t?.servers.find(t=>t.name===e.name))===`ok`).length;return G(S,{children:[G(Z,{title:`Fleet`,sub:G(S,{children:[r.length,` servers · `,t===void 0?`asking each`:`${String(i)} answering everything they were asked`]}),children:G(`button`,{class:`button`,onClick:()=>{Jt()},disabled:n,children:n?`Asking…`:`Ask again`})}),G(`div`,{class:`cards`,children:r.map(e=>G(zn,{facts:e,seen:t?.servers.find(t=>t.name===e.name)},e.name))}),G(`section`,{class:`card`,children:[G(`h2`,{children:`Fleet and local commands`}),G(Rn,{})]})]})},Vn=({id:e,question:t})=>{let[n,r]=M(``),[i,a]=M(!1),[o,s]=M(void 0),c=ke(null);N(()=>{c.current?.focus()},[]);let l=async t=>{a(!0),r(``);let n=await Nt(e,t);n.ok||(s(n.failure),a(!1))};return G(`form`,{class:`ask`,onSubmit:e=>{e.preventDefault(),i||l(n)},children:[G(`label`,{for:`run-answer`,children:G(Qt,{text:t.prompt})}),G(`input`,{id:`run-answer`,ref:c,type:t.secret?`password`:`text`,autoComplete:`off`,value:n,disabled:i,onInput:e=>{r(e.currentTarget.value)},spellcheck:!1}),G(`button`,{type:`submit`,class:`button primary`,disabled:i,children:i?`Sending…`:`Answer`}),G(`button`,{type:`button`,class:`button`,disabled:i,onClick:()=>{l(``)},children:`Decline`}),o===void 0?null:G(Y,{failure:o})]})},Hn={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Un=(e,t,n)=>t===void 0?e:V({...e,steps:e.steps.map((e,r)=>r===t?n(e):e)}),Wn=(e,t)=>Un(e,e.current,e=>({...e,said:[...e.said,t]})),Gn=(e,t,n)=>{switch(t.kind){case`plan`:return V({...e,invocation:t.invocation,steps:t.steps.map(e=>({listed:e,state:`waiting`,said:[]}))});case`started`:return Un({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Un(e,t.index,e=>({...e,state:t.failed?`failed`:t.stopped?`stopped`:`passed`,ms:t.ms,...t.why===void 0?{}:{why:t.why}}));case`ended`:{let n={failures:t.failures,ms:t.ms,footer:t.footer,...t.stop===void 0?{}:{stop:t.stop}};return V({...e,asking:void 0,ended:n,steps:e.steps.map((e,n)=>e.state===`running`||t.stop?.why===`interrupted`&&t.stop.index===n?{...e,state:`stopped`}:e.state===`waiting`?{...e,state:`skipped`}:e)})}case`output`:return Wn(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Wn(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return V({...e,asking:t});case`answered`:return V({...e,asking:void 0})}},Kn=e=>{let{ended:t}=e;return t===void 0?V(`running`):t.stop?.why===`interrupted`?V(`interrupted`):t.stop?.why===`declined`?V(`declined`):t.failures===0?V(`passed`):V(`failed`)},qn={fg:void 0,bold:!1,dim:!1},Jn=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Yn=(e,t)=>{let n=t===``?[0]:t.split(`;`).map(Number),r=(e,t)=>{let[n,...i]=t;return n===void 0?e:n===38||n===48?r(e,i[0]===5?i.slice(2):i[0]===2?i.slice(4):i):r(n===0?qn:n===1?{...e,bold:!0}:n===2?{...e,dim:!0}:n===22?{...e,bold:!1,dim:!1}:n===39?{...e,fg:void 0}:n>=30&&n<=37?{...e,fg:Jn[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${Jn[n-90]??`white`}`}:e,i)};return r(e,n)},Xn=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),Zn=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,Qn=e=>{let t=[...e.matchAll(Zn)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:Xn(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:Yn(t.look,a),at:n.index+n[0].length}},{out:[],look:qn,at:0}),n=e.slice(t.at);return n===``?t.out:V([...t.out,{text:n,classes:Xn(t.look)}])},$n={running:`active`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},er={waiting:`○`,running:``,passed:`✓`,failed:`✗`,stopped:`■`,skipped:`–`},tr=({step:e})=>G(`div`,{class:`output`,children:e.said.map((e,t)=>e.kind===`output`?G(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:Qn(e.chunk).map((e,t)=>G(`span`,{class:e.classes===``?void 0:e.classes,children:e.text},t))},t):G(`div`,{class:e.stream===`err`?`said said-err`:`said`,children:G(Qt,{text:e.text})},t))}),nr=({step:e,now:t})=>{let n=e.state===`running`||e.state===`failed`,r=e.ms??(e.started===void 0?void 0:t-e.started),i=e.said.length===0?null:G(tr,{step:e});return G(`details`,{class:`step step-${e.state}`,open:n,children:[G(`summary`,{children:[G(`span`,{class:`step-icon`,children:e.state===`running`?G(`span`,{class:`spinner`}):er[e.state]}),G(`span`,{class:`step-title`,children:e.listed.title}),G(`span`,{class:`step-kind`,children:e.listed.kind}),G(`span`,{class:`step-time`,children:[e.why===void 0?``:`${e.why} · `,r===void 0?``:On(r)]})]}),i]})},rr=({id:e})=>{let[t,n]=Oe((e,t)=>Gn(e,t,Date.now()),Hn),[r,i]=M(Date.now()),[a,o]=M(void 0);N(()=>Rt(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0,void 0,o),[e]);let s=Kn(t)===`running`;N(()=>{if(!s)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[s]);let{invocation:c,steps:l,ended:u,asking:d}=t;if(c===void 0)return a===void 0?G(X,{what:`Starting`}):G(Y,{failure:a});let f=Kn(t);return G(S,{children:[G(Z,{title:G(`code`,{class:`command`,children:c.command}),sub:`${c.about.join(` · `)} · ${String(l.length)} steps`,children:[G(q,{tone:$n[f],children:f}),s?G(`button`,{class:`button danger`,onClick:()=>{Pt(e).then(e=>{e.ok||o(e.failure)})},children:`Stop`}):null]}),a===void 0?null:G(Y,{failure:a}),d===void 0?null:G(Vn,{id:e,question:d},JSON.stringify(d)),G(`div`,{class:`timeline`,children:l.map(e=>G(`div`,{children:[e.listed.opens===void 0?null:G(`h3`,{class:`part`,children:e.listed.opens}),G(nr,{step:e,now:r})]},e.listed.index))}),u===void 0?null:G(`footer`,{class:`run-footer tone-border-${$n[f]}`,children:G($t,{lines:u.footer})})]})},ir={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},ar=({server:e})=>{let[t,n]=M(void 0);if(N(()=>{let e=()=>{Lt().then(n)};e();let t=setInterval(e,3e3);return()=>{clearInterval(t)}},[]),t===void 0)return G(X,{what:`Reading the runs`});if(!t.ok)return G(Y,{failure:t.failure});let r=t.value.filter(t=>e===void 0||t.server===e);if(r.length===0)return G(`p`,{class:`empty`,children:`Nothing run from here yet.`});let i=Date.now();return G(`table`,{class:`table`,children:G(`tbody`,{children:r.map(e=>G(`tr`,{children:[G(`td`,{class:`narrow`,children:G(K,{tone:ir[e.state],label:e.state})}),G(`td`,{children:G(Cn,{to:{page:e.session?`session`:`run`,id:e.id},children:G(`code`,{children:e.command})})}),G(`td`,{class:`tone-${ir[e.state]===`waiting`?`active`:ir[e.state]}`,children:e.state}),G(`td`,{class:`tone-muted right`,children:kn(i-An(e.started))})]},e.id))})})},or=()=>G(S,{children:[G(Z,{title:`Runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs`}),G(`section`,{class:`card`,children:G(ar,{})})]}),sr=({name:e})=>{let t=U.value;if(t.state!==`ready`)return G(X,{what:`Reading the fleet`});let n=t.value.servers.find(t=>t.name===e);if(n===void 0)return G(`p`,{class:`empty`,children:[`No server `,e,` in this fleet.`]});let r=W.value.value?.servers.find(t=>t.name===e);return G(S,{children:[G(Z,{title:G(S,{children:[G(K,{tone:Sn(r)}),` `,n.name]}),sub:G(S,{children:[G(q,{children:n.kind}),` `,G(q,{children:n.target}),` `,G(`a`,{href:`https://${n.domain}`,target:`_blank`,rel:`noreferrer`,children:n.domain})]})}),G(`div`,{class:`columns`,children:[G(`section`,{class:`card`,children:[G(`h2`,{children:`Now`}),r===void 0?G(X,{what:`asking`}):G(`dl`,{class:`facts`,children:[G(J,{label:`Address`,cell:yn(r)}),G(J,{label:`SSH`,cell:bn(r)}),G(J,{label:`Login`,cell:xn(r)})]})]}),G(`section`,{class:`card`,children:[G(`h2`,{children:`Apps`}),n.apps.length===0?G(`p`,{class:`empty`,children:n.kind===`platform`?`None in server.yml.`:`A ${n.kind} server runs no apps.`}):G(`ul`,{class:`links`,children:n.apps.map(e=>G(`li`,{children:G(Cn,{to:{page:`app`,server:n.name,app:e},children:e})},e))})]})]}),G(`section`,{class:`card`,children:[G(`h2`,{children:`Commands`}),G(Rn,{server:n})]}),G(`section`,{class:`card`,children:[G(`h2`,{children:`Runs from here`}),G(ar,{server:n.name})]})]})},cr=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,lr=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,ur={problem:`problems`,unchecked:`partly checked`,passed:`holds`},dr=()=>{N(()=>{Yt()},[]);let e=Kt.value;if(e.state===`loading`)return G(X,{what:`Checking the fleet beyond its schemas`});if(e.state===`failed`)return G(Y,{failure:e.failure});let{result:t,servers:n}=e.value,r=e=>n.flatMap(e=>e.findings).filter(t=>t.result===e).length;return G(S,{children:[G(Z,{title:`Validate`,sub:`Secrets, apps against their contract, stacks, routes · ${String(r(`problem`))} problems · ${String(r(`unchecked`))} not checked`,children:[G(q,{tone:cr(t),children:ur[t]}),G(`button`,{class:`button`,onClick:()=>void Yt(),children:`Check again`})]}),n.map(e=>G(`section`,{class:`card`,children:[G(`div`,{class:`card-head`,children:[G(K,{tone:cr(e.result)}),G(`h2`,{children:e.name}),G(q,{children:e.kind}),G(q,{children:e.target}),G(`span`,{class:`grow`}),G(q,{tone:cr(e.result),children:ur[e.result]})]}),G(`ul`,{class:`findings`,children:e.findings.map((e,t)=>G(`li`,{class:`finding finding-${e.result}`,children:[G(`span`,{class:`glyph tone-${cr(e.result)}`,children:lr(e.result)}),G(`span`,{children:[e.text,e.hint===null?null:G(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},fr=e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.text).join(``),pr=e=>e.kind===`output`?e.chunk:e.kind===`said`?`${fr(e.text)}\r\n`:``,mr=(e,t)=>{let n={current:Promise.resolve(!0)};return r=>{n.current=n.current.then(async n=>{if(!n)return!1;let i=await e(r);return i.ok||t(i.failure),i.ok})}},hr=`modulepreload`,gr=function(e){return`/`+e},_r={},vr=function(e){return e.pathname.endsWith(`.css`)},yr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=gr(t,n);let r=s(t);if(r.href in _r)return;_r[r.href]=!0;let i=vr(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:hr,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},br=({id:e})=>{let t=ke(null),[n,r]=M(void 0),[i,a]=M(void 0),[o,s]=M(`running`),[c,l]=M(void 0),[u,d]=M(!1);N(()=>{let n={current:!0},i={current:()=>void 0};return(async()=>{let{Terminal:o}=await yr(async()=>{let{Terminal:e}=await import(`./xterm-CerOhKYV.js`);return{Terminal:e}},[]);if(!n.current||t.current===null)return;let c=new o({cols:120,rows:32,fontSize:13,cursorBlink:!0,disableStdin:!0,theme:{background:`#0a0a0c`,foreground:`#e4e4e8`}});c.open(t.current),c.focus();let u={current:[]},d={current:!1},f={current:!1},p={current:!1},m=e=>{f.current=!e,c.options.disableStdin=e},h=e=>{p.current=!0,m(!0),l(e)},g=mr(t=>Ft(e,t),h),_=c.onData(e=>{f.current&&g(e)}),v=Rt(`/api/sessions/${encodeURIComponent(e)}/output`,e=>{e.kind===`plan`&&(r(e.invocation),u.current=e.steps),e.kind===`started`&&u.current.find(t=>t.index===e.index)?.kind===`session`&&m(!1),e.kind===`ask`&&(m(!0),a(e)),e.kind===`answered`&&a(void 0);let t=pr(e);t!==``&&c.write(t),e.kind===`ended`&&(d.current=!0,m(!0),s(e.stop?.why===`interrupted`?`interrupted`:e.stop?.why===`declined`?`declined`:e.failures>0||e.stop!==void 0?`failed`:`passed`),c.write(`\r
|
|
6
|
-
[Session ended]\r
|
|
7
|
-
`))},()=>{m(!0),n.current&&!d.current&&!p.current&&l({status:0,message:`Session output disconnected. Reload this page to reconnect.`})},void 0,h);i.current=()=>{v(),_.dispose(),c.dispose()}})().catch(()=>{n.current&&l({status:0,message:`The terminal could not start. Reload this page to reconnect.`})}),()=>{n.current=!1,i.current()}},[e]);let f=async()=>{d(!0);let t=await It(e);t.ok||(l(t.failure),d(!1))};return G(S,{children:[G(Z,{title:n?.command??`SSH terminal`,sub:`120 columns × 32 rows`,children:[G(q,{tone:o===`running`?`active`:o===`passed`?`ok`:`warn`,children:o}),o===`running`?G(`button`,{class:`button danger`,disabled:u,onClick:()=>{f()},children:u?`Closing…`:`Close session`}):null]}),c===void 0?null:G(Y,{failure:c}),i===void 0?null:G(Vn,{id:e,question:i},JSON.stringify(i)),G(`div`,{class:`terminal-scroll`,children:G(`div`,{ref:t,class:`terminal`})}),G(`p`,{class:`hint`,children:`Leaving this page keeps the session open. Use Close session to disconnect.`})]})},xr=()=>{let e=Ht.value;switch(e.page){case`fleet`:return G(Bn,{});case`server`:return G(sr,{name:e.server});case`app`:return G(Ln,{server:e.server,app:e.app});case`runs`:return G(or,{});case`run`:return G(rr,{id:e.id},e.id);case`session`:return G(br,{id:e.id},e.id);case`validate`:return G(dr,{});case`missing`:return G(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},Sr=()=>(N(()=>{qt(),Gt(),Jt()},[]),G(S,{children:[G(Dn,{children:[G(`div`,{class:`topbar`,children:[G(`button`,{class:`search`,onClick:gn,children:[G(`span`,{children:`Go to, or run…`}),G(`kbd`,{children:`⌘K`})]}),G(`button`,{class:`button`,onClick:()=>{rn({name:`doctor`})},children:`Doctor`})]}),G(xr,{})]}),G(fn,{}),G(hn,{})]})),Cr=document.getElementById(`app`);Cr!==null&&he(G(Sr,{}),Cr);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Dynamic Traefik configuration — rate limiting.
|
|
2
|
-
http:
|
|
3
|
-
middlewares:
|
|
4
|
-
# The trial-request endpoint is public and unauthenticated by design: it is
|
|
5
|
-
# how strangers reach the club. That also makes it the one spam vector in
|
|
6
|
-
# the system, so it gets a ceiling.
|
|
7
|
-
#
|
|
8
|
-
# No sourceCriterion: the default keys on the client's remote address,
|
|
9
|
-
# which is correct when Traefik is the edge. An ipStrategy.depth here would
|
|
10
|
-
# expect an X-Forwarded-For chain that does not exist for a direct client,
|
|
11
|
-
# and the limit silently never engages.
|
|
12
|
-
#
|
|
13
|
-
# Values are empirical, not arithmetic: shorter periods did not actually
|
|
14
|
-
# throttle in testing, this regime does. 20 per 10 minutes with a burst of
|
|
15
|
-
# 5 is far more than a human filling in a form once, and caps a spammer at
|
|
16
|
-
# roughly 3k/day.
|
|
17
|
-
trial-ratelimit:
|
|
18
|
-
rateLimit:
|
|
19
|
-
average: 20
|
|
20
|
-
period: "10m"
|
|
21
|
-
burst: 5
|