@yunuseon/kayra 0.22.3 → 0.23.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-release/SKILL.md +3 -1
- package/ansible/roles/platform/defaults/main.yml +4 -0
- package/ansible/roles/platform/tasks/main.yml +19 -0
- package/ansible/roles/platform/templates/apex.yml.j2 +19 -0
- package/cli/dist/browser/assets/index-CYYhXjdE.js +7 -0
- package/cli/dist/browser/index.html +1 -1
- package/cli/dist/core/fleet/settings.js +1 -0
- package/cli/dist/core/validation/findings.js +19 -1
- package/cli/dist/deployer/deployer.js +2 -2
- package/cli/dist/deployer/runs/records.js +7 -2
- package/compose/docker-compose.ci.yml +3 -1
- package/package.json +1 -1
- package/schema/defaults.json +5 -0
- package/schema/vars-platform.json +5 -0
- package/scripts/local/monitor-endpoints.sh +4 -1
- package/scripts/local/verify.sh +5 -0
- package/scripts/platform/registry-gc.sh +1 -1
- package/scripts/platform/resolve-images.sh +1 -1
- package/terraform/modules/platform-dns/main.tf +13 -6
- package/terraform/modules/platform-dns/outputs.tf +1 -1
- package/terraform/modules/platform-dns/tests/fleet/servers/redirecting/server.yml +6 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/redirecting/vars.yml +1 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/redirecting-nested/server.yml +6 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/redirecting-nested/vars.yml +1 -0
- package/terraform/modules/platform-dns/tests/platform-dns.tftest.hcl +30 -0
- package/cli/dist/browser/assets/index-Cjm17KRz.js +0 -7
|
@@ -16,7 +16,9 @@ The user works in the same checkouts in parallel: their own branch,
|
|
|
16
16
|
uncommitted changes, sometimes mid-task. Do all of this in a **separate git
|
|
17
17
|
worktree off `origin/main`**, and run every step with absolute paths inside
|
|
18
18
|
it. Write the steps as one script under `set -euo pipefail` with one command
|
|
19
|
-
per line.
|
|
19
|
+
per line. The worktree gets its own `npm ci`: never a symlink to the
|
|
20
|
+
user's `node_modules`. 0.22.3's `npm ci` in a linked worktree emptied the
|
|
21
|
+
checkout's, and the next lab failed with `ERR_MODULE_NOT_FOUND`. A guard such as `[ -z "$(git status --short)" ] && …` protects only
|
|
20
22
|
what is inside its `&&` chain: anything after a `;` runs regardless, and that
|
|
21
23
|
is how writes once landed in the user's working tree. If a step needs the
|
|
22
24
|
user's checkout (it rarely does here), stop and ask.
|
|
@@ -45,6 +45,10 @@ renovate_token: ""
|
|
|
45
45
|
# people's releases; a server whose repos carry the operator's own images
|
|
46
46
|
# runs it more often, so a new build reaches a PR soon after it is pushed.
|
|
47
47
|
renovate_schedule: "0 4 * * 1"
|
|
48
|
+
# The host the bare domain redirects to, permanently, path and query kept:
|
|
49
|
+
# www sends https://<domain>/x?y to https://www.<domain>/x?y. Empty, the bare
|
|
50
|
+
# domain is not served.
|
|
51
|
+
apex_redirect: ""
|
|
48
52
|
# Push webhooks start a deploy at once; without them, the poll below finds the push.
|
|
49
53
|
webhooks: true
|
|
50
54
|
deploy_poll: "17 * * * *"
|
|
@@ -81,6 +81,25 @@
|
|
|
81
81
|
become: true
|
|
82
82
|
register: platform_files
|
|
83
83
|
|
|
84
|
+
# Rendered beside the copied dynamic/ files, which the copy never deletes:
|
|
85
|
+
# gone again when apex_redirect is unset.
|
|
86
|
+
- name: Render the bare domain's redirect
|
|
87
|
+
ansible.builtin.template:
|
|
88
|
+
src: apex.yml.j2
|
|
89
|
+
dest: "{{ platform_dir }}/traefik/dynamic/apex.yml"
|
|
90
|
+
owner: deploy
|
|
91
|
+
group: deploy
|
|
92
|
+
mode: "0644"
|
|
93
|
+
when: apex_redirect | length > 0
|
|
94
|
+
become: true
|
|
95
|
+
|
|
96
|
+
- name: Remove the bare domain's redirect
|
|
97
|
+
ansible.builtin.file:
|
|
98
|
+
path: "{{ platform_dir }}/traefik/dynamic/apex.yml"
|
|
99
|
+
state: absent
|
|
100
|
+
when: apex_redirect | length == 0
|
|
101
|
+
become: true
|
|
102
|
+
|
|
84
103
|
# The deployer's code and the scripts it and the builder run, into the build
|
|
85
104
|
# context of both images: a checkout's TypeScript, or the published package's
|
|
86
105
|
# JavaScript (Node strips types only outside node_modules).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# The bare domain, {{ domain }}: a permanent redirect to {{ apex_redirect }}.{{ domain }},
|
|
2
|
+
# path and query kept (apex_redirect in vars.yml). Its certificate comes like
|
|
3
|
+
# every other host's; plain HTTP reaches it through the web entrypoint's
|
|
4
|
+
# redirect to HTTPS first, as HSTS preloading wants.
|
|
5
|
+
http:
|
|
6
|
+
routers:
|
|
7
|
+
apex:
|
|
8
|
+
rule: "Host(`{{ domain }}`)"
|
|
9
|
+
entryPoints: [websecure]
|
|
10
|
+
tls:
|
|
11
|
+
certResolver: le
|
|
12
|
+
middlewares: [apex-redirect]
|
|
13
|
+
service: noop@internal
|
|
14
|
+
middlewares:
|
|
15
|
+
apex-redirect:
|
|
16
|
+
redirectRegex:
|
|
17
|
+
regex: "^https?://[^/]+(.*)$"
|
|
18
|
+
replacement: "https://{{ apex_redirect }}.{{ domain }}${1}"
|
|
19
|
+
permanent: true
|
|
@@ -0,0 +1,7 @@
|
|
|
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(i|n|o|s|text|space)$/,m=Array.isArray,h=f.slice,g=Object.assign;function _(e){e&&e.parentNode&&e.remove()}function v(n,r,i,a,o){var s={type:n,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++t,__i:-1,__u:0};return!o&&e.vnode&&e.vnode(s),s}function y(e){return e.children}function b(e,t){this.props=e,this.context=t,this.__g=0}function x(e,t){if(t==null)return e.__&&x(e.__,e.__i+1);for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:x(e)}function S(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),S(e)}function C(t){(8&t.__g||(t.__g|=8,r.push(t),a++))&&i==e.debounceRendering||((i=e.debounceRendering)||queueMicrotask)(w)}function w(){var t,n,s,c,l,u,d,f,p;try{for(n=1;r.length;)r.length>n&&r.sort(o),t=r.shift(),n=r.length,8&t.__g&&(c=void 0,l=void 0,u=(l=(s=t).__v).__e,d=[],f=[],(p=s.__P)&&((c=g({constructor:void 0},l)).__v=l.__v+1,e.vnode&&e.vnode(c),ne(p,c,l,s.__n,p.namespaceURI,32&l.__u?[u]:null,d,u||x(l),32&l.__u,f),c.__v=l.__v,c.__.__k[c.__i]=c,ae(d,c,f),l.__=l.__e=null,c.__e!=u&&S(c)))}finally{(a=r.length)&&(i||queueMicrotask)(w)}}function ee(e,t,n,r,i,a,o,s,c,l,u){var p,m,h,g,_,v,y=r.__k||f,b=t.length;for(c=T(n,t,y,c,b),p=0;p<b;p++)(h=n.__k[p])!=null&&(m=~h.__i&&y[h.__i]||d,h.__i=p,v=ne(e,h,m,i,a,o,s,c,l,u),g=h.__e,(m.ref!=h.ref||8&m.__u)&&(m.ref&&A(m.ref,null,h,m),h.ref&&u.push(h.ref,h.__c||g,h)),_||=g,4&h.__u?(c=E(h,c,e,!m.__v),m.__e&&(m.__e=null)):typeof h.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),h.__u&=-21);return n.__e=_,c}function T(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,h=n.length,g=h,_=0,b=0,S=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=S[a]=v(null,o):m(o)?o=S[a]=v(y,{children:o}):o.constructor===void 0&&o.__b?o=S[a]=v(o.type,o.props,o.key,o.ref,o.__v):S[a]=o,c=a+_,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=D(o,n,c,g))&&(g--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=16,l==c-1?_--:l==c+1?_++:l!=c&&(l>c?_--:_++,b=1)):(~l||(i>h?_--:i<h&&_++),typeof o.type!=`function`&&(o.__u|=4))):S[a]=null;if(b){for(u=[],d=[],a=0;a<i;a++)if((o=S[a])&&16&o.__u){for(_=0,f=u.length;_<f;)u[p=_+f>>1]<o.__i?_=p+1:f=p;u[_]=o.__i,d[a]=_+1}for(_=u.length;a--;)d[a]&&(d[a]==_?_--:S[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=x(s)),se(s,s));return r}function E(e,t,n,r){var i,a,o,s;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=E(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=x(e))&&!t.parentNode&&(t=null),o=e.__e,s=t;s&&s.nodeType==8;)s=s.nextSibling;for(o!=s&&(!r&&n.moveBefore&&o.parentNode?n.moveBefore(o,t):n.insertBefore(o,t||null)),t=o;(t&&=t.nextSibling)&&t.nodeType==8&&!t.data.startsWith(`$s`););return t}function D(e,t,n,r){var i,a=e.key,o=e.type,s=t[n],c=s&&!(2&s.__u);if(s===null&&a==null||c&&a==s.key&&o==s.type)return n;if(r>+!!c){for(i=n-1;i>=0;i--)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i;for(i=n+1;i<t.length;i++)if((s=t[i])&&!(2&s.__u)&&a==s.key&&o==s.type)return i}return-1}function O(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function k(e,t,n,r,i){var a,o;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||O(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||O(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=u[t]||(u[t]=te(t)),(e.__a||={})[t]=l,a=t!=(t=t.replace(c,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,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??``;return}catch{}if(typeof n==`function`)return;n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n)}}function te(t){return function(n){var r=this.__e;if(r){if(r=r[t],n[s]==null)n[s]=l++;else if(n[s]<this.__a[t])return;return r(e.event?e.event(n):n)}}}function ne(t,n,r,i,a,o,s,c,l,u){var d,p,h,v,S,C,w,T,E,D,O,k,te,ne,ae,A,j,M,N=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=32&r.__u,d=r.__c.__z)&&(n.__u|=l,p=o=[],d.nodeType==8?c=re(d,o):o.push(d),c=o[0]||c),(d=e.__b)&&d(n);n:if(typeof N==`function`){h=s.length;try{if(T=n.props,E=(d=N.prototype)&&d.render,D=(d=N.contextType)&&i[d.__c],O=d?D?D.props.value:d.__:i,(v=r.__c)?(n.__c=v,2&v.__g&&(v.__g|=1)):(E?n.__c=v=new N(T,O):(n.__c=v=new b(T,O),v.constructor=N,v.render=ce),D&&D.sub(v),v.state||(v.state={}),v.__n=i,v.__g|=8,v.__h=[],v.__k=[]),E&&(v.__s||(v.__s=v.state),N.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=g({},v.__s)),g(v.__s,N.getDerivedStateFromProps(T,v.__s)))),S=v.props,C=v.state,v.__v=n,r.__c){if(T!==S&&E&&!N.getDerivedStateFromProps&&v.componentWillReceiveProps&&v.componentWillReceiveProps(T,O),n.__v==r.__v&&!(8&v.__g)||!(4&v.__g)&&v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(T,v.__s,O)){n.__v!=r.__v&&(v.props=T,v.state=v.__s,v.__g&=-9),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),f.push.apply(v.__h,v.__k),v.__k=[],v.__h.length&&s.push(v),c=x(r);break n}v.componentWillUpdate&&v.componentWillUpdate(T,v.__s,O),E&&v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(S,C,w)})}else E&&!N.getDerivedStateFromProps&&v.componentWillMount&&v.componentWillMount(),E&&v.componentDidMount&&v.__h.push(v.componentDidMount);if(v.context=O,v.props=T,v.__P=t,v.__g&=-5,k=e.__r,te=0,E)v.state=v.__s,v.__g&=-9,k&&k(n),d=v.render(v.props,v.state,v.context),f.push.apply(v.__h,v.__k),v.__k=[];else do v.__g&=-9,k&&k(n),d=v.render(v.props,v.state,v.context),v.state=v.__s;while(8&v.__g&&++te<25);v.state=v.__s,v.getChildContext&&(i=g({},i,v.getChildContext())),E&&r.__c&&v.getSnapshotBeforeUpdate&&(w=v.getSnapshotBeforeUpdate(S,C)),ne=d&&d.type===y&&d.key==null?d.props.children:d,T.__P&&(d=c,a=(t=T.__P).namespaceURI,l=o=null,r.props&&r.props.__P!=t&&(r.__k.some(function(e){e&&se(e,e)}),r.__k=null),c=r.__k?x(r,0):null),c=ee(t,m(ne)?ne:[ne],n,r,i,a,o,s,c,l,u),T.__P&&(n.__e=null,c=d),n.__u&=-161,p&&p.some(_),v.__h.length&&s.push(v),1&v.__g&&(v.__g&=-4)}catch(t){if(s.length=h,n.__v=null,l||o){if(t.then){if(ae=0,n.__u|=128|l,o){for(~(j=o.indexOf(c||void 0))||(j=o.length);(M=o[j-1])&&M.nodeType==8;)j--;for(;j<o.length;j++)if(M=o[j]){if(o[j]=null,M.nodeType==8){if(M.data.startsWith(`$s`))ae++||(A=M);else if(ae&&M.data.startsWith(`/$s`)&&!--ae)break}else if(!ae)break}}if(!A){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;A=c}(d=re(A=n.__c.__z||(n.__c.__z=A)))?(n.__e=A,c=d):n.__e=c,c&&=c.nextSibling}else o&&o.some(_)}else n.__e=r.__e;n.__k||=r.__k||[],t.then||ie(n),e.__e(t,n,r)}}else c=n.__e=oe(r.__e,n,r,i,a,o,s,l,u,t);return(d=e.diffed)&&d(n),c}function re(e,t){if(e&&e.nodeType==8&&e.data.startsWith(`$s`))for(var n=1;e=e.nextSibling;){if(e.nodeType==8){if(e.data.startsWith(`$s`))n++;else if(e.data.startsWith(`/$s`)&&!--n)return e}t&&t.push(e)}}function ie(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ie))}function ae(t,n,r){for(var i=0;i<r.length;)A(r[i++],r[i++],r[i++]);e.__c&&e.__c(n,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(e){e.call(n)})}catch(t){e.__e(t,n.__v)}})}function oe(t,n,r,i,a,o,s,c,l,u){var f,g,v,y,b,S,C,w,T,E=r.props||d,D=n.props,O=n.type;if(O==`svg`?a=`http://www.w3.org/2000/svg`:O==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||=`http://www.w3.org/1999/xhtml`,o){for(f=0;f<o.length;f++)if((b=o[f])&&(O?b.localName==O:b.nodeType==3)){t=b,o[f]=null;break}}if(!t){if(w=u.ownerDocument||document,!O)return w.createTextNode(D);t=w.createElementNS(a,O,D.is&&D),c&&=(e.__m&&e.__m(n,o),!1),o=null}if(O){if(u=O==`template`?t.content:t,o=O==`textarea`&&D.defaultValue!=null?null:o&&h.call(u.childNodes),!c&&o)for(E={},f=0;f<t.attributes.length;f++)E[(b=t.attributes[f]).name]=b.value;for(f in E)b=E[f],f==`dangerouslySetInnerHTML`?v=b:f==`children`||f in D||f==`value`&&`defaultValue`in D||f==`checked`&&`defaultChecked`in D||k(t,f,null,b,a);for(f in T=1&r.__u,D)b=D[f],f==`children`?y=b:f==`dangerouslySetInnerHTML`?g=b:f==`value`?S=b:f==`checked`?C=b:c&&typeof b!=`function`||!(E[f]!==b||T&&b!=null)||k(t,f,b,E[f],a);g?(c||v&&(g.__html==v.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),n.__k=[]):(v&&(t.textContent=``),(O==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&p.test(O))&&(a=`http://www.w3.org/1999/xhtml`),ee(u,m(y)?y:[y],n,r,i,a,o,s,o?o[0]:r.__k&&x(r,0),c,l),o&&o.some(_)),c&&O!=`textarea`||(f=`value`,O==`progress`&&S==null?t.removeAttribute(f):S==null||S===t[f]&&(O!=`progress`||S)||k(t,f,S,E[f],a),f=`checked`,C!=null&&C!=t[f]&&k(t,f,C,E[f],a))}else E===D||c&&t.data==D||(t.data=D);return t}function A(t,n,r,i){try{typeof t==`function`?n?n.__x=t(n)||1:(i&&=i.__c||i.__e)&&(n=i.__x)&&(i.__x=null,typeof n==`function`?n():t(null)):t.current=n}catch(t){e.__e(t,r)}}function se(t,n,r){var i,a,o,s;if(e.unmount&&e.unmount(t),!(i=t.ref)||i.current&&i.current!=t.__e||A(i,null,n,t),i=t.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){e.__e(t,n)}i.__P=i.__n=null}if(i=t.__k)for(s=0;s<i.length;s++)i[s]&&se(i[s],n,typeof t.type!=`function`||r&&!t.props.__P);!r&&(i=t.__c)&&(i=i.__z)&&(a=re(i,o=[]))&&(i==t.__e&&o.some(_),_(a),_(i)),(i=t.__e)&&(r||_(i),i.__e&&(i.__e=null)),t.__e=t.__c=t.__=null}function ce(e,t,n){return this.constructor(e,n)}function j(t,n){var r,i,a,o;e.__&&e.__(t,n),n.nodeType==9&&(n=n.documentElement),i=(r=t&&32&t.__u)?null:n.__k,n.__k=v(y,{children:[t]}),a=[],o=[],ne(n,n.__k,i||d,d,n.namespaceURI,i?null:n.firstChild?h.call(n.childNodes):null,a,i?i.__e:n.firstChild,r,o),ae(a,n.__k,o),n.__k.props.children=null}e={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((s=(o=i.constructor)&&o.getDerivedStateFromError)&&i.setState(o.getDerivedStateFromError(e)),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=1),s&&8&i.__g)return void(i.__g|=2)}catch(t){e=t}}throw a=0,e}},t=0,n=function(e){return e!=null&&e.constructor===void 0},b.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=g({},this.state)),typeof e==`function`&&(e=e(g({},n),this.props)),e&&(g(n,e),this.__v&&(t&&this.__k.push(t),C(this)))},b.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),C(this))},b.prototype.render=y,r=[],a=0,o=function(e,t){return e.__v.__b-t.__v.__b},s=Symbol(),c=/(PointerCapture)$|Capture$/i,l=0,u={};var M,N,le,ue,de=Object.is,fe=0,pe=[],me=[],P=e,he=P.__b,ge=P.__r,_e=P.diffed,ve=P.__c,ye=P.unmount,be=P.__;function xe(e,t){P.__h&&P.__h(N,e,fe||t),fe=0;var n=N.__H||(N.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function F(e){return fe=1,Se(Me,e)}function Se(e,t,n){var r=xe(M++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Me(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);de(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=N,!N.__f)){N.__f=!0;var i=N.shouldComponentUpdate;N.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,de(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function I(e,t){var n=xe(M++,3);!P.__s&&je(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,N.__H.__h.push(n))}function Ce(e){return fe=5,we(function(){return{current:e}},[])}function we(e,t){var n=xe(M++,7);return je(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function Te(){var e;do{for(;e=me.shift();)try{ke(e)}catch(t){P.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=pe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ke),t.__h.some(Ae),t.__h=[]}catch(n){t.__h=[],P.__e(n,e.__v)}}}while(me.length)}P.__b=function(e){N=null,he&&he(e)},P.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),be&&be(e,t)},P.__r=function(e){ge&&ge(e),M=0;var t=(N=e.__c).__H;t&&(le==N?N.__h=[]:(t.__h.some(ke),t.__h.some(Ae),M=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),le=N},P.diffed=function(e){_e&&_e(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&Oe(pe.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),le=N=null},P.__c=function(e,t){t.some(function(e){try{e.__h.some(ke),e.__h=e.__h.filter(function(e){return!e.__||Ae(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],P.__e(n,e.__v)}}),ve&&ve(e,t)},P.unmount=function(e){ye&&ye(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,Oe(me.push(r))}else ke(r)}catch(e){t=e}}),r.__H=void 0,t&&P.__e(t,r.__v))};var Ee=typeof requestAnimationFrame==`function`;function De(e){var t,n=function(){clearTimeout(r),Ee&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ee&&(t=requestAnimationFrame(n))}function Oe(e){e!=1&&ue==P.requestAnimationFrame||((ue=P.requestAnimationFrame)||De)(Te)}function ke(e){var t=N,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),N=t}function Ae(e){var t=N;e.__c=e.__(),N=t}function je(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!de(t,e[n])})}function Me(e,t){return typeof t==`function`?t(e):t}var Ne=Symbol.for(`preact-signals`);function Pe(){if(R>1)R--;else{var e,t=!1;for((function(){var e=He;for(He=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}})();Re!==void 0;){var n=Re;for(Re=void 0,ze++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ge(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(ze=0,R--,t)throw e}}function Fe(e){if(R>0)return e();Ve=++Be,R++;try{return e()}finally{Pe()}}var Ie,L=void 0;function Le(e){var t=L,n=Ie;L=void 0,Ie=void 0;try{return e()}finally{L=t,Ie=n}}var Re=void 0,R=0,ze=0,Be=0,Ve=0,He=void 0,Ue=0;function We(e){if(L!==void 0){var t=e.n;if(t===void 0||t.t!==L)return t={i:0,S:e,p:L.s,n:void 0,t:L,e:void 0,x:void 0,r:t},L.s!==void 0&&(L.s.n=t),L.s=t,e.n=t,32&L.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=L.s,t.n=void 0,L.s.n=t,L.s=t),t}}function z(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}z.prototype.brand=Ne,z.prototype.h=function(){return!0},z.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?Le(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},z.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&&Le(function(){var e;(e=t.Z)==null||e.call(t)}))}},z.prototype.subscribe=function(e){var t=this;return $e(function(){var n=t.value;Le(function(){return e(n)})},{name:`sub`})},z.prototype.valueOf=function(){return this.value},z.prototype.toString=function(){return this.value+``},z.prototype.toJSON=function(){return this.value},z.prototype.peek=function(){var e=this;return Le(function(){return e.value})},Object.defineProperty(z.prototype,"value",{get:function(){var e=We(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ze>100)throw Error(`Cycle detected`);(function(e){R!==0&&ze===0&&e.l!==Ve&&(e.l=Ve,He={S:e,v:e.v,i:e.i,o:He})})(this),this.v=e,this.i++,Ue++,R++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pe()}}}});function B(e,t){return new z(e,t)}function Ge(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 Ke(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 V(e,t){z.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ue-1,this.f=4}V.prototype=new z,V.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ue))return!0;if(this.g=Ue,this.f|=1,this.i>0&&!Ge(this))return this.f&=-2,!0;var e=L;try{Ke(this),L=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 L=e,qe(this),this.f&=-2,!0},V.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)}z.prototype.S.call(this,e)},V.prototype.U=function(e){if(this.t!==void 0&&(z.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)}},V.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(V.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=We(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Je(e,t){return new V(e,t)}function Ye(e){var t=e.m;if(e.m=void 0,typeof t==`function`){R++;var n=L;L=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Xe(e),t}finally{L=n,Pe()}}}function Xe(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ye(e)}function Ze(e){if(L!==this)throw Error(`Out-of-order effect`);qe(this),L=e,this.f&=-2,8&this.f&&Xe(this),Pe()}function Qe(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Ie&&Ie.push(this)}Qe.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()}},Qe.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Ye(this),Ke(this),R++;var e=L;return L=this,Ze.bind(this,e)},Qe.prototype.N=function(){2&this.f||(this.f|=2,this.u=Re,Re=this)},Qe.prototype.d=function(){this.f|=8,1&this.f||Xe(this)},Qe.prototype.dispose=function(){this.d()};function $e(e,t){var n=new Qe(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var et,tt,nt=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,rt=[];$e(function(){et=this.N})();function it(t,n){e[t]=n.bind(null,e[t]||function(){})}function at(e){if(tt){var t=tt;tt=void 0,t()}tt=e&&e.S()}function ot(e){var t=this,r=e.data,i=ct(r);i.name=`ReactiveDom`,i.value=r;var a=we(function(){for(var e=t,r=t.__v;r=r.__;)if(r.__c){r.__c.__$f|=4;break}var a=Je(function(){var e=i.value.value;return e===0?0:!0===e?``:e||``}),o=Je(function(){return!Array.isArray(a.value)&&!n(a.value)}),s=$e(function(){if(this.N=dt,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}ot.displayName=`ReactiveTextNode`,Object.defineProperties(z.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:ot},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),it(`__b`,function(e,t){if(at(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof z&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),it(`__r`,function(e,t){if(e(t),t.type!==y){at();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return $e(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;nt&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),at(n)}}),it(`__e`,function(e,t,n,r){at(),e(t,n,r)}),it(`diffed`,function(e,t){at();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=st(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function st(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=B(n);return{o:function(e,t){a.value=e,r=t},d:$e(function(){this.N=dt;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))})}}it(`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)}),it(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),b.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 ct(e,t){return we(function(){return B(e,t)},[])}var lt=function(e){queueMicrotask(function(){queueMicrotask(e)})};function ut(){Fe(function(){for(var e;e=rt.shift();)et.call(e)})}function dt(){rt.push(this)===1&&(e.requestAnimationFrame||lt)(ut)}var H=e=>e,ft={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.init":{label:`Prepare app repository`,icon:`+`},"app.check":{label:`Check app repository`,icon:`✓`},"app.launch":{label:`Launch app`,icon:`▶`},"app.hook":{label:`Hook app repository`,icon:`↪`},"app.values":{label:`App configuration requirements`,icon:`≡`},"app.config.set":{label:`Set app configuration`,icon:`⚙`},"app.secret.import":{label:`Import app secret`,icon:`+`},"app.secret.generate":{label:`Generate app secret`,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`}},pt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),mt=e=>pt(e)?e:H({}),ht=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):H([]),gt=e=>Object.freeze(Object.entries(mt(e.properties)).map(([t,n])=>{let r=mt(n);return{name:t,type:r.type,required:ht(e.required).includes(t),description:typeof r.description==`string`?r.description:``,choices:ht(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`&&mt(r.items).type===`string`}})),_t=e=>typeof e==`boolean`||typeof e==`string`?e:Array.isArray(e)?ht(e).join(`
|
|
2
|
+
`):H(``),vt=(e,t)=>Object.freeze(Object.fromEntries(gt(e).map(e=>[e.name,_t(t[e.name]??e.default)]))),yt=(e,t)=>Object.freeze(Object.fromEntries(gt(e).flatMap(e=>{let n=t[e.name];return e.type===`boolean`?H([[e.name,n===!0]]):H(typeof n!=`string`||n===``?[]:[[e.name,e.type===`array`?n.split(/\r?\n/):n]])}))),bt=(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`))),xt=(e,t)=>{let n=t.toLowerCase().replace(/\s+/g,``);if(n===``)return H(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)},St=(e,t)=>Object.freeze(e.flatMap(e=>{let n=xt(`${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)),Ct=e=>e,wt=async(e,t)=>e.ok?H({ok:!0,value:Ct(await t(e))}):H({ok:!1,failure:{status:e.status,message:(await e.text()).trim()}}),Tt=async e=>{try{return await e()}catch{return H({ok:!1,failure:{status:0,message:`Cannot reach kayra. Check that kayra serve is still running.`}})}},Et=e=>Tt(()=>fetch(e).then(e=>wt(e,e=>e.json()))),Dt=(e,t)=>Tt(async()=>wt(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),async e=>e.status===204?void 0:e.json())),Ot=(e,t)=>Dt(`/api/operations/${e.name}/preview`,{input:e.input,options:t}),kt=(e,t,n)=>Dt(`/api/operations/${e.name}`,{input:e.input,options:t,...n===void 0?{}:{confirm:n}}),At=(e,t={})=>Dt(`/api/operations/${e}`,{input:t}),jt=(e,t)=>Dt(`/api/runs/${encodeURIComponent(e)}/answers`,{text:t}),Mt=e=>Dt(`/api/runs/${encodeURIComponent(e)}/cancel`,{}),Nt=(e,t)=>Dt(`/api/sessions/${encodeURIComponent(e)}/input`,{text:t}),Pt=e=>Tt(async()=>wt(await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`}),()=>Promise.resolve(void 0))),Ft=()=>Et(`/api/runs`),It=(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(Ct(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()}},Lt=/^[A-Za-z0-9._-]+$/,Rt=e=>{let t=e.split(`/`).filter(e=>e!==``).map(decodeURIComponent);if(!t.every(e=>Lt.test(e)))return H({page:`missing`,path:e});let[n,r,i,a]=t;return n===void 0?H({page:`fleet`}):n===`runs`&&r===void 0?H({page:`runs`}):n===`runs`&&r!==void 0&&i===void 0?H({page:`run`,id:r}):n===`sessions`&&r!==void 0&&i===void 0?H({page:`session`,id:r}):n===`validate`&&r===void 0?H({page:`validate`}):n===`servers`&&r!==void 0&&i===void 0?H({page:`server`,server:r}):n===`servers`&&r!==void 0&&i===`apps`&&a!==void 0&&t.length===4?H({page:`app`,server:r,app:a}):H({page:`missing`,path:e})},zt=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}},Bt=e=>{let t=H({label:`servers`,to:{page:`fleet`}}),n=H({label:`runs`,to:{page:`runs`}}),r=e=>e.split(`-`).at(-1)??e;switch(e.page){case`fleet`:return H([{label:`overview`}]);case`server`:return H([t,{label:e.server}]);case`app`:return H([t,{label:e.server,to:{page:`server`,server:e.server}},{label:e.app}]);case`runs`:return H([{label:`runs`}]);case`run`:return H([n,{label:r(e.id)}]);case`session`:return H([n,{label:`session ${r(e.id)}`}]);case`validate`:return H([{label:`validate`}]);case`missing`:return H([{label:e.path}])}},Vt=`kayra.theme`,Ht=(e,t)=>H(e===`dark`||e===`light`?e:t?`dark`:`light`),U=B(Rt(location.pathname)),Ut=e=>{history.pushState(null,``,zt(e)),U.value=e,scrollTo({top:0})};addEventListener(`popstate`,()=>{U.value=Rt(location.pathname)});var W=B({state:`loading`}),Wt=B({state:`loading`}),Gt=async()=>{let e=await Et(`/api/operations`);Wt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},G=B({value:void 0,live:!1}),Kt=B({state:`loading`}),qt=async()=>{let e=await Et(`/api/fleet`);W.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Jt=()=>{G.value={value:G.value.value,live:!0},It(`/api/operations/status`,e=>{G.value={value:e,live:!0}},()=>{G.value={value:G.value.value,live:!1}},{input:{}})},Yt=async()=>{Kt.value={state:`loading`};let e=await At(`validate`);Kt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},K=B({state:`loading`}),Xt=async()=>{let e=await Ft();e.ok?K.value={state:`ready`,value:e.value}:K.value.state!==`ready`&&(K.value={state:`failed`,failure:e.failure})},Zt=B(Date.now()),Qt=()=>{Xt();let e=setInterval(()=>{Zt.value=Date.now(),Xt()},3e3);return()=>{clearInterval(e)}},$t=()=>{try{return localStorage.getItem(Vt)}catch{return null}},en=matchMedia(`(prefers-color-scheme: dark)`),tn=B(Ht($t(),en.matches));$e(()=>{document.documentElement.setAttribute(`data-theme`,tn.value)}),en.addEventListener(`change`,e=>{$t()===null&&(tn.value=e.matches?`dark`:`light`)});var nn=()=>{tn.value=tn.value===`dark`?`light`:`dark`;try{localStorage.setItem(Vt,tn.value)}catch{}},rn=e=>e===null?``:` · ${String(e)} ms`,an={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`},on=e=>{let{state:t,address:n,reason:r}=e.machine;switch(t){case`pending`:return H({text:`asking OpenTofu`,tone:`waiting`});case`found`:return H({text:n??`an address OpenTofu does not give`,tone:n===null?`warn`:`strong`});case`not-provisioned`:return H({text:`not provisioned`,tone:`muted`});case`no-machine`:return H({text:`no machine in its state`,tone:`muted`});case`unreadable`:return H({text:`state unreadable`,tone:`bad`,...r===null?{}:{title:r}})}},sn=e=>{let{state:t,error:n}=e.ssh;switch(t){case`pending`:return H({text:`connecting`,tone:`waiting`});case`open`:return H({text:`port ${String(e.ssh.port)} open${rn(e.ssh.ms)}`,tone:`ok`});case`refused`:return H({text:`off (refused)`,tone:`warn`,title:`Nothing listens: SSH may be on only on demand.`});case`skipped`:return H({text:`not asked`,tone:`muted`});case`answered`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return H({text:an[t],tone:`bad`,...n===null?{}:{title:n}})}},cn=e=>{let{https:t}=e;if(t!==null)switch(t.state){case`pending`:return H({text:`asking`,tone:`waiting`});case`answered`:return H({text:`HTTP ${String(t.status??`?`)}${rn(t.ms)}`,tone:t.status!==null&&t.status<400?`ok`:`bad`});case`skipped`:return H({text:`not asked`,tone:`muted`});case`open`:case`refused`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return H({text:an[t.state],tone:`bad`,...t.error===null?{}:{title:t.error}})}},ln=e=>{let{state:t,pin:n,version:r,error:i}=e.kayra,a=`This fleet pins kayra ${n}: a setup records it.`;switch(t){case`pending`:return H({text:`asking`,tone:`waiting`});case`recorded`:return H(r===n?{text:n,tone:`ok`}:{text:`${r??`?`} → ${n}`,tone:`warn`,title:a});case`unrecorded`:return H({text:`unrecorded → ${n}`,tone:`warn`,title:`Set up by a kayra that recorded no version. ${a}`});case`unreadable`:return H({text:`unreadable`,tone:`bad`,...i===null?{}:{title:i}});case`skipped`:return H({text:`not asked`,tone:`muted`})}},un=e=>{if(e===void 0)return H(`waiting`);let t=[on(e),sn(e),cn(e)].flatMap(e=>Object.freeze(e===void 0?[]:[e.tone]));return t.includes(`waiting`)?H(`waiting`):t.includes(`bad`)?H(`bad`):t.includes(`warn`)?H(`warn`):t.includes(`ok`)?H(`ok`):H(`muted`)},dn=e=>{let t=un(e);return t===`waiting`?H({word:`ASKING`,tone:t}):t===`bad`?H({word:`FAIL`,tone:t}):t===`warn`?H({word:`WARN`,tone:t}):e!==void 0&&ln(e).tone===`warn`?H({word:`BEHIND`,tone:`warn`}):H(t===`ok`?{word:`OK`,tone:t}:{word:`--`,tone:t})},fn=e=>{let t=Math.max(0,6-e.length);return`[${` `.repeat(Math.floor(t/2))}${e}${` `.repeat(Math.ceil(t/2))}]`},pn={ok:`●`,warn:`▲`,bad:`✕`,waiting:`◌`,active:`◐`,muted:`○`,strong:`●`,accent:`◆`},mn=0;Array.isArray;function q(t,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l&&typeof t!=`function`)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:t,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--mn,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),e.vnode&&e.vnode(u),u}var hn=(e,t)=>{if(typeof e==`string`)return e;let n=e.tone===void 0?void 0:`tone-${e.tone}`;return e.href===void 0?q(`span`,{class:n,children:e.text},t):q(`a`,{class:n,href:e.href,target:`_blank`,rel:`noreferrer`,children:e.text},t)},gn=({text:e})=>q(y,{children:(typeof e==`string`?[e]:e).map(hn)}),_n=({lines:e})=>q(`div`,{class:`lines`,children:e.map((e,t)=>q(`div`,{children:q(gn,{text:e})},t))}),J=({tone:e,label:t})=>q(`span`,{class:`dot dot-${e}`,title:t,"aria-label":t,role:t===void 0?void 0:`img`,"aria-hidden":t===void 0||void 0,children:pn[e]}),vn=({word:e,tone:t})=>q(`span`,{class:`tag tone-${t}${t===`waiting`||t===`active`?` pulse`:``}`,children:fn(e)}),yn={reads:`read only`,changes:`changes`,destroys:`destroys`},bn=({effect:e})=>q(`span`,{class:`badge badge-${e}`,children:yn[e]}),xn=({children:e,tone:t})=>q(`span`,{class:`pill${t===void 0?``:` pill-${t}`}`,children:e}),Sn=({label:e,cell:t})=>t===void 0?null:q(`div`,{class:`fact`,children:[q(`dt`,{children:e}),q(`dd`,{title:t.title,children:[q(J,{tone:t.tone}),q(`span`,{class:t.tone===`waiting`?`tone-muted`:`tone-${t.tone}`,children:t.text})]})]}),Y=({failure:e})=>q(`div`,{class:`problem`,role:`alert`,children:[q(`strong`,{children:e.status===0?`Connection problem`:`kayra answered ${String(e.status)}`}),q(`pre`,{children:e.message})]}),X=({what:e})=>q(`div`,{class:`waiting`,children:[q(`span`,{class:`spinner`,"aria-hidden":`true`}),` `,e]}),Cn=({kicker:e,title:t,tag:n,sub:r,children:i})=>q(`header`,{class:`page-header`,children:[q(`div`,{class:`page-title`,children:[e===void 0?null:q(`div`,{class:`kicker`,children:e}),q(`div`,{class:`title-row`,children:[q(`h1`,{children:t}),n]}),r===void 0?null:q(`div`,{class:`sub`,children:r})]}),i===void 0?null:q(`div`,{class:`actions`,children:i})]}),Z=({title:e,meta:t,aside:n,children:r,class:i})=>q(`section`,{class:i===void 0?`section`:`section ${i}`,"aria-label":e,children:[q(`div`,{class:`section-head`,children:[q(`h2`,{children:e}),q(`span`,{class:`rule`,"aria-hidden":`true`}),t===void 0?null:q(`span`,{class:`meta`,children:t}),n]}),r]}),wn=({initial:e,choose:t,close:n})=>{let[r,i]=F(e===``?`.`:e),[a,o]=F(void 0);return I(()=>{let e={current:!1};return o(void 0),Et(`/api/directories?path=${encodeURIComponent(r)}`).then(t=>{e.current||o(t)}),()=>{e.current=!0}},[r]),q(`section`,{class:`directory-picker`,"aria-label":`Choose a local directory`,children:[q(`div`,{class:`buttons`,children:[q(`strong`,{children:`Choose a local directory`}),q(`button`,{type:`button`,class:`button small`,onClick:n,children:`Close picker`})]}),a===void 0?q(X,{what:`Reading directories`}):a.ok?q(y,{children:[q(`code`,{class:`directory-path`,children:a.value.path}),q(`ul`,{class:`directory-list`,children:[a.value.parent===a.value.path?null:q(`li`,{children:q(`button`,{type:`button`,onClick:()=>{i(a.value.parent)},children:`↑ Parent directory`})}),a.value.directories.map(e=>q(`li`,{children:q(`button`,{type:`button`,onClick:()=>{i(e.path)},children:[`▸ `,e.name]})},e.path))]}),q(`button`,{type:`button`,class:`button`,onClick:()=>{t(a.value.path)},children:`Use this directory`})]}):q(Y,{failure:a.failure})]})},Tn=B(void 0),En=(e,t={})=>{Tn.value={name:e,input:t}},Dn=e=>{En(e.name,Object.fromEntries(Object.entries(e).filter(([e])=>e!==`name`)))},On=()=>{Tn.value=void 0},kn={guard:{glyph:`◆`,tone:`tone-warn`},check:{glyph:`◇`,tone:`tone-muted`},confirm:{glyph:`?`,tone:`tone-bad`},run:{glyph:`❯`,tone:`tone-accent`},session:{glyph:`>`,tone:`tone-accent`},note:{glyph:`·`,tone:`tone-muted`}},An=({step:e})=>{let t=kn[e.kind]??{glyph:`·`,tone:`tone-muted`};return q(y,{children:[e.opens===void 0?null:q(`li`,{class:`part`,children:e.opens}),q(`li`,{class:`plan-step`,children:[q(`span`,{class:`plan-index`,children:e.index+1}),q(`span`,{class:t.tone,"aria-hidden":`true`,children:t.glyph}),q(`div`,{children:[q(`span`,{children:e.title}),q(`span`,{class:`plan-kind`,children:e.kind}),e.command===void 0?null:q(`code`,{class:`plan-command`,children:e.command})]})]})]})},jn=()=>q(`button`,{type:`button`,class:`iconbtn`,onClick:On,"aria-label":`Close`,children:q(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,children:q(`path`,{d:`M3 3l8 8M11 3l-8 8`})})}),Mn=({field:e,value:t,change:n,server:r})=>{let[i,a]=F(!1),o=W.value,s=o.state===`ready`?o.value.servers:[],c=typeof t==`string`?t:``,l=`operation-${e.name}`;return e.type===`boolean`?q(`label`,{class:`toggle`,children:[q(`input`,{type:`checkbox`,checked:t===!0,onChange:e=>{n(e.currentTarget.checked)}}),e.description||e.name]}):q(`div`,{class:`operation-field`,children:[q(`label`,{for:l,children:[e.name,e.required?``:` (optional)`]}),e.name===`server`||e.choices.length>0?q(`select`,{id:l,required:e.required,value:c,onChange:e=>{n(e.currentTarget.value)},children:[q(`option`,{value:``,children:e.required?`Choose…`:`All servers`}),(e.name===`server`?s.map(e=>e.name):e.choices).map(e=>q(`option`,{value:e,children:e},e))]}):e.type===`array`?q(`textarea`,{id:l,rows:3,value:c,required:e.required,placeholder:`One item per line`,onInput:e=>{n(e.currentTarget.value)}}):q(`div`,{class:`inline`,children:[q(`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`?q(`button`,{type:`button`,class:`button`,onClick:()=>{a(!i)},children:`Browse…`}):null]}),e.name===`app`?q(`datalist`,{id:`operation-apps`,children:s.find(e=>e.name===r)?.apps.map(e=>q(`option`,{value:e},e))}):null,e.description===``?null:q(`span`,{class:`hint`,children:e.description}),e.type===`array`?q(`span`,{class:`hint`,children:[`One `,e.name===`command`?`argument`:`item`,` per line. Spaces within a line are preserved.`]}):null,i?q(wn,{initial:c,close:()=>{a(!1)},choose:e=>{n(e),a(!1)}}):null]})},Nn=({info:e,seed:t,options:n,submit:r})=>{let[i,a]=F(()=>vt(e.input,t.input)),[o,s]=F(n.verbose??!1),[c,l]=F(n.dryRun??!1),u=e.kind===`plan`||e.kind===`session`,d=gt(e.input),f=d.some(e=>!e.supported);return q(`form`,{onSubmit:t=>{t.preventDefault(),r({draft:{name:e.name,input:yt(e.input,i)},options:{verbose:o,dryRun:c}})},children:[q(`div`,{class:`sheet-body operation-fields`,children:[d.map(e=>q(Mn,{field:e,value:i[e.name]??``,server:i.server,change:t=>{a({...i,[e.name]:t})}},e.name)),f?q(`p`,{role:`alert`,children:`This operation has an unsupported input. Update the UI before running it.`}):null,u?q(`fieldset`,{class:`run-options`,children:[q(`legend`,{children:`Run options`}),q(`label`,{class:`toggle`,children:[q(`input`,{type:`checkbox`,checked:o,onChange:e=>{s(e.currentTarget.checked)}}),`Verbose output`]}),q(`label`,{class:`toggle`,children:[q(`input`,{type:`checkbox`,checked:c,onChange:e=>{l(e.currentTarget.checked)}}),`Dry run — preview only`]})]}):null]}),q(`div`,{class:`sheet-foot`,children:q(`div`,{class:`buttons`,children:[q(`button`,{type:`button`,class:`button`,onClick:On,children:[`cancel `,q(`kbd`,{children:`esc`})]}),q(`span`,{class:`spacer`}),q(`button`,{type:`submit`,class:`button primary`,disabled:f,children:u?`show the plan`:e.kind===`stream`?`follow it`:`ask`})]})})]})},Pn=e=>{if(Wt.value.state===`ready`&&Wt.value.value.some(t=>t.name===e.name&&t.local))return;let t=W.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},Fn=({prepared:e,effect:t,back:n})=>{let{draft:r,options:i}=e,[a,o]=F(void 0),[s,c]=F(``),[l,u]=F(void 0);if(I(()=>{Ot(r,i).then(o)},[e]),a===void 0)return q(`div`,{class:`sheet-body`,children:q(X,{what:`Planning`})});if(!a.ok)return q(`div`,{class:`sheet-body`,children:[q(Y,{failure:a.failure}),q(`button`,{class:`button`,onClick:n,children:`Edit inputs`})]});let{invocation:d,steps:f,changes:p}=a.value,m=p&&!i.dryRun?Pn(r):void 0,h=m===void 0||s===m,g=m===void 0||s===``?void 0:h?{text:`✓ matches`,tone:`tone-ok`}:m.startsWith(s)?{text:`keep going`,tone:`tone-muted`}:{text:`✕ not ${m}`,tone:`tone-bad`},_=async()=>{u(`starting`);let e=await kt(r,i,m===void 0?void 0:s);e.ok?(On(),Ut(`session`in e.value?{page:`session`,id:e.value.session}:{page:`run`,id:e.value.run})):u(e.failure)};return q(y,{children:[q(`div`,{class:`sheet-body`,children:[q(`div`,{children:[q(`code`,{class:`command`,children:d.command}),q(`p`,{class:`sub`,children:[d.about.join(` · `),d.about.length===0?``:` · `,p?`changes things`:`reads only`,i.verbose?` · verbose`:``,i.dryRun?` · dry run, nothing changes`:``]})]}),q(`div`,{class:`plan-head`,children:[q(`span`,{children:`the plan`}),q(`span`,{class:`rule`,"aria-hidden":`true`}),q(`span`,{children:[f.length,` steps`]})]}),q(`ol`,{class:`plan`,children:f.map(e=>q(An,{step:e},e.index))})]}),q(`form`,{class:`sheet-foot`,onSubmit:e=>{e.preventDefault(),h&&!i.dryRun&&_()},children:[m===void 0?null:q(`div`,{class:`confirm`,children:[q(`label`,{for:`operation-confirm`,children:[`Type `,q(`strong`,{children:m}),` to approve. The server checks the name too.`]}),q(`div`,{class:`field`,children:[q(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),q(`input`,{id:`operation-confirm`,value:s,onInput:e=>{c(e.currentTarget.value)},placeholder:m,autoComplete:`off`,spellcheck:!1}),g===void 0?null:q(`span`,{class:`match ${g.tone}`,children:g.text})]})]}),l===void 0||l===`starting`?null:q(Y,{failure:l}),q(`div`,{class:`buttons`,children:[q(`button`,{type:`button`,class:`button`,onClick:n,disabled:l===`starting`,children:`edit inputs`}),q(`span`,{class:`spacer`}),i.dryRun?q(`button`,{type:`button`,class:`button primary`,onClick:On,children:`done`}):q(`button`,{type:`submit`,class:t===`destroys`?`button danger`:`button primary`,disabled:!h||l===`starting`,children:l===`starting`?`starting…`:m===void 0?r.name===`ssh`?`open terminal`:`run`:`approve · ${d.command}`})]})]})]})},In=({prepared:e,info:t,back:n})=>{let[r,i]=F(void 0),[a,o]=F(t.kind===`stream`);return I(()=>{let n={current:!0};return t.kind===`stream`?It(`/api/operations/${t.name}`,e=>{i({ok:!0,value:e})},()=>{o(!1)},{input:e.draft.input},e=>{i({ok:!1,failure:e})}):(At(t.name,e.draft.input).then(e=>{n.current&&i(e)}),()=>{n.current=!1})},[e]),q(y,{children:[q(`div`,{class:`sheet-body`,children:[r===void 0?q(X,{what:`Asking kayra`}):r.ok?q(`pre`,{class:`query-result`,children:typeof r.value==`string`?r.value:JSON.stringify(r.value,null,2)}):q(Y,{failure:r.failure}),a?q(X,{what:`Receiving updates`}):null]}),q(`div`,{class:`sheet-foot`,children:q(`div`,{class:`buttons`,children:[q(`button`,{type:`button`,class:`button`,onClick:n,children:`edit inputs`}),q(`span`,{class:`spacer`}),q(`button`,{type:`button`,class:`button`,onClick:On,children:`close`})]})})]})},Ln=({draft:e,info:t})=>{let[n,r]=F(void 0),[i,a]=F({draft:e,options:{}}),o=()=>{n!==void 0&&a(n),r(void 0)},s=t.effect===`reads`||n?.options.dryRun===!0?void 0:Pn(n?.draft??e);return q(y,{children:[q(`div`,{class:s===void 0?`sheet-bar`:`sheet-bar real`,children:[q(`span`,{class:s===void 0?`prompt`:`tone-warn`,"aria-hidden":`true`,children:s===void 0?`❯`:`▲`}),q(`strong`,{children:s===void 0?`kayra ${t.name.replace(`.`,` `)}`:`this changes ${s}, a real server`}),q(bn,{effect:t.effect}),q(jn,{})]}),q(`div`,{class:`sheet-head`,children:[q(`h2`,{id:`operation-title`,children:ft[t.name].label}),q(`p`,{class:`sub`,children:t.summary})]}),n===void 0?q(Nn,{info:t,seed:i.draft,options:i.options,submit:r}):t.kind===`plan`||t.kind===`session`?q(Fn,{prepared:n,effect:t.effect,back:o}):q(In,{prepared:n,info:t,back:o})]})},Rn=()=>{let e=Tn.value,t=Ce(null),n=e!==void 0;if(I(()=>{if(!n)return;let e=document.activeElement;t.current?.focus();let r=e=>{if(e.key===`Escape`&&On(),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 q(`div`,{class:`overlay`,onClick:On,children:q(`div`,{ref:t,tabIndex:-1,class:`sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`operation-title`,onClick:e=>{e.stopPropagation()},children:r.state===`loading`?q(X,{what:`Reading operations`}):r.state===`failed`?q(Y,{failure:r.failure}):i===void 0?q(`p`,{role:`alert`,children:`Operation unavailable.`}):q(Ln,{draft:e,info:i},JSON.stringify(e))})})},Q=B(!1),zn=e=>e.replace(`.`,` `),Bn=()=>{let e=W.value,t=e.state===`ready`?e.value.servers:[],n=Wt.value.state===`ready`?Wt.value.value:[];return H([{label:`overview`,hint:`every server`,icon:`›`,line:`open /`,go:{page:`fleet`}},{label:`runs`,hint:`what ran from here`,icon:`›`,line:`open /runs`,go:{page:`runs`}},{label:`validate`,hint:`the fleet beyond its schemas`,icon:`›`,line:`open /validate`,go:{page:`validate`}},...n.filter(e=>e.scope===`fleet`||e.scope===`repo`).map(e=>H({label:zn(e.name),hint:e.summary,icon:ft[e.name].icon,line:`kayra ${zn(e.name)}`,run:{name:e.name,input:{}},effect:e.effect,real:!1})),...t.flatMap(e=>H([{label:e.name,hint:`${e.kind} on ${e.target} · ${e.domain}`,icon:`●`,line:`open /servers/${e.name}`,go:{page:`server`,server:e.name}},...e.apps.map(t=>H({label:`${e.name}/${t}`,hint:`app`,icon:`▸`,line:`open /servers/${e.name}/apps/${t}`,go:{page:`app`,server:e.name,app:t}})),...bt(n,e).map(t=>H({label:`${zn(t.name)} ${e.name}`,hint:t.summary,icon:ft[t.name].icon,line:`kayra ${zn(t.name)} ${e.name}`,run:{name:t.name,input:{server:e.name}},effect:t.effect,real:e.target!==`multipass`}))]))])},Vn=e=>{if(`go`in e)return{text:`jump`,class:`badge badge-jump`,guard:`opens it`};if(e.effect===`reads`)return{text:`read only`,class:`badge badge-reads`,guard:`reads, changes nothing`};let t=e.real?`shows its plan, then asks for the server's name`:`shows its plan first`;return e.effect===`destroys`?{text:`destroys`,class:`badge badge-destroys`,guard:t}:{text:`changes`,class:`badge badge-changes`,guard:t}},Hn=e=>{Q.value=!1,`go`in e?Ut(e.go):En(e.run.name,e.run.input)},Un=()=>{let[e,t]=F(``),[n,r]=F(0),i=Ce(null),a=Q.value;if(I(()=>{a&&i.current?.focus()},[a]),I(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),Q.value=!Q.value,t(``),r(0)):e.key===`Escape`&&(Q.value=!1)};return addEventListener(`keydown`,e),()=>{removeEventListener(`keydown`,e)}},[]),!Q.value)return null;let o=St(Bn(),e).slice(0,12),s=o[n],c=s===void 0?void 0:Vn(s);return q(`div`,{class:`overlay`,onClick:()=>{Q.value=!1},children:q(`div`,{class:`palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Go to, or run`,onClick:e=>{e.stopPropagation()},children:[q(`div`,{class:`palette-input`,children:[q(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),q(`input`,{ref:i,value:e,placeholder:`a command, a server, a page…`,"aria-label":`Go to, or run`,spellcheck:!1,autoComplete:`off`,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`)s!==void 0&&Hn(s);else return;e.preventDefault()}}),q(`kbd`,{children:`esc`})]}),q(`div`,{class:`palette-head`,children:[q(`span`,{children:e.trim()===``?`everything`:`matches`}),q(`span`,{class:`rule`,"aria-hidden":`true`}),q(`span`,{children:o.length})]}),q(`ul`,{role:`listbox`,"aria-label":`Results`,children:[o.map((e,t)=>{let i=Vn(e);return q(`li`,{role:`option`,"aria-selected":t===n,class:t===n?`selected`:void 0,onMouseEnter:()=>{r(t)},onClick:()=>{Hn(e)},children:[q(`span`,{class:`prompt`,"aria-hidden":`true`,children:e.icon}),q(`span`,{class:`label`,children:e.label}),q(`span`,{class:`hint`,children:e.hint}),q(`span`,{class:i.class,children:i.text})]},e.label)}),o.length===0?q(`li`,{class:`empty`,children:[`Nothing matches “`,e,`”: try a server's name or a verb.`]}):null]}),s===void 0||c===void 0?null:q(`div`,{class:`palette-preview`,"aria-live":`polite`,children:[q(`div`,{class:`line`,children:[q(`span`,{class:`tone-muted`,"aria-hidden":`true`,children:`$`}),q(`strong`,{class:`ellipsis`,children:s.line}),q(`span`,{class:`spacer`}),q(`span`,{class:c.class.replace(`badge `,``),children:c.guard})]}),q(`p`,{children:s.hint})]}),q(`div`,{class:`palette-foot`,children:[q(`span`,{children:[q(`kbd`,{children:`↑↓`}),` move`]}),q(`span`,{children:[q(`kbd`,{children:`↵`}),` open`]}),q(`span`,{children:[q(`kbd`,{children:`esc`}),` close`]}),q(`span`,{class:`spacer`}),q(`span`,{children:`nothing changes before its plan is shown`})]})]})})},Wn=()=>{Q.value=!0},$=({to:e,children:t,class:n,current:r})=>q(`a`,{href:zt(e),class:n,"aria-current":r===!0?`page`:void 0,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),Ut(e))},children:t}),Gn=(e,t)=>zt(e)===zt(t),Kn=()=>q(`svg`,{class:`logo`,width:`22`,height:`22`,viewBox:`0 0 22 22`,"aria-hidden":`true`,children:[q(`rect`,{width:`22`,height:`22`,rx:`5`}),q(`path`,{d:`M6.5 7l4 4-4 4M12 15.5h4`})]}),qn=()=>q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,children:[q(`circle`,{cx:`8`,cy:`8`,r:`3`}),q(`path`,{d:`M8 1.5v1.6M8 12.9v1.6M1.5 8h1.6M12.9 8h1.6M3.4 3.4l1.1 1.1M11.5 11.5l1.1 1.1M3.4 12.6l1.1-1.1M11.5 4.5l1.1-1.1`})]}),Jn=()=>q(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linejoin":`round`,children:q(`path`,{d:`M13.5 9.6A5.6 5.6 0 0 1 6.4 2.5a5.6 5.6 0 1 0 7.1 7.1z`})}),Yn=()=>{let e=W.value,t=Bt(U.value),n=tn.value===`dark`;return q(`header`,{class:`topbar`,children:[q($,{to:{page:`fleet`},class:`brand`,children:[q(Kn,{}),q(`span`,{children:[`kayra`,q(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`})]})]}),q(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),q(`span`,{class:`fleet-name`,title:`The fleet kayra serve was started in`,children:e.state===`ready`?e.value.fleet:`…`}),q(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),q(`nav`,{class:`crumbs`,"aria-label":`Breadcrumb`,children:t.map((e,t)=>q(`span`,{class:`crumb`,children:[t===0?null:q(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),e.to===void 0?q(`span`,{"aria-current":`page`,children:e.label}):q($,{to:e.to,children:e.label})]},e.label))}),q(`span`,{class:`spacer`}),q(`button`,{type:`button`,class:`cmdbar`,onClick:Wn,children:[q(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),q(`span`,{children:`run a command or jump to…`}),q(`kbd`,{children:`⌘K`})]}),q(`button`,{type:`button`,class:`iconbtn`,onClick:nn,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,title:n?`Light mode`:`Dark mode`,children:q(n?qn:Jn,{})})]})},Xn=({children:e,count:t})=>q(`div`,{class:`rail-title`,children:[q(`span`,{children:e}),q(`span`,{class:`rule`,"aria-hidden":`true`}),t===void 0?null:q(`span`,{children:t})]}),Zn=({to:e,label:t})=>{let n=Gn(U.value,e);return q($,{to:e,class:n?`rail-item on`:`rail-item`,current:n,children:[q(`span`,{class:`rail-mark`,"aria-hidden":`true`,children:n?`›`:``}),q(`span`,{children:t})]})},Qn=()=>{let e=W.value,t=U.value,n=G.value.value?.servers;return q(`div`,{class:`rail`,children:q(`div`,{class:`rail-inner`,children:[q(`nav`,{"aria-label":`Servers`,children:[q(Xn,{count:e.state===`ready`?e.value.servers.length:void 0,children:`servers`}),e.state===`ready`?e.value.servers.map(e=>{let r=`server`in t&&t.server===e.name,i=dn(n?.find(t=>t.name===e.name));return q($,{to:{page:`server`,server:e.name},class:r?`rail-item on`:`rail-item`,current:r&&t.page===`server`,children:[q(J,{tone:i.tone,label:i.word.toLowerCase()}),q(`span`,{class:`name`,children:e.name}),q(`span`,{class:`meta`,children:e.kind})]},e.name)}):null]}),q(`nav`,{"aria-label":`Pages`,children:[q(Xn,{children:`views`}),q(Zn,{to:{page:`fleet`},label:`overview`}),q(Zn,{to:{page:`runs`},label:`runs`}),q(Zn,{to:{page:`validate`},label:`validate`}),q(`button`,{type:`button`,class:`rail-item`,onClick:()=>{Dn({name:`doctor`})},children:[q(`span`,{class:`rail-mark`,"aria-hidden":`true`}),q(`span`,{children:`doctor`})]})]})]})})},$n={fleet:`FLEET`,server:`SERVER`,app:`APP`,runs:`RUNS`,run:`RUN`,session:`SSH`,validate:`VALIDATE`,missing:`?`},er=()=>{let e=W.value,{value:t,live:n}=G.value,r=t?.servers??[],i=r.filter(e=>un(e)===`ok`).length,a=r.filter(e=>ln(e).tone===`warn`).length,o=new Date(Zt.value).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return q(`footer`,{class:`statusline`,children:[q(`span`,{class:`seg seg-mode`,children:$n[U.value.page]}),q(`span`,{class:`seg`,children:e.state===`ready`?e.value.fleet:`…`}),q(`span`,{class:`seg`,children:[`kayra `,e.state===`ready`?e.value.version:`…`]}),q(`span`,{class:`seg wide-only`,children:[q(J,{tone:`ok`}),`real servers ask for their name`]}),q(`span`,{class:`spacer`}),q(`span`,{class:`seg end`,children:[n?q(y,{children:[q(J,{tone:`waiting`}),` asking`]}):`${String(i)}/${String(r.length)} answering`,a===0?null:q(`span`,{class:`tone-warn`,children:[` · `,a,` behind`]})]}),q(`span`,{class:`seg end wide-only`,children:location.host}),q(`span`,{class:`seg end`,children:o})]})},tr=({children:e})=>q(`div`,{class:`app`,children:[q(Yn,{}),q(`div`,{class:`body`,children:[q(Qn,{}),q(`main`,{class:`main`,children:e})]}),q(er,{})]}),nr=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`},rr=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`},ir=(e,t)=>{let n=new Date(e);return n.toDateString()===new Date(t).toDateString()?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString([],{day:`numeric`,month:`short`})},ar=e=>Date.parse(e),or=(e,t)=>{let[n,r]=F(void 0),i=()=>{r(void 0),e().then(r)};return I(i,[t]),H([n,i])},sr=e=>e===`success`?`ok`:e===`failure`?`bad`:`waiting`,cr=({server:e,app:t,open:n})=>{let[r]=or(()=>At(`app.runs`,{server:e,app:t}),`${e}/${t}`);if(r===void 0)return q(X,{what:`Asking the deployer`});if(!r.ok)return q(Y,{failure:r.failure});let i=Date.now(),{live:a,runs:o}=r.value;return q(y,{children:[q(`p`,{class:`sub`,children:a===void 0?`Not deployed yet.`:`Live: ${a.sha.slice(0,7)} since ${rr(i-Date.parse(a.time))}`}),q(`table`,{class:`table`,children:[q(`thead`,{children:q(`tr`,{children:[q(`th`,{}),q(`th`,{children:`Commit`}),q(`th`,{children:`Why`}),q(`th`,{children:`What`}),q(`th`,{class:`right`,children:`When`}),q(`th`,{class:`right`,children:`Took`})]})}),q(`tbody`,{children:o.map(e=>q(`tr`,{class:`clickable`,onClick:()=>{n(e.id)},children:[q(`td`,{class:`narrow`,children:q(J,{tone:sr(e.state),label:e.state})}),q(`td`,{children:q(`code`,{children:e.sha?.slice(0,7)??``})}),q(`td`,{children:e.why}),q(`td`,{children:e.what}),q(`td`,{class:`right tone-muted`,children:rr(i-Date.parse(e.started))}),q(`td`,{class:`right tone-muted`,children:e.finished===void 0?``:nr(Date.parse(e.finished)-Date.parse(e.started))})]},e.id))})]})]})},lr=({server:e,app:t})=>{let[n]=or(()=>At(`app.releases`,{server:e,app:t}),`${e}/${t}`);if(n===void 0)return q(X,{what:`Asking the deployer`});if(!n.ok)return q(Y,{failure:n.failure});let r=Date.now();return q(`ul`,{class:`releases`,children:n.value.releases.map(n=>q(`li`,{children:[q(`code`,{children:n.sha.slice(0,12)}),q(`span`,{class:`tone-muted`,children:rr(r-Date.parse(n.time))}),n.live?q(xn,{tone:`ok`,children:`live`}):q(`button`,{class:`button small`,onClick:()=>{Dn({name:`app.rollback`,server:e,app:t,sha:n.sha})},children:`Roll back to it`})]},n.sha))})},ur=e=>{if(/\b(error|failed|fatal|refused)\b/i.test(e))return H(`tone-bad`);if(/\bwarn(ing)?\b/i.test(e))return H(`tone-warn`)},dr=({server:e,app:t,run:n})=>{let[r]=or(()=>At(`app.log`,{server:e,app:t,...n===void 0?{}:{run:n}}),`${e}/${t}/${n??``}`);return r===void 0?q(X,{what:`Fetching the log`}):r.ok?q(`pre`,{class:`log`,children:r.value.split(`
|
|
5
|
+
`).map((e,t)=>q(`div`,{class:ur(e),children:e===``?` `:e},t))}):q(Y,{failure:r.failure})},fr=({server:e,app:t})=>{let[n,r]=F(`runs`),[i,a]=F(void 0),[o,s]=F(``);return q(y,{children:[q(Cn,{kicker:`app`,title:t,sub:`on ${e}`,children:q(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),Dn({name:`app.deploy`,server:e,app:t,...o.trim()===``?{}:{ref:o.trim()}})},children:[q(`input`,{value:o,onInput:e=>{s(e.currentTarget.value)},placeholder:`its ref`,spellcheck:!1,"aria-label":`Branch, tag or commit`}),q(`button`,{type:`submit`,class:`button primary`,children:`Deploy`})]})}),q(`nav`,{class:`tabs`,role:`tablist`,children:[`runs`,`releases`,`log`].map(e=>q(`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))}),q(`section`,{class:`card`,children:n===`runs`?q(cr,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?q(lr,{server:e,app:t}):q(dr,{server:e,app:t,run:i})}),q(`p`,{class:`tone-muted small`,children:[`Purging an app's data is irreversible:`,` `,q(`button`,{class:`link danger-link`,onClick:()=>{Dn({name:`app.purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},pr=({remedy:e,first:t})=>{let n=t?`button small primary`:`button small`;switch(e.kind){case`run`:return q(`button`,{type:`button`,class:n,onClick:()=>{En(e.draft.name,e.draft.input)},children:e.label});case`go`:return q($,{to:e.to,class:n,children:e.label});case`ask`:return q(`button`,{type:`button`,class:n,disabled:G.value.live,onClick:Jt,children:G.value.live?`asking…`:e.label})}},mr=({notes:e,quiet:t})=>e.length===0?q(`p`,{class:`note`,children:[q(`span`,{class:`note-title`,children:[q(J,{tone:`ok`}),` nothing needs you`]}),q(`span`,{class:`hint`,children:t})]}):q(`div`,{class:`notes`,children:e.map(e=>q(`div`,{class:`note note-${e.tone}`,children:[q(`div`,{class:`note-title`,children:[q(J,{tone:e.tone===`active`?`waiting`:e.tone}),q(`span`,{children:e.title})]}),e.text===``?null:q(`p`,{children:e.text}),q(`div`,{class:`actions`,children:e.remedies.map((e,t)=>q(pr,{remedy:e,first:t===0},e.label))})]},e.title))}),hr=({server:e})=>{let t=Wt.value;return t.state===`loading`?q(X,{what:`Reading operations`}):t.state===`failed`?q(Y,{failure:t.failure}):q(`div`,{class:`action-grid`,children:(e===void 0?t.value.filter(e=>e.scope===`fleet`||e.scope===`repo`):bt(t.value,e)).map(t=>q(`button`,{type:`button`,class:`action${t.effect===`destroys`?` danger`:``}`,onClick:()=>{En(t.name,e===void 0?{}:{server:e.name})},children:[q(`span`,{class:`icon`,"aria-hidden":`true`,children:ft[t.name].icon}),q(`strong`,{children:ft[t.name].label}),q(bn,{effect:t.effect}),q(`span`,{class:`about`,children:t.summary})]},t.name))})},gr=e=>Object.freeze(e.toSorted((e,t)=>t.started.localeCompare(e.started))),_r=(e,t,n)=>Object.freeze(gr(e).filter(e=>e.server===t).slice(0,n).toReversed().map(e=>e.state)),vr=e=>{if(e.length===0)return`No runs from here yet`;let t=H([`passed`,`failed`,`interrupted`,`declined`,`running`]).flatMap(t=>{let n=e.filter(e=>e===t).length;return Object.freeze(n===0?[]:[`${String(n)} ${t}`])});return`Last ${String(e.length)} runs: ${t.join(`, `)}`},yr=e=>e.kind===`platform`&&e.commands.includes(`deploy`)?H(`deploy`):e.commands.includes(`setup`)?H(`setup`):void 0,br=(e,t)=>t?.tone===`bad`?Object.freeze([`${e} ${t.text}`]):Object.freeze([]),xr=(e,t)=>{let n=H({kind:`go`,label:`open ${e.name}`,to:{page:`server`,server:e.name}}),r=H({kind:`ask`,label:`ask again`}),i=un(t)===`bad`?[H({tone:`bad`,title:`${e.name} does not answer`,text:[...br(`address`,on(t)),...br(`ssh`,sn(t)),...br(`login`,cn(t))].join(` · `),remedies:[n,r]})]:[],a=t.ssh.state===`refused`?[H({tone:`warn`,title:`${e.name}: SSH is off`,text:`Nothing listens on port ${String(t.ssh.port)}. If its SSH is on only on demand, switch it on, then ask again.`,remedies:[r,n]})]:[],o=yr(e),s=ln(t).tone===`warn`?[H({tone:`warn`,title:t.kayra.version===null?`${e.name} records no kayra version`:`${e.name} runs kayra ${t.kayra.version}`,text:`This fleet pins ${t.kayra.pin}${o===void 0?`.`:`: ${o} records it.`}`,remedies:o===void 0?[n]:[{kind:`run`,label:`${o} ${e.name}`,draft:{name:o,input:{server:e.name}}},n]})]:[];return Object.freeze([...i,...a,...s])},Sr=(e,t,n)=>{let r=gr(n),i=e.flatMap(e=>{let n=t.find(t=>t.name===e.name);return n===void 0?Object.freeze([]):xr(e,n)}),a=e.flatMap(e=>{let t=r.find(t=>t.server===e.name&&t.state!==`running`);return t?.state===`failed`?Object.freeze([H({tone:`bad`,title:`${t.command} failed`,text:`The last run on ${e.name} failed. Its log says where.`,remedies:[{kind:`go`,label:`open the run`,to:{page:t.session?`session`:`run`,id:t.id}}]})]):Object.freeze([])}),o=r.filter(e=>e.state===`running`).map(e=>H({tone:`active`,title:`running: ${e.command}`,text:e.session?`An SSH session is open.`:`Still going.`,remedies:[{kind:`go`,label:e.session?`open the session`:`follow it`,to:{page:e.session?`session`:`run`,id:e.id}}]}));return Object.freeze([...i.filter(e=>e.tone===`bad`),...a,...i.filter(e=>e.tone!==`bad`),...o])},Cr={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},wr=({server:e,limit:t})=>{let n=K.value;if(n.state===`loading`)return q(X,{what:`Reading the runs`});if(n.state===`failed`)return q(Y,{failure:n.failure});let r=gr(n.value).filter(t=>e===void 0||t.server===e).slice(0,t??1/0);if(r.length===0)return q(`p`,{class:`empty panel pad`,children:`Nothing run from here yet.`});let i=Zt.value;return q(`div`,{class:`panel scroll-x`,children:q(`div`,{class:`journal`,children:r.map(e=>q($,{to:{page:e.session?`session`:`run`,id:e.id},class:`jrow`,children:[q(`span`,{class:`when`,children:ir(e.started,i)}),q(J,{tone:Cr[e.state],label:e.state}),q(`span`,{class:`ellipsis`,children:e.command}),q(`span`,{class:`state tone-${Cr[e.state]===`waiting`?`active`:Cr[e.state]}`,children:e.state}),q(`span`,{class:`ago`,children:rr(i-ar(e.started))})]},e.id))})})},Tr=()=>q(y,{children:[q(Cn,{kicker:`journal`,title:`runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs.`}),q(wr,{})]}),Er=864e5,Dr=({cell:e})=>e===void 0?q(`span`,{class:`tone-muted`,children:`—`}):q(`span`,{class:`cell`,title:e.title,children:[q(J,{tone:e.tone}),q(`span`,{class:e.tone===`waiting`?`tone-muted`:`tone-${e.tone}`,children:e.text})]}),Or=({facts:e,seen:t})=>{let n=dn(t),r=K.value.state===`ready`?K.value.value:[],i=_r(r,e.name,16),a=gr(r).find(t=>t.server===e.name),o=yr(e);return q(`div`,{class:`grow-row`,children:[q(vn,{word:n.word,tone:n.tone}),q(`div`,{class:`ellipsis`,children:[q($,{to:{page:`server`,server:e.name},children:q(`strong`,{children:e.name})}),q(`span`,{class:`second ellipsis`,children:[e.kind,` · `,e.target,` · `,e.domain]})]}),q(Dr,{cell:t===void 0?void 0:on(t)}),q(Dr,{cell:t===void 0?void 0:sn(t)}),q(Dr,{cell:t===void 0?void 0:cn(t)}),q(Dr,{cell:t===void 0?void 0:ln(t)}),q(`div`,{children:[q(`span`,{class:`strip`,role:`img`,"aria-label":vr(i),children:i.map((e,t)=>q(`span`,{class:e},t))}),q(`span`,{class:`second`,children:a===void 0?`no runs yet`:rr(Zt.value-ar(a.started))})]}),q(`div`,{class:`row-actions`,children:[e.commands.includes(`plan`)?q(`button`,{type:`button`,class:`button small`,onClick:()=>{En(`plan`,{server:e.name})},children:`plan`}):null,o===void 0?null:q(`button`,{type:`button`,class:`button small primary`,onClick:()=>{En(o,{server:e.name})},children:o})]})]})},kr=({servers:e,seen:t})=>{let n=e=>t.find(t=>t.name===e),r=e.filter(e=>un(n(e.name))===`ok`),i=t.filter(e=>e.kayra.state!==`skipped`&&e.kayra.state!==`pending`),a=i.filter(e=>ln(e).tone===`warn`),o=t[0]?.kayra.pin,s=K.value.state===`ready`?K.value.value:[],c=s.filter(e=>Zt.value-ar(e.started)<Er),l=c.filter(e=>e.state===`failed`).length,u=s.filter(e=>e.state===`running`).length,d=e.flatMap(e=>e.apps),f=e.filter(e=>e.kind===`platform`).length,p=e.filter(e=>un(n(e.name))!==`ok`).map(e=>e.name);return q(`div`,{class:`tiles`,children:[q(`div`,{class:`tile`,children:[q(`div`,{class:`tile-label`,children:[q(`span`,{children:`servers`}),q(`span`,{class:G.value.live?void 0:p.length===0?`tone-ok`:`tone-warn`,children:G.value.live?`asking`:p.length===0?`all answer`:`${String(p.length)} not answering`})]}),q(`div`,{class:`tile-value`,children:[r.length,q(`small`,{children:[`/`,e.length,` answering`]})]}),q(`div`,{class:`tile-sub bar`,"aria-hidden":`true`,children:e.map(e=>q(`span`,{class:`tone-${dn(n(e.name)).tone}`,children:`█`},e.name))})]}),q(`div`,{class:`tile`,children:[q(`div`,{class:`tile-label`,children:[q(`span`,{children:`kayra`}),q(`span`,{class:i.length===0?void 0:a.length===0?`tone-ok`:`tone-warn`,children:i.length===0?`not asked`:a.length===0?`on the pin`:`${String(a.length)} behind`})]}),q(`div`,{class:`tile-value`,children:[i.length-a.length,q(`small`,{children:[`/`,i.length,` on `,o??`the pin`]})]}),q(`div`,{class:`tile-sub ellipsis`,children:a.length===0?i.length===0?`read over SSH; none open yet`:`every server asked runs it`:a.map(e=>e.name).join(`, `)})]}),q(`div`,{class:`tile`,children:[q(`div`,{class:`tile-label`,children:[q(`span`,{children:`runs · 24h`}),q(`span`,{class:l===0?void 0:`tone-bad`,children:l===0?`none failed`:`${String(l)} failed`})]}),q(`div`,{class:`tile-value`,children:c.length}),q(`div`,{class:`tile-sub`,children:u===0?`nothing running`:`${String(u)} running now`})]}),q(`div`,{class:`tile`,children:[q(`div`,{class:`tile-label`,children:[q(`span`,{children:`apps`}),q(`span`,{children:[f,` platform`]})]}),q(`div`,{class:`tile-value`,children:d.length}),q(`div`,{class:`tile-sub ellipsis`,children:d.length===0?`none in any server.yml`:d.join(`, `)})]})]})},Ar=()=>{let[e,t]=F(``),n=W.value;if(n.state===`loading`)return q(X,{what:`Reading the fleet`});if(n.state===`failed`)return q(Y,{failure:n.failure});let{value:r,live:i}=G.value,a=r?.servers??[],{servers:o,version:s}=n.value,c=e.trim().toLowerCase(),l=o.filter(e=>c===``||[e.name,e.kind,e.target,e.domain].join(` `).includes(c)),u=K.value.state===`ready`?K.value.value:[];return q(y,{children:[q(Cn,{kicker:`fleet`,title:n.value.fleet,sub:`${String(o.length)} servers · kayra ${s} pinned · every command from this machine`,children:[q(`button`,{type:`button`,class:`button`,onClick:Jt,disabled:i,children:[i?`asking…`:`ask again`,q(`span`,{class:`aside`,children:`status`})]}),q($,{to:{page:`validate`},class:`button`,children:[`validate`,q(`span`,{class:`aside`,children:`read only`})]})]}),q(kr,{servers:o,seen:a}),q(Z,{title:`servers`,aside:q(`label`,{class:`filter`,children:[q(`span`,{class:`prompt`,"aria-hidden":`true`,children:`/`}),q(`span`,{class:`visually-hidden`,children:`Filter servers`}),q(`input`,{value:e,placeholder:`filter`,spellcheck:!1,onInput:e=>{t(e.currentTarget.value)}})]}),children:q(`div`,{class:`panel scroll-x servers-table`,children:q(`div`,{class:`gtable`,children:[q(`div`,{class:`ghead`,children:[q(`span`,{children:`state`}),q(`span`,{children:`server`}),q(`span`,{children:`address`}),q(`span`,{children:`ssh`}),q(`span`,{children:`login`}),q(`span`,{children:`kayra`}),q(`span`,{children:`last runs`}),q(`span`,{class:`right`,children:`actions`})]}),l.map(e=>q(Or,{facts:e,seen:a.find(t=>t.name===e.name)},e.name)),l.length===0?q(`p`,{class:`empty pad`,children:[`No server matches “`,e,`”.`]}):null]})})}),q(`div`,{class:`split`,children:[q(`div`,{class:`wide`,children:q(Z,{title:`journal`,aside:q($,{to:{page:`runs`},class:`small`,children:`all runs →`}),children:q(wr,{limit:8})})}),q(`div`,{class:`side`,children:q(Z,{title:`needs you`,children:q(mr,{notes:Sr(o,a,u),quiet:r===void 0?`Still asking every server.`:`Every server answered; no run failed last.`})})})]}),q(Z,{title:`fleet commands`,children:q(hr,{})})]})},jr=({id:e,question:t})=>{let[n,r]=F(``),[i,a]=F(!1),[o,s]=F(void 0),c=Ce(null);I(()=>{c.current?.focus()},[]);let l=async t=>{a(!0),r(``);let n=await jt(e,t);n.ok||(s(n.failure),a(!1))},u={id:`run-answer`,ref:c,autoComplete:`off`,value:n,disabled:i,onInput:e=>{r(e.currentTarget.value)},spellcheck:!1};return q(`form`,{class:`ask`,onSubmit:e=>{e.preventDefault(),i||l(n)},children:[q(`label`,{for:`run-answer`,children:q(gn,{text:t.prompt})}),t.secret?q(`input`,{type:`password`,...u}):q(`input`,{type:`text`,...u}),q(`button`,{type:`submit`,class:`button primary`,disabled:i,children:i?`Sending…`:`Answer`}),q(`button`,{type:`button`,class:`button`,disabled:i,onClick:()=>{l(``)},children:`Decline`}),o===void 0?null:q(Y,{failure:o})]})},Mr={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Nr=(e,t,n)=>t===void 0?e:H({...e,steps:e.steps.map((e,r)=>r===t?n(e):e)}),Pr=(e,t)=>Nr(e,e.current,e=>({...e,said:[...e.said,t]})),Fr=(e,t,n)=>{switch(t.kind){case`plan`:return H({...e,invocation:t.invocation,steps:t.steps.map(e=>({listed:e,state:`waiting`,said:[]}))});case`started`:return Nr({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Nr(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 H({...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 Pr(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Pr(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return H({...e,asking:t});case`answered`:return H({...e,asking:void 0})}},Ir=e=>{let{ended:t}=e;return t===void 0?H(`running`):t.stop?.why===`interrupted`?H(`interrupted`):t.stop?.why===`declined`?H(`declined`):t.failures===0?H(`passed`):H(`failed`)},Lr={fg:void 0,bold:!1,dim:!1},Rr=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],zr=(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?Lr: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:Rr[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${Rr[n-90]??`white`}`}:e,i)};return r(e,n)},Br=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),Vr=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,Hr=e=>{let t=[...e.matchAll(Vr)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:Br(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:zr(t.look,a),at:n.index+n[0].length}},{out:[],look:Lr,at:0}),n=e.slice(t.at);return n===``?t.out:H([...t.out,{text:n,classes:Br(t.look)}])},Ur={running:{word:`RUN`,tone:`active`},passed:{word:`OK`,tone:`ok`},failed:{word:`FAILED`,tone:`bad`},interrupted:{word:`STOPPED`,tone:`warn`},declined:{word:`DECLINED`,tone:`warn`}},Wr={waiting:{glyph:`○`,tone:`tone-muted`},running:{glyph:`◐`,tone:`tone-active pulse`},passed:{glyph:`✓`,tone:`tone-ok`},failed:{glyph:`✕`,tone:`tone-bad`},stopped:{glyph:`■`,tone:`tone-warn`},skipped:{glyph:`–`,tone:`tone-muted`}},Gr=({step:e})=>q(y,{children:e.said.map((e,t)=>e.kind===`output`?q(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:Hr(e.chunk).map((e,t)=>q(`span`,{class:e.classes===``?void 0:e.classes,children:e.text},t))},t):q(`div`,{class:e.stream===`err`?`said said-err`:`said`,children:q(gn,{text:e.text})},t))}),Kr=(e,t)=>e.ms??(e.started===void 0?void 0:t-e.started),qr=({steps:e,now:t,picked:n,pick:r})=>q(`ol`,{class:`steps panel`,children:e.map(e=>{let i=Kr(e,t),a=e.listed.index,o=n===a;return q(`li`,{children:[e.listed.opens===void 0?null:q(`div`,{class:`part`,children:e.listed.opens}),q(`button`,{type:`button`,"aria-pressed":o,class:`step-button step-${e.state}${o?` on`:e.state===`running`||e.state===`failed`?` ${e.state}`:``}`,onClick:()=>{r(o?void 0:a)},children:[q(`span`,{class:Wr[e.state].tone,"aria-label":e.state,children:Wr[e.state].glyph}),q(`span`,{children:[q(`span`,{class:`step-title`,children:e.listed.title}),q(`span`,{class:`step-kind`,children:e.why===void 0?e.listed.kind:`${e.listed.kind} · ${e.why}`})]}),q(`span`,{class:`step-time`,children:i===void 0?e.state:nr(i)})]})]},a)})}),Jr=({id:e})=>{let[t,n]=Se((e,t)=>Fr(e,t,Date.now()),Mr),[r,i]=F(Date.now()),[a,o]=F(void 0),[s,c]=F(void 0),[l,u]=F(!0),d=Ce(null);I(()=>It(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0,void 0,o),[e]);let f=Ir(t)===`running`;I(()=>{if(!f)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[f]),I(()=>{l&&d.current?.scrollTo({top:d.current.scrollHeight})},[t,l,s]);let{invocation:p,steps:m,ended:h,asking:g}=t;if(p===void 0)return a===void 0?q(X,{what:`Starting`}):q(Y,{failure:a});let _=Ur[Ir(t)],v=m.flatMap(e=>e.started===void 0?[]:[e.started]),b=h?.ms??(v.length===0?0:r-Math.min(...v)),x=m.filter(e=>e.state===`passed`).length,S=h?.stop,C=S===void 0?void 0:m.find(e=>e.listed.index===S.index),w=m.find(e=>e.state===`failed`),ee=m.filter(e=>(s===void 0||e.listed.index===s)&&e.said.length>0);return q(y,{children:[q(Cn,{kicker:`run · ${e}`,title:q(`code`,{children:p.command}),tag:q(vn,{word:_.word,tone:_.tone}),sub:[...p.about,`${String(m.length)} steps`].join(` · `),children:[q(`div`,{class:`elapsed`,children:[q(`strong`,{children:nr(b)}),q(`span`,{children:[x,` of `,m.length,` steps passed`]})]}),f?q(`button`,{type:`button`,class:`button danger`,onClick:()=>{Mt(e).then(e=>{e.ok||o(e.failure)})},children:`stop`}):null]}),q(`div`,{class:`progress`,role:`img`,"aria-label":`${String(x)} of ${String(m.length)} steps passed`,children:m.map(e=>q(`span`,{class:e.state},e.listed.index))}),a===void 0?null:q(Y,{failure:a}),S===void 0||C===void 0?null:q(`div`,{class:`banner ${S.why===`failed`?`banner-bad`:`banner-warn`}`,role:`alert`,children:[q(`span`,{class:S.why===`failed`?`tone-bad`:`tone-warn`,"aria-hidden":`true`,children:S.why===`failed`?`✕`:`■`}),q(`div`,{class:`prose`,children:[q(`strong`,{children:[S.why===`failed`?`Stopped at`:S.why===`declined`?`Declined at`:`Interrupted at`,` `,C.listed.title,`.`]}),` `,C.why??``,` Nothing after it ran.`]}),q(`button`,{type:`button`,class:`button small`,onClick:()=>{c(S.index)},children:`show it`})]}),S!==void 0||h===void 0||h.failures===0||w===void 0?null:q(`div`,{class:`banner banner-bad`,role:`alert`,children:[q(`span`,{class:`tone-bad`,"aria-hidden":`true`,children:`✕`}),q(`div`,{class:`prose`,children:[q(`strong`,{children:[h.failures,` `,h.failures===1?`step`:`steps`,` failed,`]}),` `,`the first at `,w.listed.title,`. The rest ran; the footer says what to do.`]}),q(`button`,{type:`button`,class:`button small`,onClick:()=>{c(w.listed.index)},children:`show it`})]}),g===void 0?null:q(jr,{id:e,question:g},JSON.stringify(g)),q(`div`,{class:`split`,children:[q(`div`,{class:`side`,children:q(Z,{title:`steps`,meta:`from the plan`,children:q(qr,{steps:m,now:r,picked:s,pick:c})})}),q(`div`,{class:`wide`,children:q(Z,{title:`log`,aside:q(y,{children:[s===void 0?null:q(`button`,{type:`button`,class:`button small`,onClick:()=>{c(void 0)},"aria-label":`Show every step`,children:[m.find(e=>e.listed.index===s)?.listed.title??``,` ×`]}),q(`button`,{type:`button`,class:`button small`,"aria-pressed":l,onClick:()=>{u(!l)},children:[q(`span`,{class:l&&f?`tone-active pulse`:`tone-muted`,"aria-hidden":`true`,children:`●`}),l?`following`:`follow`]})]}),children:q(`div`,{class:`terminal-panel`,children:[q(`div`,{ref:d,class:`terminal-scrollbox`,onWheel:e=>{e.deltaY<0&&u(!1)},children:[ee.length===0?q(`span`,{class:`tone-muted`,children:f?`Waiting for output…`:`Nothing was printed here.`}):ee.map(e=>q(`div`,{children:[q(`div`,{class:`log-step`,children:[`── `,e.listed.index+1,` · `,e.listed.title,` ──`]}),q(Gr,{step:e})]},e.listed.index)),f&&l?q(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`}):null]}),h===void 0?null:q(`footer`,{class:`run-footer`,children:q(_n,{lines:h.footer})})]})})})]})]})},Yr=({name:e})=>{let t=W.value;if(t.state!==`ready`)return q(X,{what:`Reading the fleet`});let n=t.value.servers.find(t=>t.name===e);if(n===void 0)return q(`p`,{class:`empty`,children:[`No server `,e,` in this fleet.`]});let{value:r,live:i}=G.value,a=r?.servers.find(t=>t.name===e),o=dn(a),s=yr(n),c=K.value.state===`ready`?K.value.value.filter(t=>t.server===e):[],l=Sr([n],a===void 0?[]:[a],c).map(e=>({...e,remedies:e.remedies.filter(e=>e.kind!==`go`||e.to.page!==`server`)})),u=e=>()=>{En(e,{server:n.name})};return q(y,{children:[q(Cn,{kicker:`server`,title:n.name,tag:q(vn,{word:o.word,tone:o.tone}),sub:q(y,{children:[q(`span`,{children:[`kind `,q(`span`,{class:`tone-strong`,children:n.kind})]}),q(`span`,{children:[`target `,q(`span`,{class:`tone-strong`,children:n.target})]}),q(`span`,{children:[`domain`,` `,q(`a`,{href:`https://${n.domain}`,target:`_blank`,rel:`noreferrer`,class:`tone-strong`,children:n.domain})]})]}),children:[q(`button`,{type:`button`,class:`button`,onClick:u(`ssh`),children:[`ssh`,a?.ssh.state===`refused`?q(`span`,{class:`aside`,children:`off`}):null]}),n.commands.includes(`verify`)?q(`button`,{type:`button`,class:`button`,onClick:u(`verify`),children:[`verify`,q(`span`,{class:`aside`,children:`read only`})]}):null,n.commands.includes(`plan`)?q(`button`,{type:`button`,class:`button`,onClick:u(`plan`),children:[`plan`,q(`span`,{class:`aside`,children:`dry run`})]}):null,s===void 0?null:q(`button`,{type:`button`,class:`button primary`,onClick:u(s),children:[s,` `,n.name]})]}),l.length===0?null:q(mr,{notes:l,quiet:``}),q(`div`,{class:`split`,children:[q(`div`,{class:`wide`,children:[n.kind===`platform`?q(Z,{title:`apps`,meta:n.apps.length,children:n.apps.length===0?q(`p`,{class:`empty panel pad`,children:`None in server.yml.`}):q(`ul`,{class:`links panel`,children:n.apps.map(e=>q(`li`,{children:q($,{to:{page:`app`,server:n.name,app:e},children:[q(`span`,{class:`prompt`,"aria-hidden":`true`,children:`▸`}),q(`span`,{children:e})]})},e))})}):null,q(Z,{title:`runs from here`,children:q(wr,{server:n.name})}),q(Z,{title:`commands`,children:q(hr,{server:n})})]}),q(`div`,{class:`side`,children:q(Z,{title:`reach`,aside:q(`button`,{type:`button`,class:`button small`,onClick:Jt,disabled:i,children:i?`asking…`:`ask again`}),children:q(`div`,{class:`panel pad`,children:a===void 0?q(X,{what:`asking`}):q(`dl`,{class:`facts`,children:[q(Sn,{label:`address`,cell:on(a)}),q(Sn,{label:`ssh`,cell:sn(a)}),q(Sn,{label:`login`,cell:cn(a)}),q(Sn,{label:`kayra`,cell:ln(a)})]})})})})]})]})},Xr=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,Zr=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,Qr={problem:`problems`,unchecked:`partly checked`,passed:`holds`},$r=()=>{I(()=>{Yt()},[]);let e=Kt.value;if(e.state===`loading`)return q(X,{what:`Checking the fleet beyond its schemas`});if(e.state===`failed`)return q(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 q(y,{children:[q(Cn,{kicker:`fleet`,title:`validate`,tag:q(vn,{word:t===`problem`?`FAIL`:t===`unchecked`?`PART`:`OK`,tone:Xr(t)}),sub:`Secrets, apps against their contract, stacks, routes · ${String(r(`problem`))} problems · ${String(r(`unchecked`))} not checked`,children:q(`button`,{type:`button`,class:`button`,onClick:()=>void Yt(),children:[`check again`,q(`span`,{class:`aside`,children:`read only`})]})}),n.map(e=>q(`section`,{class:`card`,children:[q(`div`,{class:`card-head`,children:[q(J,{tone:Xr(e.result)}),q(`h2`,{children:e.name}),q(xn,{children:e.kind}),q(xn,{children:e.target}),q(`span`,{class:`grow`}),q(xn,{tone:Xr(e.result),children:Qr[e.result]})]}),q(`ul`,{class:`findings`,children:e.findings.map((e,t)=>q(`li`,{class:`finding finding-${e.result}`,children:[q(`span`,{class:`glyph tone-${Xr(e.result)}`,children:Zr(e.result)}),q(`span`,{children:[e.text,e.hint===null?null:q(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},ei=e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.text).join(``),ti=e=>e.kind===`output`?e.chunk:e.kind===`said`?`${ei(e.text)}\r\n`:``,ni=(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})}},ri=`modulepreload`,ii=function(e){return`/`+e},ai={},oi=function(e){return e.pathname.endsWith(`.css`)},si=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ci=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=ii(t,n);let r=s(t),i=oi(r);return si(ai,r.href,()=>{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 t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ri,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(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)})},li=({id:e})=>{let t=Ce(null),[n,r]=F(void 0),[i,a]=F(void 0),[o,s]=F(`running`),[c,l]=F(void 0),[u,d]=F(!1);I(()=>{let n={current:!0},i={current:()=>void 0};return(async()=>{let{Terminal:o}=await ci(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=ni(t=>Nt(e,t),h),_=c.onData(e=>{f.current&&g(e)}),v=It(`/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=ti(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 Pt(e);t.ok||(l(t.failure),d(!1))};return q(y,{children:[q(Cn,{kicker:`ssh session`,title:q(`code`,{children:n?.command??`kayra ssh`}),sub:`120 columns × 32 rows`,children:[q(xn,{tone:o===`running`?`active`:o===`passed`?`ok`:`warn`,children:o}),o===`running`?q(`button`,{class:`button danger`,disabled:u,onClick:()=>{f()},children:u?`Closing…`:`Close session`}):null]}),c===void 0?null:q(Y,{failure:c}),i===void 0?null:q(jr,{id:e,question:i},JSON.stringify(i)),q(`div`,{class:`terminal-scroll`,children:q(`div`,{ref:t,class:`terminal`})}),q(`p`,{class:`hint`,children:`Leaving this page keeps the session open. Use Close session to disconnect.`})]})},ui=()=>{let e=U.value;switch(e.page){case`fleet`:return q(Ar,{});case`server`:return q(Yr,{name:e.server});case`app`:return q(fr,{server:e.server,app:e.app});case`runs`:return q(Tr,{});case`run`:return q(Jr,{id:e.id},e.id);case`session`:return q(li,{id:e.id},e.id);case`validate`:return q($r,{});case`missing`:return q(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},di=()=>(I(()=>(qt(),Gt(),Jt(),Qt()),[]),q(y,{children:[q(tr,{children:q(ui,{})}),q(Rn,{}),q(Un,{})]})),fi=document.getElementById(`app`);fi!==null&&j(q(di,{}),fi);
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
if (chosen === "dark" || chosen === "light") document.documentElement.setAttribute("data-theme", chosen);
|
|
14
14
|
} catch {}
|
|
15
15
|
</script>
|
|
16
|
-
<script type="module" crossorigin src="/assets/index-
|
|
16
|
+
<script type="module" crossorigin src="/assets/index-CYYhXjdE.js"></script>
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/index-DzIVPXyL.css">
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
|
@@ -24,6 +24,7 @@ export const settings = [
|
|
|
24
24
|
setting("authelia_smtp_username", platform, text, "SMTP user for Authelia."),
|
|
25
25
|
setting("authelia_smtp_sender", platform, text, "Sender address of Authelia's mails."),
|
|
26
26
|
setting("acme_dns", platform, z.enum(["", "hetzner"]), "Certificates by DNS-01 instead of HTTP-01, for a server the internet never reaches: the DNS provider (hetzner)."),
|
|
27
|
+
setting("apex_redirect", platform, subdomainSchema, "The host the bare domain redirects to, permanently, path and query kept: www sends https://<domain>/x?y to https://www.<domain>/x?y. Unset, the bare domain is not served."),
|
|
27
28
|
setting("webhooks", platform, z.boolean(), "Whether a push webhook may start a deploy at once: true (default) serves deploy.<domain>/hook/<app>; false serves no such endpoint, and pushes deploy by deploy_poll."),
|
|
28
29
|
setting("deploy_poll", platform, text, "When the deployer looks for pushes no webhook brought, as a five-field cron spec in the server's time (default hourly: 17 * * * *)."),
|
|
29
30
|
setting("renovate_repositories", platform, texts, "owner/repo of the repos this server's Renovate job keeps up to date; the job runs only where the list is not empty."),
|
|
@@ -85,6 +85,24 @@ const routeFindings = (facts) => {
|
|
|
85
85
|
]);
|
|
86
86
|
}), `edge_routes: ${count(routes.length, "route")}, each with subdomains and a host:port upstream`);
|
|
87
87
|
};
|
|
88
|
+
/** apex_redirect: the bare domain redirects to a host one of the server's apps serves. */
|
|
89
|
+
const apexFindings = (facts) => {
|
|
90
|
+
const target = facts.vars["apex_redirect"];
|
|
91
|
+
if (typeof target !== "string" || target === "")
|
|
92
|
+
return typed([]);
|
|
93
|
+
const hosts = facts.server.apps.flatMap((app) => {
|
|
94
|
+
const parsed = appManifestSchema.safeParse(facts.manifests[app.name]);
|
|
95
|
+
return typed(parsed.success ? (parsed.data.routes ?? []).map((route) => String(route.host)) : []);
|
|
96
|
+
});
|
|
97
|
+
const domain = facts.server.domain;
|
|
98
|
+
if (hosts.includes(target))
|
|
99
|
+
return typed([passed(`apex_redirect: ${domain} redirects to ${target}.${domain}, which app routes serve`)]);
|
|
100
|
+
if (facts.server.apps.some((app) => facts.manifests[app.name] === undefined))
|
|
101
|
+
return typed([unchecked(`apex_redirect not checked: not every app is cloned yet`, `kayra apps ${facts.server.name} clones them`)]);
|
|
102
|
+
return typed([
|
|
103
|
+
problem(`apex_redirect: no app routes ${target}.${domain}, so ${domain} would redirect to nothing`, "name a route host of one of the server's apps"),
|
|
104
|
+
]);
|
|
105
|
+
};
|
|
88
106
|
/** Each app's contract against the fleet's values for it. */
|
|
89
107
|
const appFindings = (facts) => Object.freeze(facts.server.apps.flatMap((app) => {
|
|
90
108
|
const manifest = facts.manifests[app.name];
|
|
@@ -116,7 +134,7 @@ const appFindings = (facts) => Object.freeze(facts.server.apps.flatMap((app) =>
|
|
|
116
134
|
}));
|
|
117
135
|
const rank = { problem: 0, unchecked: 1, passed: 2 };
|
|
118
136
|
/** Everything validate finds for one server: problems first, then what it could not check, then what holds. */
|
|
119
|
-
export const findings = (facts) => Object.freeze([...secretsFindings(facts), ...recipientFindings(facts), ...terraformFindings(facts), ...stackFindings(facts), ...routeFindings(facts), ...appFindings(facts)].toSorted((a, b) => rank[a.result] - rank[b.result]));
|
|
137
|
+
export const findings = (facts) => Object.freeze([...secretsFindings(facts), ...recipientFindings(facts), ...terraformFindings(facts), ...stackFindings(facts), ...routeFindings(facts), ...apexFindings(facts), ...appFindings(facts)].toSorted((a, b) => rank[a.result] - rank[b.result]));
|
|
120
138
|
/** How a set of findings went as a whole: its worst. */
|
|
121
139
|
export const overall = (found) => verdicts.find((verdict) => found.some((each) => each.result === verdict)) ?? "passed";
|
|
122
140
|
/** How many problems, and how many checks could not look, across reports. */
|
|
@@ -135,10 +135,10 @@ const deployRequest = (app, ref, why) => typed({
|
|
|
135
135
|
const poll = async (s) => {
|
|
136
136
|
await Promise.all(registeredApps(s).map(async (app) => {
|
|
137
137
|
const commit = await builderResolve(s.builder, app, app.ref);
|
|
138
|
-
const
|
|
138
|
+
const tried = runsOf(runsDir(s), appOwner(app.name)).flatMap((run) => Object.freeze(run.sha === undefined ? [] : [run.sha]));
|
|
139
139
|
const releasesDir = join(s.platformDir, "releases", app.name);
|
|
140
140
|
const lastRelease = releases(existsSync(releasesDir) ? readdirSync(releasesDir) : [])[0];
|
|
141
|
-
if (commit.ok && moved(commit.value,
|
|
141
|
+
if (commit.ok && moved(commit.value, tried, lastRelease?.sha))
|
|
142
142
|
ask(s, deployRequest(app, app.ref, "poll"));
|
|
143
143
|
}));
|
|
144
144
|
};
|
|
@@ -13,8 +13,13 @@ export const releases = (names) => Object.freeze(names
|
|
|
13
13
|
return match?.[1] === undefined || !commit.ok ? Object.freeze([]) : Object.freeze([typed({ sha: commit.value, time: match[1] })]);
|
|
14
14
|
})
|
|
15
15
|
.filter((release, i, all) => all.findIndex((other) => other.sha === release.sha) === i));
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The poll's question: has the ref moved to a commit no kept run has tried and
|
|
18
|
+
* the newest release does not run? Every run, not only the newest: after a
|
|
19
|
+
* rollback the newest is the rollback, and the commit it rolled back from
|
|
20
|
+
* would be tried again.
|
|
21
|
+
*/
|
|
22
|
+
export const moved = (resolved, tried, lastRelease) => !tried.includes(resolved) && resolved !== lastRelease;
|
|
18
23
|
const whys = ["push", "poll", "deploy", "rollback", "restore", "schedule", "manual"];
|
|
19
24
|
const states = ["queued", "running", "success", "failure", "superseded"];
|
|
20
25
|
const isWhy = (value) => whys.some((why) => why === value);
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
services:
|
|
8
8
|
registry:
|
|
9
|
-
image: registry:
|
|
9
|
+
image: registry:3.1.2@sha256:01cd312e67026f06f5d89c3e133a4a9adc7cb9eeb9b1194e0b2954dfd770efd2
|
|
10
10
|
restart: unless-stopped
|
|
11
11
|
environment:
|
|
12
12
|
# registry-gc.sh deletes manifests nothing references any more.
|
|
13
13
|
- REGISTRY_STORAGE_DELETE_ENABLED=true
|
|
14
|
+
# The image's own config logs at debug.
|
|
15
|
+
- REGISTRY_LOG_LEVEL=info
|
|
14
16
|
# No Traefik router: builds push to registry:5000 and the host daemon pulls
|
|
15
17
|
# from localhost:5000, so nothing outside the server needs it.
|
|
16
18
|
ports:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yunuseon/kayra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "A self-hosted app platform and the CLI that runs it: Traefik, Authelia, a registry, rootless BuildKit and a small deployer per server, set up with OpenTofu and Ansible.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yunus Öztürk",
|
package/schema/defaults.json
CHANGED
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
],
|
|
39
39
|
"description": "Certificates by DNS-01 instead of HTTP-01, for a server the internet never reaches: the DNS provider (hetzner)."
|
|
40
40
|
},
|
|
41
|
+
"apex_redirect": {
|
|
42
|
+
"description": "The host the bare domain redirects to, permanently, path and query kept: www sends https://<domain>/x?y to https://www.<domain>/x?y. Unset, the bare domain is not served.",
|
|
43
|
+
"type": "string",
|
|
44
|
+
"pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"
|
|
45
|
+
},
|
|
41
46
|
"webhooks": {
|
|
42
47
|
"type": "boolean",
|
|
43
48
|
"description": "Whether a push webhook may start a deploy at once: true (default) serves deploy.<domain>/hook/<app>; false serves no such endpoint, and pushes deploy by deploy_poll."
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
],
|
|
39
39
|
"description": "Certificates by DNS-01 instead of HTTP-01, for a server the internet never reaches: the DNS provider (hetzner)."
|
|
40
40
|
},
|
|
41
|
+
"apex_redirect": {
|
|
42
|
+
"description": "The host the bare domain redirects to, permanently, path and query kept: www sends https://<domain>/x?y to https://www.<domain>/x?y. Unset, the bare domain is not served.",
|
|
43
|
+
"type": "string",
|
|
44
|
+
"pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"
|
|
45
|
+
},
|
|
41
46
|
"webhooks": {
|
|
42
47
|
"type": "boolean",
|
|
43
48
|
"description": "Whether a push webhook may start a deploy at once: true (default) serves deploy.<domain>/hook/<app>; false serves no such endpoint, and pushes deploy by deploy_poll."
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
# its vars.yml's monitor.watch,
|
|
6
6
|
# platform: auth.<domain> answers; the platform's pages (hosts.conf, status
|
|
7
7
|
# where it runs a monitor) send a browser to the login; every app route answers, not 5xx;
|
|
8
|
-
# deploy.<domain>/health is 200 (monitor_health_tokens.<server>)
|
|
8
|
+
# deploy.<domain>/health is 200 (monitor_health_tokens.<server>);
|
|
9
|
+
# with apex_redirect, the bare domain redirects (301)
|
|
9
10
|
# edge: every edge_routes name answers, not 5xx
|
|
10
11
|
# nas: nothing of its own: its stacks are monitor.extra
|
|
11
12
|
# plus monitor.extra as given. Every certificate must have 10 days left. Each
|
|
@@ -56,6 +57,8 @@ watched() {
|
|
|
56
57
|
[ "$sub" = auth ] || endpoint "${sub}.${domain}" "$server" "https://${sub}.${domain}/" false false '[STATUS] == 302' "$cert"
|
|
57
58
|
done
|
|
58
59
|
endpoint "deploy.${domain}/health" "$server" "https://deploy.${domain}/health" false true '[STATUS] == 200'
|
|
60
|
+
apex="$( [ -f "${dir}/vars.yml" ] && yq -r '.apex_redirect // ""' "${dir}/vars.yml" || true)"
|
|
61
|
+
[ -z "$apex" ] || endpoint "$domain" "$server" "https://${domain}/" false false '[STATUS] == 301' "$cert"
|
|
59
62
|
bash "${KAYRA_ROOT}/scripts/local/app-manifests.sh" --routes "$server" | while read -r sub path; do
|
|
60
63
|
[ -z "$sub" ] || endpoint "${sub}.${domain}${path%/}" "$server" "https://${sub}.${domain}${path}" true false '[STATUS] < 500' "$cert"
|
|
61
64
|
done
|
package/scripts/local/verify.sh
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
# - auth.<domain> answers; the platform's own pages (hosts.conf; status only
|
|
9
9
|
# where a monitor runs) send a browser to the login, not a 403 from rules
|
|
10
10
|
# Authelia never loaded
|
|
11
|
+
# - with apex_redirect, the bare domain redirects permanently to that host,
|
|
12
|
+
# path and query kept
|
|
11
13
|
# - every certificate is a real one (Let's Encrypt or mkcert), never
|
|
12
14
|
# Traefik's default
|
|
13
15
|
# - an unsigned webhook is refused (with webhooks: false, /hook is not
|
|
@@ -41,6 +43,7 @@ note() { echo " ! $*"; }
|
|
|
41
43
|
domain="$(yq -r '.domain' "${dir}/server.yml")"
|
|
42
44
|
# Not yq's `//`: it takes false for missing too.
|
|
43
45
|
webhooks="$( { [ -f "${dir}/vars.yml" ] && yq -r '.webhooks' "${dir}/vars.yml"; } || echo true)"
|
|
46
|
+
apex="$( { [ -f "${dir}/vars.yml" ] && yq -r '.apex_redirect // ""' "${dir}/vars.yml"; } || true)"
|
|
44
47
|
inventory="${dir}/inventory.ini"
|
|
45
48
|
[ -f "$inventory" ] || { fail "no inventory for ${name}: provision it first"; exit 1; }
|
|
46
49
|
field() { awk -v key="$1" '{for (i = 1; i <= NF; i++) if (index($i, key "=") == 1) {print substr($i, length(key) + 2); exit}}' "$inventory"; }
|
|
@@ -79,6 +82,7 @@ answers() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 200 ]; }
|
|
|
79
82
|
to_login() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 302 ] && case "$(cut -d' ' -f2 <<< "$1")" in "https://auth.${domain}/"*) return 0 ;; esac; return 1; }
|
|
80
83
|
not_5xx() { real_cert "$1" && case "$(cut -d' ' -f1 <<< "$1")" in 000|5*) return 1 ;; esac; }
|
|
81
84
|
refused() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 401 ]; }
|
|
85
|
+
to_apex() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 301 ] && [ "$(cut -d' ' -f2 <<< "$1")" = "https://${apex}.${domain}/x?y" ]; }
|
|
82
86
|
|
|
83
87
|
describe() { echo "HTTP $(cut -d' ' -f1 <<< "$1"), certificate by $(cut -d' ' -f4- <<< "$1") (verify $(cut -d' ' -f3 <<< "$1"))"; }
|
|
84
88
|
|
|
@@ -96,6 +100,7 @@ while IFS= read -r sub; do
|
|
|
96
100
|
*) check "${sub}.${domain} sends a browser to the login" "${sub}.${domain}" GET to_login ;;
|
|
97
101
|
esac
|
|
98
102
|
done < <(awk '!/^[[:space:]]*(#|$)/ {print $1}' "${KAYRA_ROOT}/hosts.conf")
|
|
103
|
+
[ -z "$apex" ] || check "${domain} redirects to ${apex}.${domain}" "$domain" GET to_apex "/x?y"
|
|
99
104
|
|
|
100
105
|
first_app="$(head -1 <<< "$registered_wanted")"
|
|
101
106
|
if [ -n "$first_app" ]; then
|
|
@@ -91,7 +91,7 @@ if [ "$deleted" -gt 0 ]; then
|
|
|
91
91
|
docker stop "$registry" >/dev/null
|
|
92
92
|
trap 'docker start "$registry" >/dev/null; rm -rf "$work"' EXIT
|
|
93
93
|
docker run --rm --volumes-from "$registry" "$image" \
|
|
94
|
-
garbage-collect /etc/
|
|
94
|
+
garbage-collect /etc/distribution/config.yml | tail -n 3
|
|
95
95
|
fi
|
|
96
96
|
|
|
97
97
|
# ── Build cache and host images ─────────────────────────────────────────────
|
|
@@ -80,7 +80,7 @@ ensure() {
|
|
|
80
80
|
read_manifest "$manifest"
|
|
81
81
|
|
|
82
82
|
# Every manifest type a push may leave, as registry-gc.sh asks: BuildKit
|
|
83
|
-
# pushes OCI manifests, and registry
|
|
83
|
+
# pushes OCI manifests, and the registry answers 404 to a request that does
|
|
84
84
|
# not accept the type it holds — every image would look missing.
|
|
85
85
|
local status
|
|
86
86
|
status=$(curl -s -o /dev/null -w '%{http_code}' \
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# =============================================================================
|
|
2
2
|
# A platform server's DNS: an A record for each host it serves, derived from
|
|
3
3
|
# the fleet, never listed by hand. The platform's own subdomains (kayra's
|
|
4
|
-
# hosts.conf)
|
|
5
|
-
# app.yml in the fleet's clone (.cache/apps, which kayra doctor fills) says
|
|
6
|
-
#
|
|
4
|
+
# hosts.conf), every route host of every app in server.yml, as the app's
|
|
5
|
+
# app.yml in the fleet's clone (.cache/apps, which kayra doctor fills) says,
|
|
6
|
+
# and the bare domain where the server redirects it (apex_redirect in
|
|
7
|
+
# vars.yml). A new route host in an app is a new record on the next apply.
|
|
7
8
|
# =============================================================================
|
|
8
9
|
|
|
9
10
|
terraform {
|
|
@@ -28,9 +29,11 @@ locals {
|
|
|
28
29
|
}
|
|
29
30
|
uncloned = [for name, manifest in local.manifests : name if !fileexists(manifest)]
|
|
30
31
|
|
|
31
|
-
# status only where the server runs a monitor, which serves it
|
|
32
|
+
# status only where the server runs a monitor, which serves it; the bare
|
|
33
|
+
# domain only where it redirects (apex_redirect).
|
|
32
34
|
vars_file = "${var.fleet_root}/servers/${var.server}/vars.yml"
|
|
33
35
|
monitored = fileexists(local.vars_file) ? try(yamldecode(file(local.vars_file)).monitor, null) != null : false
|
|
36
|
+
apex = fileexists(local.vars_file) ? try(yamldecode(file(local.vars_file)).apex_redirect, "") != "" : false
|
|
34
37
|
platform_subdomains = [
|
|
35
38
|
for sub in [
|
|
36
39
|
for line in split("\n", file("${path.module}/../../../hosts.conf")) :
|
|
@@ -44,9 +47,13 @@ locals {
|
|
|
44
47
|
subdomains = toset(concat(local.platform_subdomains, local.app_subdomains))
|
|
45
48
|
|
|
46
49
|
# A host's name in the zone: www under ippo-club.net in ippo-club.net is www;
|
|
47
|
-
# under shop.example.com in example.com it is www.shop.
|
|
50
|
+
# under shop.example.com in example.com it is www.shop. The bare domain is
|
|
51
|
+
# "@" in its own zone, else the rest of it (shop).
|
|
48
52
|
suffix = local.domain == var.zone ? "" : trimsuffix(local.domain, ".${var.zone}")
|
|
49
|
-
names
|
|
53
|
+
names = merge(
|
|
54
|
+
{ for sub in local.subdomains : sub => local.suffix == "" ? sub : "${sub}.${local.suffix}" },
|
|
55
|
+
local.apex ? { "@" = local.suffix == "" ? "@" : local.suffix } : {},
|
|
56
|
+
)
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
resource "hcloud_zone_rrset" "a" {
|
|
@@ -5,5 +5,5 @@ output "records" {
|
|
|
5
5
|
|
|
6
6
|
output "hosts" {
|
|
7
7
|
description = "Every host this server serves, fully qualified"
|
|
8
|
-
value = sort([for sub in local.
|
|
8
|
+
value = sort([for sub in keys(local.names) : sub == "@" ? local.domain : "${sub}.${local.domain}"])
|
|
9
9
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apex_redirect: www
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apex_redirect: www
|
|
@@ -77,3 +77,33 @@ run "monitor_page" {
|
|
|
77
77
|
error_message = "status should be a host where the server runs a monitor"
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
# A server redirecting its bare domain (apex_redirect) serves that too: "@" in its own zone.
|
|
82
|
+
run "bare_domain" {
|
|
83
|
+
command = plan
|
|
84
|
+
|
|
85
|
+
variables {
|
|
86
|
+
server = "redirecting"
|
|
87
|
+
zone = "example.com"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assert {
|
|
91
|
+
condition = contains(output.hosts, "example.com") && hcloud_zone_rrset.a["@"].name == "@"
|
|
92
|
+
error_message = "The bare domain should be an A record named @: ${jsonencode(output.hosts)}"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Under the zone, the bare domain's name is the rest of it.
|
|
97
|
+
run "bare_domain_under_the_zone" {
|
|
98
|
+
command = plan
|
|
99
|
+
|
|
100
|
+
variables {
|
|
101
|
+
server = "redirecting-nested"
|
|
102
|
+
zone = "example.com"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
assert {
|
|
106
|
+
condition = contains(output.hosts, "shop.example.com") && hcloud_zone_rrset.a["@"].name == "shop"
|
|
107
|
+
error_message = "shop.example.com in example.com should be named shop"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -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 b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(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 S(t,s,i,a,null)}function S(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 C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(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`?T(e):null}function E(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),oe(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??T(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,ce(i,o,a),n.__e=n.__=null,o.__e!=r&&D(o)}}function D(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}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&i.push(e)&&!k.__r++||a!=t.debounceRendering)&&((a=t.debounceRendering)||o)(k)}function k(){try{for(var e,t=1;i.length;)i.length>t&&i.sort(s),e=i.shift(),t=i.length,E(e)}finally{i.length=k.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y=r&&r.__k||g,b=t.length;for(c=te(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||h,p.__i=d,v=oe(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&de(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(c=ne(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 te(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]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(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=re(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=T(s)),fe(s,s));return r}function ne(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=ne(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=T(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function re(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 ie(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function A(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||ie(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ie(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 ae(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 oe(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,_,x,S,E,D,O,k,te,ne,re,ie,A=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 A==`function`){f=s.length;try{if(E=n.props,D=A.prototype&&A.prototype.render,O=(d=A.contextType)&&i[d.__c],k=d?O?O.props.value:d.__:i,r.__c?S=(p=n.__c=r.__c).__=p.__E:(D?n.__c=p=new A(E,k):(n.__c=p=new w(E,k),p.constructor=A,p.render=pe),O&&O.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),D&&p.__s==null&&(p.__s=p.state),D&&A.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=y({},p.__s)),y(p.__s,A.getDerivedStateFromProps(E,p.__s))),h=p.props,_=p.state,p.__v=n,m)D&&A.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),D&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(D&&A.getDerivedStateFromProps==null&&E!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(E,k),n.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(E,p.__s,k)){n.__v!=r.__v&&(p.props=E,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=T(r);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(E,p.__s,k),D&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,_,x)})}if(p.context=k,p.props=E,p.__P=e,p.__e=!1,te=t.__r,ne=0,D)p.state=p.__s,p.__d=!1,te&&te(n),d=p.render(p.props,p.state,p.context),g.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,te&&te(n),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++ne<25);p.state=p.__s,p.getChildContext!=null&&(i=y(y({},i),p.getChildContext())),D&&!m&&p.getSnapshotBeforeUpdate!=null&&(x=p.getSnapshotBeforeUpdate(h,_)),re=d!=null&&d.type===C&&d.key==null?le(d.props.children):d,c=ee(e,v(re)?re:[re],n,r,i,a,o,s,c,l,u),p.base=n.__e,n.__u&=-161,p.__h.length&&s.push(p),S&&(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(ie=o.length;ie--;)b(o[ie])}else n.__e=r.__e;n.__k??=r.__k||[],e.then||se(n),t.__e(e,n,r)}}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=ue(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function se(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(se))}function ce(e,n,r){for(var i=0;i<r.length;i++)de(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 le(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(le):e.constructor===void 0?y({},e):null}function ue(n,r,i,a,o,s,c,l,u){var d,f,p,m,g,_,y,x=i.props||h,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`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==!!C&&(C?g.localName==C:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(C==null)return document.createTextNode(S);n=document.createElementNS(o,C,S.is&&S),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(C==null)x===S||l&&n.data==S||(n.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(x={},d=0;d<n.attributes.length;d++)x[(g=n.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||A(n,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||A(n,d,g,x[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=``),ee(r.type==`template`?n.content:n,v(m)?m:[m],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&T(i,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&_==null?n.removeAttribute(`value`):_!=null&&(_!==n[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&A(n,d,_,x[d],o),d=`checked`,y!=null&&y!=n[d]&&A(n,d,y,x[d],o))}return n}function de(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 fe(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||de(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]&&fe(i[a],n,r||typeof e.type!=`function`);r||b(e.__e),e.__c=e.__=e.__e=void 0}function pe(e,t,n){return this.constructor(e,n)}function me(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=[],oe(r,n=(!a&&i||r).__k=x(C,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),ce(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},w.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),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,i=[],o=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,c=Math.random().toString(8),l=`__d`+c,u=`__a`+c,d=/(PointerCapture)$|Capture$/i,f=0,p=ae(!1),m=ae(!0);var he,j,ge,_e,ve=0,ye=[],M=t,be=M.__b,xe=M.__r,Se=M.diffed,Ce=M.__c,we=M.unmount,Te=M.__;function Ee(e,t){M.__h&&M.__h(j,e,ve||t),ve=0;var n=j.__H||(j.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function N(e){return ve=1,De(Ie,e)}function De(e,t,n){var r=Ee(he++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ie(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=j,!j.__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};j.__f=!0;var a=j.shouldComponentUpdate,o=j.componentWillUpdate;j.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)},j.shouldComponentUpdate=i}return r.__N||r.__}function P(e,t){var n=Ee(he++,3);!M.__s&&Fe(n.__H,t)&&(n.__=e,n.u=t,j.__H.__h.push(n))}function Oe(e){return ve=5,ke(function(){return{current:e}},[])}function ke(e,t){var n=Ee(he++,7);return Fe(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ae(){for(var e;e=ye.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ne),t.__h.some(Pe),t.__h=[]}catch(n){t.__h=[],M.__e(n,e.__v)}}}M.__b=function(e){j=null,be&&be(e)},M.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Te&&Te(e,t)},M.__r=function(e){xe&&xe(e),he=0;var t=(j=e.__c).__H;t&&(ge===j?(t.__h=[],j.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ne),t.__h.some(Pe),t.__h=[],he=0)),ge=j},M.diffed=function(e){Se&&Se(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ye.push(t)!==1&&_e===M.requestAnimationFrame||((_e=M.requestAnimationFrame)||Me)(Ae)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ge=j=null},M.__c=function(e,t){t.some(function(e){try{e.__h.some(Ne),e.__h=e.__h.filter(function(e){return!e.__||Pe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],M.__e(n,e.__v)}}),Ce&&Ce(e,t)},M.unmount=function(e){we&&we(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ne(e)}catch(e){t=e}}),n.__H=void 0,t&&M.__e(t,n.__v))};var je=typeof requestAnimationFrame==`function`;function Me(e){var t,n=function(){clearTimeout(r),je&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);je&&(t=requestAnimationFrame(n))}function Ne(e){var t=j,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),j=t}function Pe(e){var t=j;e.__c=e.__(),j=t}function Fe(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ie(e,t){return typeof t==`function`?t(e):t}var Le=Symbol.for(`preact-signals`);function Re(){if(I>1)I--;else{var e,t=!1;for((function(){var e=Ke;for(Ke=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}})();He!==void 0;){var n=He;for(He=void 0,Ue++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ye(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Ue=0,I--,t)throw e}}function ze(e){if(I>0)return e();Ge=++We,I++;try{return e()}finally{Re()}}var Be,F=void 0;function Ve(e){var t=F,n=Be;F=void 0,Be=void 0;try{return e()}finally{F=t,Be=n}}var He=void 0,I=0,Ue=0,We=0,Ge=0,Ke=void 0,qe=0;function Je(e){if(F!==void 0){var t=e.n;if(t===void 0||t.t!==F)return t={i:0,S:e,p:F.s,n:void 0,t:F,e:void 0,x:void 0,r:t},F.s!==void 0&&(F.s.n=t),F.s=t,e.n=t,32&F.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=F.s,t.n=void 0,F.s.n=t,F.s=t),t}}function L(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}L.prototype.brand=Le,L.prototype.h=function(){return!0},L.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?Ve(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},L.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&&Ve(function(){var e;(e=t.Z)==null||e.call(t)}))}},L.prototype.subscribe=function(e){var t=this;return it(function(){var n=t.value;Ve(function(){return e(n)})},{name:`sub`})},L.prototype.valueOf=function(){return this.value},L.prototype.toString=function(){return this.value+``},L.prototype.toJSON=function(){return this.value},L.prototype.peek=function(){var e=this;return Ve(function(){return e.value})},Object.defineProperty(L.prototype,"value",{get:function(){var e=Je(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ue>100)throw Error(`Cycle detected`);(function(e){I!==0&&Ue===0&&e.l!==Ge&&(e.l=Ge,Ke={S:e,v:e.v,i:e.i,o:Ke})})(this),this.v=e,this.i++,qe++,I++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Re()}}}});function R(e,t){return new L(e,t)}function Ye(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 Xe(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 Ze(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 Qe(e,t){L.call(this,void 0,t),this.x=e,this.s=void 0,this.g=qe-1,this.f=4}Qe.prototype=new L,Qe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===qe))return!0;if(this.g=qe,this.f|=1,this.i>0&&!Ye(this))return this.f&=-2,!0;var e=F;try{Xe(this),F=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 F=e,Ze(this),this.f&=-2,!0},Qe.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)}L.prototype.S.call(this,e)},Qe.prototype.U=function(e){if(this.t!==void 0&&(L.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)}},Qe.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(Qe.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Je(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 Qe(e,t)}function et(e){var t=e.m;if(e.m=void 0,typeof t==`function`){I++;var n=F;F=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,tt(e),t}finally{F=n,Re()}}}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(F!==this)throw Error(`Out-of-order effect`);Ze(this),F=e,this.f&=-2,8&this.f&&tt(this),Re()}function rt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Be&&Be.push(this)}rt.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()}},rt.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,et(this),Xe(this),I++;var e=F;return F=this,nt.bind(this,e)},rt.prototype.N=function(){2&this.f||(this.f|=2,this.u=He,He=this)},rt.prototype.d=function(){this.f|=8,1&this.f||tt(this)},rt.prototype.dispose=function(){this.d()};function it(e,t){var n=new rt(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var at,ot,st=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,ct=[];it(function(){at=this.N})();function lt(e,n){t[e]=n.bind(null,t[e]||function(){})}function ut(e){if(ot){var t=ot;ot=void 0,t()}ot=e&&e.S()}function dt(e){var t=this,n=e.data,i=pt(n);i.name=`ReactiveDom`,i.value=n;var a=ke(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=it(function(){if(this.N=gt,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}dt.displayName=`ReactiveTextNode`,Object.defineProperties(L.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:dt},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),lt(`__b`,function(e,t){if(ut(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof L&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),lt(`__r`,function(e,t){if(e(t),t.type!==C){ut();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return it(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;st&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),ut(n)}}),lt(`__e`,function(e,t,n,r){ut(),e(t,n,r)}),lt(`diffed`,function(e,t){ut();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=ft(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function ft(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=R(n);return{o:function(e,t){a.value=e,r=t},d:it(function(){this.N=gt;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))})}}lt(`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)}),lt(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),w.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 pt(e,t){return ke(function(){return R(e,t)},[])}var mt=function(e){queueMicrotask(function(){queueMicrotask(e)})};function ht(){ze(function(){for(var e;e=ct.shift();)at.call(e)})}function gt(){ct.push(this)===1&&(t.requestAnimationFrame||mt)(ht)}var z=e=>e,_t={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.init":{label:`Prepare app repository`,icon:`+`},"app.check":{label:`Check app repository`,icon:`✓`},"app.launch":{label:`Launch app`,icon:`▶`},"app.hook":{label:`Hook app repository`,icon:`↪`},"app.values":{label:`App configuration requirements`,icon:`≡`},"app.config.set":{label:`Set app configuration`,icon:`⚙`},"app.secret.import":{label:`Import app secret`,icon:`+`},"app.secret.generate":{label:`Generate app secret`,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`}},vt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),yt=e=>vt(e)?e:z({}),bt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):z([]),xt=e=>Object.freeze(Object.entries(yt(e.properties)).map(([t,n])=>{let r=yt(n);return{name:t,type:r.type,required:bt(e.required).includes(t),description:typeof r.description==`string`?r.description:``,choices:bt(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`&&yt(r.items).type===`string`}})),St=e=>typeof e==`boolean`||typeof e==`string`?e:Array.isArray(e)?bt(e).join(`
|
|
2
|
-
`):z(``),Ct=(e,t)=>Object.freeze(Object.fromEntries(xt(e).map(e=>[e.name,St(t[e.name]??e.default)]))),wt=(e,t)=>Object.freeze(Object.fromEntries(xt(e).flatMap(e=>{let n=t[e.name];return e.type===`boolean`?z([[e.name,n===!0]]):z(typeof n!=`string`||n===``?[]:[[e.name,e.type===`array`?n.split(/\r?\n/):n]])}))),Tt=(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`))),Et=(e,t)=>{let n=t.toLowerCase().replace(/\s+/g,``);if(n===``)return z(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)},Dt=(e,t)=>Object.freeze(e.flatMap(e=>{let n=Et(`${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)),Ot=e=>e,kt=async(e,t)=>e.ok?z({ok:!0,value:Ot(await t(e))}):z({ok:!1,failure:{status:e.status,message:(await e.text()).trim()}}),At=async e=>{try{return await e()}catch{return z({ok:!1,failure:{status:0,message:`Cannot reach kayra. Check that kayra serve is still running.`}})}},jt=e=>At(()=>fetch(e).then(e=>kt(e,e=>e.json()))),Mt=(e,t)=>At(async()=>kt(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),async e=>e.status===204?void 0:e.json())),Nt=(e,t)=>Mt(`/api/operations/${e.name}/preview`,{input:e.input,options:t}),Pt=(e,t,n)=>Mt(`/api/operations/${e.name}`,{input:e.input,options:t,...n===void 0?{}:{confirm:n}}),Ft=(e,t={})=>Mt(`/api/operations/${e}`,{input:t}),It=(e,t)=>Mt(`/api/runs/${encodeURIComponent(e)}/answers`,{text:t}),Lt=e=>Mt(`/api/runs/${encodeURIComponent(e)}/cancel`,{}),Rt=(e,t)=>Mt(`/api/sessions/${encodeURIComponent(e)}/input`,{text:t}),zt=e=>At(async()=>kt(await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`}),()=>Promise.resolve(void 0))),Bt=()=>jt(`/api/runs`),Vt=(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(Ot(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()}},Ht=/^[A-Za-z0-9._-]+$/,Ut=e=>{let t=e.split(`/`).filter(e=>e!==``).map(decodeURIComponent);if(!t.every(e=>Ht.test(e)))return z({page:`missing`,path:e});let[n,r,i,a]=t;return n===void 0?z({page:`fleet`}):n===`runs`&&r===void 0?z({page:`runs`}):n===`runs`&&r!==void 0&&i===void 0?z({page:`run`,id:r}):n===`sessions`&&r!==void 0&&i===void 0?z({page:`session`,id:r}):n===`validate`&&r===void 0?z({page:`validate`}):n===`servers`&&r!==void 0&&i===void 0?z({page:`server`,server:r}):n===`servers`&&r!==void 0&&i===`apps`&&a!==void 0&&t.length===4?z({page:`app`,server:r,app:a}):z({page:`missing`,path:e})},Wt=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}},Gt=e=>{let t=z({label:`servers`,to:{page:`fleet`}}),n=z({label:`runs`,to:{page:`runs`}}),r=e=>e.split(`-`).at(-1)??e;switch(e.page){case`fleet`:return z([{label:`overview`}]);case`server`:return z([t,{label:e.server}]);case`app`:return z([t,{label:e.server,to:{page:`server`,server:e.server}},{label:e.app}]);case`runs`:return z([{label:`runs`}]);case`run`:return z([n,{label:r(e.id)}]);case`session`:return z([n,{label:`session ${r(e.id)}`}]);case`validate`:return z([{label:`validate`}]);case`missing`:return z([{label:e.path}])}},Kt=`kayra.theme`,qt=(e,t)=>z(e===`dark`||e===`light`?e:t?`dark`:`light`),B=R(Ut(location.pathname)),Jt=e=>{history.pushState(null,``,Wt(e)),B.value=e,scrollTo({top:0})};addEventListener(`popstate`,()=>{B.value=Ut(location.pathname)});var V=R({state:`loading`}),H=R({state:`loading`}),Yt=async()=>{let e=await jt(`/api/operations`);H.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},U=R({value:void 0,live:!1}),Xt=R({state:`loading`}),Zt=async()=>{let e=await jt(`/api/fleet`);V.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Qt=()=>{U.value={value:U.value.value,live:!0},Vt(`/api/operations/status`,e=>{U.value={value:e,live:!0}},()=>{U.value={value:U.value.value,live:!1}},{input:{}})},$t=async()=>{Xt.value={state:`loading`};let e=await Ft(`validate`);Xt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},W=R({state:`loading`}),en=async()=>{let e=await Bt();e.ok?W.value={state:`ready`,value:e.value}:W.value.state!==`ready`&&(W.value={state:`failed`,failure:e.failure})},tn=R(Date.now()),nn=()=>{en();let e=setInterval(()=>{tn.value=Date.now(),en()},3e3);return()=>{clearInterval(e)}},rn=()=>{try{return localStorage.getItem(Kt)}catch{return null}},an=matchMedia(`(prefers-color-scheme: dark)`),on=R(qt(rn(),an.matches));it(()=>{document.documentElement.setAttribute(`data-theme`,on.value)}),an.addEventListener(`change`,e=>{rn()===null&&(on.value=e.matches?`dark`:`light`)});var sn=()=>{on.value=on.value===`dark`?`light`:`dark`;try{localStorage.setItem(Kt,on.value)}catch{}},cn=e=>e===null?``:` · ${String(e)} ms`,ln={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`},un=e=>{let{state:t,address:n,reason:r}=e.machine;switch(t){case`pending`:return z({text:`asking OpenTofu`,tone:`waiting`});case`found`:return z({text:n??`an address OpenTofu does not give`,tone:n===null?`warn`:`strong`});case`not-provisioned`:return z({text:`not provisioned`,tone:`muted`});case`no-machine`:return z({text:`no machine in its state`,tone:`muted`});case`unreadable`:return z({text:`state unreadable`,tone:`bad`,...r===null?{}:{title:r}})}},dn=e=>{let{state:t,error:n}=e.ssh;switch(t){case`pending`:return z({text:`connecting`,tone:`waiting`});case`open`:return z({text:`port ${String(e.ssh.port)} open${cn(e.ssh.ms)}`,tone:`ok`});case`refused`:return z({text:`off (refused)`,tone:`warn`,title:`Nothing listens: SSH may be on only on demand.`});case`skipped`:return z({text:`not asked`,tone:`muted`});case`answered`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return z({text:ln[t],tone:`bad`,...n===null?{}:{title:n}})}},fn=e=>{let{https:t}=e;if(t!==null)switch(t.state){case`pending`:return z({text:`asking`,tone:`waiting`});case`answered`:return z({text:`HTTP ${String(t.status??`?`)}${cn(t.ms)}`,tone:t.status!==null&&t.status<400?`ok`:`bad`});case`skipped`:return z({text:`not asked`,tone:`muted`});case`open`:case`refused`:case`no-answer`:case`unreachable`:case`unknown-host`:case`bad-certificate`:case`failed`:return z({text:ln[t.state],tone:`bad`,...t.error===null?{}:{title:t.error}})}},pn=e=>{let{state:t,pin:n,version:r,error:i}=e.kayra,a=`This fleet pins kayra ${n}: a setup records it.`;switch(t){case`pending`:return z({text:`asking`,tone:`waiting`});case`recorded`:return z(r===n?{text:n,tone:`ok`}:{text:`${r??`?`} → ${n}`,tone:`warn`,title:a});case`unrecorded`:return z({text:`unrecorded → ${n}`,tone:`warn`,title:`Set up by a kayra that recorded no version. ${a}`});case`unreadable`:return z({text:`unreadable`,tone:`bad`,...i===null?{}:{title:i}});case`skipped`:return z({text:`not asked`,tone:`muted`})}},mn=e=>{if(e===void 0)return z(`waiting`);let t=[un(e),dn(e),fn(e)].flatMap(e=>Object.freeze(e===void 0?[]:[e.tone]));return t.includes(`waiting`)?z(`waiting`):t.includes(`bad`)?z(`bad`):t.includes(`warn`)?z(`warn`):t.includes(`ok`)?z(`ok`):z(`muted`)},hn=e=>{let t=mn(e);return t===`waiting`?z({word:`ASKING`,tone:t}):t===`bad`?z({word:`FAIL`,tone:t}):t===`warn`?z({word:`WARN`,tone:t}):e!==void 0&&pn(e).tone===`warn`?z({word:`BEHIND`,tone:`warn`}):z(t===`ok`?{word:`OK`,tone:t}:{word:`--`,tone:t})},gn=e=>{let t=Math.max(0,6-e.length);return`[${` `.repeat(Math.floor(t/2))}${e}${` `.repeat(Math.ceil(t/2))}]`},_n={ok:`●`,warn:`▲`,bad:`✕`,waiting:`◌`,active:`◐`,muted:`○`,strong:`●`,accent:`◆`},vn=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:--vn,__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 yn=(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)},bn=({text:e})=>G(C,{children:(typeof e==`string`?[e]:e).map(yn)}),xn=({lines:e})=>G(`div`,{class:`lines`,children:e.map((e,t)=>G(`div`,{children:G(bn,{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`,"aria-hidden":t===void 0||void 0,children:_n[e]}),Sn=({word:e,tone:t})=>G(`span`,{class:`tag tone-${t}${t===`waiting`||t===`active`?` pulse`:``}`,children:gn(e)}),Cn={reads:`read only`,changes:`changes`,destroys:`destroys`},wn=({effect:e})=>G(`span`,{class:`badge badge-${e}`,children:Cn[e]}),Tn=({children:e,tone:t})=>G(`span`,{class:`pill${t===void 0?``:` pill-${t}`}`,children:e}),En=({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})]})]}),q=({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})]}),J=({what:e})=>G(`div`,{class:`waiting`,children:[G(`span`,{class:`spinner`,"aria-hidden":`true`}),` `,e]}),Y=({kicker:e,title:t,tag:n,sub:r,children:i})=>G(`header`,{class:`page-header`,children:[G(`div`,{class:`page-title`,children:[e===void 0?null:G(`div`,{class:`kicker`,children:e}),G(`div`,{class:`title-row`,children:[G(`h1`,{children:t}),n]}),r===void 0?null:G(`div`,{class:`sub`,children:r})]}),i===void 0?null:G(`div`,{class:`actions`,children:i})]}),X=({title:e,meta:t,aside:n,children:r,class:i})=>G(`section`,{class:i===void 0?`section`:`section ${i}`,"aria-label":e,children:[G(`div`,{class:`section-head`,children:[G(`h2`,{children:e}),G(`span`,{class:`rule`,"aria-hidden":`true`}),t===void 0?null:G(`span`,{class:`meta`,children:t}),n]}),r]}),Dn=({initial:e,choose:t,close:n})=>{let[r,i]=N(e===``?`.`:e),[a,o]=N(void 0);return P(()=>{let e={current:!1};return o(void 0),jt(`/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(J,{what:`Reading directories`}):a.ok?G(C,{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(q,{failure:a.failure})]})},On=R(void 0),Z=(e,t={})=>{On.value={name:e,input:t}},kn=e=>{Z(e.name,Object.fromEntries(Object.entries(e).filter(([e])=>e!==`name`)))},An=()=>{On.value=void 0},jn={guard:{glyph:`◆`,tone:`tone-warn`},check:{glyph:`◇`,tone:`tone-muted`},confirm:{glyph:`?`,tone:`tone-bad`},run:{glyph:`❯`,tone:`tone-accent`},session:{glyph:`>`,tone:`tone-accent`},note:{glyph:`·`,tone:`tone-muted`}},Mn=({step:e})=>{let t=jn[e.kind]??{glyph:`·`,tone:`tone-muted`};return G(C,{children:[e.opens===void 0?null:G(`li`,{class:`part`,children:e.opens}),G(`li`,{class:`plan-step`,children:[G(`span`,{class:`plan-index`,children:e.index+1}),G(`span`,{class:t.tone,"aria-hidden":`true`,children:t.glyph}),G(`div`,{children:[G(`span`,{children:e.title}),G(`span`,{class:`plan-kind`,children:e.kind}),e.command===void 0?null:G(`code`,{class:`plan-command`,children:e.command})]})]})]})},Nn=()=>G(`button`,{type:`button`,class:`iconbtn`,onClick:An,"aria-label":`Close`,children:G(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,children:G(`path`,{d:`M3 3l8 8M11 3l-8 8`})})}),Pn=({field:e,value:t,change:n,server:r})=>{let[i,a]=N(!1),o=V.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(Dn,{initial:c,close:()=>{a(!1)},choose:e=>{n(e),a(!1)}}):null]})},Fn=({info:e,seed:t,options:n,submit:r})=>{let[i,a]=N(()=>Ct(e.input,t.input)),[o,s]=N(n.verbose??!1),[c,l]=N(n.dryRun??!1),u=e.kind===`plan`||e.kind===`session`,d=xt(e.input),f=d.some(e=>!e.supported);return G(`form`,{onSubmit:t=>{t.preventDefault(),r({draft:{name:e.name,input:wt(e.input,i)},options:{verbose:o,dryRun:c}})},children:[G(`div`,{class:`sheet-body operation-fields`,children:[d.map(e=>G(Pn,{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`,children:G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:An,children:[`cancel `,G(`kbd`,{children:`esc`})]}),G(`span`,{class:`spacer`}),G(`button`,{type:`submit`,class:`button primary`,disabled:f,children:u?`show the plan`:e.kind===`stream`?`follow it`:`ask`})]})})]})},In=e=>{if(H.value.state===`ready`&&H.value.value.some(t=>t.name===e.name&&t.local))return;let t=V.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,effect:t,back:n})=>{let{draft:r,options:i}=e,[a,o]=N(void 0),[s,c]=N(``),[l,u]=N(void 0);if(P(()=>{Nt(r,i).then(o)},[e]),a===void 0)return G(`div`,{class:`sheet-body`,children:G(J,{what:`Planning`})});if(!a.ok)return G(`div`,{class:`sheet-body`,children:[G(q,{failure:a.failure}),G(`button`,{class:`button`,onClick:n,children:`Edit inputs`})]});let{invocation:d,steps:f,changes:p}=a.value,m=p&&!i.dryRun?In(r):void 0,h=m===void 0||s===m,g=m===void 0||s===``?void 0:h?{text:`✓ matches`,tone:`tone-ok`}:m.startsWith(s)?{text:`keep going`,tone:`tone-muted`}:{text:`✕ not ${m}`,tone:`tone-bad`},_=async()=>{u(`starting`);let e=await Pt(r,i,m===void 0?void 0:s);e.ok?(An(),Jt(`session`in e.value?{page:`session`,id:e.value.session}:{page:`run`,id:e.value.run})):u(e.failure)};return G(C,{children:[G(`div`,{class:`sheet-body`,children:[G(`div`,{children:[G(`code`,{class:`command`,children:d.command}),G(`p`,{class:`sub`,children:[d.about.join(` · `),d.about.length===0?``:` · `,p?`changes things`:`reads only`,i.verbose?` · verbose`:``,i.dryRun?` · dry run, nothing changes`:``]})]}),G(`div`,{class:`plan-head`,children:[G(`span`,{children:`the plan`}),G(`span`,{class:`rule`,"aria-hidden":`true`}),G(`span`,{children:[f.length,` steps`]})]}),G(`ol`,{class:`plan`,children:f.map(e=>G(Mn,{step:e},e.index))})]}),G(`form`,{class:`sheet-foot`,onSubmit:e=>{e.preventDefault(),h&&!i.dryRun&&_()},children:[m===void 0?null:G(`div`,{class:`confirm`,children:[G(`label`,{for:`operation-confirm`,children:[`Type `,G(`strong`,{children:m}),` to approve. The server checks the name too.`]}),G(`div`,{class:`field`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),G(`input`,{id:`operation-confirm`,value:s,onInput:e=>{c(e.currentTarget.value)},placeholder:m,autoComplete:`off`,spellcheck:!1}),g===void 0?null:G(`span`,{class:`match ${g.tone}`,children:g.text})]})]}),l===void 0||l===`starting`?null:G(q,{failure:l}),G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:n,disabled:l===`starting`,children:`edit inputs`}),G(`span`,{class:`spacer`}),i.dryRun?G(`button`,{type:`button`,class:`button primary`,onClick:An,children:`done`}):G(`button`,{type:`submit`,class:t===`destroys`?`button danger`:`button primary`,disabled:!h||l===`starting`,children:l===`starting`?`starting…`:m===void 0?r.name===`ssh`?`open terminal`:`run`:`approve · ${d.command}`})]})]})]})},Rn=({prepared:e,info:t,back:n})=>{let[r,i]=N(void 0),[a,o]=N(t.kind===`stream`);return P(()=>{let n={current:!0};return t.kind===`stream`?Vt(`/api/operations/${t.name}`,e=>{i({ok:!0,value:e})},()=>{o(!1)},{input:e.draft.input},e=>{i({ok:!1,failure:e})}):(Ft(t.name,e.draft.input).then(e=>{n.current&&i(e)}),()=>{n.current=!1})},[e]),G(C,{children:[G(`div`,{class:`sheet-body`,children:[r===void 0?G(J,{what:`Asking kayra`}):r.ok?G(`pre`,{class:`query-result`,children:typeof r.value==`string`?r.value:JSON.stringify(r.value,null,2)}):G(q,{failure:r.failure}),a?G(J,{what:`Receiving updates`}):null]}),G(`div`,{class:`sheet-foot`,children:G(`div`,{class:`buttons`,children:[G(`button`,{type:`button`,class:`button`,onClick:n,children:`edit inputs`}),G(`span`,{class:`spacer`}),G(`button`,{type:`button`,class:`button`,onClick:An,children:`close`})]})})]})},zn=({draft:e,info:t})=>{let[n,r]=N(void 0),[i,a]=N({draft:e,options:{}}),o=()=>{n!==void 0&&a(n),r(void 0)},s=t.effect===`reads`||n?.options.dryRun===!0?void 0:In(n?.draft??e);return G(C,{children:[G(`div`,{class:s===void 0?`sheet-bar`:`sheet-bar real`,children:[G(`span`,{class:s===void 0?`prompt`:`tone-warn`,"aria-hidden":`true`,children:s===void 0?`❯`:`▲`}),G(`strong`,{children:s===void 0?`kayra ${t.name.replace(`.`,` `)}`:`this changes ${s}, a real server`}),G(wn,{effect:t.effect}),G(Nn,{})]}),G(`div`,{class:`sheet-head`,children:[G(`h2`,{id:`operation-title`,children:_t[t.name].label}),G(`p`,{class:`sub`,children:t.summary})]}),n===void 0?G(Fn,{info:t,seed:i.draft,options:i.options,submit:r}):t.kind===`plan`||t.kind===`session`?G(Ln,{prepared:n,effect:t.effect,back:o}):G(Rn,{prepared:n,info:t,back:o})]})},Bn=()=>{let e=On.value,t=Oe(null),n=e!==void 0;if(P(()=>{if(!n)return;let e=document.activeElement;t.current?.focus();let r=e=>{if(e.key===`Escape`&&An(),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=H.value,i=r.state===`ready`?r.value.find(t=>t.name===e.name):void 0;return G(`div`,{class:`overlay`,onClick:An,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(J,{what:`Reading operations`}):r.state===`failed`?G(q,{failure:r.failure}):i===void 0?G(`p`,{role:`alert`,children:`Operation unavailable.`}):G(zn,{draft:e,info:i},JSON.stringify(e))})})},Q=R(!1),Vn=e=>e.replace(`.`,` `),Hn=()=>{let e=V.value,t=e.state===`ready`?e.value.servers:[],n=H.value.state===`ready`?H.value.value:[];return z([{label:`overview`,hint:`every server`,icon:`›`,line:`open /`,go:{page:`fleet`}},{label:`runs`,hint:`what ran from here`,icon:`›`,line:`open /runs`,go:{page:`runs`}},{label:`validate`,hint:`the fleet beyond its schemas`,icon:`›`,line:`open /validate`,go:{page:`validate`}},...n.filter(e=>e.scope===`fleet`||e.scope===`repo`).map(e=>z({label:Vn(e.name),hint:e.summary,icon:_t[e.name].icon,line:`kayra ${Vn(e.name)}`,run:{name:e.name,input:{}},effect:e.effect,real:!1})),...t.flatMap(e=>z([{label:e.name,hint:`${e.kind} on ${e.target} · ${e.domain}`,icon:`●`,line:`open /servers/${e.name}`,go:{page:`server`,server:e.name}},...e.apps.map(t=>z({label:`${e.name}/${t}`,hint:`app`,icon:`▸`,line:`open /servers/${e.name}/apps/${t}`,go:{page:`app`,server:e.name,app:t}})),...Tt(n,e).map(t=>z({label:`${Vn(t.name)} ${e.name}`,hint:t.summary,icon:_t[t.name].icon,line:`kayra ${Vn(t.name)} ${e.name}`,run:{name:t.name,input:{server:e.name}},effect:t.effect,real:e.target!==`multipass`}))]))])},Un=e=>{if(`go`in e)return{text:`jump`,class:`badge badge-jump`,guard:`opens it`};if(e.effect===`reads`)return{text:`read only`,class:`badge badge-reads`,guard:`reads, changes nothing`};let t=e.real?`shows its plan, then asks for the server's name`:`shows its plan first`;return e.effect===`destroys`?{text:`destroys`,class:`badge badge-destroys`,guard:t}:{text:`changes`,class:`badge badge-changes`,guard:t}},Wn=e=>{Q.value=!1,`go`in e?Jt(e.go):Z(e.run.name,e.run.input)},Gn=()=>{let[e,t]=N(``),[n,r]=N(0),i=Oe(null),a=Q.value;if(P(()=>{a&&i.current?.focus()},[a]),P(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),Q.value=!Q.value,t(``),r(0)):e.key===`Escape`&&(Q.value=!1)};return addEventListener(`keydown`,e),()=>{removeEventListener(`keydown`,e)}},[]),!Q.value)return null;let o=Dt(Hn(),e).slice(0,12),s=o[n],c=s===void 0?void 0:Un(s);return G(`div`,{class:`overlay`,onClick:()=>{Q.value=!1},children:G(`div`,{class:`palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Go to, or run`,onClick:e=>{e.stopPropagation()},children:[G(`div`,{class:`palette-input`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),G(`input`,{ref:i,value:e,placeholder:`a command, a server, a page…`,"aria-label":`Go to, or run`,spellcheck:!1,autoComplete:`off`,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`)s!==void 0&&Wn(s);else return;e.preventDefault()}}),G(`kbd`,{children:`esc`})]}),G(`div`,{class:`palette-head`,children:[G(`span`,{children:e.trim()===``?`everything`:`matches`}),G(`span`,{class:`rule`,"aria-hidden":`true`}),G(`span`,{children:o.length})]}),G(`ul`,{role:`listbox`,"aria-label":`Results`,children:[o.map((e,t)=>{let i=Un(e);return G(`li`,{role:`option`,"aria-selected":t===n,class:t===n?`selected`:void 0,onMouseEnter:()=>{r(t)},onClick:()=>{Wn(e)},children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:e.icon}),G(`span`,{class:`label`,children:e.label}),G(`span`,{class:`hint`,children:e.hint}),G(`span`,{class:i.class,children:i.text})]},e.label)}),o.length===0?G(`li`,{class:`empty`,children:[`Nothing matches “`,e,`”: try a server's name or a verb.`]}):null]}),s===void 0||c===void 0?null:G(`div`,{class:`palette-preview`,"aria-live":`polite`,children:[G(`div`,{class:`line`,children:[G(`span`,{class:`tone-muted`,"aria-hidden":`true`,children:`$`}),G(`strong`,{class:`ellipsis`,children:s.line}),G(`span`,{class:`spacer`}),G(`span`,{class:c.class.replace(`badge `,``),children:c.guard})]}),G(`p`,{children:s.hint})]}),G(`div`,{class:`palette-foot`,children:[G(`span`,{children:[G(`kbd`,{children:`↑↓`}),` move`]}),G(`span`,{children:[G(`kbd`,{children:`↵`}),` open`]}),G(`span`,{children:[G(`kbd`,{children:`esc`}),` close`]}),G(`span`,{class:`spacer`}),G(`span`,{children:`nothing changes before its plan is shown`})]})]})})},Kn=()=>{Q.value=!0},$=({to:e,children:t,class:n,current:r})=>G(`a`,{href:Wt(e),class:n,"aria-current":r===!0?`page`:void 0,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),Jt(e))},children:t}),qn=(e,t)=>Wt(e)===Wt(t),Jn=()=>G(`svg`,{class:`logo`,width:`22`,height:`22`,viewBox:`0 0 22 22`,"aria-hidden":`true`,children:[G(`rect`,{width:`22`,height:`22`,rx:`5`}),G(`path`,{d:`M6.5 7l4 4-4 4M12 15.5h4`})]}),Yn=()=>G(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,children:[G(`circle`,{cx:`8`,cy:`8`,r:`3`}),G(`path`,{d:`M8 1.5v1.6M8 12.9v1.6M1.5 8h1.6M12.9 8h1.6M3.4 3.4l1.1 1.1M11.5 11.5l1.1 1.1M3.4 12.6l1.1-1.1M11.5 4.5l1.1-1.1`})]}),Xn=()=>G(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linejoin":`round`,children:G(`path`,{d:`M13.5 9.6A5.6 5.6 0 0 1 6.4 2.5a5.6 5.6 0 1 0 7.1 7.1z`})}),Zn=()=>{let e=V.value,t=Gt(B.value),n=on.value===`dark`;return G(`header`,{class:`topbar`,children:[G($,{to:{page:`fleet`},class:`brand`,children:[G(Jn,{}),G(`span`,{children:[`kayra`,G(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`})]})]}),G(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),G(`span`,{class:`fleet-name`,title:`The fleet kayra serve was started in`,children:e.state===`ready`?e.value.fleet:`…`}),G(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),G(`nav`,{class:`crumbs`,"aria-label":`Breadcrumb`,children:t.map((e,t)=>G(`span`,{class:`crumb`,children:[t===0?null:G(`span`,{class:`slash`,"aria-hidden":`true`,children:`/`}),e.to===void 0?G(`span`,{"aria-current":`page`,children:e.label}):G($,{to:e.to,children:e.label})]},e.label))}),G(`span`,{class:`spacer`}),G(`button`,{type:`button`,class:`cmdbar`,onClick:Kn,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`❯`}),G(`span`,{children:`run a command or jump to…`}),G(`kbd`,{children:`⌘K`})]}),G(`button`,{type:`button`,class:`iconbtn`,onClick:sn,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,title:n?`Light mode`:`Dark mode`,children:G(n?Yn:Xn,{})})]})},Qn=({children:e,count:t})=>G(`div`,{class:`rail-title`,children:[G(`span`,{children:e}),G(`span`,{class:`rule`,"aria-hidden":`true`}),t===void 0?null:G(`span`,{children:t})]}),$n=({to:e,label:t})=>{let n=qn(B.value,e);return G($,{to:e,class:n?`rail-item on`:`rail-item`,current:n,children:[G(`span`,{class:`rail-mark`,"aria-hidden":`true`,children:n?`›`:``}),G(`span`,{children:t})]})},er=()=>{let e=V.value,t=B.value,n=U.value.value?.servers;return G(`div`,{class:`rail`,children:G(`div`,{class:`rail-inner`,children:[G(`nav`,{"aria-label":`Servers`,children:[G(Qn,{count:e.state===`ready`?e.value.servers.length:void 0,children:`servers`}),e.state===`ready`?e.value.servers.map(e=>{let r=`server`in t&&t.server===e.name,i=hn(n?.find(t=>t.name===e.name));return G($,{to:{page:`server`,server:e.name},class:r?`rail-item on`:`rail-item`,current:r&&t.page===`server`,children:[G(K,{tone:i.tone,label:i.word.toLowerCase()}),G(`span`,{class:`name`,children:e.name}),G(`span`,{class:`meta`,children:e.kind})]},e.name)}):null]}),G(`nav`,{"aria-label":`Pages`,children:[G(Qn,{children:`views`}),G($n,{to:{page:`fleet`},label:`overview`}),G($n,{to:{page:`runs`},label:`runs`}),G($n,{to:{page:`validate`},label:`validate`}),G(`button`,{type:`button`,class:`rail-item`,onClick:()=>{kn({name:`doctor`})},children:[G(`span`,{class:`rail-mark`,"aria-hidden":`true`}),G(`span`,{children:`doctor`})]})]})]})})},tr={fleet:`FLEET`,server:`SERVER`,app:`APP`,runs:`RUNS`,run:`RUN`,session:`SSH`,validate:`VALIDATE`,missing:`?`},nr=()=>{let e=V.value,{value:t,live:n}=U.value,r=t?.servers??[],i=r.filter(e=>mn(e)===`ok`).length,a=r.filter(e=>pn(e).tone===`warn`).length,o=new Date(tn.value).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return G(`footer`,{class:`statusline`,children:[G(`span`,{class:`seg seg-mode`,children:tr[B.value.page]}),G(`span`,{class:`seg`,children:e.state===`ready`?e.value.fleet:`…`}),G(`span`,{class:`seg`,children:[`kayra `,e.state===`ready`?e.value.version:`…`]}),G(`span`,{class:`seg wide-only`,children:[G(K,{tone:`ok`}),`real servers ask for their name`]}),G(`span`,{class:`spacer`}),G(`span`,{class:`seg end`,children:[n?G(C,{children:[G(K,{tone:`waiting`}),` asking`]}):`${String(i)}/${String(r.length)} answering`,a===0?null:G(`span`,{class:`tone-warn`,children:[` · `,a,` behind`]})]}),G(`span`,{class:`seg end wide-only`,children:location.host}),G(`span`,{class:`seg end`,children:o})]})},rr=({children:e})=>G(`div`,{class:`app`,children:[G(Zn,{}),G(`div`,{class:`body`,children:[G(er,{}),G(`main`,{class:`main`,children:e})]}),G(nr,{})]}),ir=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`},ar=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`},or=(e,t)=>{let n=new Date(e);return n.toDateString()===new Date(t).toDateString()?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n.toLocaleDateString([],{day:`numeric`,month:`short`})},sr=e=>Date.parse(e),cr=(e,t)=>{let[n,r]=N(void 0),i=()=>{r(void 0),e().then(r)};return P(i,[t]),z([n,i])},lr=e=>e===`success`?`ok`:e===`failure`?`bad`:`waiting`,ur=({server:e,app:t,open:n})=>{let[r]=cr(()=>Ft(`app.runs`,{server:e,app:t}),`${e}/${t}`);if(r===void 0)return G(J,{what:`Asking the deployer`});if(!r.ok)return G(q,{failure:r.failure});let i=Date.now(),{live:a,runs:o}=r.value;return G(C,{children:[G(`p`,{class:`sub`,children:a===void 0?`Not deployed yet.`:`Live: ${a.sha.slice(0,7)} since ${ar(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:lr(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:ar(i-Date.parse(e.started))}),G(`td`,{class:`right tone-muted`,children:e.finished===void 0?``:ir(Date.parse(e.finished)-Date.parse(e.started))})]},e.id))})]})]})},dr=({server:e,app:t})=>{let[n]=cr(()=>Ft(`app.releases`,{server:e,app:t}),`${e}/${t}`);if(n===void 0)return G(J,{what:`Asking the deployer`});if(!n.ok)return G(q,{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:ar(r-Date.parse(n.time))}),n.live?G(Tn,{tone:`ok`,children:`live`}):G(`button`,{class:`button small`,onClick:()=>{kn({name:`app.rollback`,server:e,app:t,sha:n.sha})},children:`Roll back to it`})]},n.sha))})},fr=e=>{if(/\b(error|failed|fatal|refused)\b/i.test(e))return z(`tone-bad`);if(/\bwarn(ing)?\b/i.test(e))return z(`tone-warn`)},pr=({server:e,app:t,run:n})=>{let[r]=cr(()=>Ft(`app.log`,{server:e,app:t,...n===void 0?{}:{run:n}}),`${e}/${t}/${n??``}`);return r===void 0?G(J,{what:`Fetching the log`}):r.ok?G(`pre`,{class:`log`,children:r.value.split(`
|
|
5
|
-
`).map((e,t)=>G(`div`,{class:fr(e),children:e===``?` `:e},t))}):G(q,{failure:r.failure})},mr=({server:e,app:t})=>{let[n,r]=N(`runs`),[i,a]=N(void 0),[o,s]=N(``);return G(C,{children:[G(Y,{kicker:`app`,title:t,sub:`on ${e}`,children:G(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),kn({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(ur,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?G(dr,{server:e,app:t}):G(pr,{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:()=>{kn({name:`app.purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},hr=({remedy:e,first:t})=>{let n=t?`button small primary`:`button small`;switch(e.kind){case`run`:return G(`button`,{type:`button`,class:n,onClick:()=>{Z(e.draft.name,e.draft.input)},children:e.label});case`go`:return G($,{to:e.to,class:n,children:e.label});case`ask`:return G(`button`,{type:`button`,class:n,disabled:U.value.live,onClick:Qt,children:U.value.live?`asking…`:e.label})}},gr=({notes:e,quiet:t})=>e.length===0?G(`p`,{class:`note`,children:[G(`span`,{class:`note-title`,children:[G(K,{tone:`ok`}),` nothing needs you`]}),G(`span`,{class:`hint`,children:t})]}):G(`div`,{class:`notes`,children:e.map(e=>G(`div`,{class:`note note-${e.tone}`,children:[G(`div`,{class:`note-title`,children:[G(K,{tone:e.tone===`active`?`waiting`:e.tone}),G(`span`,{children:e.title})]}),e.text===``?null:G(`p`,{children:e.text}),G(`div`,{class:`actions`,children:e.remedies.map((e,t)=>G(hr,{remedy:e,first:t===0},e.label))})]},e.title))}),_r=({server:e})=>{let t=H.value;return t.state===`loading`?G(J,{what:`Reading operations`}):t.state===`failed`?G(q,{failure:t.failure}):G(`div`,{class:`action-grid`,children:(e===void 0?t.value.filter(e=>e.scope===`fleet`||e.scope===`repo`):Tt(t.value,e)).map(t=>G(`button`,{type:`button`,class:`action${t.effect===`destroys`?` danger`:``}`,onClick:()=>{Z(t.name,e===void 0?{}:{server:e.name})},children:[G(`span`,{class:`icon`,"aria-hidden":`true`,children:_t[t.name].icon}),G(`strong`,{children:_t[t.name].label}),G(wn,{effect:t.effect}),G(`span`,{class:`about`,children:t.summary})]},t.name))})},vr=e=>Object.freeze(e.toSorted((e,t)=>t.started.localeCompare(e.started))),yr=(e,t,n)=>Object.freeze(vr(e).filter(e=>e.server===t).slice(0,n).toReversed().map(e=>e.state)),br=e=>{if(e.length===0)return`No runs from here yet`;let t=z([`passed`,`failed`,`interrupted`,`declined`,`running`]).flatMap(t=>{let n=e.filter(e=>e===t).length;return Object.freeze(n===0?[]:[`${String(n)} ${t}`])});return`Last ${String(e.length)} runs: ${t.join(`, `)}`},xr=e=>e.kind===`platform`&&e.commands.includes(`deploy`)?z(`deploy`):e.commands.includes(`setup`)?z(`setup`):void 0,Sr=(e,t)=>t?.tone===`bad`?Object.freeze([`${e} ${t.text}`]):Object.freeze([]),Cr=(e,t)=>{let n=z({kind:`go`,label:`open ${e.name}`,to:{page:`server`,server:e.name}}),r=z({kind:`ask`,label:`ask again`}),i=mn(t)===`bad`?[z({tone:`bad`,title:`${e.name} does not answer`,text:[...Sr(`address`,un(t)),...Sr(`ssh`,dn(t)),...Sr(`login`,fn(t))].join(` · `),remedies:[n,r]})]:[],a=t.ssh.state===`refused`?[z({tone:`warn`,title:`${e.name}: SSH is off`,text:`Nothing listens on port ${String(t.ssh.port)}. If its SSH is on only on demand, switch it on, then ask again.`,remedies:[r,n]})]:[],o=xr(e),s=pn(t).tone===`warn`?[z({tone:`warn`,title:t.kayra.version===null?`${e.name} records no kayra version`:`${e.name} runs kayra ${t.kayra.version}`,text:`This fleet pins ${t.kayra.pin}${o===void 0?`.`:`: ${o} records it.`}`,remedies:o===void 0?[n]:[{kind:`run`,label:`${o} ${e.name}`,draft:{name:o,input:{server:e.name}}},n]})]:[];return Object.freeze([...i,...a,...s])},wr=(e,t,n)=>{let r=vr(n),i=e.flatMap(e=>{let n=t.find(t=>t.name===e.name);return n===void 0?Object.freeze([]):Cr(e,n)}),a=e.flatMap(e=>{let t=r.find(t=>t.server===e.name&&t.state!==`running`);return t?.state===`failed`?Object.freeze([z({tone:`bad`,title:`${t.command} failed`,text:`The last run on ${e.name} failed. Its log says where.`,remedies:[{kind:`go`,label:`open the run`,to:{page:t.session?`session`:`run`,id:t.id}}]})]):Object.freeze([])}),o=r.filter(e=>e.state===`running`).map(e=>z({tone:`active`,title:`running: ${e.command}`,text:e.session?`An SSH session is open.`:`Still going.`,remedies:[{kind:`go`,label:e.session?`open the session`:`follow it`,to:{page:e.session?`session`:`run`,id:e.id}}]}));return Object.freeze([...i.filter(e=>e.tone===`bad`),...a,...i.filter(e=>e.tone!==`bad`),...o])},Tr={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},Er=({server:e,limit:t})=>{let n=W.value;if(n.state===`loading`)return G(J,{what:`Reading the runs`});if(n.state===`failed`)return G(q,{failure:n.failure});let r=vr(n.value).filter(t=>e===void 0||t.server===e).slice(0,t??1/0);if(r.length===0)return G(`p`,{class:`empty panel pad`,children:`Nothing run from here yet.`});let i=tn.value;return G(`div`,{class:`panel scroll-x`,children:G(`div`,{class:`journal`,children:r.map(e=>G($,{to:{page:e.session?`session`:`run`,id:e.id},class:`jrow`,children:[G(`span`,{class:`when`,children:or(e.started,i)}),G(K,{tone:Tr[e.state],label:e.state}),G(`span`,{class:`ellipsis`,children:e.command}),G(`span`,{class:`state tone-${Tr[e.state]===`waiting`?`active`:Tr[e.state]}`,children:e.state}),G(`span`,{class:`ago`,children:ar(i-sr(e.started))})]},e.id))})})},Dr=()=>G(C,{children:[G(Y,{kicker:`journal`,title:`runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs.`}),G(Er,{})]}),Or=864e5,kr=({cell:e})=>e===void 0?G(`span`,{class:`tone-muted`,children:`—`}):G(`span`,{class:`cell`,title:e.title,children:[G(K,{tone:e.tone}),G(`span`,{class:e.tone===`waiting`?`tone-muted`:`tone-${e.tone}`,children:e.text})]}),Ar=({facts:e,seen:t})=>{let n=hn(t),r=W.value.state===`ready`?W.value.value:[],i=yr(r,e.name,16),a=vr(r).find(t=>t.server===e.name),o=xr(e);return G(`div`,{class:`grow-row`,children:[G(Sn,{word:n.word,tone:n.tone}),G(`div`,{class:`ellipsis`,children:[G($,{to:{page:`server`,server:e.name},children:G(`strong`,{children:e.name})}),G(`span`,{class:`second ellipsis`,children:[e.kind,` · `,e.target,` · `,e.domain]})]}),G(kr,{cell:t===void 0?void 0:un(t)}),G(kr,{cell:t===void 0?void 0:dn(t)}),G(kr,{cell:t===void 0?void 0:fn(t)}),G(kr,{cell:t===void 0?void 0:pn(t)}),G(`div`,{children:[G(`span`,{class:`strip`,role:`img`,"aria-label":br(i),children:i.map((e,t)=>G(`span`,{class:e},t))}),G(`span`,{class:`second`,children:a===void 0?`no runs yet`:ar(tn.value-sr(a.started))})]}),G(`div`,{class:`row-actions`,children:[e.commands.includes(`plan`)?G(`button`,{type:`button`,class:`button small`,onClick:()=>{Z(`plan`,{server:e.name})},children:`plan`}):null,o===void 0?null:G(`button`,{type:`button`,class:`button small primary`,onClick:()=>{Z(o,{server:e.name})},children:o})]})]})},jr=({servers:e,seen:t})=>{let n=e=>t.find(t=>t.name===e),r=e.filter(e=>mn(n(e.name))===`ok`),i=t.filter(e=>e.kayra.state!==`skipped`&&e.kayra.state!==`pending`),a=i.filter(e=>pn(e).tone===`warn`),o=t[0]?.kayra.pin,s=W.value.state===`ready`?W.value.value:[],c=s.filter(e=>tn.value-sr(e.started)<Or),l=c.filter(e=>e.state===`failed`).length,u=s.filter(e=>e.state===`running`).length,d=e.flatMap(e=>e.apps),f=e.filter(e=>e.kind===`platform`).length,p=e.filter(e=>mn(n(e.name))!==`ok`).map(e=>e.name);return G(`div`,{class:`tiles`,children:[G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`servers`}),G(`span`,{class:U.value.live?void 0:p.length===0?`tone-ok`:`tone-warn`,children:U.value.live?`asking`:p.length===0?`all answer`:`${String(p.length)} not answering`})]}),G(`div`,{class:`tile-value`,children:[r.length,G(`small`,{children:[`/`,e.length,` answering`]})]}),G(`div`,{class:`tile-sub bar`,"aria-hidden":`true`,children:e.map(e=>G(`span`,{class:`tone-${hn(n(e.name)).tone}`,children:`█`},e.name))})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`kayra`}),G(`span`,{class:i.length===0?void 0:a.length===0?`tone-ok`:`tone-warn`,children:i.length===0?`not asked`:a.length===0?`on the pin`:`${String(a.length)} behind`})]}),G(`div`,{class:`tile-value`,children:[i.length-a.length,G(`small`,{children:[`/`,i.length,` on `,o??`the pin`]})]}),G(`div`,{class:`tile-sub ellipsis`,children:a.length===0?i.length===0?`read over SSH; none open yet`:`every server asked runs it`:a.map(e=>e.name).join(`, `)})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`runs · 24h`}),G(`span`,{class:l===0?void 0:`tone-bad`,children:l===0?`none failed`:`${String(l)} failed`})]}),G(`div`,{class:`tile-value`,children:c.length}),G(`div`,{class:`tile-sub`,children:u===0?`nothing running`:`${String(u)} running now`})]}),G(`div`,{class:`tile`,children:[G(`div`,{class:`tile-label`,children:[G(`span`,{children:`apps`}),G(`span`,{children:[f,` platform`]})]}),G(`div`,{class:`tile-value`,children:d.length}),G(`div`,{class:`tile-sub ellipsis`,children:d.length===0?`none in any server.yml`:d.join(`, `)})]})]})},Mr=()=>{let[e,t]=N(``),n=V.value;if(n.state===`loading`)return G(J,{what:`Reading the fleet`});if(n.state===`failed`)return G(q,{failure:n.failure});let{value:r,live:i}=U.value,a=r?.servers??[],{servers:o,version:s}=n.value,c=e.trim().toLowerCase(),l=o.filter(e=>c===``||[e.name,e.kind,e.target,e.domain].join(` `).includes(c)),u=W.value.state===`ready`?W.value.value:[];return G(C,{children:[G(Y,{kicker:`fleet`,title:n.value.fleet,sub:`${String(o.length)} servers · kayra ${s} pinned · every command from this machine`,children:[G(`button`,{type:`button`,class:`button`,onClick:Qt,disabled:i,children:[i?`asking…`:`ask again`,G(`span`,{class:`aside`,children:`status`})]}),G($,{to:{page:`validate`},class:`button`,children:[`validate`,G(`span`,{class:`aside`,children:`read only`})]})]}),G(jr,{servers:o,seen:a}),G(X,{title:`servers`,aside:G(`label`,{class:`filter`,children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`/`}),G(`span`,{class:`visually-hidden`,children:`Filter servers`}),G(`input`,{value:e,placeholder:`filter`,spellcheck:!1,onInput:e=>{t(e.currentTarget.value)}})]}),children:G(`div`,{class:`panel scroll-x servers-table`,children:G(`div`,{class:`gtable`,children:[G(`div`,{class:`ghead`,children:[G(`span`,{children:`state`}),G(`span`,{children:`server`}),G(`span`,{children:`address`}),G(`span`,{children:`ssh`}),G(`span`,{children:`login`}),G(`span`,{children:`kayra`}),G(`span`,{children:`last runs`}),G(`span`,{class:`right`,children:`actions`})]}),l.map(e=>G(Ar,{facts:e,seen:a.find(t=>t.name===e.name)},e.name)),l.length===0?G(`p`,{class:`empty pad`,children:[`No server matches “`,e,`”.`]}):null]})})}),G(`div`,{class:`split`,children:[G(`div`,{class:`wide`,children:G(X,{title:`journal`,aside:G($,{to:{page:`runs`},class:`small`,children:`all runs →`}),children:G(Er,{limit:8})})}),G(`div`,{class:`side`,children:G(X,{title:`needs you`,children:G(gr,{notes:wr(o,a,u),quiet:r===void 0?`Still asking every server.`:`Every server answered; no run failed last.`})})})]}),G(X,{title:`fleet commands`,children:G(_r,{})})]})},Nr=({id:e,question:t})=>{let[n,r]=N(``),[i,a]=N(!1),[o,s]=N(void 0),c=Oe(null);P(()=>{c.current?.focus()},[]);let l=async t=>{a(!0),r(``);let n=await It(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(bn,{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(q,{failure:o})]})},Pr={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Fr=(e,t,n)=>t===void 0?e:z({...e,steps:e.steps.map((e,r)=>r===t?n(e):e)}),Ir=(e,t)=>Fr(e,e.current,e=>({...e,said:[...e.said,t]})),Lr=(e,t,n)=>{switch(t.kind){case`plan`:return z({...e,invocation:t.invocation,steps:t.steps.map(e=>({listed:e,state:`waiting`,said:[]}))});case`started`:return Fr({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Fr(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 z({...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 Ir(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Ir(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return z({...e,asking:t});case`answered`:return z({...e,asking:void 0})}},Rr=e=>{let{ended:t}=e;return t===void 0?z(`running`):t.stop?.why===`interrupted`?z(`interrupted`):t.stop?.why===`declined`?z(`declined`):t.failures===0?z(`passed`):z(`failed`)},zr={fg:void 0,bold:!1,dim:!1},Br=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Vr=(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?zr: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:Br[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${Br[n-90]??`white`}`}:e,i)};return r(e,n)},Hr=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),Ur=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,Wr=e=>{let t=[...e.matchAll(Ur)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:Hr(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:Vr(t.look,a),at:n.index+n[0].length}},{out:[],look:zr,at:0}),n=e.slice(t.at);return n===``?t.out:z([...t.out,{text:n,classes:Hr(t.look)}])},Gr={running:{word:`RUN`,tone:`active`},passed:{word:`OK`,tone:`ok`},failed:{word:`FAILED`,tone:`bad`},interrupted:{word:`STOPPED`,tone:`warn`},declined:{word:`DECLINED`,tone:`warn`}},Kr={waiting:{glyph:`○`,tone:`tone-muted`},running:{glyph:`◐`,tone:`tone-active pulse`},passed:{glyph:`✓`,tone:`tone-ok`},failed:{glyph:`✕`,tone:`tone-bad`},stopped:{glyph:`■`,tone:`tone-warn`},skipped:{glyph:`–`,tone:`tone-muted`}},qr=({step:e})=>G(C,{children:e.said.map((e,t)=>e.kind===`output`?G(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:Wr(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(bn,{text:e.text})},t))}),Jr=(e,t)=>e.ms??(e.started===void 0?void 0:t-e.started),Yr=({steps:e,now:t,picked:n,pick:r})=>G(`ol`,{class:`steps panel`,children:e.map(e=>{let i=Jr(e,t),a=e.listed.index,o=n===a;return G(`li`,{children:[e.listed.opens===void 0?null:G(`div`,{class:`part`,children:e.listed.opens}),G(`button`,{type:`button`,"aria-pressed":o,class:`step-button step-${e.state}${o?` on`:e.state===`running`||e.state===`failed`?` ${e.state}`:``}`,onClick:()=>{r(o?void 0:a)},children:[G(`span`,{class:Kr[e.state].tone,"aria-label":e.state,children:Kr[e.state].glyph}),G(`span`,{children:[G(`span`,{class:`step-title`,children:e.listed.title}),G(`span`,{class:`step-kind`,children:e.why===void 0?e.listed.kind:`${e.listed.kind} · ${e.why}`})]}),G(`span`,{class:`step-time`,children:i===void 0?e.state:ir(i)})]})]},a)})}),Xr=({id:e})=>{let[t,n]=De((e,t)=>Lr(e,t,Date.now()),Pr),[r,i]=N(Date.now()),[a,o]=N(void 0),[s,c]=N(void 0),[l,u]=N(!0),d=Oe(null);P(()=>Vt(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0,void 0,o),[e]);let f=Rr(t)===`running`;P(()=>{if(!f)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[f]),P(()=>{l&&d.current?.scrollTo({top:d.current.scrollHeight})},[t,l,s]);let{invocation:p,steps:m,ended:h,asking:g}=t;if(p===void 0)return a===void 0?G(J,{what:`Starting`}):G(q,{failure:a});let _=Gr[Rr(t)],v=m.flatMap(e=>e.started===void 0?[]:[e.started]),y=h?.ms??(v.length===0?0:r-Math.min(...v)),b=m.filter(e=>e.state===`passed`).length,x=h?.stop,S=x===void 0?void 0:m.find(e=>e.listed.index===x.index),w=m.find(e=>e.state===`failed`),T=m.filter(e=>(s===void 0||e.listed.index===s)&&e.said.length>0);return G(C,{children:[G(Y,{kicker:`run · ${e}`,title:G(`code`,{children:p.command}),tag:G(Sn,{word:_.word,tone:_.tone}),sub:[...p.about,`${String(m.length)} steps`].join(` · `),children:[G(`div`,{class:`elapsed`,children:[G(`strong`,{children:ir(y)}),G(`span`,{children:[b,` of `,m.length,` steps passed`]})]}),f?G(`button`,{type:`button`,class:`button danger`,onClick:()=>{Lt(e).then(e=>{e.ok||o(e.failure)})},children:`stop`}):null]}),G(`div`,{class:`progress`,role:`img`,"aria-label":`${String(b)} of ${String(m.length)} steps passed`,children:m.map(e=>G(`span`,{class:e.state},e.listed.index))}),a===void 0?null:G(q,{failure:a}),x===void 0||S===void 0?null:G(`div`,{class:`banner ${x.why===`failed`?`banner-bad`:`banner-warn`}`,role:`alert`,children:[G(`span`,{class:x.why===`failed`?`tone-bad`:`tone-warn`,"aria-hidden":`true`,children:x.why===`failed`?`✕`:`■`}),G(`div`,{class:`prose`,children:[G(`strong`,{children:[x.why===`failed`?`Stopped at`:x.why===`declined`?`Declined at`:`Interrupted at`,` `,S.listed.title,`.`]}),` `,S.why??``,` Nothing after it ran.`]}),G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(x.index)},children:`show it`})]}),x!==void 0||h===void 0||h.failures===0||w===void 0?null:G(`div`,{class:`banner banner-bad`,role:`alert`,children:[G(`span`,{class:`tone-bad`,"aria-hidden":`true`,children:`✕`}),G(`div`,{class:`prose`,children:[G(`strong`,{children:[h.failures,` `,h.failures===1?`step`:`steps`,` failed,`]}),` `,`the first at `,w.listed.title,`. The rest ran; the footer says what to do.`]}),G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(w.listed.index)},children:`show it`})]}),g===void 0?null:G(Nr,{id:e,question:g},JSON.stringify(g)),G(`div`,{class:`split`,children:[G(`div`,{class:`side`,children:G(X,{title:`steps`,meta:`from the plan`,children:G(Yr,{steps:m,now:r,picked:s,pick:c})})}),G(`div`,{class:`wide`,children:G(X,{title:`log`,aside:G(C,{children:[s===void 0?null:G(`button`,{type:`button`,class:`button small`,onClick:()=>{c(void 0)},"aria-label":`Show every step`,children:[m.find(e=>e.listed.index===s)?.listed.title??``,` ×`]}),G(`button`,{type:`button`,class:`button small`,"aria-pressed":l,onClick:()=>{u(!l)},children:[G(`span`,{class:l&&f?`tone-active pulse`:`tone-muted`,"aria-hidden":`true`,children:`●`}),l?`following`:`follow`]})]}),children:G(`div`,{class:`terminal-panel`,children:[G(`div`,{ref:d,class:`terminal-scrollbox`,onWheel:e=>{e.deltaY<0&&u(!1)},children:[T.length===0?G(`span`,{class:`tone-muted`,children:f?`Waiting for output…`:`Nothing was printed here.`}):T.map(e=>G(`div`,{children:[G(`div`,{class:`log-step`,children:[`── `,e.listed.index+1,` · `,e.listed.title,` ──`]}),G(qr,{step:e})]},e.listed.index)),f&&l?G(`span`,{class:`cursor`,"aria-hidden":`true`,children:`▌`}):null]}),h===void 0?null:G(`footer`,{class:`run-footer`,children:G(xn,{lines:h.footer})})]})})})]})]})},Zr=({name:e})=>{let t=V.value;if(t.state!==`ready`)return G(J,{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{value:r,live:i}=U.value,a=r?.servers.find(t=>t.name===e),o=hn(a),s=xr(n),c=W.value.state===`ready`?W.value.value.filter(t=>t.server===e):[],l=wr([n],a===void 0?[]:[a],c).map(e=>({...e,remedies:e.remedies.filter(e=>e.kind!==`go`||e.to.page!==`server`)})),u=e=>()=>{Z(e,{server:n.name})};return G(C,{children:[G(Y,{kicker:`server`,title:n.name,tag:G(Sn,{word:o.word,tone:o.tone}),sub:G(C,{children:[G(`span`,{children:[`kind `,G(`span`,{class:`tone-strong`,children:n.kind})]}),G(`span`,{children:[`target `,G(`span`,{class:`tone-strong`,children:n.target})]}),G(`span`,{children:[`domain`,` `,G(`a`,{href:`https://${n.domain}`,target:`_blank`,rel:`noreferrer`,class:`tone-strong`,children:n.domain})]})]}),children:[G(`button`,{type:`button`,class:`button`,onClick:u(`ssh`),children:[`ssh`,a?.ssh.state===`refused`?G(`span`,{class:`aside`,children:`off`}):null]}),n.commands.includes(`verify`)?G(`button`,{type:`button`,class:`button`,onClick:u(`verify`),children:[`verify`,G(`span`,{class:`aside`,children:`read only`})]}):null,n.commands.includes(`plan`)?G(`button`,{type:`button`,class:`button`,onClick:u(`plan`),children:[`plan`,G(`span`,{class:`aside`,children:`dry run`})]}):null,s===void 0?null:G(`button`,{type:`button`,class:`button primary`,onClick:u(s),children:[s,` `,n.name]})]}),l.length===0?null:G(gr,{notes:l,quiet:``}),G(`div`,{class:`split`,children:[G(`div`,{class:`wide`,children:[n.kind===`platform`?G(X,{title:`apps`,meta:n.apps.length,children:n.apps.length===0?G(`p`,{class:`empty panel pad`,children:`None in server.yml.`}):G(`ul`,{class:`links panel`,children:n.apps.map(e=>G(`li`,{children:G($,{to:{page:`app`,server:n.name,app:e},children:[G(`span`,{class:`prompt`,"aria-hidden":`true`,children:`▸`}),G(`span`,{children:e})]})},e))})}):null,G(X,{title:`runs from here`,children:G(Er,{server:n.name})}),G(X,{title:`commands`,children:G(_r,{server:n})})]}),G(`div`,{class:`side`,children:G(X,{title:`reach`,aside:G(`button`,{type:`button`,class:`button small`,onClick:Qt,disabled:i,children:i?`asking…`:`ask again`}),children:G(`div`,{class:`panel pad`,children:a===void 0?G(J,{what:`asking`}):G(`dl`,{class:`facts`,children:[G(En,{label:`address`,cell:un(a)}),G(En,{label:`ssh`,cell:dn(a)}),G(En,{label:`login`,cell:fn(a)}),G(En,{label:`kayra`,cell:pn(a)})]})})})})]})]})},Qr=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,$r=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,ei={problem:`problems`,unchecked:`partly checked`,passed:`holds`},ti=()=>{P(()=>{$t()},[]);let e=Xt.value;if(e.state===`loading`)return G(J,{what:`Checking the fleet beyond its schemas`});if(e.state===`failed`)return G(q,{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(C,{children:[G(Y,{kicker:`fleet`,title:`validate`,tag:G(Sn,{word:t===`problem`?`FAIL`:t===`unchecked`?`PART`:`OK`,tone:Qr(t)}),sub:`Secrets, apps against their contract, stacks, routes · ${String(r(`problem`))} problems · ${String(r(`unchecked`))} not checked`,children:G(`button`,{type:`button`,class:`button`,onClick:()=>void $t(),children:[`check again`,G(`span`,{class:`aside`,children:`read only`})]})}),n.map(e=>G(`section`,{class:`card`,children:[G(`div`,{class:`card-head`,children:[G(K,{tone:Qr(e.result)}),G(`h2`,{children:e.name}),G(Tn,{children:e.kind}),G(Tn,{children:e.target}),G(`span`,{class:`grow`}),G(Tn,{tone:Qr(e.result),children:ei[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-${Qr(e.result)}`,children:$r(e.result)}),G(`span`,{children:[e.text,e.hint===null?null:G(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},ni=e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.text).join(``),ri=e=>e.kind===`output`?e.chunk:e.kind===`said`?`${ni(e.text)}\r\n`:``,ii=(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})}},ai=`modulepreload`,oi=function(e){return`/`+e},si={},ci=function(e){return e.pathname.endsWith(`.css`)},li=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ui=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=oi(t,n);let r=s(t),i=ci(r);return li(si,r.href,()=>{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 t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ai,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(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)})},di=({id:e})=>{let t=Oe(null),[n,r]=N(void 0),[i,a]=N(void 0),[o,s]=N(`running`),[c,l]=N(void 0),[u,d]=N(!1);P(()=>{let n={current:!0},i={current:()=>void 0};return(async()=>{let{Terminal:o}=await ui(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=ii(t=>Rt(e,t),h),_=c.onData(e=>{f.current&&g(e)}),v=Vt(`/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=ri(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 zt(e);t.ok||(l(t.failure),d(!1))};return G(C,{children:[G(Y,{kicker:`ssh session`,title:G(`code`,{children:n?.command??`kayra ssh`}),sub:`120 columns × 32 rows`,children:[G(Tn,{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(q,{failure:c}),i===void 0?null:G(Nr,{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.`})]})},fi=()=>{let e=B.value;switch(e.page){case`fleet`:return G(Mr,{});case`server`:return G(Zr,{name:e.server});case`app`:return G(mr,{server:e.server,app:e.app});case`runs`:return G(Dr,{});case`run`:return G(Xr,{id:e.id},e.id);case`session`:return G(di,{id:e.id},e.id);case`validate`:return G(ti,{});case`missing`:return G(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},pi=()=>(P(()=>(Zt(),Yt(),Qt(),nn()),[]),G(C,{children:[G(rr,{children:G(fi,{})}),G(Bn,{}),G(Gn,{})]})),mi=document.getElementById(`app`);mi!==null&&me(G(pi,{}),mi);
|