@yunuseon/kayra 0.23.0 → 0.24.1

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.
@@ -7,7 +7,8 @@
7
7
  # {{ apps_dir }}/<app>/.env operator config for compose
8
8
  # app-apply secrets → app-secrets/<app>/
9
9
  # app-restore a deployed app that runs
10
- # nothing, deployed again
10
+ # nothing, or whose registration
11
+ # or .env changed, deployed again
11
12
  # {{ platform_dir }}/apps/<app>.json the registration the deployer
12
13
  # and the builder read
13
14
  #
@@ -99,6 +100,7 @@
99
100
  owner: deploy
100
101
  group: deploy
101
102
  mode: "0644"
103
+ register: app_env
102
104
  become: true
103
105
 
104
106
  # Secrets before the registration: a push in between finds them in place.
@@ -127,17 +129,22 @@
127
129
  path: "{{ app.path | default('.') }}"
128
130
  hosts: "{{ app_subdomains | map('regex_replace', '$', '.' ~ domain) | list }}"
129
131
  secrets: "{{ manifest.secrets | default([]) }}"
132
+ register: app_registration
130
133
  become: true
131
134
 
132
135
  # A Docker update or a reboot stops every container, and one deployed before
133
136
  # the platform gave each service a restart policy stays down (bin/app-restore).
137
+ # A changed registration or .env (a new domain moves every host; new config)
138
+ # reaches a running app only by a deploy: until then it keeps the routes and
139
+ # environment it started with, and a new domain's redirects send visitors to
140
+ # hosts it does not serve. So then it is deployed again at the release it runs.
134
141
  # The retries wait out a deployer the host layer has just restarted.
135
- - name: Restore the app if it was deployed but runs nothing
142
+ - name: Restore the app if it was deployed but runs nothing, or redeploy it if its registration changed
136
143
  ansible.builtin.command:
137
- cmd: "{{ platform_dir }}/bin/app-restore {{ app.name }}"
144
+ cmd: "{{ platform_dir }}/bin/app-restore {{ app.name }}{{ ' --changed' if (app_env is changed or app_registration is changed) else '' }}"
138
145
  register: app_restored
139
146
  retries: 5
140
147
  delay: 3
141
148
  until: app_restored.rc == 0
142
- changed_when: "'restored ' in app_restored.stdout"
149
+ changed_when: "'restored ' in app_restored.stdout or 'redeployed ' in app_restored.stdout"
143
150
  become: true
@@ -1,7 +1,7 @@
1
1
  # Managed by Ansible (ntfy role).
2
2
  services:
3
3
  ntfy:
4
- image: binwiederhier/ntfy:v2.33.1
4
+ image: binwiederhier/ntfy:v2.37.2
5
5
  container_name: ntfy
6
6
  restart: unless-stopped
7
7
  command: ["serve"]
@@ -49,6 +49,11 @@ renovate_schedule: "0 4 * * 1"
49
49
  # www sends https://<domain>/x?y to https://www.<domain>/x?y. Empty, the bare
50
50
  # domain is not served.
51
51
  apex_redirect: ""
52
+ # Other domains that only redirect here, domain => a host of this server's
53
+ # domain: {example.de: www} sends example.de and www.example.de, path and query
54
+ # kept, to https://www.<domain>, permanently. Their names must already point at
55
+ # the server: certificates come by HTTP-01 like every other host's.
56
+ redirect_domains: {}
52
57
  # Push webhooks start a deploy at once; without them, the poll below finds the push.
53
58
  webhooks: true
54
59
  deploy_poll: "17 * * * *"
@@ -100,6 +100,24 @@
100
100
  when: apex_redirect | length == 0
101
101
  become: true
102
102
 
103
+ # The same for other domains that only redirect here (redirect_domains).
104
+ - name: Render the other domains' redirects
105
+ ansible.builtin.template:
106
+ src: redirect-domains.yml.j2
107
+ dest: "{{ platform_dir }}/traefik/dynamic/redirect-domains.yml"
108
+ owner: deploy
109
+ group: deploy
110
+ mode: "0644"
111
+ when: redirect_domains | length > 0
112
+ become: true
113
+
114
+ - name: Remove the other domains' redirects
115
+ ansible.builtin.file:
116
+ path: "{{ platform_dir }}/traefik/dynamic/redirect-domains.yml"
117
+ state: absent
118
+ when: redirect_domains | length == 0
119
+ become: true
120
+
103
121
  # The deployer's code and the scripts it and the builder run, into the build
104
122
  # context of both images: a checkout's TypeScript, or the published package's
105
123
  # JavaScript (Node strips types only outside node_modules).
@@ -0,0 +1,26 @@
1
+ # Other domains that only send visitors to {{ domain }} (redirect_domains in
2
+ # vars.yml): each, bare and www, a permanent redirect to its host there, path
3
+ # and query kept. Their certificates come like every other host's; plain HTTP
4
+ # reaches them through the web entrypoint's redirect to HTTPS first.
5
+ http:
6
+ routers:
7
+ {% for alias, target in redirect_domains | dictsort %}
8
+ redirect-{{ alias | replace('.', '-') }}:
9
+ rule: "Host(`{{ alias }}`) || Host(`www.{{ alias }}`)"
10
+ entryPoints: [websecure]
11
+ tls:
12
+ certResolver: le
13
+ domains:
14
+ - main: "{{ alias }}"
15
+ sans: ["www.{{ alias }}"]
16
+ middlewares: [redirect-{{ alias | replace('.', '-') }}]
17
+ service: noop@internal
18
+ {% endfor %}
19
+ middlewares:
20
+ {% for alias, target in redirect_domains | dictsort %}
21
+ redirect-{{ alias | replace('.', '-') }}:
22
+ redirectRegex:
23
+ regex: "^https?://[^/]+(.*)$"
24
+ replacement: "https://{{ target }}.{{ domain }}${1}"
25
+ permanent: true
26
+ {% endfor %}
@@ -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(e,t,n){var r,i,a,o={},s=arguments.length;for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return s>2&&(o.children=s>3?h.call(arguments,2):n),y(e,o,r,i,null)}function y(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 b(e){return e.children}function x(e,t){this.props=e,this.context=t,this.__g=0}function S(e,t){if(t==null)return e.__&&S(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:S(e)}function C(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),C(e)}function w(t){(8&t.__g||(t.__g|=8,r.push(t),a++))&&i==e.debounceRendering||((i=e.debounceRendering)||queueMicrotask)(T)}function T(){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),k(p,c,l,s.__n,p.namespaceURI,32&l.__u?[u]:null,d,u||S(l),32&l.__u,f),c.__v=l.__v,c.__.__k[c.__i]=c,A(d,c,f),l.__=l.__e=null,c.__e!=u&&C(c)))}finally{(a=r.length)&&(i||queueMicrotask)(T)}}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=E(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=k(e,h,m,i,a,o,s,c,l,u),g=h.__e,(m.ref!=h.ref||8&m.__u)&&(m.ref&&j(m.ref,null,h,m),h.ref&&u.push(h.ref,h.__c||g,h)),_||=g,4&h.__u?(c=D(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 E(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,h=n.length,g=h,_=0,v=0,x=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=x[a]=y(null,o):m(o)?o=x[a]=y(b,{children:o}):o.constructor===void 0&&o.__b?o=x[a]=y(o.type,o.props,o.key,o.ref,o.__v):x[a]=o,c=a+_,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=O(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?_--:_++,v=1)):(~l||(i>h?_--:i<h&&_++),typeof o.type!=`function`&&(o.__u|=4))):x[a]=null;if(v){for(u=[],d=[],a=0;a<i;a++)if((o=x[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]==_?_--:x[a].__u|=4)}if(g)for(a=0;a<h;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=S(s)),se(s,s));return r}function D(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=D(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=S(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 O(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 te(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function ne(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||te(e.style,t);if(n)for(t in n)r&&n[t]==r[t]||te(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=u[t]||(u[t]=re(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 re(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 k(t,n,r,i,a,o,s,c,l,u){var d,p,h,v,y,C,w,T,E,D,O,te,ne,re,k,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=ie(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 x(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)))),y=v.props,C=v.state,v.__v=n,r.__c){if(T!==y&&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=S(r);break n}v.componentWillUpdate&&v.componentWillUpdate(T,v.__s,O),E&&v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(y,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,te=e.__r,ne=0,E)v.state=v.__s,v.__g&=-9,te&&te(n),d=v.render(v.props,v.state,v.context),f.push.apply(v.__h,v.__k),v.__k=[];else do v.__g&=-9,te&&te(n),d=v.render(v.props,v.state,v.context),v.state=v.__s;while(8&v.__g&&++ne<25);v.state=v.__s,v.getChildContext&&(i=g({},i,v.getChildContext())),E&&r.__c&&v.getSnapshotBeforeUpdate&&(w=v.getSnapshotBeforeUpdate(y,C)),re=d&&d.type===b&&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?S(r,0):null),c=ee(t,m(re)?re:[re],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(k=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`))k++||(A=M);else if(k&&M.data.startsWith(`/$s`)&&!--k)break}else if(!k)break}}if(!A){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;A=c}(d=ie(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||ae(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 ie(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 ae(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(ae))}function A(t,n,r){for(var i=0;i<r.length;)j(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,x,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||ne(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`?x=b:f==`checked`?C=b:c&&typeof b!=`function`||!(E[f]!==b||T&&b!=null)||ne(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&&S(r,0),c,l),o&&o.some(_)),c&&O!=`textarea`||(f=`value`,O==`progress`&&x==null?t.removeAttribute(f):x==null||x===t[f]&&(O!=`progress`||x)||ne(t,f,x,E[f],a),f=`checked`,C!=null&&C!=t[f]&&ne(t,f,C,E[f],a))}else E===D||c&&t.data==D||(t.data=D);return t}function j(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||j(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=ie(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 M(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=y(b,{children:[t]}),a=[],o=[],k(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),A(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},x.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),w(this)))},x.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),w(this))},x.prototype.render=b,r=[],a=0,o=function(e,t){return e.__v.__b-t.__v.__b},s=Symbol(),c=/(PointerCapture)$|Capture$/i,l=0,u={};var N,P,le,ue,de=Object.is,fe=0,pe=[],me=[],F=e,he=F.__b,ge=F.__r,_e=F.diffed,ve=F.__c,ye=F.unmount,be=F.__;function xe(e,t){F.__h&&F.__h(P,e,fe||t),fe=0;var n=P.__H||(P.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return fe=1,Se(Me,e)}function Se(e,t,n){var r=xe(N++,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=P,!P.__f)){P.__f=!0;var i=P.shouldComponentUpdate;P.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 L(e,t){var n=xe(N++,3);!F.__s&&je(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,P.__H.__h.push(n))}function Ce(e){return fe=5,we(function(){return{current:e}},[])}function we(e,t){var n=xe(N++,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){F.__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=[],F.__e(n,e.__v)}}}while(me.length)}F.__b=function(e){P=null,he&&he(e)},F.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),be&&be(e,t)},F.__r=function(e){ge&&ge(e),N=0;var t=(P=e.__c).__H;t&&(le==P?P.__h=[]:(t.__h.some(ke),t.__h.some(Ae),N=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),le=P},F.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=P=null},F.__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=[],F.__e(n,e.__v)}}),ve&&ve(e,t)},F.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&&F.__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==F.requestAnimationFrame||((ue=F.requestAnimationFrame)||De)(Te)}function ke(e){var t=P,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),P=t}function Ae(e){var t=P;e.__c=e.__(),P=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(z>1)z--;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,z--,t)throw e}}function Fe(e){if(z>0)return e();Ve=++Be,z++;try{return e()}finally{Pe()}}var Ie,R=void 0;function Le(e){var t=R,n=Ie;R=void 0,Ie=void 0;try{return e()}finally{R=t,Ie=n}}var Re=void 0,z=0,ze=0,Be=0,Ve=0,He=void 0,Ue=0;function We(e){if(R!==void 0){var t=e.n;if(t===void 0||t.t!==R)return t={i:0,S:e,p:R.s,n:void 0,t:R,e:void 0,x:void 0,r:t},R.s!==void 0&&(R.s.n=t),R.s=t,e.n=t,32&R.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=R.s,t.n=void 0,R.s.n=t,R.s=t),t}}function B(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}B.prototype.brand=Ne,B.prototype.h=function(){return!0},B.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)},B.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)}))}},B.prototype.subscribe=function(e){var t=this;return et(function(){var n=t.value;Le(function(){return e(n)})},{name:`sub`})},B.prototype.valueOf=function(){return this.value},B.prototype.toString=function(){return this.value+``},B.prototype.toJSON=function(){return this.value},B.prototype.peek=function(){var e=this;return Le(function(){return e.value})},Object.defineProperty(B.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){z!==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++,z++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pe()}}}});function V(e,t){return new B(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 Je(e,t){B.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ue-1,this.f=4}Je.prototype=new B,Je.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=R;try{Ke(this),R=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 R=e,qe(this),this.f&=-2,!0},Je.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)}B.prototype.S.call(this,e)},Je.prototype.U=function(e){if(this.t!==void 0&&(B.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)}},Je.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(Je.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 Ye(e,t){return new Je(e,t)}function Xe(e){var t=e.j;if(e.j=void 0,typeof t==`function`){z++;var n=R;R=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,Ze(e),t}finally{R=n,Pe()}}}function Ze(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Xe(e)}function Qe(e){if(R!==this)throw Error(`Out-of-order effect`);qe(this),R=e,this.f&=-2;try{8&this.f&&Ze(this)}finally{Pe()}}function $e(e,t){this.x=e,this.j=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Ie&&Ie.push(this)}$e.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.j=t)}finally{e()}},$e.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Xe(this),Ke(this),z++;var e=R;return R=this,Qe.bind(this,e)},$e.prototype.N=function(){2&this.f||(this.f|=2,this.u=Re,Re=this)},$e.prototype.d=function(){this.f|=8,1&this.f||Ze(this)},$e.prototype.dispose=function(){this.d()};function et(e,t){var n=new $e(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var tt,nt,rt=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,it=[];et(function(){tt=this.N})();function at(t,n){e[t]=n.bind(null,e[t]||function(){})}function ot(e){if(nt){var t=nt;nt=void 0,t()}nt=e&&e.S()}function st(e){var t=this,r=e.data,i=lt(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=Ye(function(){var e=i.value.value;return e===0?0:!0===e?``:e||``}),o=Ye(function(){return!Array.isArray(a.value)&&!n(a.value)}),s=et(function(){if(this.N=ft,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}st.displayName=`ReactiveTextNode`,Object.defineProperties(B.prototype,{constructor:{configurable:!0,value:v(b,null).constructor},type:{configurable:!0,value:st},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),at(`__b`,function(e,t){if(ot(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof B&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),at(`__r`,function(e,t){if(e(t),t.type!==b){ot();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return et(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;rt&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),ot(n)}}),at(`__e`,function(e,t,n,r){ot(),e(t,n,r)}),at(`diffed`,function(e,t){ot();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=ct(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function ct(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=V(n);return{o:function(e,t){a.value=e,r=t},d:et(function(){this.N=ft;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))})}}at(`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)}),at(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),x.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 lt(e,t){return we(function(){return V(e,t)},[])}var ut=function(e){queueMicrotask(function(){queueMicrotask(e)})};function dt(){Fe(function(){for(var e;e=it.shift();)tt.call(e)})}function ft(){it.push(this)===1&&(e.requestAnimationFrame||ut)(dt)}var H=e=>e,pt={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`}},mt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ht=e=>mt(e)?e:H({}),gt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):H([]),_t=e=>Object.freeze(Object.entries(ht(e.properties)).map(([t,n])=>{let r=ht(n);return{name:t,type:r.type,required:gt(e.required).includes(t),description:typeof r.description==`string`?r.description:``,choices:gt(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`&&ht(r.items).type===`string`}})),vt=e=>typeof e==`boolean`||typeof e==`string`?e:Array.isArray(e)?gt(e).join(`
2
+ `):H(``),yt=(e,t)=>Object.freeze(Object.fromEntries(_t(e).map(e=>[e.name,vt(t[e.name]??e.default)]))),bt=(e,t)=>Object.freeze(Object.fromEntries(_t(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]])}))),xt=(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`))),St=(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)},Ct=(e,t)=>Object.freeze(e.flatMap(e=>{let n=St(`${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)),wt=e=>e,Tt=async(e,t)=>e.ok?H({ok:!0,value:wt(await t(e))}):H({ok:!1,failure:{status:e.status,message:(await e.text()).trim()}}),Et=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.`}})}},Dt=e=>Et(()=>fetch(e).then(e=>Tt(e,e=>e.json()))),Ot=(e,t)=>Et(async()=>Tt(await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),async e=>e.status===204?void 0:e.json())),kt=(e,t)=>Ot(`/api/operations/${e.name}/preview`,{input:e.input,options:t}),At=(e,t,n)=>Ot(`/api/operations/${e.name}`,{input:e.input,options:t,...n===void 0?{}:{confirm:n}}),jt=(e,t={})=>Ot(`/api/operations/${e}`,{input:t}),Mt=(e,t)=>Ot(`/api/runs/${encodeURIComponent(e)}/answers`,{text:t}),Nt=e=>Ot(`/api/runs/${encodeURIComponent(e)}/cancel`,{}),Pt=(e,t)=>Ot(`/api/sessions/${encodeURIComponent(e)}/input`,{text:t}),Ft=e=>Et(async()=>Tt(await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`}),()=>Promise.resolve(void 0))),It=()=>Dt(`/api/runs`),Lt=(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(wt(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()}},Rt=/^[A-Za-z0-9._-]+$/,zt=e=>{let t=e.split(`/`).filter(e=>e!==``).map(decodeURIComponent);if(!t.every(e=>Rt.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})},Bt=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}},Vt=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}])}},Ht=`kayra.theme`,Ut=(e,t)=>H(e===`dark`||e===`light`?e:t?`dark`:`light`),Wt=V(zt(location.pathname)),Gt=e=>{history.pushState(null,``,Bt(e)),Wt.value=e,scrollTo({top:0})};addEventListener(`popstate`,()=>{Wt.value=zt(location.pathname)});var U=V({state:`loading`}),W=V({state:`loading`}),Kt=async()=>{let e=await Dt(`/api/operations`);W.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},G=V({value:void 0,live:!1}),qt=V({state:`loading`}),Jt=async()=>{let e=await Dt(`/api/fleet`);U.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},Yt=()=>{G.value={value:G.value.value,live:!0},Lt(`/api/operations/status`,e=>{G.value={value:e,live:!0}},()=>{G.value={value:G.value.value,live:!1}},{input:{}})},Xt=async()=>{qt.value={state:`loading`};let e=await jt(`validate`);qt.value=e.ok?{state:`ready`,value:e.value}:{state:`failed`,failure:e.failure}},K=V({state:`loading`}),Zt=async()=>{let e=await It();e.ok?K.value={state:`ready`,value:e.value}:K.value.state!==`ready`&&(K.value={state:`failed`,failure:e.failure})},Qt=V(Date.now()),$t=()=>{Zt();let e=setInterval(()=>{Qt.value=Date.now(),Zt()},3e3);return()=>{clearInterval(e)}},en=()=>{try{return localStorage.getItem(Ht)}catch{return null}},tn=matchMedia(`(prefers-color-scheme: dark)`),nn=V(Ut(en(),tn.matches));et(()=>{document.documentElement.setAttribute(`data-theme`,nn.value)}),tn.addEventListener(`change`,e=>{en()===null&&(nn.value=e.matches?`dark`:`light`)});var rn=()=>{nn.value=nn.value===`dark`?`light`:`dark`;try{localStorage.setItem(Ht,nn.value)}catch{}},an=e=>e===null?``:` · ${String(e)} ms`,on={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`},sn=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}})}},cn=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${an(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:on[t],tone:`bad`,...n===null?{}:{title:n}})}},ln=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??`?`)}${an(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:on[t.state],tone:`bad`,...t.error===null?{}:{title:t.error}})}},un=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`})}},dn=e=>{if(e===void 0)return H(`waiting`);let t=[sn(e),cn(e),ln(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`)},fn=e=>{let t=dn(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&&un(e).tone===`warn`?H({word:`BEHIND`,tone:`warn`}):H(t===`ok`?{word:`OK`,tone:t}:{word:`--`,tone:t})},pn=e=>{let t=Math.max(0,6-e.length);return`[${` `.repeat(Math.floor(t/2))}${e}${` `.repeat(Math.ceil(t/2))}]`},mn={ok:`●`,warn:`▲`,bad:`✕`,waiting:`◌`,active:`◐`,muted:`○`,strong:`●`,accent:`◆`},hn=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:--hn,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),e.vnode&&e.vnode(u),u}var gn=(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)},_n=({text:e})=>q(b,{children:(typeof e==`string`?[e]:e).map(gn)}),vn=({lines:e})=>q(`div`,{class:`lines`,children:e.map((e,t)=>q(`div`,{children:q(_n,{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:mn[e]}),yn=({word:e,tone:t})=>q(`span`,{class:`tag tone-${t}${t===`waiting`||t===`active`?` pulse`:``}`,children:pn(e)}),bn={reads:`read only`,changes:`changes`,destroys:`destroys`},xn=({effect:e})=>q(`span`,{class:`badge badge-${e}`,children:bn[e]}),Sn=({children:e,tone:t})=>q(`span`,{class:`pill${t===void 0?``:` pill-${t}`}`,children:e}),Cn=({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]}),wn=({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]}),Tn=({initial:e,choose:t,close:n})=>{let[r,i]=I(e===``?`.`:e),[a,o]=I(void 0);return L(()=>{let e={current:!1};return o(void 0),Dt(`/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(b,{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})]})},En=V(void 0),Dn=(e,t={})=>{En.value={name:e,input:t}},On=e=>{Dn(e.name,Object.fromEntries(Object.entries(e).filter(([e])=>e!==`name`)))},kn=()=>{En.value=void 0},An={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`}},jn=({step:e})=>{let t=An[e.kind]??{glyph:`·`,tone:`tone-muted`};return q(b,{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})]})]})]})},Mn=()=>q(`button`,{type:`button`,class:`iconbtn`,onClick:kn,"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`})})}),Nn=({field:e,value:t,change:n,server:r})=>{let[i,a]=I(!1),o=U.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(Tn,{initial:c,close:()=>{a(!1)},choose:e=>{n(e),a(!1)}}):null]})},Pn=({info:e,seed:t,options:n,submit:r})=>{let[i,a]=I(()=>yt(e.input,t.input)),[o,s]=I(n.verbose??!1),[c,l]=I(n.dryRun??!1),u=e.kind===`plan`||e.kind===`session`,d=_t(e.input),f=d.some(e=>!e.supported);return q(`form`,{onSubmit:t=>{t.preventDefault(),r({draft:{name:e.name,input:bt(e.input,i)},options:{verbose:o,dryRun:c}})},children:[q(`div`,{class:`sheet-body operation-fields`,children:[d.map(e=>q(Nn,{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:kn,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`})]})})]})},Fn=e=>{if(W.value.state===`ready`&&W.value.value.some(t=>t.name===e.name&&t.local))return;let t=U.value,n=t.state===`ready`?t.value.servers.find(t=>t.name===e.input.server):void 0;return n?.target===`multipass`?void 0:n?.name},In=({prepared:e,effect:t,back:n})=>{let{draft:r,options:i}=e,[a,o]=I(void 0),[s,c]=I(``),[l,u]=I(void 0);if(L(()=>{kt(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?Fn(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 At(r,i,m===void 0?void 0:s);e.ok?(kn(),Gt(`session`in e.value?{page:`session`,id:e.value.session}:{page:`run`,id:e.value.run})):u(e.failure)};return q(b,{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(jn,{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:kn,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}`})]})]})]})},Ln=({prepared:e,info:t,back:n})=>{let[r,i]=I(void 0),[a,o]=I(t.kind===`stream`);return L(()=>{let n={current:!0};return t.kind===`stream`?Lt(`/api/operations/${t.name}`,e=>{i({ok:!0,value:e})},()=>{o(!1)},{input:e.draft.input},e=>{i({ok:!1,failure:e})}):(jt(t.name,e.draft.input).then(e=>{n.current&&i(e)}),()=>{n.current=!1})},[e]),q(b,{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:kn,children:`close`})]})})]})},Rn=({draft:e,info:t})=>{let[n,r]=I(void 0),[i,a]=I({draft:e,options:{}}),o=()=>{n!==void 0&&a(n),r(void 0)},s=t.effect===`reads`||n?.options.dryRun===!0?void 0:Fn(n?.draft??e);return q(b,{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(xn,{effect:t.effect}),q(Mn,{})]}),q(`div`,{class:`sheet-head`,children:[q(`h2`,{id:`operation-title`,children:pt[t.name].label}),q(`p`,{class:`sub`,children:t.summary})]}),n===void 0?q(Pn,{info:t,seed:i.draft,options:i.options,submit:r}):t.kind===`plan`||t.kind===`session`?q(In,{prepared:n,effect:t.effect,back:o}):q(Ln,{prepared:n,info:t,back:o})]})},zn=()=>{let e=En.value,t=Ce(null),n=e!==void 0;if(L(()=>{if(!n)return;let e=document.activeElement;t.current?.focus();let r=e=>{if(e.key===`Escape`&&kn(),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=W.value,i=r.state===`ready`?r.value.find(t=>t.name===e.name):void 0;return q(`div`,{class:`overlay`,onClick:kn,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(Rn,{draft:e,info:i},JSON.stringify(e))})})},Q=V(!1),Bn=e=>e.replace(`.`,` `),Vn=()=>{let e=U.value,t=e.state===`ready`?e.value.servers:[],n=W.value.state===`ready`?W.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:Bn(e.name),hint:e.summary,icon:pt[e.name].icon,line:`kayra ${Bn(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}})),...xt(n,e).map(t=>H({label:`${Bn(t.name)} ${e.name}`,hint:t.summary,icon:pt[t.name].icon,line:`kayra ${Bn(t.name)} ${e.name}`,run:{name:t.name,input:{server:e.name}},effect:t.effect,real:e.target!==`multipass`}))]))])},Hn=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}},Un=e=>{Q.value=!1,`go`in e?Gt(e.go):Dn(e.run.name,e.run.input)},Wn=()=>{let[e,t]=I(``),[n,r]=I(0),i=Ce(null),a=Q.value;if(L(()=>{a&&i.current?.focus()},[a]),L(()=>{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=Ct(Vn(),e).slice(0,12),s=o[n],c=s===void 0?void 0:Hn(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&&Un(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=Hn(e);return q(`li`,{role:`option`,"aria-selected":t===n,class:t===n?`selected`:void 0,onMouseEnter:()=>{r(t)},onClick:()=>{Un(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`})]})]})})},Gn=()=>{Q.value=!0},$=({to:e,children:t,class:n,current:r})=>q(`a`,{href:Bt(e),class:n,"aria-current":r===!0?`page`:void 0,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),Gt(e))},children:t}),Kn=(e,t)=>Bt(e)===Bt(t),qn=()=>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`})]}),Jn=()=>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`})]}),Yn=()=>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`})}),Xn=()=>{let e=U.value,t=Vt(Wt.value),n=nn.value===`dark`;return q(`header`,{class:`topbar`,children:[q($,{to:{page:`fleet`},class:`brand`,children:[q(qn,{}),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:Gn,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:rn,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,title:n?`Light mode`:`Dark mode`,children:q(n?Jn:Yn,{})})]})},Zn=({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})]}),Qn=({to:e,label:t})=>{let n=Kn(Wt.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})]})},$n=()=>{let e=U.value,t=Wt.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(Zn,{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=fn(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(Zn,{children:`views`}),q(Qn,{to:{page:`fleet`},label:`overview`}),q(Qn,{to:{page:`runs`},label:`runs`}),q(Qn,{to:{page:`validate`},label:`validate`}),q(`button`,{type:`button`,class:`rail-item`,onClick:()=>{On({name:`doctor`})},children:[q(`span`,{class:`rail-mark`,"aria-hidden":`true`}),q(`span`,{children:`doctor`})]})]})]})})},er={fleet:`FLEET`,server:`SERVER`,app:`APP`,runs:`RUNS`,run:`RUN`,session:`SSH`,validate:`VALIDATE`,missing:`?`},tr=()=>{let e=U.value,{value:t,live:n}=G.value,r=t?.servers??[],i=r.filter(e=>dn(e)===`ok`).length,a=r.filter(e=>un(e).tone===`warn`).length,o=new Date(Qt.value).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return q(`footer`,{class:`statusline`,children:[q(`span`,{class:`seg seg-mode`,children:er[Wt.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(b,{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})]})},nr=({children:e})=>q(`div`,{class:`app`,children:[q(Xn,{}),q(`div`,{class:`body`,children:[q($n,{}),q(`main`,{class:`main`,children:e})]}),q(tr,{})]}),rr=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`},ir=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`},ar=(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`})},or=e=>Date.parse(e),sr=(e,t)=>{let[n,r]=I(void 0),i=()=>{r(void 0),e().then(r)};return L(i,[t]),H([n,i])},cr=e=>e===`success`?`ok`:e===`failure`?`bad`:`waiting`,lr=({server:e,app:t,open:n})=>{let[r]=sr(()=>jt(`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(b,{children:[q(`p`,{class:`sub`,children:a===void 0?`Not deployed yet.`:`Live: ${a.sha.slice(0,7)} since ${ir(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:cr(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:ir(i-Date.parse(e.started))}),q(`td`,{class:`right tone-muted`,children:e.finished===void 0?``:rr(Date.parse(e.finished)-Date.parse(e.started))})]},e.id))})]})]})},ur=({server:e,app:t})=>{let[n]=sr(()=>jt(`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:ir(r-Date.parse(n.time))}),n.live?q(Sn,{tone:`ok`,children:`live`}):q(`button`,{class:`button small`,onClick:()=>{On({name:`app.rollback`,server:e,app:t,sha:n.sha})},children:`Roll back to it`})]},n.sha))})},dr=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`)},fr=({server:e,app:t,run:n})=>{let[r]=sr(()=>jt(`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:dr(e),children:e===``?` `:e},t))}):q(Y,{failure:r.failure})},pr=({server:e,app:t})=>{let[n,r]=I(`runs`),[i,a]=I(void 0),[o,s]=I(``);return q(b,{children:[q(wn,{kicker:`app`,title:t,sub:`on ${e}`,children:q(`form`,{class:`inline`,onSubmit:n=>{n.preventDefault(),On({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(lr,{server:e,app:t,open:e=>{a(e),r(`log`)}}):n===`releases`?q(ur,{server:e,app:t}):q(fr,{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:()=>{On({name:`app.purge`,server:e,app:t})},children:[`purge `,t,`'s volumes`]})]})]})},mr=({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:()=>{Dn(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:Yt,children:G.value.live?`asking…`:e.label})}},hr=({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(mr,{remedy:e,first:t===0},e.label))})]},e.title))}),gr=({server:e})=>{let t=W.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`):xt(t.value,e)).map(t=>q(`button`,{type:`button`,class:`action${t.effect===`destroys`?` danger`:``}`,onClick:()=>{Dn(t.name,e===void 0?{}:{server:e.name})},children:[q(`span`,{class:`icon`,"aria-hidden":`true`,children:pt[t.name].icon}),q(`strong`,{children:pt[t.name].label}),q(xn,{effect:t.effect}),q(`span`,{class:`about`,children:t.summary})]},t.name))})},_r=e=>Object.freeze(e.toSorted((e,t)=>t.started.localeCompare(e.started))),vr=(e,t,n)=>Object.freeze(_r(e).filter(e=>e.server===t).slice(0,n).toReversed().map(e=>e.state)),yr=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(`, `)}`},br=e=>e.kind===`platform`&&e.commands.includes(`deploy`)?H(`deploy`):e.commands.includes(`setup`)?H(`setup`):void 0,xr=(e,t)=>t?.tone===`bad`?Object.freeze([`${e} ${t.text}`]):Object.freeze([]),Sr=(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=dn(t)===`bad`?[H({tone:`bad`,title:`${e.name} does not answer`,text:[...xr(`address`,sn(t)),...xr(`ssh`,cn(t)),...xr(`login`,ln(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=br(e),s=un(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])},Cr=(e,t,n)=>{let r=_r(n),i=e.flatMap(e=>{let n=t.find(t=>t.name===e.name);return n===void 0?Object.freeze([]):Sr(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])},wr={running:`waiting`,passed:`ok`,failed:`bad`,interrupted:`warn`,declined:`warn`},Tr=({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=_r(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=Qt.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:ar(e.started,i)}),q(J,{tone:wr[e.state],label:e.state}),q(`span`,{class:`ellipsis`,children:e.command}),q(`span`,{class:`state tone-${wr[e.state]===`waiting`?`active`:wr[e.state]}`,children:e.state}),q(`span`,{class:`ago`,children:ir(i-or(e.started))})]},e.id))})})},Er=()=>q(b,{children:[q(wn,{kicker:`journal`,title:`runs`,sub:`Every command run from here, recorded in the fleet's .cache/ui/runs.`}),q(Tr,{})]}),Dr=864e5,Or=({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})]}),kr=({facts:e,seen:t})=>{let n=fn(t),r=K.value.state===`ready`?K.value.value:[],i=vr(r,e.name,16),a=_r(r).find(t=>t.server===e.name),o=br(e);return q(`div`,{class:`grow-row`,children:[q(yn,{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(Or,{cell:t===void 0?void 0:sn(t)}),q(Or,{cell:t===void 0?void 0:cn(t)}),q(Or,{cell:t===void 0?void 0:ln(t)}),q(Or,{cell:t===void 0?void 0:un(t)}),q(`div`,{children:[q(`span`,{class:`strip`,role:`img`,"aria-label":yr(i),children:i.map((e,t)=>q(`span`,{class:e},t))}),q(`span`,{class:`second`,children:a===void 0?`no runs yet`:ir(Qt.value-or(a.started))})]}),q(`div`,{class:`row-actions`,children:[e.commands.includes(`plan`)?q(`button`,{type:`button`,class:`button small`,onClick:()=>{Dn(`plan`,{server:e.name})},children:`plan`}):null,o===void 0?null:q(`button`,{type:`button`,class:`button small primary`,onClick:()=>{Dn(o,{server:e.name})},children:o})]})]})},Ar=({servers:e,seen:t})=>{let n=e=>t.find(t=>t.name===e),r=e.filter(e=>dn(n(e.name))===`ok`),i=t.filter(e=>e.kayra.state!==`skipped`&&e.kayra.state!==`pending`),a=i.filter(e=>un(e).tone===`warn`),o=t[0]?.kayra.pin,s=K.value.state===`ready`?K.value.value:[],c=s.filter(e=>Qt.value-or(e.started)<Dr),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=>dn(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-${fn(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(`, `)})]})]})},jr=()=>{let[e,t]=I(``),n=U.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(b,{children:[q(wn,{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:Yt,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(Ar,{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(kr,{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(Tr,{limit:8})})}),q(`div`,{class:`side`,children:q(Z,{title:`needs you`,children:q(hr,{notes:Cr(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(gr,{})})]})},Mr=({id:e,question:t})=>{let[n,r]=I(``),[i,a]=I(!1),[o,s]=I(void 0),c=Ce(null);L(()=>{c.current?.focus()},[]);let l=async t=>{a(!0),r(``);let n=await Mt(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(_n,{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})]})},Nr={invocation:void 0,steps:[],current:void 0,asking:void 0,ended:void 0},Pr=(e,t,n)=>t===void 0?e:H({...e,steps:e.steps.map((e,r)=>r===t?n(e):e)}),Fr=(e,t)=>Pr(e,e.current,e=>({...e,said:[...e.said,t]})),Ir=(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 Pr({...e,current:t.index},t.index,e=>({...e,state:`running`,started:n}));case`done`:return Pr(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 Fr(e,{kind:`output`,stream:t.stream,chunk:t.chunk});case`said`:return Fr(e,{kind:`said`,stream:t.stream,text:t.text});case`ask`:return H({...e,asking:t});case`answered`:return H({...e,asking:void 0})}},Lr=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`)},Rr={fg:void 0,bold:!1,dim:!1},zr=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],Br=(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?Rr: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:zr[n-30]}:n>=90&&n<=97?{...e,fg:`bright-${zr[n-90]??`white`}`}:e,i)};return r(e,n)},Vr=e=>[e.fg===void 0?``:`sgr-${e.fg}`,e.bold?`sgr-bold`:``,e.dim?`sgr-dim`:``].filter(e=>e!==``).join(` `),Hr=/\u001b\[([0-9;]*)m|\u001b\[[0-9;?]*[A-Za-z]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,Ur=e=>{let t=[...e.matchAll(Hr)].reduce((t,n)=>{let r=e.slice(t.at,n.index),i=r===``?t.out:[...t.out,{text:r,classes:Vr(t.look)}],a=n[1];return{out:i,look:a===void 0?t.look:Br(t.look,a),at:n.index+n[0].length}},{out:[],look:Rr,at:0}),n=e.slice(t.at);return n===``?t.out:H([...t.out,{text:n,classes:Vr(t.look)}])},Wr={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`}},Gr={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`}},Kr=({step:e})=>q(b,{children:e.said.map((e,t)=>e.kind===`output`?q(`span`,{class:e.stream===`stderr`?`stderr`:void 0,children:Ur(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(_n,{text:e.text})},t))}),qr=(e,t)=>e.ms??(e.started===void 0?void 0:t-e.started),Jr=({steps:e,now:t,picked:n,pick:r})=>q(`ol`,{class:`steps panel`,children:e.map(e=>{let i=qr(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:Gr[e.state].tone,"aria-label":e.state,children:Gr[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:rr(i)})]})]},a)})}),Yr=({id:e})=>{let[t,n]=Se((e,t)=>Ir(e,t,Date.now()),Nr),[r,i]=I(Date.now()),[a,o]=I(void 0),[s,c]=I(void 0),[l,u]=I(!0),d=Ce(null);L(()=>Lt(`/api/runs/${encodeURIComponent(e)}/events`,n,()=>void 0,void 0,o),[e]);let f=Lr(t)===`running`;L(()=>{if(!f)return;let e=setInterval(()=>{i(Date.now())},250);return()=>{clearInterval(e)}},[f]),L(()=>{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 _=Wr[Lr(t)],v=m.flatMap(e=>e.started===void 0?[]:[e.started]),y=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`),T=m.filter(e=>(s===void 0||e.listed.index===s)&&e.said.length>0);return q(b,{children:[q(wn,{kicker:`run · ${e}`,title:q(`code`,{children:p.command}),tag:q(yn,{word:_.word,tone:_.tone}),sub:[...p.about,`${String(m.length)} steps`].join(` · `),children:[q(`div`,{class:`elapsed`,children:[q(`strong`,{children:rr(y)}),q(`span`,{children:[x,` of `,m.length,` steps passed`]})]}),f?q(`button`,{type:`button`,class:`button danger`,onClick:()=>{Nt(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(Mr,{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(Jr,{steps:m,now:r,picked:s,pick:c})})}),q(`div`,{class:`wide`,children:q(Z,{title:`log`,aside:q(b,{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:[T.length===0?q(`span`,{class:`tone-muted`,children:f?`Waiting for output…`:`Nothing was printed here.`}):T.map(e=>q(`div`,{children:[q(`div`,{class:`log-step`,children:[`── `,e.listed.index+1,` · `,e.listed.title,` ──`]}),q(Kr,{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(vn,{lines:h.footer})})]})})})]})]})},Xr=({name:e})=>{let t=U.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=fn(a),s=br(n),c=K.value.state===`ready`?K.value.value.filter(t=>t.server===e):[],l=Cr([n],a===void 0?[]:[a],c).map(e=>({...e,remedies:e.remedies.filter(e=>e.kind!==`go`||e.to.page!==`server`)})),u=e=>()=>{Dn(e,{server:n.name})};return q(b,{children:[q(wn,{kicker:`server`,title:n.name,tag:q(yn,{word:o.word,tone:o.tone}),sub:q(b,{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(hr,{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(Tr,{server:n.name})}),q(Z,{title:`commands`,children:q(gr,{server:n})})]}),q(`div`,{class:`side`,children:q(Z,{title:`reach`,aside:q(`button`,{type:`button`,class:`button small`,onClick:Yt,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(Cn,{label:`address`,cell:sn(a)}),q(Cn,{label:`ssh`,cell:cn(a)}),q(Cn,{label:`login`,cell:ln(a)}),q(Cn,{label:`kayra`,cell:un(a)})]})})})})]})]})},Zr=e=>e===`problem`?`bad`:e===`unchecked`?`warn`:`ok`,Qr=e=>e===`problem`?`✗`:e===`unchecked`?`·`:`✓`,$r={problem:`problems`,unchecked:`partly checked`,passed:`holds`},ei=()=>{L(()=>{Xt()},[]);let e=qt.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(b,{children:[q(wn,{kicker:`fleet`,title:`validate`,tag:q(yn,{word:t===`problem`?`FAIL`:t===`unchecked`?`PART`:`OK`,tone:Zr(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 Xt(),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:Zr(e.result)}),q(`h2`,{children:e.name}),q(Sn,{children:e.kind}),q(Sn,{children:e.target}),q(`span`,{class:`grow`}),q(Sn,{tone:Zr(e.result),children:$r[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-${Zr(e.result)}`,children:Qr(e.result)}),q(`span`,{children:[e.text,e.hint===null?null:q(`span`,{class:`hint`,children:[`→ `,e.hint]})]})]},t))})]},e.name))]})},ti=e=>typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.text).join(``),ni=e=>e.kind===`output`?e.chunk:e.kind===`said`?`${ti(e.text)}\r\n`:``,ri=(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})}},ii=`modulepreload`,ai=function(e){return`/`+e},oi={},si=function(e){return e.pathname.endsWith(`.css`)},ci=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},li=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=ai(t,n);let r=s(t),i=si(r);return ci(oi,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`:ii,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)})},ui=({id:e})=>{let t=Ce(null),[n,r]=I(void 0),[i,a]=I(void 0),[o,s]=I(`running`),[c,l]=I(void 0),[u,d]=I(!1);L(()=>{let n={current:!0},i={current:()=>void 0};return(async()=>{let{Terminal:o}=await li(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=ri(t=>Pt(e,t),h),_=c.onData(e=>{f.current&&g(e)}),v=Lt(`/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=ni(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 Ft(e);t.ok||(l(t.failure),d(!1))};return q(b,{children:[q(wn,{kicker:`ssh session`,title:q(`code`,{children:n?.command??`kayra ssh`}),sub:`120 columns × 32 rows`,children:[q(Sn,{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(Mr,{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.`})]})},di=()=>{let e=Wt.value;switch(e.page){case`fleet`:return q(jr,{});case`server`:return q(Xr,{name:e.server});case`app`:return q(pr,{server:e.server,app:e.app});case`runs`:return q(Er,{});case`run`:return q(Yr,{id:e.id},e.id);case`session`:return q(ui,{id:e.id},e.id);case`validate`:return q(ei,{});case`missing`:return q(`p`,{class:`empty`,children:[`Nothing at `,e.path,`.`]})}},fi=()=>(L(()=>(Jt(),Kt(),Yt(),$t()),[]),q(b,{children:[q(nr,{children:q(di,{})}),q(zn,{}),q(Wn,{})]})),pi=document.getElementById(`app`);pi!==null&&M(q(fi,{}),pi);
@@ -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-CYYhXjdE.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-CmGTvoz9.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-DzIVPXyL.css">
18
18
  </head>
19
19
  <body>
@@ -25,6 +25,7 @@ export const settings = [
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
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."),
28
+ setting("redirect_domains", platform, z.record(domainSchema, subdomainSchema), "Other domains that only send visitors here, each to a host of the server's domain: example.de: www sends https://example.de/x?y and https://www.example.de/x?y to https://www.<domain>/x?y, permanently, path and query kept. Their DNS is the fleet's: both names must point at the server before setup, or their certificates fail."),
28
29
  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."),
29
30
  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 * * * *)."),
30
31
  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,23 +85,37 @@ const routeFindings = (facts) => {
85
85
  ]);
86
86
  }), `edge_routes: ${count(routes.length, "route")}, each with subdomains and a host:port upstream`);
87
87
  };
88
+ const routedHosts = (facts) => typed({
89
+ hosts: facts.server.apps.flatMap((app) => {
90
+ const parsed = appManifestSchema.safeParse(facts.manifests[app.name]);
91
+ return typed(parsed.success ? (parsed.data.routes ?? []).map((route) => String(route.host)) : []);
92
+ }),
93
+ complete: facts.server.apps.every((app) => facts.manifests[app.name] !== undefined),
94
+ });
95
+ /** A redirect to target.<domain> (named by setting, sending from): one of the server's apps must serve that host. */
96
+ const redirectFinding = (facts, setting, from, target, routed) => {
97
+ const domain = facts.server.domain;
98
+ if (routed.hosts.includes(target))
99
+ return passed(`${setting}: ${from} redirects to ${target}.${domain}, which app routes serve`);
100
+ if (!routed.complete)
101
+ return unchecked(`${setting} not checked: not every app is cloned yet`, `kayra apps ${facts.server.name} clones them`);
102
+ return problem(`${setting}: no app routes ${target}.${domain}, so ${from} would redirect to nothing`, "name a route host of one of the server's apps");
103
+ };
88
104
  /** apex_redirect: the bare domain redirects to a host one of the server's apps serves. */
89
105
  const apexFindings = (facts) => {
90
106
  const target = facts.vars["apex_redirect"];
91
107
  if (typeof target !== "string" || target === "")
92
108
  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
- });
109
+ return typed([redirectFinding(facts, "apex_redirect", facts.server.domain, target, routedHosts(facts))]);
110
+ };
111
+ /** redirect_domains: each other domain redirects to a host one of the server's apps serves, and is not the server's own. */
112
+ const redirectDomainFindings = (facts) => {
113
+ const redirects = mapping(facts.vars["redirect_domains"]);
114
+ const routed = routedHosts(facts);
97
115
  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
- ]);
116
+ return Object.freeze(Object.entries(redirects).map(([alias, target]) => alias === domain || alias.endsWith(`.${domain}`)
117
+ ? problem(`redirect_domains: ${alias} is the server's own domain or under it`, "list only other domains; apex_redirect sends the bare domain")
118
+ : redirectFinding(facts, `redirect_domains.${alias}`, `${alias} (and www.${alias})`, String(target), routed)));
105
119
  };
106
120
  /** Each app's contract against the fleet's values for it. */
107
121
  const appFindings = (facts) => Object.freeze(facts.server.apps.flatMap((app) => {
@@ -134,7 +148,7 @@ const appFindings = (facts) => Object.freeze(facts.server.apps.flatMap((app) =>
134
148
  }));
135
149
  const rank = { problem: 0, unchecked: 1, passed: 2 };
136
150
  /** Everything validate finds for one server: problems first, then what it could not check, then what holds. */
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]));
151
+ export const findings = (facts) => Object.freeze([...secretsFindings(facts), ...recipientFindings(facts), ...terraformFindings(facts), ...stackFindings(facts), ...routeFindings(facts), ...apexFindings(facts), ...redirectDomainFindings(facts), ...appFindings(facts)].toSorted((a, b) => rank[a.result] - rank[b.result]));
138
152
  /** How a set of findings went as a whole: its worst. */
139
153
  export const overall = (found) => verdicts.find((verdict) => found.some((each) => each.result === verdict)) ?? "passed";
140
154
  /** How many problems, and how many checks could not look, across reports. */
@@ -11,7 +11,7 @@
11
11
  # code and the platform scripts).
12
12
  # =============================================================================
13
13
 
14
- FROM node:24.22.1-trixie-slim@sha256:43b9ba1142b8dcf33fa8f922ca1be85714adc444e0586c7cf7726daaeabc1bea
14
+ FROM node:24.22.1-trixie-slim@sha256:89c5244bc22a9bc3287d89ebc7e49b9cb5bb84cd40e6175ac3421d5a9f68b95a
15
15
 
16
16
  # renovate: datasource=github-releases depName=moby/buildkit
17
17
  ARG BUILDKIT_VERSION=v0.34.1
@@ -7,13 +7,13 @@
7
7
  # Context: <platform_dir>/kayra, copied by the platform role.
8
8
  # =============================================================================
9
9
 
10
- FROM node:24.22.1-trixie-slim@sha256:43b9ba1142b8dcf33fa8f922ca1be85714adc444e0586c7cf7726daaeabc1bea
10
+ FROM node:24.22.1-trixie-slim@sha256:89c5244bc22a9bc3287d89ebc7e49b9cb5bb84cd40e6175ac3421d5a9f68b95a
11
11
 
12
12
  # renovate: datasource=github-releases depName=moby/buildkit
13
13
  ARG BUILDKIT_VERSION=v0.34.1
14
14
  # What the Renovate job runs, pinned here so Renovate keeps it current itself.
15
15
  # renovate: datasource=docker depName=renovate/renovate
16
- ARG RENOVATE_VERSION=44.181.0
16
+ ARG RENOVATE_VERSION=44.222.0
17
17
  ENV RENOVATE_IMAGE=renovate/renovate:${RENOVATE_VERSION}
18
18
 
19
19
  RUN apt-get update && \
@@ -6,7 +6,7 @@
6
6
 
7
7
  services:
8
8
  registry:
9
- image: registry:3.1.2@sha256:01cd312e67026f06f5d89c3e133a4a9adc7cb9eeb9b1194e0b2954dfd770efd2
9
+ image: registry:3.1.2@sha256:38907510915c3f1604c7e83d6ab602ab3020d092f73bdaed8696773693ff768c
10
10
  restart: unless-stopped
11
11
  environment:
12
12
  # registry-gc.sh deletes manifests nothing references any more.
@@ -5,7 +5,7 @@
5
5
 
6
6
  services:
7
7
  traefik:
8
- image: traefik:v3.7.16@sha256:c8a121e4bb1347e8fd52657fab12f2cb70b68f8a018895e2068f92c9e519b9c2
8
+ image: traefik:v3.7.16@sha256:1336e85aaed293bd63d005086e0dd013b04078b26aaeb1c18b26a2f928af7e65
9
9
  restart: unless-stopped
10
10
  ports:
11
11
  - "80:80"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yunuseon/kayra",
3
- "version": "0.23.0",
3
+ "version": "0.24.1",
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",
@@ -59,7 +59,7 @@
59
59
  "eslint": "10.13.0",
60
60
  "eslint-plugin-functional": "10.0.1",
61
61
  "typescript": "6.0.3",
62
- "typescript-eslint": "8.72.0"
62
+ "typescript-eslint": "8.72.1"
63
63
  },
64
64
  "overrides": {
65
65
  "eslint-plugin-functional": {
@@ -43,6 +43,18 @@
43
43
  "type": "string",
44
44
  "pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"
45
45
  },
46
+ "redirect_domains": {
47
+ "type": "object",
48
+ "propertyNames": {
49
+ "type": "string",
50
+ "pattern": "^([a-z0-9]([a-z0-9-]*[a-z0-9])?\\.)+[a-z][a-z0-9-]*$"
51
+ },
52
+ "additionalProperties": {
53
+ "type": "string",
54
+ "pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"
55
+ },
56
+ "description": "Other domains that only send visitors here, each to a host of the server's domain: example.de: www sends https://example.de/x?y and https://www.example.de/x?y to https://www.<domain>/x?y, permanently, path and query kept. Their DNS is the fleet's: both names must point at the server before setup, or their certificates fail."
57
+ },
46
58
  "webhooks": {
47
59
  "type": "boolean",
48
60
  "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."
@@ -43,6 +43,18 @@
43
43
  "type": "string",
44
44
  "pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"
45
45
  },
46
+ "redirect_domains": {
47
+ "type": "object",
48
+ "propertyNames": {
49
+ "type": "string",
50
+ "pattern": "^([a-z0-9]([a-z0-9-]*[a-z0-9])?\\.)+[a-z][a-z0-9-]*$"
51
+ },
52
+ "additionalProperties": {
53
+ "type": "string",
54
+ "pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"
55
+ },
56
+ "description": "Other domains that only send visitors here, each to a host of the server's domain: example.de: www sends https://example.de/x?y and https://www.example.de/x?y to https://www.<domain>/x?y, permanently, path and query kept. Their DNS is the fleet's: both names must point at the server before setup, or their certificates fail."
57
+ },
46
58
  "webhooks": {
47
59
  "type": "boolean",
48
60
  "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."
@@ -6,7 +6,8 @@
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
8
  # deploy.<domain>/health is 200 (monitor_health_tokens.<server>);
9
- # with apex_redirect, the bare domain redirects (301)
9
+ # with apex_redirect, the bare domain redirects (301); so does
10
+ # each redirect_domains domain and its www
10
11
  # edge: every edge_routes name answers, not 5xx
11
12
  # nas: nothing of its own: its stacks are monitor.extra
12
13
  # plus monitor.extra as given. Every certificate must have 10 days left. Each
@@ -59,6 +60,11 @@ watched() {
59
60
  endpoint "deploy.${domain}/health" "$server" "https://deploy.${domain}/health" false true '[STATUS] == 200'
60
61
  apex="$( [ -f "${dir}/vars.yml" ] && yq -r '.apex_redirect // ""' "${dir}/vars.yml" || true)"
61
62
  [ -z "$apex" ] || endpoint "$domain" "$server" "https://${domain}/" false false '[STATUS] == 301' "$cert"
63
+ { [ -f "${dir}/vars.yml" ] && yq -r '.redirect_domains // {} | keys | .[]' "${dir}/vars.yml" || true; } | while IFS= read -r other; do
64
+ for host in "$other" "www.${other}"; do
65
+ endpoint "$host" "$server" "https://${host}/" false false '[STATUS] == 301' "$cert"
66
+ done
67
+ done
62
68
  bash "${KAYRA_ROOT}/scripts/local/app-manifests.sh" --routes "$server" | while read -r sub path; do
63
69
  [ -z "$sub" ] || endpoint "${sub}.${domain}${path%/}" "$server" "https://${sub}.${domain}${path}" true false '[STATUS] < 500' "$cert"
64
70
  done
@@ -9,7 +9,8 @@
9
9
  # where a monitor runs) send a browser to the login, not a 403 from rules
10
10
  # Authelia never loaded
11
11
  # - with apex_redirect, the bare domain redirects permanently to that host,
12
- # path and query kept
12
+ # path and query kept; with redirect_domains, each other domain and its
13
+ # www to theirs
13
14
  # - every certificate is a real one (Let's Encrypt or mkcert), never
14
15
  # Traefik's default
15
16
  # - an unsigned webhook is refused (with webhooks: false, /hook is not
@@ -44,6 +45,8 @@ domain="$(yq -r '.domain' "${dir}/server.yml")"
44
45
  # Not yq's `//`: it takes false for missing too.
45
46
  webhooks="$( { [ -f "${dir}/vars.yml" ] && yq -r '.webhooks' "${dir}/vars.yml"; } || echo true)"
46
47
  apex="$( { [ -f "${dir}/vars.yml" ] && yq -r '.apex_redirect // ""' "${dir}/vars.yml"; } || true)"
48
+ # "<other domain> <host>" per line, from redirect_domains.
49
+ redirects="$( { [ -f "${dir}/vars.yml" ] && yq -r '.redirect_domains // {} | to_entries | .[] | .key + " " + .value' "${dir}/vars.yml"; } || true)"
47
50
  inventory="${dir}/inventory.ini"
48
51
  [ -f "$inventory" ] || { fail "no inventory for ${name}: provision it first"; exit 1; }
49
52
  field() { awk -v key="$1" '{for (i = 1; i <= NF; i++) if (index($i, key "=") == 1) {print substr($i, length(key) + 2); exit}}' "$inventory"; }
@@ -83,6 +86,9 @@ to_login() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 302 ] && case "$(
83
86
  not_5xx() { real_cert "$1" && case "$(cut -d' ' -f1 <<< "$1")" in 000|5*) return 1 ;; esac; }
84
87
  refused() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 401 ]; }
85
88
  to_apex() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 301 ] && [ "$(cut -d' ' -f2 <<< "$1")" = "https://${apex}.${domain}/x?y" ]; }
89
+ # The host a redirect_domains probe expects, set before each check.
90
+ redirect_to=""
91
+ to_redirect() { real_cert "$1" && [ "$(cut -d' ' -f1 <<< "$1")" = 301 ] && [ "$(cut -d' ' -f2 <<< "$1")" = "https://${redirect_to}/x?y" ]; }
86
92
 
87
93
  describe() { echo "HTTP $(cut -d' ' -f1 <<< "$1"), certificate by $(cut -d' ' -f4- <<< "$1") (verify $(cut -d' ' -f3 <<< "$1"))"; }
88
94
 
@@ -101,6 +107,13 @@ while IFS= read -r sub; do
101
107
  esac
102
108
  done < <(awk '!/^[[:space:]]*(#|$)/ {print $1}' "${KAYRA_ROOT}/hosts.conf")
103
109
  [ -z "$apex" ] || check "${domain} redirects to ${apex}.${domain}" "$domain" GET to_apex "/x?y"
110
+ while read -r other target; do
111
+ [ -n "$other" ] || continue
112
+ redirect_to="${target}.${domain}"
113
+ for host in "$other" "www.${other}"; do
114
+ check "${host} redirects to ${redirect_to}" "$host" GET to_redirect "/x?y"
115
+ done
116
+ done <<< "$redirects"
104
117
 
105
118
  first_app="$(head -1 <<< "$registered_wanted")"
106
119
  if [ -n "$first_app" ]; then
@@ -1,20 +1,30 @@
1
1
  #!/usr/bin/env bash
2
2
  # =============================================================================
3
- # app-restore <app> — an app that was deployed, yet runs no container now,
4
- # deployed again at the release that ran.
3
+ # app-restore <app> [--changed] — an app that was deployed, yet runs no
4
+ # container now, deployed again at the release that ran. With --changed, the
5
+ # app's registration or .env has just changed (its hosts, after a new domain;
6
+ # its config): it is deployed again at that release even if it runs, since a
7
+ # running deploy keeps the routes and environment it was started with.
5
8
  #
6
9
  # A Docker update or a reboot stops every container; one deployed before the
7
10
  # platform gave each service a restart policy stays down. The deployer's ctl
8
11
  # follows the run to its end, so this exits as the run did. An app never
9
- # deployed (no release record) and one that runs are left alone.
12
+ # deployed (no release record) is left alone, and so is one that runs unless
13
+ # --changed.
10
14
  #
11
15
  # Installed by the platform role at <platform_dir>/bin; run by the app role
12
16
  # after it registers the app. Run as root. Prints what it did on its last line:
13
- # "never deployed", "runs", or "restored <sha>".
17
+ # "never deployed", "runs", "restored <sha>" or "redeployed <sha>".
14
18
  # =============================================================================
15
19
  set -euo pipefail
16
20
 
17
- app="${1:?Usage: app-restore <app>}"
21
+ app="${1:?Usage: app-restore <app> [--changed]}"
22
+ changed=false
23
+ case "${2:-}" in
24
+ "") ;;
25
+ --changed) changed=true ;;
26
+ *) echo "Usage: app-restore <app> [--changed]" >&2; exit 2 ;;
27
+ esac
18
28
  platform_dir="${PLATFORM_DIR:-$(cd "$(dirname "$0")/.." && pwd)}"
19
29
  releases="${platform_dir}/releases/${app}"
20
30
 
@@ -29,11 +39,12 @@ if [ -z "$live" ]; then
29
39
  exit 0
30
40
  fi
31
41
 
32
- if [ -n "$(docker ps -q --filter "label=com.docker.compose.project=${app}" --filter status=running --filter status=restarting)" ]; then
42
+ running="$(docker ps -q --filter "label=com.docker.compose.project=${app}" --filter status=running --filter status=restarting)"
43
+ if [ -n "$running" ] && [ "$changed" = false ]; then
33
44
  echo "runs"
34
45
  exit 0
35
46
  fi
36
47
 
37
48
  cd "$platform_dir"
38
49
  docker compose exec -T deployer kayra-deployer ctl deploy "$app" "$live"
39
- echo "restored ${live}"
50
+ if [ -n "$running" ]; then echo "redeployed ${live}"; else echo "restored ${live}"; fi
@@ -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(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);