gestalt-mobile 0.34.0 → 0.35.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.
@@ -1,9 +1,9 @@
1
1
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=Array.isArray,u=Array.prototype.indexOf,d=Array.prototype.includes,f=Array.from,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyDescriptors,g=Object.prototype,_=Array.prototype,v=Object.getPrototypeOf,y=Object.isExtensible,b=()=>{};function x(e){for(var t=0;t<e.length;t++)e[t]()}function S(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function C(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var w=1<<24,T=1024,E=2048,D=4096,O=8192,ee=16384,k=32768,te=1<<25,ne=65536,re=1<<18,ie=1<<19,ae=1<<20,oe=1<<25,se=65536,ce=1<<21,le=1<<22,ue=1<<23,de=Symbol(`$state`),fe=Symbol(`legacy props`),pe=Symbol(``),me=Symbol(`attributes`),he=Symbol(`class`),ge=Symbol(`style`),_e=Symbol(`text`),ve=Symbol(`form reset`),ye=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},be=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function xe(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Se(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ce(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function we(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Te(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ee(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function De(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Oe(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function ke(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ae(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function je(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Me(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ne={},Pe=Symbol(`uninitialized`),Fe=`http://www.w3.org/1999/xhtml`;function Ie(){console.warn(`https://svelte.dev/e/derived_inert`)}function Le(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Re(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function ze(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var A=!1;function Be(e){A=e}var j;function Ve(e){if(e===null)throw Le(),Ne;return j=e}function He(){return Ve(_n(j))}function M(e){if(A){if(_n(j)!==null)throw Le(),Ne;j=e}}function Ue(e=1){if(A){for(var t=e,n=j;t--;)n=_n(n);j=n}}function We(e=!0){for(var t=0,n=j;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=_n(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Le(),Ne;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=!1;function Xe(){Ye=!0}var N=null;function Ze(e){N=e}function Qe(e,t=!1,n){N={p:N,i:!1,c:null,e:null,s:e,x:null,r:W,l:Ye&&!t?{s:null,u:null,$:[]}:null}}function $e(e){var t=N,n=t.e;if(n!==null){t.e=null;for(var r of n)Nn(r)}return e!==void 0&&(t.x=e),t.i=!0,N=t.p,e??{}}function et(){return!Ye||N!==null&&N.l===null}var tt=[];function nt(){var e=tt;tt=[],x(e)}function rt(e){if(tt.length===0&&!Ft){var t=tt;queueMicrotask(()=>{t===tt&&nt()})}tt.push(e)}function it(){for(;tt.length>0;)nt()}function at(e){var t=W;if(t===null)return U.f|=ue,e;if(!(t.f&32768)&&!(t.f&4))throw e;ot(e,t)}function ot(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}var st=~(E|D|T);function ct(e,t){e.f=e.f&st|t}function lt(e){e.f&512||e.deps===null?ct(e,T):ct(e,D)}function ut(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=se,ut(t.deps))}function dt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ut(e.deps),ct(e,T)}var ft=!1;function pt(e){var t=ft;try{return ft=!1,[e(),ft]}finally{ft=t}}function mt(e){let t=0,n=en(0),r;return()=>{An()&&(G(n),Ln(()=>(t===0&&(r=Er(()=>e(()=>an(n)))),t+=1,()=>{rt(()=>{--t,t===0&&(r?.(),r=void 0,an(n))})})))}}var ht=ne|ie;function gt(e,t,n,r){new _t(e,t,n,r)}var _t=class{parent;is_pending=!1;transform_error;#e;#t=A?j:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=mt(()=>(this.#m=en(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=W;t.b=this,t.f|=128,n(e)},this.parent=W.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=zn(()=>{if(A){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},ht),A&&(this.#e=j)}#g(){try{this.#a=Vn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Vn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Vn(()=>e(this.#e)),rt(()=>{var e=this.#c=document.createDocumentFragment(),t=hn();e.append(t),this.#a=this.#x(()=>Vn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Jn(this.#o,()=>{this.#o=null}),this.#b(F))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Vn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Qn(this.#a,e);let t=this.#n.pending;this.#o=Vn(()=>t(this.#e))}else this.#b(F)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){dt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=W,n=U,r=N;ar(this.#i),ir(this.#i),Ze(this.#i.ctx);try{return Vt.ensure(),e()}catch(e){return at(e),null}finally{ar(t),ir(n),Ze(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Jn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,rt(()=>{this.#d=!1,this.#m&&nn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;F?.is_fork?(this.#a&&F.skip_effect(this.#a),this.#o&&F.skip_effect(this.#o),this.#s&&F.skip_effect(this.#s),F.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Gn(this.#a),null),this.#o&&=(Gn(this.#o),null),this.#s&&=(Gn(this.#s),null),A&&(Ve(this.#t),Ue(),Ve(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){ze();return}r=!0,i&&Me(),this.#s!==null&&Jn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){ot(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Vn(()=>{var t=W;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return ot(e,this.#i.parent),null}}))};rt(()=>{var t;try{t=this.transform_error(e)}catch(e){ot(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>ot(e,this.#i&&this.#i.parent)):o(t)})}};function vt(e,t,n,r){let i=et()?St:Tt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=W,c=yt(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){ot(e,s)}bt()}}var d=xt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>wt(e))).then(u).catch(e=>ot(e,s)).finally(d)}l?l.then(()=>{c(),f(),bt()}):f()}function yt(){var e=W,t=U,n=N,r=F;return function(i=!0){ar(e),ir(t),Ze(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function bt(e=!0){ar(null),ir(null),Ze(null),e&&F?.deactivate()}function xt(){var e=W,t=e.b,n=F,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function St(e){var t=2|E;return W!==null&&(W.f|=ie),{ctx:N,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:Pe,wv:0,parent:W,ac:null}}var Ct=Symbol(`obsolete`);function wt(e,t,n){let r=W;r===null&&Se();var i=void 0,a=en(Pe),o=!U,s=new Set;return In(()=>{var t=W,n=S();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ye&&n.reject(e)}).finally(bt)}catch(e){n.reject(e),bt()}var c=F;if(o){if(t.f&32768)var l=xt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(Ct);else for(let e of s.values())e.reject(Ct);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Ct&&(c.activate(),t?(a.f|=ue,nn(a,t)):(a.f&8388608&&(a.f^=ue),nn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),jn(()=>{for(let e of s)e.reject(Ct)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function P(e){let t=St(e);return sr(t),t}function Tt(e){let t=St(e);return t.equals=Je,t}function Et(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Gn(t[n])}}function Dt(e){var t,n=W,r=e.parent;if(!tr&&r!==null&&e.v!==Pe&&r.f&24576)return Ie(),e.v;ar(r);try{e.f&=~se,Et(e),t=yr(e)}finally{ar(n)}return t}function Ot(e){var t=Dt(e);if(!e.equals(t)&&(e.wv=gr(),(!F?.is_fork||e.deps===null)&&(F===null?e.v=t:(F.capture(e,t,!0),Mt?.capture(e,t,!0)),e.deps===null))){ct(e,T);return}tr||(Nt===null?lt(e):(An()||F?.is_fork)&&Nt.set(e,t))}function kt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(ye),t.fn!==null&&(t.teardown=b),t.ac=null,xr(t,0),Un(t))}function At(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&Sr(t)}var jt=null,F=null,Mt=null,Nt=null,Pt=null,Ft=!1,It=!1,Lt=null,Rt=null,zt=0,Bt=1,Vt=class e{id=Bt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){jt===null?jt=this:(jt.#n=this,this.#t=jt),jt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)ct(r,E),t(r);for(r of n.m)ct(r,D),t(r)}this.#p.add(e)}#g(){this.#e=!0,zt++>1e3&&(this.#x(),Ut());for(let e of this.#u)this.#d.delete(e),ct(e,E),this.schedule(e);for(let e of this.#d)ct(e,D),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=Lt=[],r=[],i=Rt=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Xt(e),this.#h()||this.discard(),t}if(F=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Lt=null,Rt=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Yt(e,t);i.length>0&&F.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),Mt=this,Gt(r),Gt(n),Mt=null,this.#s?.resolve();var s=F;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=T;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=T:i&4?t.push(r):_r(r)&&(i&16&&this.#d.add(r),Sr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#v(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#y(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),ct(i,E),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),F=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)dt(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==Pe&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),Nt?.set(e,t)),this.is_fork||(e.v=t)}activate(){F=this}deactivate(){F=null,Nt=null}flush(){try{It=!0,F=this,this.#g()}finally{zt=0,Pt=null,Lt=null,Rt=null,It=!1,F=null,Nt=null,Qt.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear();for(let e of this.async_deriveds.values())e.reject(Ct);this.#x(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,rt(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=S()).promise}static ensure(){if(F===null){let t=F=new e;!It&&!Ft&&rt(()=>{t.#e||t.flush()})}return F}apply(){Nt=null}schedule(e){if(Pt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Lt!==null&&t===W&&(U===null||!(U.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=T}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?jt=e:t.#t=e,this.linked=!1}}};function Ht(e){var t=Ft;Ft=!0;try{var n;for(e&&(F!==null&&!F.is_fork&&F.flush(),n=e());;){if(it(),F===null)return n;F.flush()}}finally{Ft=t}}function Ut(){try{De()}catch(e){ot(e,Pt)}}var Wt=null;function Gt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&_r(r)&&(Wt=new Set,Sr(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&qn(r),Wt?.size>0)){Qt.clear();for(let e of Wt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Wt.has(n)&&(Wt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sr(n)}}Wt.clear()}}Wt=null}}function Kt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Kt(i,t,n,r):e&4194320&&!(e&2048)&&qt(i,t,r)&&(ct(i,E),Jt(i))}}function qt(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(d.call(t,r))return!0;if(r.f&2&&qt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Jt(e){F.schedule(e)}function Yt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),ct(e,T);for(var n=e.first;n!==null;)Yt(n,t),n=n.next}}function Xt(e){ct(e,T);for(var t=e.first;t!==null;)Xt(t),t=t.next}var Zt=new Set,Qt=new Map,$t=!1;function en(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function I(e,t){let n=en(e,t);return sr(n),n}function tn(e,t=!1,n=!0){let r=en(e);return t||(r.equals=Je),Ye&&n&&N!==null&&N.l!==null&&(N.l.s??=[]).push(r),r}function L(e,t,n=!1){return U!==null&&(!rr||U.f&131072)&&et()&&U.f&4325394&&(or===null||!or.has(e))&&je(),nn(e,n?R(t):t,Rt)}function nn(e,t,n=null){if(!e.equals(t)){Qt.set(e,tr?t:e.v);var r=Vt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Dt(t),Nt===null&&lt(t)}e.wv=gr(),on(e,E,n),et()&&W!==null&&W.f&1024&&!(W.f&96)&&(ur===null?dr([e]):ur.push(e)),!r.is_fork&&Zt.size>0&&!$t&&rn()}return t}function rn(){$t=!1;for(let e of Zt){e.f&1024&&ct(e,D);let t;try{t=_r(e)}catch{t=!0}t&&Sr(e)}Zt.clear()}function an(e){L(e,e.v+1)}function on(e,t,n){var r=e.reactions;if(r!==null)for(var i=et(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===W)){var l=(c&E)===0;if(l&&ct(s,t),c&131072)Zt.add(s);else if(c&2){var u=s;Nt?.delete(u),c&65536||(c&512&&(W===null||!(W.f&2097152))&&(s.f|=se),on(u,D,n))}else if(l){var d=s;c&16&&Wt!==null&&Wt.add(d),n===null?Jt(d):n.push(d)}}}}function R(e){if(typeof e!=`object`||!e||de in e)return e;let t=v(e);if(t!==g&&t!==_)return e;var n=new Map,r=l(e),i=I(0),a=null,o=mr,s=e=>{if(mr===o)return e();var t=U,n=mr;ir(null),hr(o);var r=e();return ir(t),hr(n),r};return r&&n.set(`length`,I(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&ke();var i=n.get(t);return i===void 0?s(()=>{var e=I(r.value,a);return n.set(t,e),e}):L(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>I(Pe,a));n.set(t,e),an(i)}}else L(r,Pe),an(i);return!0},get(t,r,i){if(r===de)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||m(t,r)?.writable)&&(o=s(()=>I(R(c?t[r]:Pe),a)),n.set(r,o)),o!==void 0){var l=G(o);return l===Pe?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=G(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==Pe)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===de)return!0;var r=n.get(t),i=r!==void 0&&r.v!==Pe||Reflect.has(e,t);return(r!==void 0||W!==null&&(!i||m(e,t)?.writable))&&(r===void 0&&(r=s(()=>I(i?R(e[t]):Pe,a)),n.set(t,r)),G(r)===Pe)?!1:i},set(e,t,o,c){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var d=o;d<l.v;d+=1){var f=n.get(d+``);f===void 0?d in e&&(f=s(()=>I(Pe,a)),n.set(d+``,f)):L(f,Pe)}if(l===void 0)(!u||m(e,t)?.writable)&&(l=s(()=>I(void 0,a)),L(l,R(o)),n.set(t,l));else{u=l.v!==Pe;var p=s(()=>R(o));L(l,p)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(c,o),!u){if(r&&typeof t==`string`){var g=n.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&L(g,_+1)}an(i)}return!0},ownKeys(e){G(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==Pe});for(var[r,a]of n)a.v!==Pe&&!(r in e)&&t.push(r);return t},setPrototypeOf(){Ae()}})}function sn(e){try{if(typeof e==`object`&&e&&de in e)return e[de]}catch{}return e}function cn(e,t){return Object.is(sn(e),sn(t))}var ln,un,dn,fn,pn;function mn(){if(ln===void 0){ln=window,un=document,dn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;fn=m(t,`firstChild`).get,pn=m(t,`nextSibling`).get,y(e)&&(e[he]=void 0,e[me]=null,e[ge]=void 0,e.__e=void 0),y(n)&&(n[_e]=void 0)}}function hn(e=``){return document.createTextNode(e)}function gn(e){return fn.call(e)}function _n(e){return pn.call(e)}function z(e,t){if(!A)return gn(e);var n=gn(j);if(n===null)n=j.appendChild(hn());else if(t&&n.nodeType!==3){var r=hn();return n?.before(r),Ve(r),r}return t&&xn(n),Ve(n),n}function B(e,t=!1){if(!A){var n=gn(e);return n instanceof Comment&&n.data===``?_n(n):n}if(t){if(j?.nodeType!==3){var r=hn();return j?.before(r),Ve(r),r}xn(j)}return j}function V(e,t=1,n=!1){let r=A?j:e;for(var i;t--;)i=r,r=_n(r);if(!A)return r;if(n){if(r?.nodeType!==3){var a=hn();return r===null?i?.after(a):r.before(a),Ve(a),a}xn(r)}return Ve(r),r}function vn(e){e.textContent=``}function yn(){return!1}function bn(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function xn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Sn(e){A&&gn(e)!==null&&vn(e)}var Cn=!1;function wn(){Cn||(Cn=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[ve]?.()})},{capture:!0}))}function Tn(e){var t=U,n=W;ir(null),ar(null);try{return e()}finally{ir(t),ar(n)}}function En(e,t,n,r=n){e.addEventListener(t,()=>Tn(n));let i=e[ve];i?e[ve]=()=>{i(),r(!0)}:e[ve]=()=>r(!0),wn()}function Dn(e){W===null&&(U===null&&Ee(e),Te()),tr&&we(e)}function On(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function kn(e,t){var n=W;n!==null&&n.f&8192&&(e|=O);var r={ctx:N,deps:null,nodes:null,f:e|E|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};F?.register_created_effect(r);var i=r;if(e&4)Lt===null?Vt.ensure().schedule(r):Lt.push(r);else if(t!==null){try{Sr(r)}catch(e){throw Gn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=ne))}if(i!==null&&(i.parent=n,n!==null&&On(i,n),U!==null&&U.f&2&&!(e&64))){var a=U;(a.effects??=[]).push(i)}return r}function An(){return U!==null&&!rr}function jn(e){let t=kn(8,null);return ct(t,T),t.teardown=e,t}function Mn(e){Dn(`$effect`);var t=W.f;if(!U&&t&32&&N!==null&&!N.i){var n=N;(n.e??=[]).push(e)}else return Nn(e)}function Nn(e){return kn(4|ae,e)}function Pn(e){Vt.ensure();let t=kn(64|ie,e);return(e={})=>new Promise(n=>{e.outro?Jn(t,()=>{Gn(t),n(void 0)}):(Gn(t),n(void 0))})}function Fn(e){return kn(4,e)}function In(e){return kn(le|ie,e)}function Ln(e,t=0){return kn(8|t,e)}function H(e,t=[],n=[],r=[]){vt(r,t,n,t=>{kn(8,()=>{e(...t.map(G))})})}function Rn(e,t=[],n=[],r=[]){vt(r,t,n,t=>{kn(4,()=>e(...t.map(G)))})}function zn(e,t=0){return kn(16|t,e)}function Bn(e,t=0){return kn(w|t,e)}function Vn(e){return kn(32|ie,e)}function Hn(e){var t=e.teardown;if(t!==null){let e=tr,n=U;nr(!0),ir(null);try{t.call(null)}finally{nr(e),ir(n)}}}function Un(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Tn(()=>{e.abort(ye)});var r=n.next;n.f&64?n.parent=null:Gn(n,t),n=r}}function Wn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Gn(t),t=n}}function Gn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Kn(e.nodes.start,e.nodes.end),n=!0),e.f|=te,Un(e,t&&!n),xr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Hn(e),e.f^=te,e.f|=ee;var i=e.parent;i!==null&&i.first!==null&&qn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Kn(e,t){for(;e!==null;){var n=e===t?null:_n(e);e.remove(),e=n}}function qn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Jn(e,t,n=!0){var r=[];Yn(e,r,!0);var i=()=>{n&&Gn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Yn(e,t,n){if(!(e.f&8192)){e.f^=O;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Yn(i,t,o?n:!1)}i=a}}}function Xn(e){Zn(e,!0)}function Zn(e,t){if(e.f&8192){e.f^=O,e.f&1024||(ct(e,E),Vt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Zn(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Qn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:_n(n);t.append(n),n=i}}var $n=null,er=!1,tr=!1;function nr(e){tr=e}var U=null,rr=!1;function ir(e){U=e}var W=null;function ar(e){W=e}var or=null;function sr(e){U!==null&&(or??=new Set).add(e)}var cr=null,lr=0,ur=null;function dr(e){ur=e}var fr=1,pr=0,mr=pr;function hr(e){mr=e}function gr(){return++fr}function _r(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~se),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(_r(a)&&Ot(a),a.wv>e.wv)return!0}t&512&&Nt===null&&ct(e,T)}return!1}function vr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(or!==null&&or.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?vr(a,t,!1):t===a&&(n?ct(a,E):a.f&1024&&ct(a,D),Jt(a))}}function yr(e){var t=cr,n=lr,r=ur,i=U,a=or,o=N,s=rr,c=mr,l=e.f;cr=null,lr=0,ur=null,U=l&96?null:e,or=null,Ze(e.ctx),rr=!1,mr=++pr,e.ac!==null&&(Tn(()=>{e.ac.abort(ye)}),e.ac=null);try{e.f|=ce;var u=e.fn,d=u();e.f|=k;var f=e.deps,p=F?.is_fork;if(cr!==null){var m;if(p||xr(e,lr),f!==null&&lr>0)for(f.length=lr+cr.length,m=0;m<cr.length;m++)f[lr+m]=cr[m];else e.deps=f=cr;if(An()&&e.f&512)for(m=lr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else!p&&f!==null&&lr<f.length&&(xr(e,lr),f.length=lr);if(et()&&ur!==null&&!rr&&f!==null&&!(e.f&6146))for(m=0;m<ur.length;m++)vr(ur[m],e);if(i!==null&&i!==e){if(pr++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=pr;if(t!==null)for(let e of t)e.rv=pr;ur!==null&&(r===null?r=ur:r.push(...ur))}return e.f&8388608&&(e.f^=ue),d}catch(e){return at(e)}finally{e.f^=ce,cr=t,lr=n,ur=r,U=i,or=a,Ze(o),rr=s,mr=c}}function br(e,t){let n=t.reactions;if(n!==null){var r=u.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(cr===null||!d.call(cr,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~se),a.v!==Pe&&lt(a),kt(a),xr(a,0)}}function xr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)br(e,n[r])}function Sr(e){var t=e.f;if(!(t&16384)){ct(e,T);var n=W,r=er;W=e,er=!0;try{t&16777232?Wn(e):Un(e),Hn(e);var i=yr(e);e.teardown=typeof i==`function`?i:null,e.wv=fr}finally{er=r,W=n}}}async function Cr(){await Promise.resolve(),Ht()}function G(e){var t=(e.f&2)!=0;if($n?.add(e),U!==null&&!rr&&!(W!==null&&W.f&16384)&&(or===null||!or.has(e))){var n=U.deps;if(U.f&2097152)e.rv<pr&&(e.rv=pr,cr===null&&n!==null&&n[lr]===e?lr++:cr===null?cr=[e]:cr.push(e));else{U.deps??=[],d.call(U.deps,e)||U.deps.push(e);var r=e.reactions;r===null?e.reactions=[U]:d.call(r,U)||r.push(U)}}if(tr&&Qt.has(e))return Qt.get(e);if(t){var i=e;if(tr){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Tr(i))&&(a=Dt(i)),Qt.set(i,a),a}var o=(i.f&512)==0&&!rr&&U!==null&&(er||(U.f&512)!=0),s=(i.f&k)===0;_r(i)&&(o&&(i.f|=512),Ot(i)),o&&!s&&(At(i),wr(i))}if(Nt?.has(e))return Nt.get(e);if(e.f&8388608)throw e.v;return e.v}function wr(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(At(t),wr(t))}function Tr(e){if(e.v===Pe)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Qt.has(t)||t.f&2&&Tr(t))return!0;return!1}function Er(e){var t=rr;try{return rr=!0,e()}finally{rr=t}}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var Dr=[`touchstart`,`touchmove`];function Or(e){return Dr.includes(e)}var kr=Symbol(`events`),Ar=new Set,jr=new Set;function Mr(e,t,n,r={}){function i(e){if(r.capture||Ir.call(t,e),!e.cancelBubble)return Tn(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?rt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Nr(e,t,n,r,i){var a={capture:r,passive:i},o=Mr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&jn(()=>{t.removeEventListener(e,o,a)})}function K(e,t,n){(t[kr]??={})[e]=n}function Pr(e){for(var t=0;t<e.length;t++)Ar.add(e[t]);for(var n of jr)n(e)}var Fr=null;function Ir(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;Fr=e;var o=0,s=Fr===e&&e[kr];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[kr]=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){p(e,`currentTarget`,{configurable:!0,get(){return a||n}});var u=U,d=W;ir(null),ar(null);try{for(var f,m=[];a!==null&&a!==t;){try{var h=a[kr]?.[r];h!=null&&(!a.disabled||e.target===a)&&h.call(a,e)}catch(e){f?m.push(e):f=e}if(e.cancelBubble)break;o++,a=o<i.length?i[o]:null}if(f){for(let e of m)queueMicrotask(()=>{throw e});throw f}}finally{e[kr]=t,delete e.currentTarget,ir(u),ar(d)}}}var Lr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Rr(e){return Lr?.createHTML(e)??e}function zr(e){var t=bn(`template`);return t.innerHTML=Rr(e.replaceAll(`<!>`,`<!---->`)),t.content}function Br(e,t){var n=W;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function q(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(A)return Br(j,null),j;i===void 0&&(i=zr(a?e:`<!>`+e),n||(i=gn(i)));var t=r||dn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=gn(t),s=t.lastChild;Br(o,s)}else Br(t,t);return t}}function Vr(e=``){if(!A){var t=hn(e+``);return Br(t,t),t}var n=j;return n.nodeType===3?xn(n):(n.before(n=hn()),Ve(n)),Br(n,n),n}function Hr(){if(A)return Br(j,null),j;var e=document.createDocumentFragment(),t=document.createComment(``),n=hn();return e.append(t,n),Br(t,n),e}function J(e,t){if(A){var n=W;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=j),He();return}e!==null&&e.before(t)}function Y(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[_e]??=e.nodeValue)&&(e[_e]=n,e.nodeValue=`${n}`)}function Ur(e,t){return Gr(e,t)}var Wr=new Map;function Gr(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){mn();var c=void 0,l=Pn(()=>{var o=n??t.appendChild(hn());gt(o,{pending:()=>{}},t=>{Qe({});var n=N;if(a&&(n.c=a),i&&(r.$$events=i),A&&Br(t,null),c=e(t,r)||{},A&&(W.nodes.end=j,j===null||j.nodeType!==8||j.data!==`]`))throw Le(),Ne;$e()},s);var l=new Set,u=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!l.has(r)){l.add(r);var i=Or(r);for(let e of[t,document]){var a=Wr.get(e);a===void 0&&(a=new Map,Wr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Ir,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return u(f(Ar)),jr.add(u),()=>{for(var e of l)for(let n of[t,document]){var r=Wr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Ir),r.delete(e),r.size===0&&Wr.delete(n)):r.set(e,i)}jr.delete(u),o!==n&&o.parentNode?.removeChild(o)}});return Kr.set(c,l),c}var Kr=new WeakMap,qr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Xn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Xn(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(Gn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Qn(r,t),t.append(hn()),this.#n.set(e,{effect:r,fragment:t})}else Gn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Jn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(Gn(n.effect),this.#n.delete(e))};ensure(e,t){var n=F,r=yn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=hn();i.append(a),this.#n.set(e,{effect:Vn(()=>t(a)),fragment:i})}else this.#t.set(e,Vn(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else A&&(this.anchor=j),this.#a(n)}};function X(e,t,n=!1){var r;A&&(r=j,He());var i=new qr(e),a=n?ne:0;function o(e,t){if(A){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();Ve(a),i.anchor=a,Be(!1),i.ensure(e,t),Be(!0);return}}i.ensure(e,t)}zn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Jr=Symbol(`NaN`);function Yr(e,t,n){A&&He();var r=new qr(e),i=!et();zn(()=>{var e=t();e!==e&&(e=Jr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function Xr(e,t){return t}function Zr(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s<i;s++){let n=t[s];Jn(n,()=>{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;Qr(e,f(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else--o},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var l=n,u=l.parentNode;vn(u),u.append(l),e.items.clear()}Qr(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function Qr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=oe,Qn(a,document.createDocumentFragment())):Gn(t[i],n)}}var $r;function Z(e,t,n,r,i,a=null){var o=e,s=new Map;if(t&4){var c=e;o=A?Ve(gn(c)):c.appendChild(hn())}A&&He();var u=null,d=Tt(()=>{var e=n();return l(e)?e:e==null?[]:f(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=u,ti(v,p,o,t,r),u!==null&&(p.length===0?u.f&33554432?(u.f^=oe,ri(u,null,o)):Xn(u):Jn(u,()=>{u=null})))}function _(e){v.pending.delete(e)}var v={effect:zn(()=>{p=G(d);var e=p.length;let c=!1;A&&Ge(o)===`[!`!=(e===0)&&(o=We(),Ve(o),Be(!1),c=!0);for(var l=new Set,f=F,v=yn(),y=0;y<e;y+=1){A&&j.nodeType===8&&j.data===`]`&&(o=j,c=!0,Be(!1));var b=p[y],x=r(b,y),S=h?null:s.get(x);S?(S.v&&nn(S.v,b),S.i&&nn(S.i,y),v&&f.unskip_effect(S.e)):(S=ni(s,h?o:$r??=hn(),b,x,y,i,t,n),h||(S.e.f|=oe),s.set(x,S)),l.add(x)}if(e===0&&a&&!u&&(h?u=Vn(()=>a(o)):(u=Vn(()=>a($r??=hn())),u.f|=oe)),e>l.size&&Ce(``,``,``),A&&e>0&&Ve(We()),!h)if(m.set(f,l),v){for(let[e,t]of s)l.has(e)||f.skip_effect(t.e);f.oncommit(g),f.ondiscard(_)}else g(f);c&&Be(!0),G(d)}),flags:t,items:s,pending:m,outrogroups:null,fallback:u};h=!1,A&&(o=j)}function ei(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function ti(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=ei(e.effect.first),l,u=null,d,p=[],m=[],h,g,_,v;if(a)for(v=0;v<o;v+=1)h=t[v],g=i(h,v),_=s.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(d??=new Set).add(_));for(v=0;v<o;v+=1){if(h=t[v],g=i(h,v),_=s.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(Xn(_),a&&(_.nodes?.a?.unfix(),(d??=new Set).delete(_))),_.f&33554432)if(_.f^=oe,_===c)ri(_,null,n);else{var y=u?u.next:c;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ii(e,u,_),ii(e,_,y),ri(_,y,n),u=_,p=[],m=[],c=ei(u.next);continue}if(_!==c){if(l!==void 0&&l.has(_)){if(p.length<m.length){var b=m[0],x;u=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)ri(p[x],b,n);for(x=0;x<m.length;x+=1)l.delete(m[x]);ii(e,S.prev,C.next),ii(e,u,S),ii(e,C,b),c=b,u=C,--v,p=[],m=[]}else l.delete(_),ri(_,c,n),ii(e,_.prev,_.next),ii(e,_,u===null?e.effect.first:u.next),ii(e,u,_),u=_;continue}for(p=[],m=[];c!==null&&c!==_;)(l??=new Set).add(c),m.push(c),c=ei(c.next);if(c===null)continue}_.f&33554432||p.push(_),u=_,c=ei(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(Qr(e,f(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||l!==void 0){var w=[];if(l!==void 0)for(_ of l)_.f&8192||w.push(_);for(;c!==null;)!(c.f&8192)&&c!==e.fallback&&w.push(c),c=ei(c.next);var T=w.length;if(T>0){var E=r&4&&o===0?n:null;if(a){for(v=0;v<T;v+=1)w[v].nodes?.a?.measure();for(v=0;v<T;v+=1)w[v].nodes?.a?.fix()}Zr(e,w,E)}}a&&rt(()=>{if(d!==void 0)for(_ of d)_.nodes?.a?.apply()})}function ni(e,t,n,r,i,a,o,s){var c=o&1?o&16?en(n):tn(n,!1,!1):null,l=o&2?en(i):null;return{v:c,i:l,e:Vn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ri(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=_n(r);if(a.before(r),r===i)return;r=o}}function ii(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ai(e,t,...n){var r=new qr(e);zn(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},ne)}function oi(e,t){let n=null,r=A;var i;if(A){n=j;for(var a=gn(document.head);a!==null&&(a.nodeType!==8||a.data!==e);)a=_n(a);if(a===null)Be(!1);else{var o=_n(a);a.remove(),Ve(o)}}A||(i=document.head.appendChild(hn()));try{zn(()=>{var e=Vn(()=>t(i));e.f|=re})}finally{r&&(Be(!0),Ve(n))}}function si(e,t){var n=void 0,r;Bn(()=>{n!==(n=t())&&(r&&=(Gn(r),null),n&&(r=Vn(()=>{Fn(()=>n(e))})))})}function ci(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ci(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function li(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ci(e))&&(r&&(r+=` `),r+=t);return r}function ui(e){return typeof e==`object`?li(e):e??``}var di=[...`
2
2
  \r\f\xA0\v`];function fi(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||di.includes(r[o-1]))&&(s===r.length||di.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function pi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function mi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function hi(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(mi)),i&&c.push(...Object.keys(i).map(mi));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=mi(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=pi(r)),i&&(n+=pi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function gi(e,t,n,r,i,a){var o=e[he];if(A||o!==n||o===void 0){var s=fi(n,r,a);(!A||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[he]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function _i(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function vi(e,t,n,r){var i=e[ge];if(A||i!==t){var a=hi(t,r);(!A||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[ge]=t}else r&&(Array.isArray(r)?(_i(e,n?.[0],r[0]),_i(e,n?.[1],r[1],`important`)):_i(e,n,r));return r}function yi(e,t,n=!1){if(e.multiple){if(t==null)return;if(!l(t))return Re();for(var r of e.options)r.selected=t.includes(Si(r));return}for(r of e.options)if(cn(Si(r),t)){r.selected=!0;return}(!n||t!==void 0)&&(e.selectedIndex=-1)}function bi(e){var t=new MutationObserver(()=>{yi(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),jn(()=>{t.disconnect()})}function xi(e,t,n=t){var r=new WeakSet,i=!0;En(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Si);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Si(o)}n(a),e.__value=a,F!==null&&r.add(F)}),Fn(()=>{var a=t();if(e===document.activeElement){var o=F;if(r.has(o))return}if(yi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Si(s),n(a))}e.__value=a,i=!1}),bi(e)}function Si(e){return`__value`in e?e.__value:e.value}var Ci=Symbol(`is custom element`),wi=Symbol(`is html`),Ti=be?`link`:`LINK`,Ei=be?`progress`:`PROGRESS`;function Di(e){if(A){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[ve]=n,rt(n),wn()}}function Oi(e,t){var n=Ai(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Ei)||(e.value=t??``)}function ki(e,t){var n=Ai(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=Ai(e);A&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Ti)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[pe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Mi(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Ai(e){return e[me]??={[Ci]:e.nodeName.includes(`-`),[wi]:e.namespaceURI===Fe}}var ji=new Map;function Mi(e){var t=e.getAttribute(`is`)||e.nodeName,n=ji.get(t);if(n)return n;ji.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=h(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=v(i)}return n}function Ni(e,t,n=t){var r=new WeakSet;En(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Pi(e)?Fi(a):a,n(a),F!==null&&r.add(F),await Cr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(A&&e.defaultValue!==e.value||Er(t)==null&&e.value)&&(n(Pi(e)?Fi(e.value):e.value),F!==null&&r.add(F)),Ln(()=>{var n=t();if(e===document.activeElement){var i=F;if(r.has(i))return}Pi(e)&&n===Fi(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function Pi(e){var t=e.type;return t===`number`||t===`range`}function Fi(e){return e===``?null:+e}function Ii(e,t){return e===t||e?.[de]===t}function Li(e={},t,n,r){var i=N.r,a=W;return Fn(()=>{var o,s;return Ln(()=>{o=s,s=r?.()||[],Er(()=>{Ii(n(...s),e)||(t(e,...s),o&&Ii(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Ii(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function $(e,t,n,r){var i=!Ye||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??=St(r),G(l)):(c&&(c=!1,s=o?Er(r):r),s);let d;if(a){var f=de in e||fe in e;d=m(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,h=!1;a?[p,h]=pt(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=u(),d&&(i&&Oe(t),d(p)));var g=i?()=>{var n=e[t];return n===void 0?u():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return g;if(d){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&d(t?g():e),e):g()})}var v=!1,y=(n&1?St:Tt)(()=>(v=!1,g()));a&&G(y);var b=W;return(function(e,t){if(arguments.length>0){let n=t?G(y):i&&a?R(e):e;return L(y,n),v=!0,s!==void 0&&(s=n),e}return tr&&v||b.f&16384?y.v:G(y)})}function Ri(e){N===null&&xe(`onMount`),Ye&&N.l!==null?Bi(N).m.push(e):Mn(()=>{let t=Er(e);if(typeof t==`function`)return t})}function zi(e){N===null&&xe(`onDestroy`),Ri(()=>()=>Er(e))}function Bi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var Vi=`gestalt-mobile.theme`,Hi=`dyne-org`,Ui=[{id:`dyne-org`,label:`Dyne.org`,colorScheme:`light`,logoTone:`dark`},{id:`minimal-light`,label:`Minimal light`,colorScheme:`light`,logoTone:`dark`},{id:`minimal-dark`,label:`Minimal dark`,colorScheme:`dark`,logoTone:`light`}];function Wi(e){return typeof e==`string`&&Ui.some(t=>t.id===e)}function Gi(e){return e===`light`?`minimal-light`:e===`dark`?`minimal-dark`:Wi(e)?e:Hi}function Ki(e){return Ui.find(t=>t.id===e)||qi(e)}function qi(e){throw Error(`Unknown theme ID: ${e}`)}function Ji(e){try{return e?.getItem(`gestalt-mobile.theme`)??null}catch{return null}}function Yi(e){if(`storage`in e)return e.storage??null;try{return window.localStorage}catch{return null}}function Xi(e){return`meta`in e?e.meta??null:document.querySelector(`meta[name="color-scheme"]`)}function Zi(e,t={}){let n=t.root??document.documentElement,r=Xi(t),i=Ki(e);return n.dataset.theme=i.id,n.dataset.logoTone=i.logoTone,n.style.colorScheme=i.colorScheme,r&&(r.content=i.colorScheme),i.id}function Qi(e={}){return Zi(Gi(Ji(Yi(e))),e)}function $i(e,t={}){let n=Zi(e,t);try{Yi(t)?.setItem(Vi,n)}catch{}return n}var ea=q(`<span class="session-model svelte-t9laac"><small> </small></span>`),ta=q(`<p class="session-path svelte-t9laac"> <!></p>`),na=q(`<span class="weekly-quota" aria-label="Weekly quota remaining"> </span>`),ra=q(`<button class="detach-chat svelte-t9laac" type="button" aria-label="Open Chat in a separate window" title="Open Chat in a separate window"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-t9laac"><path d="M14 5h5v5M19 5l-8 8"></path><path d="M18 13v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"></path></svg></button>`),ia=q(`<option> </option>`),aa=q(`<button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Authorized devices</button> <button type="button" class="lock-relay" popovertarget="configuration-panel" popovertargetaction="hide">Lock Gestalt Mobile</button>`,1),oa=q(`<div class="svelte-t9laac"><dt class="svelte-t9laac"> </dt> <dd class="svelte-t9laac"> </dd></div>`),sa=q(`<section class="component-versions svelte-t9laac" aria-labelledby="component-versions-title"><h2 id="component-versions-title" class="svelte-t9laac">Versions</h2> <dl class="svelte-t9laac"></dl></section>`),ca=q(`<header class="app-header"><a class="brand" href="/" aria-label="Gestalt Mobile"><img class="brand-icon light-asset" src="/branding/p_glogo_grey.svg" alt=""/> <img class="brand-icon dark-asset" src="/branding/p_glogo_white.svg" alt=""/> <img class="brand-logotype light-asset" src="/branding/t_glogo_grey.svg" alt=""/> <img class="brand-logotype dark-asset" src="/branding/t_glogo_white.svg" alt=""/></a> <!> <div class="header-actions"><!> <!> <button class="menu-trigger" type="button" popovertarget="configuration-panel" aria-label="Open configuration"><span class="menu-lines" aria-hidden="true"><span></span><span></span><span></span></span></button></div></header> <div id="configuration-panel" class="configuration-panel" popover="auto"><div class="configuration-brand" aria-label="Dyne"><img class="configuration-logo light-asset" src="/branding/dyne-logotype-black.svg" alt=""/> <img class="configuration-logo dark-asset" src="/branding/dyne-logotype-white.svg" alt=""/></div> <label class="appearance-control" for="appearance"><span aria-hidden="true">aA</span> <select id="appearance" aria-label="Appearance"></select></label> <button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Notifications</button> <button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Scratchpad</button> <!> <!> <div class="maintenance-actions svelte-t9laac"><button type="button" popovertarget="configuration-panel" popovertargetaction="hide" class="svelte-t9laac">Update and restart</button></div></div> <dialog aria-labelledby="update-restart-title" aria-describedby="update-restart-description" class="svelte-t9laac"><h2 id="update-restart-title" class="svelte-t9laac">Update Gestalt?</h2> <p id="update-restart-description" class="svelte-t9laac">Mobile and every active session will disconnect briefly. Saved sessions remain available after
3
3
  the relay restarts.</p> <div class="dialog-actions svelte-t9laac"><button type="button" class="svelte-t9laac">Cancel</button> <button type="button" class="svelte-t9laac"> </button></div></dialog>`,1);function la(e,t){Qe(t,!0);let n=$(t,`sessionPath`,3,null),r=$(t,`sessionModel`,3,null),i=$(t,`weeklyQuotaRemaining`,3,null),a=$(t,`passkeyAuthEnabled`,3,!0),o=$(t,`componentVersions`,19,()=>[]),s=$(t,`onlock`,3,()=>{}),c=$(t,`ondevices`,3,()=>{}),l=$(t,`onnotifications`,3,()=>{}),u=$(t,`onscratchpad`,3,()=>{}),d=$(t,`onupdaterestart`,3,async()=>{}),f=I(null),p=I(null),m=I(!1);function h(){G(f)?.showModal(),queueMicrotask(()=>G(p)?.focus())}async function g(){L(m,!0);try{await d()(),G(f)?.close()}catch{}finally{L(m,!1)}}var _=ca(),v=B(_),y=V(z(v),2),b=e=>{var t=ta(),i=z(t,!0),a=V(i),o=e=>{var t=ea(),n=z(t),i=z(n);M(n),M(t),H(()=>Y(i,`· ${r()??``}`)),J(e,t)};X(a,e=>{r()&&e(o)}),M(t),H(()=>{Q(t,`title`,n()),Y(i,n())}),J(e,t)};X(y,e=>{n()&&e(b)});var x=V(y,2),S=z(x),C=e=>{var t=na(),n=z(t);M(t),H(()=>Y(n,`${i()??``}% left`)),J(e,t)};X(S,e=>{i()!==null&&e(C)});var w=V(S,2),T=e=>{var n=ra();K(`click`,n,function(...e){t.ondetach?.apply(this,e)}),J(e,n)};X(w,e=>{t.ondetach&&e(T)}),Ue(2),M(x),M(v);var E=V(v,2),D=V(z(E),2),O=V(z(D),2);Z(O,21,()=>Ui,e=>e.id,(e,t)=>{var n=ia(),r=z(n,!0);M(n);var i={};H(()=>{Y(r,G(t).label),i!==(i=G(t).id)&&(n.value=(n.__value=G(t).id)??``)}),J(e,n)}),M(O);var ee;bi(O),M(D);var k=V(D,2),te=V(k,2),ne=V(te,2),re=e=>{var t=aa(),n=B(t),r=V(n,2);K(`click`,n,e=>c()(e.currentTarget)),K(`click`,r,function(...e){s()?.apply(this,e)}),J(e,t)};X(ne,e=>{a()&&e(re)});var ie=V(ne,2),ae=e=>{var t=sa(),n=V(z(t),2);Z(n,21,o,e=>e.id,(e,t)=>{var n=oa(),r=z(n),i=z(r,!0);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(()=>{Y(i,G(t).label),Q(a,`title`,G(t).version??`Version unavailable`),Y(o,G(t).version??`Unavailable`)}),J(e,n)}),M(n),M(t),J(e,t)};X(ie,e=>{o().length&&e(ae)});var oe=V(ie,2),se=z(oe);M(oe),M(E);var ce=V(E,2),le=V(z(ce),4),ue=z(le);Li(ue,e=>L(p,e),()=>G(p));var de=V(ue,2),fe=z(de,!0);M(de),M(le),M(ce),Li(ce,e=>L(f,e),()=>G(f)),H(()=>{ee!==(ee=t.theme)&&(O.value=(O.__value=t.theme)??``,yi(O,t.theme)),ue.disabled=G(m),de.disabled=G(m),Y(fe,G(m)?`Starting update…`:`Update and restart`)}),K(`change`,O,e=>t.onthemechange(e.currentTarget.value)),K(`click`,k,function(...e){l()?.apply(this,e)}),K(`click`,te,function(...e){u()?.apply(this,e)}),K(`click`,se,h),Nr(`cancel`,ce,e=>G(m)&&e.preventDefault()),K(`click`,ue,()=>G(f)?.close()),K(`click`,de,()=>void g()),J(e,_),$e()}Pr([`click`,`change`]);function ua(e){return e.reduce((e,t)=>{let n=da(t);return n?.kind===`Command`?(n.status===`completed`&&(e.successful+=1),n.status===`failed`&&(e.failed+=1),e):e},{successful:0,failed:0})}function da(e){if(fa(e))return null;let[t,n]=e.label.split(` · `,2);return{kind:t,...n?{status:n}:{},content:pa(t,e.detail)}}function fa(e){return e.label.startsWith(`Tool`)&&(e.detail.includes(`context_mode`)||/(^|[_:])ctx_[a-z]/i.test(e.detail))}function pa(e,t){return e===`Command`?ma(t):e===`File change`||e===`fileChange`?t.split(`
4
- `).filter(Boolean).join(`, `):t}function ma(e){let t=e.match(/^\/bin\/bash -lc "([\s\S]*)"$/);return t?t[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`):e}var ha=q(`<dl class="command-counts svelte-thyolt"><div data-command-outcome="successful" class="svelte-thyolt"><dt class="svelte-thyolt">Successful commands</dt> <dd class="svelte-thyolt"> </dd></div> <div data-command-outcome="failed" class="svelte-thyolt"><dt class="svelte-thyolt">Failed commands</dt> <dd class="svelte-thyolt"> </dd></div></dl>`),ga=q(`<li class="activity-row svelte-thyolt"><small class="activity-type svelte-thyolt"> </small> <span class="activity-content svelte-thyolt"> </span></li>`),_a=q(`<ul class="activity-list svelte-thyolt"></ul>`),va=q(`<details class="chat-activity svelte-thyolt"><summary class="svelte-thyolt">activity</summary> <!> <!></details>`),ya=q(`<section class="live-activity svelte-thyolt" aria-label="Current activity"><strong class="svelte-thyolt">activity</strong> <!> <!></section>`);function ba(e,t){Qe(t,!0);let n=e=>{var t=ha(),n=z(t),r=V(z(n),2),i=z(r,!0);M(r),M(n);var a=V(n,2),o=V(z(a),2),c=z(o,!0);M(o),M(a),M(t),H(()=>{Y(i,G(s).successful),Y(c,G(s).failed)}),J(e,t)},r=e=>{var t=Hr(),n=B(t),r=e=>{var t=_a();Z(t,21,()=>G(c),e=>e.id,(e,t)=>{var n=ga(),r=z(n),i=z(r);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(e=>{Q(n,`data-activity-kind`,e),Q(n,`data-activity-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)},[()=>G(t).kind.toLowerCase().replaceAll(` `,`-`)]),J(e,n)}),M(t),J(e,t)};X(n,e=>{G(c).length&&e(r)}),J(e,t)},i=$(t,`variant`,3,`summary`),a=P(()=>t.activities.flatMap(e=>{let t=da(e);return t&&t.kind.toLowerCase().replaceAll(` `,``)!==`filechange`?[{id:e.id,...t}]:[]})),o=P(()=>G(a).some(e=>e.kind===`Command`)),s=P(()=>ua(t.activities)),c=P(()=>G(a).filter(e=>e.kind!==`Command`));var l=Hr(),u=B(l),d=e=>{var t=Hr(),a=B(t),s=e=>{var t=va(),i=V(z(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=V(i,2);r(s),M(t),J(e,t)},c=e=>{var t=ya(),i=V(z(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=V(i,2);r(s),M(t),J(e,t)};X(a,e=>{i()===`summary`?e(s):e(c,-1)}),J(e,t)};X(u,e=>{(G(o)||G(c).length)&&e(d)}),J(e,l),$e()}var xa=q(`<summary><!></summary>`),Sa=q(`<button><!></button>`);function Ca(e,t){let n=$(t,`element`,3,`button`),r=$(t,`type`,3,`button`),i=$(t,`disabled`,3,!1),a=$(t,`compact`,3,!1),o=$(t,`full`,3,!1),s=$(t,`primary`,3,!1),c=$(t,`accentPressed`,3,!1);var l=Hr(),u=B(l),d=e=>{var n=xa();ai(z(n),()=>t.children),M(n),H(()=>{Q(n,`id`,t.id),gi(n,1,ui([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`data-state`,t.state)}),J(e,n)},f=e=>{var n=Sa();ai(z(n),()=>t.children),M(n),H(()=>{Q(n,`id`,t.id),Q(n,`type`,r()),n.disabled=i(),gi(n,1,ui([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`aria-label`,t.label),Q(n,`aria-current`,t.current),Q(n,`aria-pressed`,t.pressed),Q(n,`aria-describedby`,t.describedby),Q(n,`aria-disabled`,t.ariaDisabled)}),K(`click`,n,function(...e){t.onclick?.apply(this,e)}),J(e,n)};X(u,e=>{n()===`summary`?e(d):e(f,-1)}),J(e,l)}Pr([`click`]);var wa=e=>({working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`})[e];function Ta(e,t){if(!t)return{polite:``,critical:``};let n=!e||e.root.state!==t.root.state||e.aggregateSubagents!==t.aggregateSubagents,r=t.root.state===`blocked`||t.root.state===`awaitingHuman`;return{polite:n?`l0 ${wa(t.root.state)}; subagents ${wa(t.aggregateSubagents)}.`:``,critical:r&&(!e||e.root.state!==t.root.state)?`l0 ${wa(t.root.state)}.`:``}}function Ea(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`recently`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`<1m`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);if(o<7)return`${o}d`;let s=Math.floor(o/7);if(s<5)return`${s}w`;let c=Math.floor(o/30);return c<12?`${c}mo`:`${Math.floor(o/365)}y`}var Da=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <span class="agent-metadata svelte-d9jh4j"> </span> <time class="svelte-d9jh4j"> </time></li>`),Oa=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j">l0</strong> <span class="agent-metadata svelte-d9jh4j"> </span> <span class="unavailable svelte-d9jh4j" role="status">activity unavailable</span></li>`),ka=q(`<details class="agents svelte-d9jh4j"><!> <ul class="svelte-d9jh4j"><!></ul></details>`),Aa=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <small class="svelte-d9jh4j"> </small></li>`),ja=q(`<div class="chips svelte-d9jh4j"><span class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">●</span> </span> <details class="children svelte-d9jh4j"><summary class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">◆</span> </summary> <ul class="svelte-d9jh4j"></ul></details> <span class="freshness svelte-d9jh4j"> </span></div>`),Ma=q(`<p class="visually-hidden svelte-d9jh4j" role="alert"> </p>`),Na=q(`<p class="visually-hidden svelte-d9jh4j" aria-live="polite" aria-atomic="true"> </p> <!>`,1),Pa=q(`<section aria-label="Agent activity"><!> <!></section>`);function Fa(e,t){Qe(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`popupAlign`,3,`end`),i=$(t,`onopen`,3,()=>{}),a={working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`},o={working:0,awaitingAgent:1,awaitingHuman:1,blocked:1,idle:2,disconnected:3},s=I(``),c=I(``),l=null,u=I(R(Date.now())),d=P(()=>t.activity?`${t.activity.sessionId}:${t.activity.root.state}:${t.activity.aggregateSubagents}`:``),f=P(()=>t.activity?[`blocked`,`awaitingHuman`,`disconnected`].includes(t.activity.root.state)?t.activity.root.state:t.activity.aggregateSubagents:`unavailable`);function p(e){let n=/^L([1-9]\d*)$/.exec(e??``);return n?t.plan?.steps[Number(n[1])-1]?.title:void 0}function m(e){let t=p(e.canonicalPosition),n=e.canonicalTaskName??e.canonicalPosition?.toLowerCase()??e.nickname??e.role??e.id;return t?`${n} — ${t}`:n}function h(){return`l0`}function g(e){return e===void 0?`(ctx: —)`:`(ctx: ${e}%)`}function _(e){let t=/^L([1-9]\d*)(?:\.([1-9]\d*))?$/.exec(e??``);return t?Number(t[1])*1e3+Number(t[2]??0):2**53-1}function v(e,t){return _(e.canonicalPosition)-_(t.canonicalPosition)||(e.continuationGeneration??1)-(t.continuationGeneration??1)||o[e.state]-o[t.state]||m(e).localeCompare(m(t))}let y=P(()=>t.activity?[{key:`root`,name:h(),planOrder:-1,generation:0,contextUsedPercent:t.activity.root.contextUsedPercent,role:`supervisor`,...t.rootModel?{model:t.rootModel}:{},state:t.activity.root.state,lastActivityAt:t.activity.root.lastActivityAt},...t.activity.subagents.map(e=>({key:`child:${e.id}`,name:m(e),planOrder:_(e.canonicalPosition),generation:e.continuationGeneration??1,contextUsedPercent:e.contextUsedPercent,...e.role?{role:e.role}:{},...e.model?{model:e.model}:{},state:e.state,lastActivityAt:e.lastActivityAt}))].sort((e,t)=>e.planOrder-t.planOrder||e.generation-t.generation||o[e.state]-o[t.state]||e.name.localeCompare(t.name)):[]),b=P(()=>t.activity?[...t.activity.subagents].sort(v):[]);Ri(()=>{let e=window.setInterval(()=>L(u,Date.now(),!0),6e4);return()=>window.clearInterval(e)});function x(e,t){let n=Ea(t,G(u));return e===`idle`||e===`disconnected`?`${a[e]} since ${n}`:`${a[e]} · active ${n} ago`}Mn(()=>{if(!G(d))return;let e=Er(()=>t.activity),n=Er(()=>l);if(!e)return;let r=Ta(n?.sessionId===e.sessionId?n:null,e);r.polite&&L(s,r.polite,!0),r.critical?L(c,r.critical,!0):e.root.state!==`blocked`&&e.root.state!==`awaitingHuman`&&L(c,``),l=e});var S=Pa();let C;var w=z(S),T=e=>{var n=ka(),r=z(n);Ca(r,{element:`summary`,compact:!0,full:!0,get state(){return G(f)},children:(e,n)=>{Ue();var r=Vr();H(()=>Y(r,`Agents (${(t.activity?.subagents.length??0)+1})`)),J(e,r)},$$slots:{default:!0}});var a=V(r,2),o=z(a),s=e=>{var t=Hr();Z(B(t),17,()=>G(y),e=>e.key,(e,t)=>{var n=Da(),r=z(n),i=z(r,!0);M(r);var a=V(r,2),o=z(a,!0);M(a);var s=V(a,2),c=z(s,!0);M(s),M(n),H((e,n)=>{Y(i,G(t).name),Y(o,e),Q(s,`datetime`,G(t).lastActivityAt),Y(c,n)},[()=>[g(G(t).contextUsedPercent),G(t).role,G(t).model?`Model: ${G(t).model}`:`Model unavailable`].filter(Boolean).join(` · `),()=>x(G(t).state,G(t).lastActivityAt)]),J(e,n)}),J(e,t)},c=e=>{var n=Oa(),r=V(z(n),2),i=z(r,!0);M(r),Ue(2),M(n),H(e=>Y(i,e),[()=>[`(ctx: —)`,`supervisor`,t.rootModel?`Model: ${t.rootModel}`:`Model unavailable`].filter(Boolean).join(` · `)]),J(e,n)};X(o,e=>{t.activity?e(s):e(c,-1)}),M(a),M(n),Nr(`toggle`,n,e=>e.currentTarget.open&&i()()),J(e,n)},E=e=>{var n=ja(),r=z(n),i=V(z(r));M(r);var o=V(r,2),s=z(o),c=V(z(s));M(s);var l=V(s,2);Z(l,21,()=>G(b),e=>e.id,(e,t)=>{var n=Aa(),r=z(n),i=z(r,!0);M(r);var o=V(r),s=V(o),c=z(s,!0);M(s),M(n),H((e,n)=>{Y(i,e),Y(o,` · ${n??``}${G(t).role?` · ${G(t).role}`:``}${G(t).model?` · Model: ${G(t).model}`:``} —
5
- ${a[G(t).state]??``} `),Y(c,G(t).lastActivityAt)},[()=>m(G(t)),()=>g(G(t).contextUsedPercent)]),J(e,n)}),M(l),M(o);var u=V(o,2),d=z(u,!0);M(u),M(n),H(e=>{Q(r,`data-state`,t.activity.root.state),Y(i,` l0: ${a[t.activity.root.state]??``}
6
- ${e??``}`),Q(s,`data-state`,t.activity.aggregateSubagents),Y(c,` Subagents: ${a[t.activity.aggregateSubagents]??``} (${t.activity.subagents.length??``})`),Y(d,t.activity.confidence===`fresh`?`Current`:t.activity.confidence===`reconciling`?`Checking updates`:`May be stale`)},[()=>g(t.activity.root.contextUsedPercent)]),J(e,n)};X(w,e=>{n()?e(T):t.activity&&e(E,1)});var D=V(w,2),O=e=>{var t=Na(),n=B(t),r=z(n,!0);M(n);var i=V(n,2),a=e=>{var t=Ma(),n=z(t,!0);M(t),H(()=>Y(n,G(c))),J(e,t)};X(i,e=>{G(c)&&e(a)}),H(()=>Y(r,G(s))),J(e,t)};X(D,e=>{t.activity&&e(O)}),M(S),H(()=>C=gi(S,1,`agent-activity svelte-d9jh4j`,null,C,{compact:n(),"align-start":r()===`start`})),J(e,S),$e()}Xe();var Ia=q(`<main class="svelte-iw6wrs"><h1 class="svelte-iw6wrs">Activity evidence</h1> <!><!></main>`);function La(e){let t={sessionId:`evidence`,confidence:`reconciling`,aggregateSubagents:`working`,root:{state:`awaitingAgent`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`},subagents:[{id:`α-worker`,nickname:`α worker`,role:`research`,state:`working`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`}]},n=[`working`,`awaitingAgent`,`awaitingHuman`,`blocked`,`idle`,`disconnected`];var r=Ia(),i=V(z(r),2);Fa(i,{get activity(){return t}}),Z(V(i),1,()=>n,e=>e,(e,n)=>{{let r=Tt(()=>({...t,sessionId:G(n),confidence:G(n)===`blocked`?`stale`:`fresh`,root:{...t.root,state:G(n)},aggregateSubagents:G(n)}));Fa(e,{get activity(){return G(r)}})}}),M(r),J(e,r)}function Ra(e,t){if(!e||typeof e!=`object`)return!1;let n=e,r=new Set([`working`,`idle`,`awaitingAgent`,`awaitingHuman`,`blocked`,`disconnected`]),i=(e,t=256)=>typeof e==`string`&&e.length<=t,a=e=>Array.isArray(e)&&e.length<=64&&e.every(e=>{let t=e;return t&&typeof t==`object`&&[`running`,`detached-active`,`exited-awaiting-result`,`result-consumed`,`terminated-for-budget`].includes(t.state)&&[`executor`,`supervisor`].includes(t.ownership)&&i(t.observedAt,64)&&!Number.isNaN(Date.parse(t.observedAt))}),o=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return i(t.state,32)&&r.has(t.state)&&i(t.observedAt,64)&&i(t.lastActivityAt,64)&&!Number.isNaN(Date.parse(t.observedAt))&&!Number.isNaN(Date.parse(t.lastActivityAt))&&(t.reason===void 0||i(t.reason,64))&&(t.contextUsedPercent===void 0||Number.isInteger(t.contextUsedPercent)&&t.contextUsedPercent>=0&&t.contextUsedPercent<=100)};return i(n.sessionId)&&(!t||n.sessionId===t)&&o(n.root)&&Array.isArray(n.subagents)&&n.subagents.length<=64&&n.subagents.every(e=>o(e)&&i(e.id)&&(e.nickname===void 0||i(e.nickname))&&(e.role===void 0||i(e.role))&&(e.model===void 0||i(e.model))&&(e.canonicalTaskName===void 0||i(e.canonicalTaskName))&&(e.canonicalPosition===void 0||i(e.canonicalPosition,32))&&(e.continuationGeneration===void 0||Number.isInteger(e.continuationGeneration)&&e.continuationGeneration>0)&&(e.outcome===void 0||[`partial`,`cancelled`,`failed`].includes(e.outcome))&&(e.ownedProcesses===void 0||a(e.ownedProcesses)))&&i(n.aggregateSubagents,32)&&r.has(n.aggregateSubagents)&&(n.confidence===`fresh`||n.confidence===`stale`||n.confidence===`reconciling`)}var za=class{#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=null;#l=!1;#u;constructor(e){this.#u={...e,websocket:e.websocket??(e=>new WebSocket(e)),location:e.location??location,setTimeout:e.setTimeout??setTimeout,clearTimeout:e.clearTimeout??clearTimeout}}get(e){return e?this.#e.get(e)??null:null}bootstrap(e,t){for(let t of e)!this.#e.has(t.id)&&Ra(t.agentActivity,t.id)&&this.#p(t.id,this.#t.get(t.id)??0,t.agentActivity);this.sync(e.map(e=>e.id),t)}sync(e,t){if(!this.#l){this.#c=t,this.#n=new Set(e);for(let e of this.#n)this.#i.has(e)||this.#i.set(e,0);for(let e of[...this.#i.keys()])this.#n.has(e)||this.remove(e);for(let[e,n]of this.#r)(e===t||!this.#n.has(e))&&(n.close(),this.#r.delete(e));for(let e of this.#n)this.hydrate(e),e!==t&&!this.#r.has(e)&&this.#f(e)}}select(e){this.sync([...this.#n],e)}remove(e){this.#n.delete(e),this.#i.set(e,(this.#i.get(e)??0)+1),this.#r.get(e)?.close(),this.#r.delete(e);let t=this.#a.get(e);t&&this.#u.clearTimeout(t),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#e.delete(e),this.#t.delete(e),this.#u.publish(this.#e)}observe(e,t){if(this.#l||!this.#n.has(e)||!Number.isInteger(t.sequence))return;let n=this.#t.get(e)??0;t.sequence<=n||(t.sequence>n+1&&(this.#t.set(e,t.sequence-1),this.resync(e)),this.#t.set(e,t.sequence),this.#u.onEvent?.(e,t),t.type===`agent.activity.updated`&&Ra(t.payload,e)&&this.#p(e,t.sequence,t.payload))}async hydrate(e){let t=this.#i.get(e)??0,n=this.#t.get(e)??0;try{let r=await this.#u.relay.getSession(e);if(!this.#d(e,t))return;let i=this.#t.get(e)??0,a=r.currentSequence;if(Number.isInteger(a)){if(a<i)return;this.#t.set(e,a),Ra(r.agentActivity,e)&&this.#p(e,a,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r)}else i===n&&Ra(r.agentActivity,e)&&(this.#p(e,i,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r))}catch{this.#m(e)}}async resync(e){let t=this.#o.get(e);if(t)return t;let n=this.#i.get(e)??0;this.#m(e);let r;return r=(async()=>{try{await this.#u.relay.refreshActivity(e),this.#d(e,n)&&await this.hydrate(e)}catch{}finally{this.#o.get(e)===r&&this.#o.delete(e)}})(),this.#o.set(e,r),r}dispose(){this.#l=!0;for(let e of[...this.#n])this.remove(e)}#d(e,t){return!this.#l&&this.#n.has(e)&&this.#i.get(e)===t}#f(e){let t=this.#i.get(e)??0,n=this.#u.location.protocol===`https:`?`wss:`:`ws:`,r=this.#u.websocket(`${n}//${this.#u.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#t.get(e)??0}`);this.#r.set(e,r),r.onmessage=n=>{if(!(!this.#d(e,t)||this.#r.get(e)!==r))try{this.#s.delete(e);let t=JSON.parse(String(n.data));t.type===`relay.resyncRequired`?this.resync(e):t.type===`relay.event`&&t.event&&this.observe(e,t.event)}catch{}},r.onclose=()=>{if(!this.#d(e,t)||this.#c===e)return;this.#r.delete(e),this.#m(e);let n=this.#s.get(e)??0,r=(this.#u.reconnectDelaysMs??[250,1e3,5e3])[n];r!==void 0&&(this.#s.set(e,n+1),this.#a.set(e,this.#u.setTimeout(()=>{this.#a.delete(e),this.#d(e,t)&&e!==this.#c&&this.#f(e)},r)))}}#p(e,t,n){let r=this.#e.get(e);this.#t.set(e,Math.max(t,this.#t.get(e)??0)),JSON.stringify(r)!==JSON.stringify(n)&&(this.#e.set(e,n),this.#u.publish(this.#e))}#m(e){let t=this.#e.get(e);t&&t.confidence===`fresh`&&(this.#e.set(e,{...t,confidence:`stale`}),this.#u.publish(this.#e))}};function Ba(e=globalThis.crypto,t=Date.now,n=Math.random){return typeof e?.randomUUID==`function`?e.randomUUID():`k-${t().toString(36)}-${Math.floor(n()*4294967296).toString(36)}`}var Va=(e,t=600)=>typeof e==`string`&&e.length<=t,Ha=e=>Va(e,64)&&!Number.isNaN(Date.parse(e));function Ua(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.enabled==`boolean`&&typeof t.state==`string`&&[`disabled`,`monitoring`,`backoff`,`attentionRequired`,`completed`,`safetyPaused`].includes(t.state)&&!!t.retry&&typeof t.retry==`object`&&Number.isInteger(t.retry.position)&&Number.isInteger(t.retry.limit)&&Va(t.updatedAt,64)&&(t.reason===void 0||Va(t.reason,80))&&(t.nextEvaluationAt===void 0||Va(t.nextEvaluationAt,64))&&(t.health===void 0||Wa(t.health))}function Wa(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.wait||typeof t.wait!=`object`)return!1;let n=t.wait;return typeof t.healthy==`boolean`&&typeof t.phase==`string`&&[`off`,`rootWorking`,`continuationScheduled`,`waitingForAgentEvent`,`checkingState`,`needsYou`,`safetyPaused`,`complete`,`degraded`].includes(t.phase)&&[`active`,`probeRequired`,`parked`,`retrying`,`attentionRequired`,`safetyPaused`,`none`].includes(t.supervision)&&typeof n.present==`boolean`&&Array.isArray(n.wakeCategories)&&n.wakeCategories.length<=9&&new Set(n.wakeCategories).size===n.wakeCategories.length&&n.wakeCategories.every(e=>[`planChanged`,`reviewChanged`,`checkpointChanged`,`interactionChanged`,`executorChanged`,`processExited`,`processResultAvailable`,`processLimitBreached`,`agentActivityChanged`].includes(e))&&Ha(t.observedAt)&&Ha(t.lastTransitionAt)&&Va(t.nextExpectedAction)&&(t.degradationReason===void 0||[`missingContinuation`,`invalidWaitLease`,`controllerUnavailable`,`staleTransition`,`planMismatch`].includes(t.degradationReason))}function Ga(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.attention;if(!n||typeof n!=`object`)return!1;let r=n;return Va(t.requestId,256)&&(t.turnId===null||Va(t.turnId,256))&&(t.requestedAt===null||Va(t.requestedAt,64))&&Va(r.reason,64)&&Va(r.summary)&&Va(r.requestedAction)&&Va(r.resumeCondition,64)}function Ka(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`orgPlanAttention`&&Ga({requestId:t.requestId,turnId:t.turnId??null,requestedAt:t.requestedAt??null,attention:t.payload})}function qa(e){return{requestId:e.requestId,turnId:e.turnId,requestedAt:e.requestedAt,attention:e.payload}}var Ja=e=>{let t=e&&typeof e==`object`?e.code:void 0;return t===`AUTOPILOT_PLAN_REQUIRED`?`An incomplete supervised plan is required before Autopilot can start.`:t===`AUTOPILOT_PLAN_COMPLETE`?`This plan is complete, so Autopilot is unavailable.`:t===`AUTOPILOT_SESSION_UNAVAILABLE`?`This session is unavailable for Autopilot.`:e instanceof Error?e.message:`Could not update Autopilot.`},Ya=class{relay;publish;createKey;#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Set;#f=!1;constructor(e,t,n=Ba){this.relay=e,this.publish=t,this.createKey=n}bootstrap(e){if(this.#f)return;let t=new Set(e.map(e=>e.id));for(let e of this.#d)t.has(e)||this.remove(e);this.#d=t;for(let t of e){this.#i.has(t.id)||this.#i.set(t.id,0),this.#a.has(t.id)||this.#a.set(t.id,0);let e=this.#u.get(t.id)??0,n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#c.get(t.id);!this.#n.has(t.id)&&(r===void 0||n!==null&&n>r)&&(n!==null&&n>e||!this.#e.has(t.id)&&e===0)&&(n!==null&&(this.#u.set(t.id,n),r!==void 0&&n>r&&this.#c.delete(t.id)),this.#g(t.id,t))}this.#_()}observe(e,t){if(this.#f||!this.#d.has(e)||!Number.isInteger(t.sequence))return;let n=this.#u.get(e)??0;t.sequence<=n||(this.#u.set(e,t.sequence),this.#a.set(e,(this.#a.get(e)??0)+1),t.type===`autopilot.updated`&&this.#m(e,t.payload),t.type===`org-plan.attention-required`&&this.#h(e,t.payload),t.type===`org-plan.attention-resolved`&&(t.payload&&typeof t.payload==`object`&&t.payload.outcome,this.#t.delete(e)),this.#_())}async hydrate(e,t){let n=this.#i.get(e)??0,r=(this.#l.get(e)??0)+1;this.#l.set(e,r);let i=t??this.#u.get(e)??0,a=this.#o.get(e),o=this.#s.get(e)??0;try{let t=await this.relay.getSession(e);if(!this.#p(e,n)||this.#l.get(e)!==r||(this.#s.get(e)??0)!==o||this.#o.has(e)&&this.#o.get(e)!==a)return;let s=this.#u.get(e)??0,c=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null;c!==null&&c>s?(this.#u.set(e,c),this.#g(e,t)):c===null&&s===i&&this.#g(e,t),this.#_()}catch{}}async toggle(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=this.#i.get(e)??0,r=this.#a.get(e)??0;this.#o.set(e,(this.#o.get(e)??0)+1),this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{let i=await this.relay.setAutopilot(e,t,this.createKey());this.#p(e,n)&&this.#a.get(e)===r&&(this.#m(e,i.autopilot),this.#a.set(e,r+1),this.#c.set(e,this.#u.get(e)??0),Ua(i.autopilot)&&!i.autopilot.enabled&&this.#t.delete(e))}catch(t){this.#p(e,n)&&this.#a.get(e)===r&&this.#r.set(e,Ja(t))}finally{this.#p(e,n)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}async resolve(e,t,n){let r=this.#t.get(e);if(!r||this.#n.has(e)||this.#f)return;let i=n?.trim();if(i&&i.length>600){this.#r.set(e,`Guidance must be 600 characters or fewer.`),this.#_();return}let a=this.#i.get(e)??0,o=this.#a.get(e)??0;this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{await this.relay.resolveAttention(e,r.requestId,{operationKey:this.createKey(),action:t,...i?{guidance:i}:{}}),this.#p(e,a)&&this.#a.get(e)===o&&await this.hydrate(e)}catch(t){this.#p(e,a)&&this.#a.get(e)===o&&this.#r.set(e,t instanceof Error?t.message:`Could not resolve attention.`)}finally{this.#p(e,a)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}remove(e){this.#i.set(e,(this.#i.get(e)??0)+1),this.#d.delete(e),this.#e.delete(e),this.#t.delete(e),this.#n.delete(e),this.#r.delete(e),this.#u.delete(e),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#c.delete(e),this.#l.delete(e),this.#_()}dispose(){this.#f=!0,this.#d.clear(),this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#l.clear(),this.#a.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#_()}#p(e,t){return!this.#f&&this.#d.has(e)&&this.#i.get(e)===t}#m(e,t){Ua(t)&&this.#e.set(e,t)}#h(e,t){if(Ga(t))this.#t.set(e,t);else if(Ka(t))this.#t.set(e,qa(t));else if(Array.isArray(t)){let n=t.find(Ka);n?this.#t.set(e,qa(n)):this.#t.delete(e)}}applyAuthoritative(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#u.get(e)??0,i=this.#c.get(e);i!==void 0&&(n===null||n<=i)||n!==null&&n<r||(n!==null&&(this.#u.set(e,n),i!==void 0&&n>i&&this.#c.delete(e)),this.#g(e,t),this.#_())}#g(e,t){this.#a.set(e,(this.#a.get(e)??0)+1),this.#m(e,t.autopilot),this.#h(e,t.pendingInteractions)}#_(){this.publish({snapshots:new Map(this.#e),attention:new Map(this.#t),pending:new Set(this.#n),errors:new Map(this.#r)})}},Xa=q(`<span aria-hidden="true" class="svelte-1qf1ppf"> </span> `,1),Za=q(`<div class="control-row svelte-1qf1ppf"><span class="status svelte-1qf1ppf"><span aria-hidden="true" class="svelte-1qf1ppf"> </span> </span> <!></div>`),Qa=q(`<section aria-label="Autopilot"><p class="visually-hidden svelte-1qf1ppf" data-testid="autopilot-live-status" aria-live="polite" aria-atomic="true"> </p> <!> <p> </p></section>`);function $a(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-control`),r=$(t,`compact`,3,!1),i=$(t,`indicatorOnly`,3,!1),a=$(t,`pending`,3,!1),o=$(t,`ontoggle`,3,()=>{}),s={disabled:`Off`,monitoring:`Monitoring`,backoff:`Waiting to continue`,attentionRequired:`Paused for attention`,completed:`Complete`,safetyPaused:`Safety paused`},c={off:`Off`,rootWorking:`On · root working`,continuationScheduled:`On · continuation scheduled`,waitingForAgentEvent:`On · waiting for agent event`,checkingState:`On · checking state`,needsYou:`Paused · needs you`,safetyPaused:`Safety paused`,complete:`Complete`,degraded:`On · continuation unavailable`},l={planRequired:`An incomplete supervised plan is required before Autopilot can start.`,planComplete:`This plan is complete, so Autopilot is unavailable.`,sessionUnavailable:`This session is unavailable for Autopilot.`,attentionRequired:`Autopilot is paused because an agent is waiting for human input.`,noPlanProgress:`Autopilot paused because the plan did not make durable progress.`,reconcileFailed:`Autopilot paused because it could not safely confirm session state.`,startUnavailable:`Automatic continuation could not start because the session runtime is unavailable. Restore or reopen the session, then retry Autopilot.`,actionRateExceeded:`Autopilot paused after too many automatic actions in ten minutes. Wait for the safety window to clear, or continue manually.`,planRemoved:`The retained plan was removed.`,planReplaced:`The retained plan changed. Enable Autopilot again after reviewing it.`,sessionEnded:`This session ended.`,manualDisabled:`Autopilot is off.`,safetyPaused:`Autopilot paused after a repeated or invalid automatic continuation. Resume manually when ready.`},u=P(()=>t.autopilot?t.autopilot.health?c[t.autopilot.health.phase]:s[t.autopilot.state]:`Unavailable`),d=P(()=>t.autopilot?.state===`backoff`&&t.autopilot.retry.position>0&&t.autopilot.retry.limit>0?`Retry ${t.autopilot.retry.position} of ${t.autopilot.retry.limit}.`:null),f=P(()=>(t.autopilot?.reason?l[t.autopilot.reason]:null)??G(d)??t.autopilot?.health?.nextExpectedAction??(t.autopilot?.state===`monitoring`?`Autopilot is monitoring this supervised plan.`:t.autopilot?.state===`attentionRequired`?`Autopilot is paused because human attention is required.`:`Autopilot state is loading from the relay.`)),p=P(()=>`Autopilot status: ${G(u)}. ${G(f)}`),m=P(()=>t.autopilot?.enabled??!1);var h=Qa();let g;var _=z(h),v=z(_,!0);M(_);var y=V(_,2),b=e=>{{let t=P(()=>`${n()}-button`),r=P(()=>i()?`Autopilot: ${a()?`Updating`:G(u)}`:void 0),s=P(()=>`${n()}-help`);Ca(e,{get id(){return G(t)},compact:!0,full:!0,get pressed(){return G(m)},get accentPressed(){return i()},get label(){return G(r)},get describedby(){return G(s)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{var n=Hr(),r=B(n),o=e=>{J(e,Vr(`Autopilot`))},s=e=>{var t=Xa(),n=B(t),r=z(n,!0);M(n);var i=V(n);H(()=>{Y(r,G(m)?`●`:`○`),Y(i,` Autopilot: ${(a()?`Updating…`:G(u))??``}`)}),J(e,t)};X(r,e=>{i()?e(o):e(s,-1)}),J(e,n)},$$slots:{default:!0}})}},x=e=>{var r=Za(),i=z(r),s=z(i),c=z(s,!0);M(s);var l=V(s);M(i);var d=V(i,2);{let e=P(()=>`${n()}-button`),t=P(()=>`${n()}-help`);Ca(d,{get id(){return G(e)},get pressed(){return G(m)},get describedby(){return G(t)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{Ue();var n=Vr();H(()=>Y(n,a()?`Updating…`:G(m)?`Pause`:`Enable`)),J(e,n)},$$slots:{default:!0}})}M(r),H(()=>{Q(i,`data-state`,t.autopilot?.state??`unavailable`),Y(c,G(m)?`●`:`○`),Y(l,` Autopilot: ${G(u)??``}`)}),J(e,r)};X(y,e=>{r()?e(b):e(x,-1)});var S=V(y,2);let C;var w=z(S,!0);M(S),M(h),H(()=>{g=gi(h,1,`autopilot-control svelte-1qf1ppf`,null,g,{compact:r()}),Y(v,G(p)),Q(S,`id`,`${n()}-help`),C=gi(S,1,`svelte-1qf1ppf`,null,C,{"visually-hidden":r()}),Y(w,G(f))}),J(e,h),$e()}var eo=q(`<section class="attention svelte-1hnxk0w" role="alert"><h3 class="svelte-1hnxk0w">Autopilot needs your attention</h3> <dl class="svelte-1hnxk0w"><div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Reason</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">What happened</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Requested action</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Resume when</dt> <dd class="svelte-1hnxk0w"> </dd></div></dl> <label>Optional guidance for the resumed work</label> <textarea maxlength="600" class="svelte-1hnxk0w"></textarea> <p class="guidance-help svelte-1hnxk0w"> </p> <div class="actions svelte-1hnxk0w"><button type="button" class="svelte-1hnxk0w"> </button> <button type="button" class="svelte-1hnxk0w">Disable Autopilot</button></div></section>`);function to(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-attention`),r=$(t,`pending`,3,!1),i=$(t,`onresolve`,3,()=>{}),a=I(``),o=P(()=>G(a).trim().length>600?`Guidance must be 600 characters or fewer.`:``);var s=Hr(),c=B(s),l=e=>{var s=eo(),c=z(s),l=V(c,2),u=z(l),d=V(z(u),2),f=z(d,!0);M(d),M(u);var p=V(u,2),m=V(z(p),2),h=z(m,!0);M(m),M(p);var g=V(p,2),_=V(z(g),2),v=z(_,!0);M(_),M(g);var y=V(g,2),b=V(z(y),2),x=z(b,!0);M(b),M(y),M(l);var S=V(l,2),C=V(S,2);Sn(C);var w=V(C,2),T=z(w,!0);M(w);var E=V(w,2),D=z(E),O=z(D,!0);M(D);var ee=V(D,2);M(E),M(s),H((e,i)=>{Q(s,`aria-labelledby`,`${n()}-title`),Q(c,`id`,`${n()}-title`),Y(f,t.attention.attention.reason),Y(h,t.attention.attention.summary),Y(v,t.attention.attention.requestedAction),Y(x,t.attention.attention.resumeCondition),Q(S,`for`,`${n()}-guidance`),Q(C,`id`,`${n()}-guidance`),Q(C,`aria-describedby`,`${n()}-guidance-help`),Q(C,`aria-invalid`,e),Q(w,`id`,`${n()}-guidance-help`),Y(T,G(o)||`Up to 600 characters. Do not include secrets.`),D.disabled=i,Y(O,r()?`Updating…`:`Resume`),ee.disabled=r()},[()=>!!G(o),()=>r()||!!G(o)]),Ni(C,()=>G(a),e=>L(a,e)),K(`click`,D,()=>G(a).trim()?i()(`resume`,G(a)):i()(`resume`)),K(`click`,ee,()=>i()(`disableAutopilot`)),J(e,s)};X(c,e=>{t.attention&&e(l)}),J(e,s),$e()}Pr([`click`]);var no=q(`<section class="safety-stop svelte-yp6bgs" role="alert"><h3 class="svelte-yp6bgs">Autopilot safety stop</h3> <p class="svelte-yp6bgs"> </p> <p class="svelte-yp6bgs"> </p> <div class="actions svelte-yp6bgs"><button type="button" class="svelte-yp6bgs"> </button> <button type="button" class="svelte-yp6bgs">Disable Autopilot</button></div></section>`);function ro(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-safety-stop`),r=$(t,`pending`,3,!1),i=$(t,`onrecover`,3,()=>{}),a=$(t,`ondisable`,3,()=>{}),o={attentionRequired:`The coordinator stopped because it needs a human safety decision, but no actionable agent request is available.`,noPlanProgress:`The coordinator stopped because recent automatic turns made no durable plan progress.`,reconcileFailed:`The coordinator stopped because it could not safely confirm the session state.`,startUnavailable:`The coordinator stopped because the session runtime was unavailable when it tried to start an automatic turn.`,actionRateExceeded:`The coordinator stopped because it reached the automatic-action safety limit.`},s=P(()=>t.autopilot?.reason&&!t.attention?o[t.autopilot.reason]??null:null),c=P(()=>t.autopilot?.reason===`startUnavailable`?`There is no pending agent attention request to answer. Restore or reopen this session, then retry Autopilot.`:t.autopilot?.reason===`actionRateExceeded`?`There is no pending agent attention request to answer. Wait for the ten-minute safety window to clear, or continue manually.`:`There is no pending agent attention request to answer. Retry the supported Autopilot coordinator after addressing the cause, or disable it.`);var l=Hr(),u=B(l),d=e=>{var t=no(),o=z(t),l=V(o,2),u=z(l,!0);M(l);var d=V(l,2),f=z(d,!0);M(d);var p=V(d,2),m=z(p),h=z(m,!0);M(m);var g=V(m,2);M(p),M(t),H(()=>{Q(t,`aria-labelledby`,`${n()}-title`),Q(o,`id`,`${n()}-title`),Y(u,G(s)),Y(f,G(c)),m.disabled=r(),Y(h,r()?`Updating…`:`Retry Autopilot`),g.disabled=r()}),K(`click`,m,function(...e){i()?.apply(this,e)}),K(`click`,g,function(...e){a()?.apply(this,e)}),J(e,t)};X(u,e=>{t.autopilot?.state===`attentionRequired`&&G(s)&&e(d)}),J(e,l),$e()}Pr([`click`]);function io(e,t=`gestalt-mobile.autopilot-attention-toasts.v1`,n=100){let r=ao(e,t,n);return{claim(i){if(r.has(i))return!1;r=new Set([...r,i].slice(-n));try{e?.setItem(t,JSON.stringify([...r]))}catch{}return!0}}}function ao(e,t,n){try{let r=JSON.parse(e?.getItem(t)??`[]`);return new Set(Array.isArray(r)?r.filter(e=>typeof e==`string`).slice(-n):[])}catch{return new Set}}var oo=[{name:`model`,description:`Choose the model for the next turn`,argumentPicker:`models`},{name:`reasoning`,description:`Choose reasoning effort for the next turn`,argumentPicker:`reasoning`}];function so(e){let t=e.match(/^\/([^\s]*)$/);return t?t[1].toLowerCase():null}function co(e){let t=so(e);return t===null?[]:oo.filter(e=>e.name.startsWith(t))}function lo(e){let t=e.match(/^\/([^\s]+)\s*$/)?.[1]?.toLowerCase();return oo.find(e=>e.name===t)?.argumentPicker}function uo(e){return[...e].sort((e,t)=>fo(t,e)||t.localeCompare(e))}function fo(e,t){let n=e.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[],r=t.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[];for(let e=0;e<Math.max(n.length,r.length);e+=1){let t=(n[e]??0)-(r[e]??0);if(t)return t}return 0}var po=q(`Ready <span class="block-cursor svelte-1264sfg" aria-hidden="true"></span>`,1),mo=q(`<p id="writer-hint" class="writer-hint svelte-1264sfg">You can read this conversation. Sending will connect to Codex.</p>`),ho=q(`<button type="button" class="svelte-1264sfg">Retry send</button>`),go=q(`<div class="writer-feedback svelte-1264sfg" role="alert" aria-atomic="true"><p class="svelte-1264sfg"> </p> <!></div>`),_o=q(`<li><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code> <small class="svelte-1264sfg"> </small></button></li>`),vo=q(`<ul id="chat-command-completion" class="command-menu svelte-1264sfg" aria-label="Chat commands"></ul>`),yo=q(`<li class="svelte-1264sfg"><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code></button></li>`),bo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Available models"></ul>`),xo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Reasoning efforts"></ul>`),So=q(`<div id="prompt-action-panel" class="action-panel svelte-1264sfg" aria-label="Prompt actions"><button type="button" class="svelte-1264sfg">Queue message</button> <button type="button" class="svelte-1264sfg">Interrupt and send</button></div>`),Co=q(`<div class="prompt-action svelte-1264sfg"><button type="button" aria-label="Choose prompt action" aria-controls="prompt-action-panel" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><circle cx="6" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="12" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="18" cy="12" r="1.5" class="svelte-1264sfg"></circle></svg></button> <!></div>`),wo=q(`<button type="button" aria-label="Interrupt" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="m7 7 10 10M17 7 7 17" class="svelte-1264sfg"></path></svg></button>`),To=q(`<button type="button" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="M9 10 5 14l4 4M5 14h8a6 6 0 0 0 6-6V6" class="svelte-1264sfg"></path></svg></button>`),Eo=q(`<form class="svelte-1264sfg"><p role="status" aria-live="polite" aria-atomic="true" class="svelte-1264sfg"><!></p> <!> <!> <!> <!> <!> <div class="prompt-row svelte-1264sfg"><textarea id="message" aria-label="Prompt" placeholder="Prompt" rows="1" required="" class="svelte-1264sfg"></textarea> <!></div></form>`);function Do(e,t){Qe(t,!0);let n=$(t,`detached`,3,!1),r=$(t,`retryMessage`,3,null),i=$(t,`retryable`,3,!1),a=$(t,`models`,19,()=>[]),o=$(t,`onscrollbottom`,3,()=>{}),s=$(t,`onmodelselect`,3,()=>{}),c=$(t,`onqueue`,3,()=>{}),l=$(t,`oninterruptsend`,3,()=>{}),u=$(t,`onretry`,3,()=>{}),d=I(0),f=I(null),p=I(!1),m=P(()=>co(t.message)),h=P(()=>so(t.message)),g=P(()=>G(h)!==null&&G(h)!==G(f)&&G(m).length>0),_=P(()=>lo(t.message)),v=P(()=>G(_)===`models`),y=P(()=>uo(a())),b=P(()=>G(_)===`reasoning`),x=P(()=>!t.activeTurnId&&!t.starting&&!!t.message.trim()),S=P(()=>!!t.message.trim()),C=P(()=>i()&&!r());function w(e){L(p,!1),e===`queue`?c()():l()()}function T(e,n=!1){L(f,null),L(d,0),t.onchange(e),n&&o()()}function E(e=G(d)){let t=G(m)[e];t&&T(`/${t.name} `,!0)}function D(e){if(e.key===`Enter`&&e.ctrlKey&&!e.isComposing){if(t.activeTurnId&&!t.starting&&G(S)){e.preventDefault(),w(`queue`);return}if(G(x)){e.preventDefault(),t.onsend();return}}if(G(g)){if(e.key===`ArrowDown`){e.preventDefault(),L(d,(G(d)+1)%G(m).length);return}if(e.key===`ArrowUp`){e.preventDefault(),L(d,(G(d)-1+G(m).length)%G(m).length);return}if(e.key===`Escape`){e.preventDefault(),L(f,G(h),!0);return}if(e.key===`Tab`){e.preventDefault(),E();return}}}var O=Eo(),ee=z(O),k=z(ee),te=e=>{var t=po();Ue(),J(e,t)},ne=e=>{var n=Vr();H(()=>Y(n,t.status)),J(e,n)};X(k,e=>{t.status===`Ready.`?e(te):e(ne,-1)}),M(ee);var re=V(ee,2),ie=e=>{J(e,mo())};X(re,e=>{n()&&e(ie)});var ae=V(re,2),oe=e=>{var n=go(),a=z(n),o=z(a,!0);M(a);var s=V(a,2),c=e=>{var n=ho();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){u()?.apply(this,e)}),J(e,n)};X(s,e=>{i()&&e(c)}),M(n),H(()=>Y(o,r())),J(e,n)};X(ae,e=>{r()&&e(oe)});var se=V(ae,2),ce=e=>{var t=vo();Z(t,23,()=>G(m),e=>e.name,(e,t,n)=>{var r=_o(),i=z(r),a=z(i),o=z(a);M(a);var s=V(a,2),c=z(s,!0);M(s),M(i),M(r),H(()=>{gi(r,1,ui(G(n)===G(d)?`command-selected`:void 0),`svelte-1264sfg`),Y(o,`/${G(t).name??``}`),Y(c,G(t).description)}),K(`click`,i,()=>E(G(n))),J(e,r)}),M(t),J(e,t)};X(se,e=>{G(g)&&e(ce)});var le=V(se,2),ue=e=>{var t=bo();Z(t,20,()=>G(y),e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>{s()(t),o()()}),J(e,n)}),M(t),J(e,t)};X(le,e=>{G(v)&&e(ue)});var de=V(le,2),fe=e=>{var t=xo();Z(t,20,()=>[`low`,`medium`,`high`],e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>T(`/reasoning ${t} `,!0)),J(e,n)}),M(t),J(e,t)};X(de,e=>{G(b)&&e(fe)});var pe=V(de,2),me=z(pe);Sn(me);var he=V(me,2),ge=e=>{var t=Co(),n=z(t),r=V(n,2),i=e=>{var t=So(),n=z(t),r=V(n,2);M(t),K(`click`,n,()=>w(`queue`)),K(`click`,r,()=>w(`interrupt-send`)),J(e,t)};X(r,e=>{G(p)&&e(i)}),M(t),H(()=>Q(n,`aria-expanded`,G(p))),K(`click`,n,()=>L(p,!G(p))),J(e,t)},_e=e=>{var n=wo();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){t.oninterrupt?.apply(this,e)}),J(e,n)},ve=e=>{var n=To();H(()=>{Q(n,`aria-label`,G(C)?`Retry send`:`Send prompt`),n.disabled=!G(x)}),K(`click`,n,function(...e){(G(C)?u():t.onsend)?.apply(this,e)}),J(e,n)};X(he,e=>{t.activeTurnId&&G(S)?e(ge):t.activeTurnId?e(_e,1):e(ve,-1)}),M(pe),M(O),H(()=>{Q(O,`aria-busy`,t.starting),Q(ee,`aria-label`,t.status),Oi(me,t.message),Q(me,`aria-describedby`,n()?`writer-hint`:void 0)}),K(`input`,me,e=>T(e.currentTarget.value)),K(`keydown`,me,D),J(e,O),$e()}Pr([`click`,`input`,`keydown`]);function Oo(e){let t=new Map;for(let n of e){if(!n.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))continue;let e=n.changes?.length?n.changes:n.detail.split(`
4
+ `).filter(Boolean).join(`, `):t}function ma(e){let t=e.match(/^\/bin\/bash -lc "([\s\S]*)"$/);return t?t[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`):e}var ha=q(`<dl class="command-counts svelte-thyolt"><div data-command-outcome="successful" class="svelte-thyolt"><dt class="svelte-thyolt">Successful commands</dt> <dd class="svelte-thyolt"> </dd></div> <div data-command-outcome="failed" class="svelte-thyolt"><dt class="svelte-thyolt">Failed commands</dt> <dd class="svelte-thyolt"> </dd></div></dl>`),ga=q(`<li class="activity-row svelte-thyolt"><small class="activity-type svelte-thyolt"> </small> <span class="activity-content svelte-thyolt"> </span></li>`),_a=q(`<ul class="activity-list svelte-thyolt"></ul>`),va=q(`<details class="chat-activity svelte-thyolt"><summary class="svelte-thyolt">activity</summary> <!> <!></details>`),ya=q(`<section class="live-activity svelte-thyolt" aria-label="Current activity"><strong class="svelte-thyolt">activity</strong> <!> <!></section>`);function ba(e,t){Qe(t,!0);let n=e=>{var t=ha(),n=z(t),r=V(z(n),2),i=z(r,!0);M(r),M(n);var a=V(n,2),o=V(z(a),2),c=z(o,!0);M(o),M(a),M(t),H(()=>{Y(i,G(s).successful),Y(c,G(s).failed)}),J(e,t)},r=e=>{var t=Hr(),n=B(t),r=e=>{var t=_a();Z(t,21,()=>G(c),e=>e.id,(e,t)=>{var n=ga(),r=z(n),i=z(r);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(e=>{Q(n,`data-activity-kind`,e),Q(n,`data-activity-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)},[()=>G(t).kind.toLowerCase().replaceAll(` `,`-`)]),J(e,n)}),M(t),J(e,t)};X(n,e=>{G(c).length&&e(r)}),J(e,t)},i=$(t,`variant`,3,`summary`),a=P(()=>t.activities.flatMap(e=>{let t=da(e);return t&&t.kind.toLowerCase().replaceAll(` `,``)!==`filechange`?[{id:e.id,...t}]:[]})),o=P(()=>G(a).some(e=>e.kind===`Command`)),s=P(()=>ua(t.activities)),c=P(()=>G(a).filter(e=>e.kind!==`Command`));var l=Hr(),u=B(l),d=e=>{var t=Hr(),a=B(t),s=e=>{var t=va(),i=V(z(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=V(i,2);r(s),M(t),J(e,t)},c=e=>{var t=ya(),i=V(z(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=V(i,2);r(s),M(t),J(e,t)};X(a,e=>{i()===`summary`?e(s):e(c,-1)}),J(e,t)};X(u,e=>{(G(o)||G(c).length)&&e(d)}),J(e,l),$e()}var xa=q(`<summary><!></summary>`),Sa=q(`<button><!></button>`);function Ca(e,t){let n=$(t,`element`,3,`button`),r=$(t,`type`,3,`button`),i=$(t,`disabled`,3,!1),a=$(t,`compact`,3,!1),o=$(t,`full`,3,!1),s=$(t,`primary`,3,!1),c=$(t,`accentPressed`,3,!1);var l=Hr(),u=B(l),d=e=>{var n=xa();ai(z(n),()=>t.children),M(n),H(()=>{Q(n,`id`,t.id),gi(n,1,ui([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`data-state`,t.state)}),J(e,n)},f=e=>{var n=Sa();ai(z(n),()=>t.children),M(n),H(()=>{Q(n,`id`,t.id),Q(n,`type`,r()),n.disabled=i(),gi(n,1,ui([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`aria-label`,t.label),Q(n,`aria-current`,t.current),Q(n,`aria-pressed`,t.pressed),Q(n,`aria-describedby`,t.describedby),Q(n,`aria-disabled`,t.ariaDisabled)}),K(`click`,n,function(...e){t.onclick?.apply(this,e)}),J(e,n)};X(u,e=>{n()===`summary`?e(d):e(f,-1)}),J(e,l)}Pr([`click`]);var wa=e=>({working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`})[e];function Ta(e,t){if(!t)return{polite:``,critical:``};let n=!e||e.root.state!==t.root.state||e.aggregateSubagents!==t.aggregateSubagents,r=t.root.state===`blocked`||t.root.state===`awaitingHuman`;return{polite:n?`l0 ${wa(t.root.state)}; subagents ${wa(t.aggregateSubagents)}.`:``,critical:r&&(!e||e.root.state!==t.root.state)?`l0 ${wa(t.root.state)}.`:``}}function Ea(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`recently`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`<1m`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);if(o<7)return`${o}d`;let s=Math.floor(o/7);if(s<5)return`${s}w`;let c=Math.floor(o/30);return c<12?`${c}mo`:`${Math.floor(o/365)}y`}var Da=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <span class="agent-metadata svelte-d9jh4j"> </span> <time class="svelte-d9jh4j"> </time></li>`),Oa=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j">l0</strong> <span class="agent-metadata svelte-d9jh4j"> </span> <span class="unavailable svelte-d9jh4j" role="status">activity unavailable</span></li>`),ka=q(`<details class="agents svelte-d9jh4j"><!> <ul class="svelte-d9jh4j"><!></ul></details>`),Aa=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <small class="svelte-d9jh4j"> </small></li>`),ja=q(`<div class="chips svelte-d9jh4j"><span class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">●</span> </span> <details class="children svelte-d9jh4j"><summary class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">◆</span> </summary> <ul class="svelte-d9jh4j"></ul></details> <span class="freshness svelte-d9jh4j"> </span></div>`),Ma=q(`<p class="visually-hidden svelte-d9jh4j" role="alert"> </p>`),Na=q(`<p class="visually-hidden svelte-d9jh4j" aria-live="polite" aria-atomic="true"> </p> <!>`,1),Pa=q(`<section aria-label="Agent activity"><!> <!></section>`);function Fa(e,t){Qe(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`popupAlign`,3,`end`),i=$(t,`onopen`,3,()=>{}),a={working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`},o={working:0,awaitingAgent:1,awaitingHuman:1,blocked:1,idle:2,disconnected:3},s=I(``),c=I(``),l=null,u=I(R(Date.now())),d=P(()=>t.activity?`${t.activity.sessionId}:${t.activity.root.state}:${t.activity.aggregateSubagents}`:``),f=P(()=>t.activity?[`blocked`,`awaitingHuman`,`disconnected`].includes(t.activity.root.state)?t.activity.root.state:t.activity.aggregateSubagents:`unavailable`);function p(e){return e.canonicalTaskName??e.canonicalPosition?.toLowerCase()??e.nickname??e.role??e.id}function m(){return`l0`}function h(e){return e===void 0?`(ctx: —)`:`(ctx: ${e}%)`}function g(e){let t=/^L([1-9]\d*)(?:\.([1-9]\d*))?$/.exec(e??``);return t?Number(t[1])*1e3+Number(t[2]??0):2**53-1}function _(e,t){return g(e.canonicalPosition)-g(t.canonicalPosition)||(e.continuationGeneration??1)-(t.continuationGeneration??1)||o[e.state]-o[t.state]||p(e).localeCompare(p(t))}let v=P(()=>t.activity?[{key:`root`,name:m(),planOrder:-1,generation:0,contextUsedPercent:t.activity.root.contextUsedPercent,role:`supervisor`,...t.rootModel?{model:t.rootModel}:{},state:t.activity.root.state,lastActivityAt:t.activity.root.lastActivityAt},...t.activity.subagents.map(e=>({key:`child:${e.id}`,name:p(e),planOrder:g(e.canonicalPosition),generation:e.continuationGeneration??1,contextUsedPercent:e.contextUsedPercent,...e.role?{role:e.role}:{},...e.model?{model:e.model}:{},state:e.state,lastActivityAt:e.lastActivityAt}))].sort((e,t)=>e.planOrder-t.planOrder||e.generation-t.generation||o[e.state]-o[t.state]||e.name.localeCompare(t.name)):[]),y=P(()=>t.activity?[...t.activity.subagents].sort(_):[]);Ri(()=>{let e=window.setInterval(()=>L(u,Date.now(),!0),6e4);return()=>window.clearInterval(e)});function b(e,t){let n=Ea(t,G(u));return e===`idle`||e===`disconnected`?`${a[e]} since ${n}`:`${a[e]} · active ${n} ago`}Mn(()=>{if(!G(d))return;let e=Er(()=>t.activity),n=Er(()=>l);if(!e)return;let r=Ta(n?.sessionId===e.sessionId?n:null,e);r.polite&&L(s,r.polite,!0),r.critical?L(c,r.critical,!0):e.root.state!==`blocked`&&e.root.state!==`awaitingHuman`&&L(c,``),l=e});var x=Pa();let S;var C=z(x),w=e=>{var n=ka(),r=z(n);Ca(r,{element:`summary`,compact:!0,full:!0,get state(){return G(f)},children:(e,n)=>{Ue();var r=Vr();H(()=>Y(r,`Agents (${(t.activity?.subagents.length??0)+1})`)),J(e,r)},$$slots:{default:!0}});var a=V(r,2),o=z(a),s=e=>{var t=Hr();Z(B(t),17,()=>G(v),e=>e.key,(e,t)=>{var n=Da(),r=z(n),i=z(r,!0);M(r);var a=V(r,2),o=z(a,!0);M(a);var s=V(a,2),c=z(s,!0);M(s),M(n),H((e,n)=>{Y(i,G(t).name),Y(o,e),Q(s,`datetime`,G(t).lastActivityAt),Y(c,n)},[()=>[h(G(t).contextUsedPercent),G(t).role,G(t).model?`Model: ${G(t).model}`:`Model unavailable`].filter(Boolean).join(` · `),()=>b(G(t).state,G(t).lastActivityAt)]),J(e,n)}),J(e,t)},c=e=>{var n=Oa(),r=V(z(n),2),i=z(r,!0);M(r),Ue(2),M(n),H(e=>Y(i,e),[()=>[`(ctx: —)`,`supervisor`,t.rootModel?`Model: ${t.rootModel}`:`Model unavailable`].filter(Boolean).join(` · `)]),J(e,n)};X(o,e=>{t.activity?e(s):e(c,-1)}),M(a),M(n),Nr(`toggle`,n,e=>e.currentTarget.open&&i()()),J(e,n)},T=e=>{var n=ja(),r=z(n),i=V(z(r));M(r);var o=V(r,2),s=z(o),c=V(z(s));M(s);var l=V(s,2);Z(l,21,()=>G(y),e=>e.id,(e,t)=>{var n=Aa(),r=z(n),i=z(r,!0);M(r);var o=V(r),s=V(o),c=z(s,!0);M(s),M(n),H((e,n)=>{Y(i,e),Y(o,` · ${n??``}${G(t).role?` · ${G(t).role}`:``}${G(t).model?` · Model: ${G(t).model}`:``} —
5
+ ${a[G(t).state]??``} `),Y(c,G(t).lastActivityAt)},[()=>p(G(t)),()=>h(G(t).contextUsedPercent)]),J(e,n)}),M(l),M(o);var u=V(o,2),d=z(u,!0);M(u),M(n),H(e=>{Q(r,`data-state`,t.activity.root.state),Y(i,` l0: ${a[t.activity.root.state]??``}
6
+ ${e??``}`),Q(s,`data-state`,t.activity.aggregateSubagents),Y(c,` Subagents: ${a[t.activity.aggregateSubagents]??``} (${t.activity.subagents.length??``})`),Y(d,t.activity.confidence===`fresh`?`Current`:t.activity.confidence===`reconciling`?`Checking updates`:`May be stale`)},[()=>h(t.activity.root.contextUsedPercent)]),J(e,n)};X(C,e=>{n()?e(w):t.activity&&e(T,1)});var E=V(C,2),D=e=>{var t=Na(),n=B(t),r=z(n,!0);M(n);var i=V(n,2),a=e=>{var t=Ma(),n=z(t,!0);M(t),H(()=>Y(n,G(c))),J(e,t)};X(i,e=>{G(c)&&e(a)}),H(()=>Y(r,G(s))),J(e,t)};X(E,e=>{t.activity&&e(D)}),M(x),H(()=>S=gi(x,1,`agent-activity svelte-d9jh4j`,null,S,{compact:n(),"align-start":r()===`start`})),J(e,x),$e()}Xe();var Ia=q(`<main class="svelte-iw6wrs"><h1 class="svelte-iw6wrs">Activity evidence</h1> <!><!></main>`);function La(e){let t={sessionId:`evidence`,confidence:`reconciling`,aggregateSubagents:`working`,root:{state:`awaitingAgent`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`},subagents:[{id:`α-worker`,nickname:`α worker`,role:`research`,state:`working`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`}]},n=[`working`,`awaitingAgent`,`awaitingHuman`,`blocked`,`idle`,`disconnected`];var r=Ia(),i=V(z(r),2);Fa(i,{get activity(){return t}}),Z(V(i),1,()=>n,e=>e,(e,n)=>{{let r=Tt(()=>({...t,sessionId:G(n),confidence:G(n)===`blocked`?`stale`:`fresh`,root:{...t.root,state:G(n)},aggregateSubagents:G(n)}));Fa(e,{get activity(){return G(r)}})}}),M(r),J(e,r)}function Ra(e,t){if(!e||typeof e!=`object`)return!1;let n=e,r=new Set([`working`,`idle`,`awaitingAgent`,`awaitingHuman`,`blocked`,`disconnected`]),i=(e,t=256)=>typeof e==`string`&&e.length<=t,a=e=>Array.isArray(e)&&e.length<=64&&e.every(e=>{let t=e;return t&&typeof t==`object`&&[`running`,`detached-active`,`exited-awaiting-result`,`result-consumed`,`terminated-for-budget`].includes(t.state)&&[`executor`,`supervisor`].includes(t.ownership)&&i(t.observedAt,64)&&!Number.isNaN(Date.parse(t.observedAt))}),o=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return i(t.state,32)&&r.has(t.state)&&i(t.observedAt,64)&&i(t.lastActivityAt,64)&&!Number.isNaN(Date.parse(t.observedAt))&&!Number.isNaN(Date.parse(t.lastActivityAt))&&(t.reason===void 0||i(t.reason,64))&&(t.contextUsedPercent===void 0||Number.isInteger(t.contextUsedPercent)&&t.contextUsedPercent>=0&&t.contextUsedPercent<=100)};return i(n.sessionId)&&(!t||n.sessionId===t)&&o(n.root)&&Array.isArray(n.subagents)&&n.subagents.length<=64&&n.subagents.every(e=>o(e)&&i(e.id)&&(e.nickname===void 0||i(e.nickname))&&(e.role===void 0||i(e.role))&&(e.model===void 0||i(e.model))&&(e.canonicalTaskName===void 0||i(e.canonicalTaskName))&&(e.canonicalPosition===void 0||i(e.canonicalPosition,32))&&(e.continuationGeneration===void 0||Number.isInteger(e.continuationGeneration)&&e.continuationGeneration>0)&&(e.outcome===void 0||[`partial`,`cancelled`,`failed`].includes(e.outcome))&&(e.ownedProcesses===void 0||a(e.ownedProcesses)))&&i(n.aggregateSubagents,32)&&r.has(n.aggregateSubagents)&&(n.confidence===`fresh`||n.confidence===`stale`||n.confidence===`reconciling`)}var za=class{#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=null;#l=!1;#u;constructor(e){this.#u={...e,websocket:e.websocket??(e=>new WebSocket(e)),location:e.location??location,setTimeout:e.setTimeout??setTimeout,clearTimeout:e.clearTimeout??clearTimeout}}get(e){return e?this.#e.get(e)??null:null}bootstrap(e,t){for(let t of e)!this.#e.has(t.id)&&Ra(t.agentActivity,t.id)&&this.#p(t.id,this.#t.get(t.id)??0,t.agentActivity);this.sync(e.map(e=>e.id),t)}sync(e,t){if(!this.#l){this.#c=t,this.#n=new Set(e);for(let e of this.#n)this.#i.has(e)||this.#i.set(e,0);for(let e of[...this.#i.keys()])this.#n.has(e)||this.remove(e);for(let[e,n]of this.#r)(e===t||!this.#n.has(e))&&(n.close(),this.#r.delete(e));for(let e of this.#n)this.hydrate(e),e!==t&&!this.#r.has(e)&&this.#f(e)}}select(e){this.sync([...this.#n],e)}remove(e){this.#n.delete(e),this.#i.set(e,(this.#i.get(e)??0)+1),this.#r.get(e)?.close(),this.#r.delete(e);let t=this.#a.get(e);t&&this.#u.clearTimeout(t),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#e.delete(e),this.#t.delete(e),this.#u.publish(this.#e)}observe(e,t){if(this.#l||!this.#n.has(e)||!Number.isInteger(t.sequence))return;let n=this.#t.get(e)??0;t.sequence<=n||(t.sequence>n+1&&(this.#t.set(e,t.sequence-1),this.resync(e)),this.#t.set(e,t.sequence),this.#u.onEvent?.(e,t),t.type===`agent.activity.updated`&&Ra(t.payload,e)&&this.#p(e,t.sequence,t.payload))}async hydrate(e){let t=this.#i.get(e)??0,n=this.#t.get(e)??0;try{let r=await this.#u.relay.getSession(e);if(!this.#d(e,t))return;let i=this.#t.get(e)??0,a=r.currentSequence;if(Number.isInteger(a)){if(a<i)return;this.#t.set(e,a),Ra(r.agentActivity,e)&&this.#p(e,a,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r)}else i===n&&Ra(r.agentActivity,e)&&(this.#p(e,i,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r))}catch{this.#m(e)}}async resync(e){let t=this.#o.get(e);if(t)return t;let n=this.#i.get(e)??0;this.#m(e);let r;return r=(async()=>{try{await this.#u.relay.refreshActivity(e),this.#d(e,n)&&await this.hydrate(e)}catch{}finally{this.#o.get(e)===r&&this.#o.delete(e)}})(),this.#o.set(e,r),r}dispose(){this.#l=!0;for(let e of[...this.#n])this.remove(e)}#d(e,t){return!this.#l&&this.#n.has(e)&&this.#i.get(e)===t}#f(e){let t=this.#i.get(e)??0,n=this.#u.location.protocol===`https:`?`wss:`:`ws:`,r=this.#u.websocket(`${n}//${this.#u.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#t.get(e)??0}`);this.#r.set(e,r),r.onmessage=n=>{if(!(!this.#d(e,t)||this.#r.get(e)!==r))try{this.#s.delete(e);let t=JSON.parse(String(n.data));t.type===`relay.resyncRequired`?this.resync(e):t.type===`relay.event`&&t.event&&this.observe(e,t.event)}catch{}},r.onclose=()=>{if(!this.#d(e,t)||this.#c===e)return;this.#r.delete(e),this.#m(e);let n=this.#s.get(e)??0,r=(this.#u.reconnectDelaysMs??[250,1e3,5e3])[n];r!==void 0&&(this.#s.set(e,n+1),this.#a.set(e,this.#u.setTimeout(()=>{this.#a.delete(e),this.#d(e,t)&&e!==this.#c&&this.#f(e)},r)))}}#p(e,t,n){let r=this.#e.get(e);this.#t.set(e,Math.max(t,this.#t.get(e)??0)),JSON.stringify(r)!==JSON.stringify(n)&&(this.#e.set(e,n),this.#u.publish(this.#e))}#m(e){let t=this.#e.get(e);t&&t.confidence===`fresh`&&(this.#e.set(e,{...t,confidence:`stale`}),this.#u.publish(this.#e))}};function Ba(e=globalThis.crypto,t=Date.now,n=Math.random){return typeof e?.randomUUID==`function`?e.randomUUID():`k-${t().toString(36)}-${Math.floor(n()*4294967296).toString(36)}`}var Va=(e,t=600)=>typeof e==`string`&&e.length<=t,Ha=e=>Va(e,64)&&!Number.isNaN(Date.parse(e));function Ua(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.enabled==`boolean`&&typeof t.state==`string`&&[`disabled`,`monitoring`,`backoff`,`attentionRequired`,`completed`,`safetyPaused`].includes(t.state)&&!!t.retry&&typeof t.retry==`object`&&Number.isInteger(t.retry.position)&&Number.isInteger(t.retry.limit)&&Va(t.updatedAt,64)&&(t.reason===void 0||Va(t.reason,80))&&(t.nextEvaluationAt===void 0||Va(t.nextEvaluationAt,64))&&(t.health===void 0||Wa(t.health))}function Wa(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.wait||typeof t.wait!=`object`)return!1;let n=t.wait;return typeof t.healthy==`boolean`&&typeof t.phase==`string`&&[`off`,`rootWorking`,`continuationScheduled`,`waitingForAgentEvent`,`checkingState`,`needsYou`,`safetyPaused`,`complete`,`degraded`].includes(t.phase)&&[`active`,`probeRequired`,`parked`,`retrying`,`attentionRequired`,`safetyPaused`,`none`].includes(t.supervision)&&typeof n.present==`boolean`&&Array.isArray(n.wakeCategories)&&n.wakeCategories.length<=9&&new Set(n.wakeCategories).size===n.wakeCategories.length&&n.wakeCategories.every(e=>[`planChanged`,`reviewChanged`,`checkpointChanged`,`interactionChanged`,`executorChanged`,`processExited`,`processResultAvailable`,`processLimitBreached`,`agentActivityChanged`].includes(e))&&(n.resumeAt===void 0||Ha(n.resumeAt))&&Ha(t.observedAt)&&Ha(t.lastTransitionAt)&&Va(t.nextExpectedAction)&&(t.degradationReason===void 0||[`missingContinuation`,`invalidWaitLease`,`controllerUnavailable`,`staleTransition`,`planMismatch`].includes(t.degradationReason))}function Ga(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.attention;if(!n||typeof n!=`object`)return!1;let r=n;return Va(t.requestId,256)&&(t.turnId===null||Va(t.turnId,256))&&(t.requestedAt===null||Va(t.requestedAt,64))&&Va(r.reason,64)&&Va(r.summary)&&Va(r.requestedAction)&&Va(r.resumeCondition,64)}function Ka(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`orgPlanAttention`&&Ga({requestId:t.requestId,turnId:t.turnId??null,requestedAt:t.requestedAt??null,attention:t.payload})}function qa(e){return{requestId:e.requestId,turnId:e.turnId,requestedAt:e.requestedAt,attention:e.payload}}var Ja=e=>{let t=e&&typeof e==`object`?e.code:void 0;return t===`AUTOPILOT_PLAN_REQUIRED`?`An incomplete supervised plan is required before Autopilot can start.`:t===`AUTOPILOT_PLAN_COMPLETE`?`This plan is complete, so Autopilot is unavailable.`:t===`AUTOPILOT_SESSION_UNAVAILABLE`?`This session is unavailable for Autopilot.`:e instanceof Error?e.message:`Could not update Autopilot.`},Ya=class{relay;publish;createKey;#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Set;#f=!1;constructor(e,t,n=Ba){this.relay=e,this.publish=t,this.createKey=n}bootstrap(e){if(this.#f)return;let t=new Set(e.map(e=>e.id));for(let e of this.#d)t.has(e)||this.remove(e);this.#d=t;for(let t of e){this.#i.has(t.id)||this.#i.set(t.id,0),this.#a.has(t.id)||this.#a.set(t.id,0);let e=this.#u.get(t.id)??0,n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#c.get(t.id);!this.#n.has(t.id)&&(r===void 0||n!==null&&n>r)&&(n!==null&&n>e||!this.#e.has(t.id)&&e===0)&&(n!==null&&(this.#u.set(t.id,n),r!==void 0&&n>r&&this.#c.delete(t.id)),this.#g(t.id,t))}this.#_()}observe(e,t){if(this.#f||!this.#d.has(e)||!Number.isInteger(t.sequence))return;let n=this.#u.get(e)??0;t.sequence<=n||(this.#u.set(e,t.sequence),this.#a.set(e,(this.#a.get(e)??0)+1),t.type===`autopilot.updated`&&this.#m(e,t.payload),t.type===`org-plan.attention-required`&&this.#h(e,t.payload),t.type===`org-plan.attention-resolved`&&(t.payload&&typeof t.payload==`object`&&t.payload.outcome,this.#t.delete(e)),this.#_())}async hydrate(e,t){let n=this.#i.get(e)??0,r=(this.#l.get(e)??0)+1;this.#l.set(e,r);let i=t??this.#u.get(e)??0,a=this.#o.get(e),o=this.#s.get(e)??0;try{let t=await this.relay.getSession(e);if(!this.#p(e,n)||this.#l.get(e)!==r||(this.#s.get(e)??0)!==o||this.#o.has(e)&&this.#o.get(e)!==a)return;let s=this.#u.get(e)??0,c=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null;c!==null&&c>s?(this.#u.set(e,c),this.#g(e,t)):c===null&&s===i&&this.#g(e,t),this.#_()}catch{}}async toggle(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=this.#i.get(e)??0,r=this.#a.get(e)??0;this.#o.set(e,(this.#o.get(e)??0)+1),this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{let i=await this.relay.setAutopilot(e,t,this.createKey());this.#p(e,n)&&this.#a.get(e)===r&&(this.#m(e,i.autopilot),this.#a.set(e,r+1),this.#c.set(e,this.#u.get(e)??0),Ua(i.autopilot)&&!i.autopilot.enabled&&this.#t.delete(e))}catch(t){this.#p(e,n)&&this.#a.get(e)===r&&this.#r.set(e,Ja(t))}finally{this.#p(e,n)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}async resolve(e,t,n){let r=this.#t.get(e);if(!r||this.#n.has(e)||this.#f)return;let i=n?.trim();if(i&&i.length>600){this.#r.set(e,`Guidance must be 600 characters or fewer.`),this.#_();return}let a=this.#i.get(e)??0,o=this.#a.get(e)??0;this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{await this.relay.resolveAttention(e,r.requestId,{operationKey:this.createKey(),action:t,...i?{guidance:i}:{}}),this.#p(e,a)&&this.#a.get(e)===o&&await this.hydrate(e)}catch(t){this.#p(e,a)&&this.#a.get(e)===o&&this.#r.set(e,t instanceof Error?t.message:`Could not resolve attention.`)}finally{this.#p(e,a)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}remove(e){this.#i.set(e,(this.#i.get(e)??0)+1),this.#d.delete(e),this.#e.delete(e),this.#t.delete(e),this.#n.delete(e),this.#r.delete(e),this.#u.delete(e),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#c.delete(e),this.#l.delete(e),this.#_()}dispose(){this.#f=!0,this.#d.clear(),this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#l.clear(),this.#a.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#_()}#p(e,t){return!this.#f&&this.#d.has(e)&&this.#i.get(e)===t}#m(e,t){Ua(t)&&this.#e.set(e,t)}#h(e,t){if(Ga(t))this.#t.set(e,t);else if(Ka(t))this.#t.set(e,qa(t));else if(Array.isArray(t)){let n=t.find(Ka);n?this.#t.set(e,qa(n)):this.#t.delete(e)}}applyAuthoritative(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#u.get(e)??0,i=this.#c.get(e);i!==void 0&&(n===null||n<=i)||n!==null&&n<r||(n!==null&&(this.#u.set(e,n),i!==void 0&&n>i&&this.#c.delete(e)),this.#g(e,t),this.#_())}#g(e,t){this.#a.set(e,(this.#a.get(e)??0)+1),this.#m(e,t.autopilot),this.#h(e,t.pendingInteractions)}#_(){this.publish({snapshots:new Map(this.#e),attention:new Map(this.#t),pending:new Set(this.#n),errors:new Map(this.#r)})}},Xa=q(`<span aria-hidden="true" class="svelte-1qf1ppf"> </span> `,1),Za=q(`<div class="control-row svelte-1qf1ppf"><span class="status svelte-1qf1ppf"><span aria-hidden="true" class="svelte-1qf1ppf"> </span> </span> <!></div>`),Qa=q(`<section aria-label="Autopilot"><p class="visually-hidden svelte-1qf1ppf" data-testid="autopilot-live-status" aria-live="polite" aria-atomic="true"> </p> <!> <p> </p></section>`);function $a(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-control`),r=$(t,`compact`,3,!1),i=$(t,`indicatorOnly`,3,!1),a=$(t,`pending`,3,!1),o=$(t,`ontoggle`,3,()=>{}),s={disabled:`Off`,monitoring:`Monitoring`,backoff:`Waiting to continue`,attentionRequired:`Paused for attention`,completed:`Complete`,safetyPaused:`Safety paused`},c={off:`Off`,rootWorking:`On · root working`,continuationScheduled:`On · continuation scheduled`,waitingForAgentEvent:`On · waiting for agent event`,checkingState:`On · checking state`,needsYou:`Paused · needs you`,safetyPaused:`Safety paused`,complete:`Complete`,degraded:`On · continuation unavailable`},l={planRequired:`An incomplete supervised plan is required before Autopilot can start.`,planComplete:`This plan is complete, so Autopilot is unavailable.`,sessionUnavailable:`This session is unavailable for Autopilot.`,attentionRequired:`Autopilot is paused because an agent is waiting for human input.`,noPlanProgress:`Autopilot paused because the plan did not make durable progress.`,reconcileFailed:`Autopilot paused because it could not safely confirm session state.`,startUnavailable:`Automatic continuation could not start because the session runtime is unavailable. Restore or reopen the session, then retry Autopilot.`,actionRateExceeded:`Autopilot paused after too many automatic actions in ten minutes. Wait for the safety window to clear, or continue manually.`,planRemoved:`The retained plan was removed.`,planReplaced:`The retained plan changed. Enable Autopilot again after reviewing it.`,sessionEnded:`This session ended.`,manualDisabled:`Autopilot is off.`,safetyPaused:`Autopilot paused after a repeated or invalid automatic continuation. Resume manually when ready.`},u=P(()=>t.autopilot?t.autopilot.health?c[t.autopilot.health.phase]:s[t.autopilot.state]:`Unavailable`),d=P(()=>t.autopilot?.state===`backoff`&&t.autopilot.retry.position>0&&t.autopilot.retry.limit>0?`Retry ${t.autopilot.retry.position} of ${t.autopilot.retry.limit}.`:null),f=P(()=>(t.autopilot?.reason?l[t.autopilot.reason]:null)??G(d)??t.autopilot?.health?.nextExpectedAction??(t.autopilot?.state===`monitoring`?`Autopilot is monitoring this supervised plan.`:t.autopilot?.state===`attentionRequired`?`Autopilot is paused because human attention is required.`:`Autopilot state is loading from the relay.`)),p=P(()=>`Autopilot status: ${G(u)}. ${G(f)}`),m=P(()=>t.autopilot?.enabled??!1);var h=Qa();let g;var _=z(h),v=z(_,!0);M(_);var y=V(_,2),b=e=>{{let t=P(()=>`${n()}-button`),r=P(()=>i()?`Autopilot: ${a()?`Updating`:G(u)}`:void 0),s=P(()=>`${n()}-help`);Ca(e,{get id(){return G(t)},compact:!0,full:!0,get pressed(){return G(m)},get accentPressed(){return i()},get label(){return G(r)},get describedby(){return G(s)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{var n=Hr(),r=B(n),o=e=>{J(e,Vr(`Autopilot`))},s=e=>{var t=Xa(),n=B(t),r=z(n,!0);M(n);var i=V(n);H(()=>{Y(r,G(m)?`●`:`○`),Y(i,` Autopilot: ${(a()?`Updating…`:G(u))??``}`)}),J(e,t)};X(r,e=>{i()?e(o):e(s,-1)}),J(e,n)},$$slots:{default:!0}})}},x=e=>{var r=Za(),i=z(r),s=z(i),c=z(s,!0);M(s);var l=V(s);M(i);var d=V(i,2);{let e=P(()=>`${n()}-button`),t=P(()=>`${n()}-help`);Ca(d,{get id(){return G(e)},get pressed(){return G(m)},get describedby(){return G(t)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{Ue();var n=Vr();H(()=>Y(n,a()?`Updating…`:G(m)?`Pause`:`Enable`)),J(e,n)},$$slots:{default:!0}})}M(r),H(()=>{Q(i,`data-state`,t.autopilot?.state??`unavailable`),Y(c,G(m)?`●`:`○`),Y(l,` Autopilot: ${G(u)??``}`)}),J(e,r)};X(y,e=>{r()?e(b):e(x,-1)});var S=V(y,2);let C;var w=z(S,!0);M(S),M(h),H(()=>{g=gi(h,1,`autopilot-control svelte-1qf1ppf`,null,g,{compact:r()}),Y(v,G(p)),Q(S,`id`,`${n()}-help`),C=gi(S,1,`svelte-1qf1ppf`,null,C,{"visually-hidden":r()}),Y(w,G(f))}),J(e,h),$e()}var eo=q(`<section class="attention svelte-1hnxk0w" role="alert"><h3 class="svelte-1hnxk0w">Autopilot needs your attention</h3> <dl class="svelte-1hnxk0w"><div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Reason</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">What happened</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Requested action</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Resume when</dt> <dd class="svelte-1hnxk0w"> </dd></div></dl> <label>Optional guidance for the resumed work</label> <textarea maxlength="600" class="svelte-1hnxk0w"></textarea> <p class="guidance-help svelte-1hnxk0w"> </p> <div class="actions svelte-1hnxk0w"><button type="button" class="svelte-1hnxk0w"> </button> <button type="button" class="svelte-1hnxk0w">Disable Autopilot</button></div></section>`);function to(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-attention`),r=$(t,`pending`,3,!1),i=$(t,`onresolve`,3,()=>{}),a=I(``),o=P(()=>G(a).trim().length>600?`Guidance must be 600 characters or fewer.`:``);var s=Hr(),c=B(s),l=e=>{var s=eo(),c=z(s),l=V(c,2),u=z(l),d=V(z(u),2),f=z(d,!0);M(d),M(u);var p=V(u,2),m=V(z(p),2),h=z(m,!0);M(m),M(p);var g=V(p,2),_=V(z(g),2),v=z(_,!0);M(_),M(g);var y=V(g,2),b=V(z(y),2),x=z(b,!0);M(b),M(y),M(l);var S=V(l,2),C=V(S,2);Sn(C);var w=V(C,2),T=z(w,!0);M(w);var E=V(w,2),D=z(E),O=z(D,!0);M(D);var ee=V(D,2);M(E),M(s),H((e,i)=>{Q(s,`aria-labelledby`,`${n()}-title`),Q(c,`id`,`${n()}-title`),Y(f,t.attention.attention.reason),Y(h,t.attention.attention.summary),Y(v,t.attention.attention.requestedAction),Y(x,t.attention.attention.resumeCondition),Q(S,`for`,`${n()}-guidance`),Q(C,`id`,`${n()}-guidance`),Q(C,`aria-describedby`,`${n()}-guidance-help`),Q(C,`aria-invalid`,e),Q(w,`id`,`${n()}-guidance-help`),Y(T,G(o)||`Up to 600 characters. Do not include secrets.`),D.disabled=i,Y(O,r()?`Updating…`:`Resume`),ee.disabled=r()},[()=>!!G(o),()=>r()||!!G(o)]),Ni(C,()=>G(a),e=>L(a,e)),K(`click`,D,()=>G(a).trim()?i()(`resume`,G(a)):i()(`resume`)),K(`click`,ee,()=>i()(`disableAutopilot`)),J(e,s)};X(c,e=>{t.attention&&e(l)}),J(e,s),$e()}Pr([`click`]);var no=q(`<section class="safety-stop svelte-yp6bgs" role="alert"><h3 class="svelte-yp6bgs">Autopilot safety stop</h3> <p class="svelte-yp6bgs"> </p> <p class="svelte-yp6bgs"> </p> <div class="actions svelte-yp6bgs"><button type="button" class="svelte-yp6bgs"> </button> <button type="button" class="svelte-yp6bgs">Disable Autopilot</button></div></section>`);function ro(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-safety-stop`),r=$(t,`pending`,3,!1),i=$(t,`onrecover`,3,()=>{}),a=$(t,`ondisable`,3,()=>{}),o={attentionRequired:`The coordinator stopped because it needs a human safety decision, but no actionable agent request is available.`,noPlanProgress:`The coordinator stopped because recent automatic turns made no durable plan progress.`,reconcileFailed:`The coordinator stopped because it could not safely confirm the session state.`,startUnavailable:`The coordinator stopped because the session runtime was unavailable when it tried to start an automatic turn.`,actionRateExceeded:`The coordinator stopped because it reached the automatic-action safety limit.`},s=P(()=>t.autopilot?.reason&&!t.attention?o[t.autopilot.reason]??null:null),c=P(()=>t.autopilot?.reason===`startUnavailable`?`There is no pending agent attention request to answer. Restore or reopen this session, then retry Autopilot.`:t.autopilot?.reason===`actionRateExceeded`?`There is no pending agent attention request to answer. Wait for the ten-minute safety window to clear, or continue manually.`:`There is no pending agent attention request to answer. Retry the supported Autopilot coordinator after addressing the cause, or disable it.`);var l=Hr(),u=B(l),d=e=>{var t=no(),o=z(t),l=V(o,2),u=z(l,!0);M(l);var d=V(l,2),f=z(d,!0);M(d);var p=V(d,2),m=z(p),h=z(m,!0);M(m);var g=V(m,2);M(p),M(t),H(()=>{Q(t,`aria-labelledby`,`${n()}-title`),Q(o,`id`,`${n()}-title`),Y(u,G(s)),Y(f,G(c)),m.disabled=r(),Y(h,r()?`Updating…`:`Retry Autopilot`),g.disabled=r()}),K(`click`,m,function(...e){i()?.apply(this,e)}),K(`click`,g,function(...e){a()?.apply(this,e)}),J(e,t)};X(u,e=>{t.autopilot?.state===`attentionRequired`&&G(s)&&e(d)}),J(e,l),$e()}Pr([`click`]);function io(e,t=`gestalt-mobile.autopilot-attention-toasts.v1`,n=100){let r=ao(e,t,n);return{claim(i){if(r.has(i))return!1;r=new Set([...r,i].slice(-n));try{e?.setItem(t,JSON.stringify([...r]))}catch{}return!0}}}function ao(e,t,n){try{let r=JSON.parse(e?.getItem(t)??`[]`);return new Set(Array.isArray(r)?r.filter(e=>typeof e==`string`).slice(-n):[])}catch{return new Set}}var oo=[{name:`model`,description:`Choose the model for the next turn`,argumentPicker:`models`},{name:`reasoning`,description:`Choose reasoning effort for the next turn`,argumentPicker:`reasoning`}];function so(e){let t=e.match(/^\/([^\s]*)$/);return t?t[1].toLowerCase():null}function co(e){let t=so(e);return t===null?[]:oo.filter(e=>e.name.startsWith(t))}function lo(e){let t=e.match(/^\/([^\s]+)\s*$/)?.[1]?.toLowerCase();return oo.find(e=>e.name===t)?.argumentPicker}function uo(e){return[...e].sort((e,t)=>fo(t,e)||t.localeCompare(e))}function fo(e,t){let n=e.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[],r=t.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[];for(let e=0;e<Math.max(n.length,r.length);e+=1){let t=(n[e]??0)-(r[e]??0);if(t)return t}return 0}var po=q(`Ready <span class="block-cursor svelte-1264sfg" aria-hidden="true"></span>`,1),mo=q(`<p id="writer-hint" class="writer-hint svelte-1264sfg">You can read this conversation. Sending will connect to Codex.</p>`),ho=q(`<button type="button" class="svelte-1264sfg">Retry send</button>`),go=q(`<div class="writer-feedback svelte-1264sfg" role="alert" aria-atomic="true"><p class="svelte-1264sfg"> </p> <!></div>`),_o=q(`<li><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code> <small class="svelte-1264sfg"> </small></button></li>`),vo=q(`<ul id="chat-command-completion" class="command-menu svelte-1264sfg" aria-label="Chat commands"></ul>`),yo=q(`<li class="svelte-1264sfg"><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code></button></li>`),bo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Available models"></ul>`),xo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Reasoning efforts"></ul>`),So=q(`<div id="prompt-action-panel" class="action-panel svelte-1264sfg" aria-label="Prompt actions"><button type="button" class="svelte-1264sfg">Queue message</button> <button type="button" class="svelte-1264sfg">Interrupt and send</button></div>`),Co=q(`<div class="prompt-action svelte-1264sfg"><button type="button" aria-label="Choose prompt action" aria-controls="prompt-action-panel" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><circle cx="6" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="12" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="18" cy="12" r="1.5" class="svelte-1264sfg"></circle></svg></button> <!></div>`),wo=q(`<button type="button" aria-label="Interrupt" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="m7 7 10 10M17 7 7 17" class="svelte-1264sfg"></path></svg></button>`),To=q(`<button type="button" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="M9 10 5 14l4 4M5 14h8a6 6 0 0 0 6-6V6" class="svelte-1264sfg"></path></svg></button>`),Eo=q(`<form class="svelte-1264sfg"><p role="status" aria-live="polite" aria-atomic="true" class="svelte-1264sfg"><!></p> <!> <!> <!> <!> <!> <div class="prompt-row svelte-1264sfg"><textarea id="message" aria-label="Prompt" placeholder="Prompt" rows="1" required="" class="svelte-1264sfg"></textarea> <!></div></form>`);function Do(e,t){Qe(t,!0);let n=$(t,`detached`,3,!1),r=$(t,`retryMessage`,3,null),i=$(t,`retryable`,3,!1),a=$(t,`models`,19,()=>[]),o=$(t,`onscrollbottom`,3,()=>{}),s=$(t,`onmodelselect`,3,()=>{}),c=$(t,`onqueue`,3,()=>{}),l=$(t,`oninterruptsend`,3,()=>{}),u=$(t,`onretry`,3,()=>{}),d=I(0),f=I(null),p=I(!1),m=P(()=>co(t.message)),h=P(()=>so(t.message)),g=P(()=>G(h)!==null&&G(h)!==G(f)&&G(m).length>0),_=P(()=>lo(t.message)),v=P(()=>G(_)===`models`),y=P(()=>uo(a())),b=P(()=>G(_)===`reasoning`),x=P(()=>!t.activeTurnId&&!t.starting&&!!t.message.trim()),S=P(()=>!!t.message.trim()),C=P(()=>i()&&!r());function w(e){L(p,!1),e===`queue`?c()():l()()}function T(e,n=!1){L(f,null),L(d,0),t.onchange(e),n&&o()()}function E(e=G(d)){let t=G(m)[e];t&&T(`/${t.name} `,!0)}function D(e){if(e.key===`Enter`&&e.ctrlKey&&!e.isComposing){if(t.activeTurnId&&!t.starting&&G(S)){e.preventDefault(),w(`queue`);return}if(G(x)){e.preventDefault(),t.onsend();return}}if(G(g)){if(e.key===`ArrowDown`){e.preventDefault(),L(d,(G(d)+1)%G(m).length);return}if(e.key===`ArrowUp`){e.preventDefault(),L(d,(G(d)-1+G(m).length)%G(m).length);return}if(e.key===`Escape`){e.preventDefault(),L(f,G(h),!0);return}if(e.key===`Tab`){e.preventDefault(),E();return}}}var O=Eo(),ee=z(O),k=z(ee),te=e=>{var t=po();Ue(),J(e,t)},ne=e=>{var n=Vr();H(()=>Y(n,t.status)),J(e,n)};X(k,e=>{t.status===`Ready.`?e(te):e(ne,-1)}),M(ee);var re=V(ee,2),ie=e=>{J(e,mo())};X(re,e=>{n()&&e(ie)});var ae=V(re,2),oe=e=>{var n=go(),a=z(n),o=z(a,!0);M(a);var s=V(a,2),c=e=>{var n=ho();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){u()?.apply(this,e)}),J(e,n)};X(s,e=>{i()&&e(c)}),M(n),H(()=>Y(o,r())),J(e,n)};X(ae,e=>{r()&&e(oe)});var se=V(ae,2),ce=e=>{var t=vo();Z(t,23,()=>G(m),e=>e.name,(e,t,n)=>{var r=_o(),i=z(r),a=z(i),o=z(a);M(a);var s=V(a,2),c=z(s,!0);M(s),M(i),M(r),H(()=>{gi(r,1,ui(G(n)===G(d)?`command-selected`:void 0),`svelte-1264sfg`),Y(o,`/${G(t).name??``}`),Y(c,G(t).description)}),K(`click`,i,()=>E(G(n))),J(e,r)}),M(t),J(e,t)};X(se,e=>{G(g)&&e(ce)});var le=V(se,2),ue=e=>{var t=bo();Z(t,20,()=>G(y),e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>{s()(t),o()()}),J(e,n)}),M(t),J(e,t)};X(le,e=>{G(v)&&e(ue)});var de=V(le,2),fe=e=>{var t=xo();Z(t,20,()=>[`low`,`medium`,`high`],e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>T(`/reasoning ${t} `,!0)),J(e,n)}),M(t),J(e,t)};X(de,e=>{G(b)&&e(fe)});var pe=V(de,2),me=z(pe);Sn(me);var he=V(me,2),ge=e=>{var t=Co(),n=z(t),r=V(n,2),i=e=>{var t=So(),n=z(t),r=V(n,2);M(t),K(`click`,n,()=>w(`queue`)),K(`click`,r,()=>w(`interrupt-send`)),J(e,t)};X(r,e=>{G(p)&&e(i)}),M(t),H(()=>Q(n,`aria-expanded`,G(p))),K(`click`,n,()=>L(p,!G(p))),J(e,t)},_e=e=>{var n=wo();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){t.oninterrupt?.apply(this,e)}),J(e,n)},ve=e=>{var n=To();H(()=>{Q(n,`aria-label`,G(C)?`Retry send`:`Send prompt`),n.disabled=!G(x)}),K(`click`,n,function(...e){(G(C)?u():t.onsend)?.apply(this,e)}),J(e,n)};X(he,e=>{t.activeTurnId&&G(S)?e(ge):t.activeTurnId?e(_e,1):e(ve,-1)}),M(pe),M(O),H(()=>{Q(O,`aria-busy`,t.starting),Q(ee,`aria-label`,t.status),Oi(me,t.message),Q(me,`aria-describedby`,n()?`writer-hint`:void 0)}),K(`input`,me,e=>T(e.currentTarget.value)),K(`keydown`,me,D),J(e,O),$e()}Pr([`click`,`input`,`keydown`]);function Oo(e){let t=new Map;for(let n of e){if(!n.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))continue;let e=n.changes?.length?n.changes:n.detail.split(`
7
7
  `).filter(Boolean).map(e=>({path:e,additions:null,deletions:null}));for(let r of e){let e=t.get(r.path),i=typeof r.additions==`number`&&typeof r.deletions==`number`;t.set(r.path,{path:r.path,additions:i&&e?.additions!==null?(e?.additions??0)+r.additions:null,deletions:i&&e?.deletions!==null?(e?.deletions??0)+r.deletions:null,...n.occurredAt===void 0?e?.touchedAt===void 0?{}:{touchedAt:e.touchedAt}:{touchedAt:Math.max(e?.touchedAt??0,n.occurredAt)}})}}return[...t.values()]}function ko(e){return{files:e.length,additions:e.every(e=>e.additions!==null)?e.reduce((e,t)=>e+t.additions,0):null,deletions:e.every(e=>e.deletions!==null)?e.reduce((e,t)=>e+t.deletions,0):null}}function Ao(e,t){if(e===void 0||t===void 0||!Number.isFinite(e)||!Number.isFinite(t))return null;let n=Math.floor(Math.max(0,t-e)/6e4);if(n<1)return`moments later`;if(n<60)return`${n} minute${n===1?``:`s`} later`;let r=Math.floor(n/60);if(r<24)return`${r} hour${r===1?``:`s`} later`;let i=Math.floor(r/24);return`${i} day${i===1?``:`s`} later`}function jo(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}).format(e)}function Mo(e,t){let n=Math.floor(Math.max(0,t-e)/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}var No=q(`<dl class="command-counts svelte-11ye6aj"><div class="svelte-11ye6aj"><dt class="svelte-11ye6aj">Successful commands</dt> <dd class="svelte-11ye6aj"> </dd></div> <div class="svelte-11ye6aj"><dt class="svelte-11ye6aj">Failed commands</dt> <dd class="svelte-11ye6aj"> </dd></div></dl>`),Po=q(`<li data-status="failed" class="svelte-11ye6aj"><code class="svelte-11ye6aj"> </code></li>`),Fo=q(`<section aria-label="Failed commands"><strong>Failed commands</strong> <ul class="activity-list svelte-11ye6aj"></ul></section>`),Io=q(`<li class="svelte-11ye6aj"><small class="svelte-11ye6aj"> </small> <span class="svelte-11ye6aj"> </span></li>`),Lo=q(`<ul class="activity-list svelte-11ye6aj" aria-label="Work activity"></ul>`),Ro=q(`<time class="svelte-11ye6aj"> </time>`),zo=q(`<span class="svelte-11ye6aj">time unknown</span>`),Bo=q(`<li class="svelte-11ye6aj"><code class="svelte-11ye6aj"> </code> <span class="file-counts svelte-11ye6aj" aria-label="Line changes"><span class="svelte-11ye6aj"> </span><span class="svelte-11ye6aj"> </span></span> <!></li>`),Vo=q(`<section aria-label="Files changed"><strong>Files changed</strong> <ul class="file-list svelte-11ye6aj"></ul></section>`),Ho=q(`<details class="work-details svelte-11ye6aj"><summary class="svelte-11ye6aj"> </summary> <div class="work-details-content svelte-11ye6aj"><!> <!> <!> <!></div></details>`);function Uo(e,t){Qe(t,!0);let n=$(t,`now`,19,()=>Date.now()),r=P(()=>ua(t.activities)),i=P(()=>t.activities.flatMap(e=>{let t=da(e);return t?.kind===`Command`&&t.status===`failed`?[{id:e.id,command:t.content}]:[]})),a=P(()=>Oo(t.activities)),o=P(()=>ko(G(a))),s=P(()=>t.activities.flatMap(e=>{let t=da(e);return t&&t.kind!==`Command`&&t.kind!==`File change`?[{id:e.id,...t}]:[]})),c=P(()=>t.activities.length),l=P(()=>G(a).length?`${G(o).files} ${G(o).files===1?`file`:`files`} changed · +${G(o).additions??`?`} −${G(o).deletions??`?`}`:`Work details · ${G(c)} ${G(c)===1?`activity`:`activities`}`);var u=Hr(),d=B(u),f=e=>{var t=Ho(),o=z(t),c=z(o,!0);M(o);var u=V(o,2),d=z(u),f=e=>{var t=No(),n=z(t),i=V(z(n),2),a=z(i,!0);M(i),M(n);var o=V(n,2),s=V(z(o),2),c=z(s,!0);M(s),M(o),M(t),H(()=>{Y(a,G(r).successful),Y(c,G(r).failed)}),J(e,t)};X(d,e=>{(G(r).successful||G(r).failed)&&e(f)});var p=V(d,2),m=e=>{var t=Fo(),n=V(z(t),2);Z(n,21,()=>G(i),e=>e.id,(e,t)=>{var n=Po(),r=z(n),i=z(r,!0);M(r),M(n),H(()=>Y(i,G(t).command)),J(e,n)}),M(n),M(t),J(e,t)};X(p,e=>{G(i).length&&e(m)});var h=V(p,2),g=e=>{var t=Lo();Z(t,21,()=>G(s),e=>e.id,(e,t)=>{var n=Io(),r=z(n),i=z(r);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(()=>{Q(n,`data-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)}),J(e,n)}),M(t),J(e,t)};X(h,e=>{G(s).length&&e(g)});var _=V(h,2),v=e=>{var t=Vo(),r=V(z(t),2);Z(r,21,()=>G(a),e=>e.path,(e,t)=>{var r=Bo(),i=z(r),a=z(i,!0);M(i);var o=V(i,2),s=z(o),c=z(s);M(s);var l=V(s),u=z(l);M(l),M(o);var d=V(o,2),f=e=>{var r=Ro(),i=z(r,!0);M(r),H((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t).touchedAt).toISOString(),()=>Mo(G(t).touchedAt,n())]),J(e,r)},p=e=>{J(e,zo())};X(d,e=>{G(t).touchedAt===void 0?e(p,-1):e(f)}),M(r),H(()=>{Y(a,G(t).path),Y(c,`+${G(t).additions??`?`??``}`),Y(u,`-${G(t).deletions??`?`??``}`)}),J(e,r)}),M(r),M(t),J(e,t)};X(_,e=>{G(a).length&&e(v)}),M(u),M(t),H(()=>Y(c,G(l))),J(e,t)};X(d,e=>{G(c)&&e(f)}),J(e,u),$e()}function Wo(e){if(!e||typeof e!=`object`)return null;let t=e.command;return typeof t==`string`&&t.trim()?t:null}function Go(e){if(!Ko(e))return null;let t=e.changes;if(!Array.isArray(t))return null;let n=t.map(e=>Ko(e)&&typeof e.path==`string`&&e.path.trim()?e.path:null).filter(e=>e!==null);return n.length===t.length&&n.length>0?n:null}function Ko(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var qo=q(`<div class="choice svelte-77f3gb"><input type="radio" class="svelte-77f3gb"/> <label class="svelte-77f3gb"><strong> </strong><span class="svelte-77f3gb"> </span></label></div>`),Jo=q(`<label class="custom svelte-77f3gb">Your custom answer <input required="" class="svelte-77f3gb"/></label>`),Yo=q(`<div class="choice svelte-77f3gb"><input type="radio" class="svelte-77f3gb"/> <label class="svelte-77f3gb"><strong>Custom answer</strong><span class="svelte-77f3gb">Provide your own response.</span></label></div> <!>`,1),Xo=q(`<fieldset class="svelte-77f3gb"><legend class="svelte-77f3gb"><strong> </strong><span class="svelte-77f3gb"> </span></legend> <div class="choices svelte-77f3gb"><!> <!></div></fieldset>`),Zo=q(`<form class="quiz-form svelte-77f3gb"><fieldset class="questions svelte-77f3gb"></fieldset> <button type="submit">Send answers</button></form>`);function Qo(e,t){Qe(t,!0);let n=$(t,`disabled`,3,!1),r=R({}),i=R({}),a=P(()=>t.quiz.questions.every(e=>!!t.answers[e.id]?.trim()));async function o(e){i[e]=!0,t.onanswer(e,t.answers[e]??``),await Cr(),r[e]?.focus()}var s=Zo(),c=z(s);Z(c,21,()=>t.quiz.questions,e=>e.id,(e,n)=>{let a=P(()=>`${t.requestId}-${G(n).id}-custom`),s=P(()=>G(n).choices.some(e=>e.label===t.answers[G(n).id]));var c=Xo(),l=z(c),u=z(l),d=z(u,!0);M(u);var f=V(u),p=z(f,!0);M(f),M(l);var m=V(l,2),h=z(m);Z(h,17,()=>G(n).choices,e=>`${G(n).id}-${e.label}`,(e,r)=>{let a=P(()=>`${t.requestId}-${G(n).id}-${G(r).label}`);var o=qo(),s=z(o);Di(s);var c=V(s,2),l=z(c),u=z(l,!0);M(l);var d=V(l),f=z(d,!0);M(d),M(c),M(o),H(()=>{Q(s,`id`,G(a)),Q(s,`name`,`${t.requestId}-${G(n).id}`),ki(s,t.answers[G(n).id]===G(r).label),Q(c,`for`,G(a)),Y(u,G(r).label),Y(f,G(r).description)}),K(`change`,s,()=>{i[G(n).id]=!1,t.onanswer(G(n).id,G(r).label)}),J(e,o)});var g=V(h,2),_=e=>{var c=Yo(),l=B(c),u=z(l);Di(u);var d=V(u,2);M(l);var f=V(l,2),p=e=>{var i=Jo(),o=V(z(i));Di(o),Li(o,(e,t)=>r[t.id]=e,e=>r?.[e.id],()=>[G(n)]),M(i),H(()=>{Q(i,`for`,`${G(a)}-text`),Q(o,`id`,`${G(a)}-text`),Q(o,`type`,G(n).isSecret?`password`:`text`),Oi(o,t.answers[G(n).id])}),K(`input`,o,e=>t.onanswer(G(n).id,e.currentTarget.value)),J(e,i)},m=P(()=>i[G(n).id]||!!t.answers[G(n).id]&&!G(s));X(f,e=>{G(m)&&e(p)}),H(e=>{Q(u,`id`,G(a)),Q(u,`name`,`${t.requestId}-${G(n).id}`),ki(u,e),Q(d,`for`,G(a))},[()=>i[G(n).id]||!!t.answers[G(n).id]&&!G(s)]),K(`change`,u,()=>o(G(n).id)),K(`click`,u,()=>{i[G(n).id]&&o(G(n).id)}),J(e,c)};X(g,e=>{G(n).allowCustom&&e(_)}),M(m),M(c),H(()=>{Y(d,G(n).header),Y(p,G(n).question)}),J(e,c)}),M(c);var l=V(c,2);M(s),H(()=>{c.disabled=n(),l.disabled=n()||!G(a)}),Nr(`submit`,s,e=>{e.preventDefault(),G(a)&&t.onsubmit()}),J(e,s),$e()}Pr([`change`,`click`,`input`]);function $o(e,t=2){if(!os(e)||!Array.isArray(e.questions)||e.questions.length<1||e.questions.length>8)return null;let n=e.questions.map(e=>ns(e,t));if(n.some(e=>e===null))return null;let r=n;return new Set(r.map(e=>e.id)).size===r.length?{questions:r}:null}function es(e){return!os(e)||!Array.isArray(e.questions)||e.questions.length>3?null:$o({questions:e.questions.map(e=>os(e)?{id:e.id,header:e.header,question:e.question,choices:e.options,allowCustom:e.isOther===!0,isSecret:e.isSecret===!0}:e)},1)}function ts(e){return{contentItems:[{type:`inputText`,text:JSON.stringify({answers:Object.fromEntries(e.filter(e=>e.answer.trim()).map(e=>[e.id,e.answer]))})}],success:!0}}function ns(e,t){if(!os(e)||!Array.isArray(e.choices)||e.choices.length<t||e.choices.length>5||!is(e.id)||!as(e.header,120)||!as(e.question,600)||typeof e.allowCustom!=`boolean`)return null;let n=e.choices.map(rs);return n.some(e=>e===null)?null:{id:e.id,header:e.header,question:e.question,choices:n,allowCustom:e.allowCustom,isSecret:e.isSecret===!0}}function rs(e){return!os(e)||!as(e.label,160)||!as(e.description,600)?null:{label:e.label,description:e.description}}function is(e){return typeof e==`string`&&/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)}function as(e,t){return typeof e==`string`&&e.trim().length>0&&e.length<=t}function os(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ss=q(`<p class="interaction-result svelte-ajsqcq" data-interaction-state="resolved" tabindex="-1"> </p>`),cs=q(`<p class="interaction-submitting svelte-ajsqcq" data-interaction-state="submitting">Submitting…</p>`),ls=q(`<p>Codex sent an invalid quiz request.</p>`),us=q(`<p>Grant the requested permissions for this turn only.</p> <button type="button">Approve</button>`,1),ds=q(`<pre class="command-approval-command svelte-ajsqcq"><code> </code></pre>`),fs=q(`<p class="command-approval-missing svelte-ajsqcq">Command details were not provided.</p>`),ps=q(`<p>Approve this command?</p> <!> <div class="approval-actions svelte-ajsqcq"><button type="button">Approve</button> <button type="button">Deny</button></div>`,1),ms=q(`<li><code> </code></li>`),hs=q(`<ul class="file-change-approval-targets svelte-ajsqcq" aria-label="Files to change"></ul>`),gs=q(`<p class="file-change-approval-missing svelte-ajsqcq">File details were not provided.</p>`),_s=q(`<p>Approve changes to these files?</p> <!> <div class="approval-actions svelte-ajsqcq"><button type="button">Approve</button> <button type="button">Deny</button></div>`,1),vs=q(`<button type="button">Approve</button><button type="button">Deny</button>`,1),ys=q(`<p class="interaction-failed svelte-ajsqcq" data-interaction-state="failed">Could not send. Try again.</p> <button type="button">Retry</button>`,1),bs=q(`<!> <!> <!>`,1),xs=q(`<li class="svelte-ajsqcq"><span class="submitted-question svelte-ajsqcq"><strong> </strong> </span> <span class="submitted-answer svelte-ajsqcq"> </span></li>`),Ss=q(`<section class="submitted-answers svelte-ajsqcq" aria-label="Submitted answers" aria-live="polite"><p class="svelte-ajsqcq"><strong>Submitted answers</strong></p> <ol class="svelte-ajsqcq"></ol> <p class="submitted-note svelte-ajsqcq">Recorded in this chat view before delivery.</p></section>`),Cs=q(`<article><p class="interaction-kind svelte-ajsqcq"> </p> <!> <!></article>`);function ws(e,t){Qe(t,!0);let n=$(t,`submittedAnswers`,19,()=>({})),r=$(t,`onretry`,3,()=>{}),i=I(null),a=R({}),o=e=>Object.fromEntries(Object.entries(t.answers).filter(([t])=>t.startsWith(`${e}:`)).map(([t,n])=>[t.slice(e.length+1),n]));function s(e,t){L(i,e.requestId,!0),t()}Mn(()=>{let e=t.interactions.find(e=>e.requestId===G(i));e?.state===`resolved`&&(Cr().then(()=>a[e.requestId]?.focus()),L(i,null))});var c=Hr();Z(B(c),17,()=>t.interactions,e=>e.key??e.requestId,(e,i)=>{let c=P(()=>G(i).state===`submitting`);var l=Cs();let u;var d=z(l),f=z(d,!0);M(d);var p=V(d,2),m=e=>{var t=ss(),n=z(t,!0);M(t),Li(t,(e,t)=>a[t.requestId]=e,e=>a?.[e.requestId],()=>[G(i)]),H(()=>Y(n,G(i).attemptedOutcome===`denied`?`Denied`:G(i).attemptedOutcome===`dismissed`?`No longer awaiting a response`:G(i).attemptedOutcome===`answered`?`Answers sent`:`Approved`)),J(e,t)},h=e=>{var n=bs(),a=B(n),l=e=>{J(e,cs())};X(a,e=>{G(c)&&e(l)});var u=V(a,2),d=e=>{let n=P(()=>G(i).kind===`quiz`?$o(G(i).payload):es(G(i).payload));var r=Hr(),a=B(r),l=e=>{{let r=P(()=>o(G(i).requestId));Qo(e,{get requestId(){return G(i).requestId},get quiz(){return G(n)},get answers(){return G(r)},get disabled(){return G(c)},onanswer:(e,n)=>t.onanswer(G(i).requestId,e,n),onsubmit:()=>s(G(i),()=>t.onquiz(G(i)))})}},u=e=>{J(e,ls())};X(a,e=>{G(n)?e(l):e(u,-1)}),J(e,r)},f=e=>{var n=us(),r=V(B(n),2);H(()=>r.disabled=G(c)),K(`click`,r,()=>s(G(i),()=>t.onpermission(G(i)))),J(e,n)},p=e=>{let n=P(()=>Wo(G(i).payload));var r=ps(),a=V(B(r),2),o=e=>{var t=ds(),r=z(t),i=z(r,!0);M(r),M(t),H(()=>Y(i,G(n))),J(e,t)},l=e=>{J(e,fs())};X(a,e=>{G(n)?e(o):e(l,-1)});var u=V(a,2),d=z(u),f=V(d,2);M(u),H(()=>{d.disabled=G(c),f.disabled=G(c)}),K(`click`,d,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,f,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,r)},m=e=>{let n=P(()=>Go(G(i).payload));var r=_s(),a=V(B(r),2),o=e=>{var t=hs();Z(t,20,()=>G(n),e=>e,(e,t)=>{var n=ms(),r=z(n),i=z(r,!0);M(r),M(n),H(()=>Y(i,t)),J(e,n)}),M(t),J(e,t)},l=e=>{J(e,gs())};X(a,e=>{G(n)?e(o):e(l,-1)});var u=V(a,2),d=z(u),f=V(d,2);M(u),H(()=>{d.disabled=G(c),f.disabled=G(c)}),K(`click`,d,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,f,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,r)},h=e=>{var n=vs(),r=B(n),a=V(r);H(()=>{r.disabled=G(c),a.disabled=G(c)}),K(`click`,r,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,a,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,n)};X(u,e=>{G(i).kind===`userInput`||G(i).kind===`quiz`?e(d):G(i).kind===`permissionsApproval`?e(f,1):G(i).kind===`commandApproval`?e(p,2):G(i).kind===`fileChangeApproval`?e(m,3):e(h,-1)});var g=V(u,2),_=e=>{var t=ys();K(`click`,V(B(t),2),()=>r()(G(i))),J(e,t)};X(g,e=>{G(i).state===`failed`&&e(_)}),J(e,n)};X(p,e=>{G(i).state===`resolved`?e(m):e(h,-1)});var g=V(p,2),_=e=>{var t=Ss(),r=V(z(t),2);Z(r,21,()=>n()[G(i).requestId],e=>e.id,(e,t)=>{var n=xs(),r=z(n),i=z(r),a=z(i,!0);M(i);var o=V(i);M(r);var s=V(r,2),c=z(s,!0);M(s),M(n),H(()=>{Y(a,G(t).header),Y(o,` — ${G(t).question??``}`),Y(c,G(t).answer)}),J(e,n)}),M(r),Ue(2),M(t),J(e,t)};X(g,e=>{n()[G(i).requestId]?.length&&e(_)}),M(l),H(()=>{u=gi(l,1,`svelte-ajsqcq`,null,u,{resolved:G(i).state===`resolved`}),Y(f,G(i).kind)}),J(e,l)}),J(e,c),$e()}Pr([`click`]);function Ts(e){let t=[],n=[],r=()=>{n.length&&(t.push({id:n.at(-1).id,kind:`assistant`,commentary:n.map(e=>e.text).join(`
8
8
 
9
9
  `),answer:null,...n.at(-1)?.turnId?{turnId:n.at(-1).turnId}:{},...n.at(-1)?.occurredAt===void 0?{}:{occurredAt:n.at(-1).occurredAt}}),n=[])};for(let i of e){if(i.role===`audit`){r(),t.push({id:i.id,kind:`audit`,text:i.text,...i.controlId?{controlId:i.controlId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},count:1,timestamps:i.occurredAt===void 0?[]:[i.occurredAt]});continue}if(i.role===`user`){r(),t.push({id:i.id,kind:`user`,text:i.text,...i.turnId?{turnId:i.turnId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt}});continue}if(i.phase===`commentary`){n.push(i);continue}t.push({id:i.id,kind:`assistant`,commentary:n.length?n.map(e=>e.text).join(`
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
16
16
  <link rel="icon" href="/icons/gestalt-mobile-192.png" />
17
17
  <link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
18
18
  <title>Gestalt Mobile</title>
19
- <script type="module" crossorigin src="/assets/index-nivA6-l4.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-BkQMGFPJ.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-CPQBJDsg.css">
21
21
  </head>
22
22
  <body>
@@ -36,7 +36,7 @@ import { RelaySession, } from './features/sessions/model/relay-session.js';
36
36
  import { AgentActivityRegistry } from './features/agent-activity/registry.js';
37
37
  import { toAgentActivityDto } from './features/agent-activity/activity-dto.js';
38
38
  import { decodeAgentActivityFacts } from './platform/codex/activity-facts.js';
39
- import { isAgentCapacityRecoveryCall, isAutopilotWaitLeaseCall, resolvedServerRequestId, toPendingInteraction, } from './platform/codex/server-request.js';
39
+ import { completedCommandId, isAgentCapacityRecoveryCall, isAutopilotWaitLeaseCall, resolvedServerRequestId, toPendingInteraction, } from './platform/codex/server-request.js';
40
40
  import { parseOrgPlanCheckpoint, toOrgPlanCheckpointToolResponse, } from '../shared/contracts/org-plan-checkpoint.js';
41
41
  import { validOrgPlanCheckpoint } from './features/org-plan-checkpoint/application/validate.js';
42
42
  import { isValidInteractionResponse, isValidQuizInteractionResponse, } from './features/sessions/interaction/response-validator.js';
@@ -437,6 +437,9 @@ export async function composeRelayApp(options) {
437
437
  ? { ...origin, kind: 'root' }
438
438
  : origin;
439
439
  const normalized = normalizeCodexNotification(sessionId, 0, occurredAt, notification, currentSession?.workspacePath, currentSession?.activeTurnId, resolvedOrigin);
440
+ const rootCommandId = resolvedOrigin.kind === 'root' ? completedCommandId(notification) : null;
441
+ if (rootCommandId)
442
+ autopilot.rootProcessCompleted(sessionId, rootCommandId);
440
443
  if (!normalized) {
441
444
  for (const activityFact of activityFacts)
442
445
  activity.observe(activityFact);
@@ -483,12 +486,19 @@ export async function composeRelayApp(options) {
483
486
  const lease = rawInteraction.payload;
484
487
  const rootOwned = origin.kind === 'root' && origin.physicalTurnId === session.activeTurnId;
485
488
  const accepted = rootOwned &&
486
- autopilot.reportProbe(sessionId, {
487
- id: lease.reportId,
488
- kind: 'wait',
489
- leaseId: lease.leaseId,
490
- wakeConditions: lease.wakeConditions,
491
- });
489
+ (lease.version === 2
490
+ ? autopilot.registerProactiveWait(sessionId, {
491
+ id: lease.reportId,
492
+ leaseId: lease.leaseId,
493
+ wakeConditions: lease.wakeConditions,
494
+ maxWaitMs: lease.maxWaitMs,
495
+ })
496
+ : autopilot.reportProbe(sessionId, {
497
+ id: lease.reportId,
498
+ kind: 'wait',
499
+ leaseId: lease.leaseId,
500
+ wakeConditions: lease.wakeConditions,
501
+ }));
492
502
  if (!accepted) {
493
503
  if (rootOwned)
494
504
  autopilot.rejectProbe(sessionId);
@@ -3,9 +3,9 @@
3
3
  * Designed by Denis Roio <jaromil@dyne.org>
4
4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5
5
  */
6
- export const AUTOPILOT_PROMPT_VERSION = 'v7';
7
- export const AUTOPILOT_CONTINUATION_PROMPT = 'Inspect the active supervised Org Plan. Refer to every L1 as L<a> and each nested L2 as L<a>.<b>, using one-based positions. For a subagent dedicated to that position, use the collaboration-safe task_name l<a> or l<a>_<b> and refer to it by its canonical L label. If the active L1 is still WIP and its executor stopped or is idle after a partial report or L2 checkpoint, call followup_task on that same executor before sending any response. Treat a status question as an interruption: answer briefly, then perform that continuation in the same turn. Before sending any blocker response or yielding because progress cannot continue safely, call gestalt_org_plan_attention for the matching decision-table blocker; never rely on blocker prose as the signal. Do not call it for routine progress or a recoverable failure. When the Autopilot probe is active, register gestalt_autopilot_wait_lease with an observable wake condition, declare genuine attention, or immediately do actionable work; never acknowledge waiting in prose. Do not send a status-only response.';
8
- export const AUTOPILOT_EXECUTOR_CONTINUATION_PROMPT = 'Continue the same assigned Org L1 from its durable state. A prior turn ending did not complete the objective. Consume any supplied process result, take the next legal L2 action, and report only at the L1 review boundary or through structured attention.';
6
+ export const AUTOPILOT_PROMPT_VERSION = 'v9';
7
+ export const AUTOPILOT_CONTINUATION_PROMPT = 'Inspect the active supervised Org Plan. Refer to every L1 as L<a> and each nested L2 as L<a>.<b>, using one-based positions. Spawn exactly one executor per L1 and pass the exact literal task_name l<a>: l1 for L1, l2 for L2, and so on. Never create an L2-specific task name or append a title, role, nickname, plan name, or generated label. A validated DONE L2 and an accepted L1 are mandatory answer boundaries. The corresponding gestalt_org_plan_checkpoint call must be the last tool call of that root turn: immediately emit exactly one boundary final and end the turn, without followup_task, review, executor launch, or later milestone work. On this later Autopilot turn, resume the same executor after an L2 boundary or launch the next executor after an accepted-L1 boundary. Treat a status question as an interruption: answer briefly, then perform the applicable continuation in the same turn. Before sending any blocker response or yielding because progress cannot continue safely, call gestalt_org_plan_attention for the matching decision-table blocker; never rely on blocker prose as the signal. Do not call it for routine progress or a recoverable failure. Before yielding for known long work, call gestalt_autopilot_wait_lease version 2 with relevant observable wake conditions and a bounded maxWaitMs; it is one episode, so reassess before registering another in a later turn. For GitHub PR CI, start an owned gh pr checks --watch process and lease processExited plus processResultAvailable while it runs. When the Autopilot probe is active, register the compatible wait lease, declare genuine attention, or immediately do actionable work; never acknowledge waiting in prose. Do not send a status-only response.';
8
+ export const AUTOPILOT_EXECUTOR_CONTINUATION_PROMPT = 'Continue the same assigned Org L1 from its durable state. A prior turn ending did not complete the objective. Consume any supplied process result and take the next legal L2 action. Whenever an L2 reaches DONE, return its concise structured evidence and end the executor turn so the root can publish that mandatory answer boundary. Also report at the L1 review boundary or through structured attention.';
9
9
  /** Builds a physical launch instruction while keeping durable L1 identity canonical. */
10
10
  export function autopilotExecutorLaunchPrompt(identity) {
11
11
  const launch = `Launch task_name ${identity.taskName} for canonical ${identity.canonicalPosition}; retain the canonical label in status and review output.`;
@@ -5,15 +5,17 @@
5
5
  */
6
6
  import { deriveSessionStatus } from '../../sessions/session-status.js';
7
7
  import { createHash } from 'node:crypto';
8
+ import { AUTOPILOT_WAIT_MAX_MS, AUTOPILOT_WAIT_MIN_MS, } from '../../../../shared/contracts/autopilot-wait-lease.js';
8
9
  import { autopilotSnapshot, disabledAutopilot, } from '../domain/autopilot-session.js';
9
10
  import { classifyExecutorOutcome, decideSupervisedLifecycle, executorIdentity, validStructuredBlock, } from '../domain/supervised-lifecycle.js';
10
11
  import { classifyAgentActivity, decideAutopilot, executionComplete, } from './policy.js';
11
- import { consumeObservableWake, recordAutomaticContinuation, recoverSafetyPause, reportProbe, semanticProgressKey, startSupervisionProtocol, } from '../domain/supervision-protocol.js';
12
+ import { consumeObservableWake, consumeWaitDeadline, recordAutomaticContinuation, recoverSafetyPause, registerProactiveWait as registerProtocolWait, reportProbe, semanticProgressKey, startSupervisionProtocol, } from '../domain/supervision-protocol.js';
12
13
  export class AutopilotCoordinator {
13
14
  deps;
14
15
  timers = new Map();
15
16
  completionTimers = new Map();
16
17
  executorTimers = new Map();
18
+ waitTimers = new Map();
17
19
  publishedSnapshots = new Map();
18
20
  planEventKeys = new Map();
19
21
  activityEventKeys = new Map();
@@ -75,6 +77,8 @@ export class AutopilotCoordinator {
75
77
  });
76
78
  if (state.supervision.waitLease && validated.health.wait.wakeCategories.length > 0) {
77
79
  this.parkedSubscriptions.set(sessionId, state.supervision.waitLease.id);
80
+ if (state.supervision.waitLease.resumeAt)
81
+ this.armWaitDeadline(sessionId, state.supervision.waitLease.id, state.supervision.waitLease.resumeAt);
78
82
  return;
79
83
  }
80
84
  this.parkedSubscriptions.delete(sessionId);
@@ -113,6 +117,7 @@ export class AutopilotCoordinator {
113
117
  }
114
118
  dispose(sessionId) {
115
119
  this.cancelTimer(sessionId);
120
+ this.cancelWaitTimer(sessionId);
116
121
  this.planEventKeys.delete(sessionId);
117
122
  this.activityEventKeys.delete(sessionId);
118
123
  this.reconciling.delete(sessionId);
@@ -123,8 +128,9 @@ export class AutopilotCoordinator {
123
128
  const state = this.deps.store.find(sessionId);
124
129
  if (!state?.requestedEnabled)
125
130
  return false;
126
- const nextProtocol = reportProbe(state.supervision ?? startSupervisionProtocol(this.progressKey(sessionId)), report);
127
- if (nextProtocol === state.supervision)
131
+ const protocol = state.supervision ?? startSupervisionProtocol(this.progressKey(sessionId));
132
+ const nextProtocol = reportProbe(protocol, report);
133
+ if (nextProtocol === protocol)
128
134
  return false;
129
135
  if (nextProtocol.outcome === 'parked' && nextProtocol.waitLease)
130
136
  this.parkedSubscriptions.set(sessionId, nextProtocol.waitLease.id);
@@ -147,6 +153,38 @@ export class AutopilotCoordinator {
147
153
  this.cancelTimer(sessionId);
148
154
  return true;
149
155
  }
156
+ /** Parks one explicitly requested long wait without changing future pulse policy. */
157
+ registerProactiveWait(sessionId, report) {
158
+ const state = this.deps.store.find(sessionId);
159
+ if (!state?.requestedEnabled ||
160
+ !Number.isSafeInteger(report.maxWaitMs) ||
161
+ report.maxWaitMs < AUTOPILOT_WAIT_MIN_MS ||
162
+ report.maxWaitMs > AUTOPILOT_WAIT_MAX_MS)
163
+ return false;
164
+ const now = this.deps.now();
165
+ const resumeAt = new Date(Date.parse(now) + report.maxWaitMs).toISOString();
166
+ const protocol = state.supervision ?? startSupervisionProtocol(this.progressKey(sessionId));
167
+ const nextProtocol = registerProtocolWait(protocol, { ...report, resumeAt });
168
+ if (nextProtocol === protocol)
169
+ return false;
170
+ const cancelled = this.cancelScheduledControl(state, now);
171
+ this.timers.get(sessionId)?.();
172
+ this.timers.delete(sessionId);
173
+ this.completionTimers.get(sessionId)?.();
174
+ this.completionTimers.delete(sessionId);
175
+ this.parkedSubscriptions.set(sessionId, report.leaseId);
176
+ this.persist({
177
+ ...state,
178
+ state: 'monitoring',
179
+ generation: state.generation + (cancelled ? 1 : 0),
180
+ nextEvaluationAt: null,
181
+ ...(cancelled ? { lastControlId: null } : {}),
182
+ supervision: nextProtocol,
183
+ updatedAt: now,
184
+ }, cancelled);
185
+ this.armWaitDeadline(sessionId, report.leaseId, resumeAt);
186
+ return true;
187
+ }
150
188
  /** Fails closed only for the currently active bounded probe. */
151
189
  rejectProbe(sessionId) {
152
190
  const state = this.deps.store.find(sessionId);
@@ -187,6 +225,7 @@ export class AutopilotCoordinator {
187
225
  const nextProtocol = consumeObservableWake(state.supervision, wake);
188
226
  if (nextProtocol === state.supervision)
189
227
  return false;
228
+ this.cancelWaitTimer(sessionId);
190
229
  this.parkedSubscriptions.delete(sessionId);
191
230
  this.persist({ ...state, supervision: nextProtocol, updatedAt: this.deps.now() });
192
231
  this.evaluate(sessionId);
@@ -203,6 +242,23 @@ export class AutopilotCoordinator {
203
242
  progressKey: this.progressKey(sessionId),
204
243
  });
205
244
  }
245
+ /** Bridges a completed root-owned background command into its one active wait episode. */
246
+ rootProcessCompleted(sessionId, processId) {
247
+ const lease = this.deps.store.find(sessionId)?.supervision?.waitLease;
248
+ if (!lease || !processId || processId.length > 256)
249
+ return false;
250
+ const condition = lease.wakeConditions.includes('processResultAvailable')
251
+ ? 'processResultAvailable'
252
+ : lease.wakeConditions.includes('processExited')
253
+ ? 'processExited'
254
+ : null;
255
+ if (!condition)
256
+ return false;
257
+ const progressKey = createHash('sha256')
258
+ .update(`${this.progressKey(sessionId)}\0root-process\0${processId}`)
259
+ .digest('hex');
260
+ return this.observableWake(sessionId, { leaseId: lease.id, condition, progressKey });
261
+ }
206
262
  enable(sessionId) {
207
263
  const session = this.deps.session(sessionId);
208
264
  if (!session || !session.threadId || !['ready', 'turnActive'].includes(session.state))
@@ -216,6 +272,8 @@ export class AutopilotCoordinator {
216
272
  const prior = this.deps.store.find(sessionId) ?? disabledAutopilot(sessionId, now);
217
273
  const nextFingerprint = fingerprint(currentPlan.plan);
218
274
  const replacing = Boolean(prior.planIdentity && prior.planIdentity !== currentPlan.identity);
275
+ if (replacing)
276
+ this.cancelWaitTimer(sessionId);
219
277
  if (prior.requestedEnabled &&
220
278
  prior.planIdentity === currentPlan.identity &&
221
279
  prior.state !== 'attentionRequired')
@@ -273,6 +331,7 @@ export class AutopilotCoordinator {
273
331
  };
274
332
  this.persist(next, cancelled);
275
333
  this.cancelTimer(sessionId);
334
+ this.cancelWaitTimer(sessionId);
276
335
  return this.snapshot(sessionId);
277
336
  }
278
337
  cancel(sessionId, reason) {
@@ -293,6 +352,7 @@ export class AutopilotCoordinator {
293
352
  updatedAt: now,
294
353
  }, cancelled);
295
354
  this.cancelTimer(sessionId);
355
+ this.cancelWaitTimer(sessionId);
296
356
  }
297
357
  evaluate(sessionId) {
298
358
  const prior = this.deps.store.find(sessionId);
@@ -607,8 +667,10 @@ export class AutopilotCoordinator {
607
667
  return this.snapshot(sessionId);
608
668
  const replacing = Boolean(prior.planIdentity && prior.planIdentity !== currentPlan.identity);
609
669
  const cancelled = replacing ? this.cancelScheduledControl(prior, now) : undefined;
610
- if (replacing)
670
+ if (replacing) {
611
671
  this.cancelTimer(sessionId);
672
+ this.cancelWaitTimer(sessionId);
673
+ }
612
674
  const next = {
613
675
  ...prior,
614
676
  state: 'monitoring',
@@ -894,6 +956,27 @@ export class AutopilotCoordinator {
894
956
  this.executorTimers.get(sessionId)?.();
895
957
  this.executorTimers.delete(sessionId);
896
958
  }
959
+ cancelWaitTimer(sessionId) {
960
+ this.waitTimers.get(sessionId)?.();
961
+ this.waitTimers.delete(sessionId);
962
+ }
963
+ armWaitDeadline(sessionId, leaseId, resumeAt) {
964
+ this.cancelWaitTimer(sessionId);
965
+ this.waitTimers.set(sessionId, this.deps.schedule(() => {
966
+ this.waitTimers.delete(sessionId);
967
+ const state = this.deps.store.find(sessionId);
968
+ if (!state?.requestedEnabled || !state.supervision)
969
+ return;
970
+ const protocol = consumeWaitDeadline(state.supervision, leaseId, this.deps.now());
971
+ if (protocol === state.supervision) {
972
+ this.armWaitDeadline(sessionId, leaseId, resumeAt);
973
+ return;
974
+ }
975
+ this.parkedSubscriptions.delete(sessionId);
976
+ this.persist({ ...state, supervision: protocol, updatedAt: this.deps.now() });
977
+ this.evaluate(sessionId);
978
+ }, Math.max(0, Date.parse(resumeAt) - Date.parse(this.deps.now()))));
979
+ }
897
980
  async enforceSupervisedLifecycle(sessionId, event) {
898
981
  const controller = this.deps.executorController;
899
982
  const retained = this.deps.plan(sessionId);
@@ -95,6 +95,9 @@ export function autopilotSnapshot(state, retryLimit, facts = {
95
95
  wait: {
96
96
  present: Boolean(state.supervision?.waitLease),
97
97
  wakeCategories: [...waitCategories].slice(0, 9),
98
+ ...(state.supervision?.waitLease?.resumeAt
99
+ ? { resumeAt: state.supervision.waitLease.resumeAt }
100
+ : {}),
98
101
  },
99
102
  observedAt: facts.observedAt,
100
103
  lastTransitionAt: state.updatedAt,
@@ -85,6 +85,29 @@ export function recordAutomaticContinuation(state, progressKey) {
85
85
  return { ...state, unchangedContinuations, outcome: 'probeRequired', probeKey: progressKey };
86
86
  return { ...state, unchangedContinuations };
87
87
  }
88
+ /** Registers one explicit long-wait episode without changing future pulse policy. */
89
+ export function registerProactiveWait(state, report) {
90
+ if (state.lastReportId === report.id ||
91
+ state.outcome === 'parked' ||
92
+ state.outcome === 'attentionRequired' ||
93
+ state.outcome === 'safetyPaused' ||
94
+ !Number.isFinite(Date.parse(report.resumeAt)))
95
+ return state;
96
+ const wakeConditions = uniqueSupportedWakeConditions(report.wakeConditions);
97
+ if (!report.leaseId || wakeConditions.length === 0)
98
+ return state;
99
+ return {
100
+ ...state,
101
+ outcome: 'parked',
102
+ lastReportId: report.id,
103
+ waitLease: {
104
+ id: report.leaseId,
105
+ probeKey: state.progressKey,
106
+ wakeConditions,
107
+ resumeAt: report.resumeAt,
108
+ },
109
+ };
110
+ }
88
111
  /** Accepts only structured, bounded probe reports. Unsupported waits fail closed. */
89
112
  export function reportProbe(state, report) {
90
113
  if (state.lastReportId === report.id)
@@ -117,6 +140,11 @@ export function consumeObservableWake(state, wake) {
117
140
  !lease.wakeConditions.includes(wake.condition) ||
118
141
  wake.progressKey === lease.probeKey)
119
142
  return state;
143
+ if (lease.resumeAt)
144
+ return {
145
+ ...startSupervisionProtocol(wake.progressKey),
146
+ lastReportId: state.lastReportId,
147
+ };
120
148
  return {
121
149
  ...state,
122
150
  outcome: 'retrying',
@@ -127,6 +155,20 @@ export function consumeObservableWake(state, wake) {
127
155
  retryKey: wake.progressKey,
128
156
  };
129
157
  }
158
+ /** A proactive deadline consumes only its matching episode and restores normal policy. */
159
+ export function consumeWaitDeadline(state, leaseId, observedAt) {
160
+ const lease = state.waitLease;
161
+ if (state.outcome !== 'parked' ||
162
+ !lease?.resumeAt ||
163
+ lease.id !== leaseId ||
164
+ !Number.isFinite(Date.parse(observedAt)) ||
165
+ Date.parse(observedAt) < Date.parse(lease.resumeAt))
166
+ return state;
167
+ return {
168
+ ...startSupervisionProtocol(state.progressKey),
169
+ lastReportId: state.lastReportId,
170
+ };
171
+ }
130
172
  /** Manual recovery is the only transition out of durable safety pause. */
131
173
  export function recoverSafetyPause(state, progressKey) {
132
174
  return state.outcome === 'safetyPaused' ? startSupervisionProtocol(progressKey) : state;
@@ -197,7 +239,16 @@ function parseWaitLease(value) {
197
239
  !Array.isArray(candidate.wakeConditions))
198
240
  return undefined;
199
241
  const wakeConditions = uniqueSupportedWakeConditions(candidate.wakeConditions);
200
- return wakeConditions.length === candidate.wakeConditions.length
201
- ? { id: candidate.id, probeKey: candidate.probeKey, wakeConditions }
202
- : undefined;
242
+ if (wakeConditions.length !== candidate.wakeConditions.length)
243
+ return undefined;
244
+ const resumeAt = candidate.resumeAt;
245
+ if (resumeAt !== undefined &&
246
+ (typeof resumeAt !== 'string' || !Number.isFinite(Date.parse(resumeAt))))
247
+ return undefined;
248
+ return {
249
+ id: candidate.id,
250
+ probeKey: candidate.probeKey,
251
+ wakeConditions,
252
+ ...(typeof resumeAt === 'string' ? { resumeAt } : {}),
253
+ };
203
254
  }
@@ -53,6 +53,17 @@ export function resolvedServerRequestId(input) {
53
53
  return null;
54
54
  return String(requestId);
55
55
  }
56
+ /** Returns only the bounded identity of a completed command item. Ownership is checked by caller. */
57
+ export function completedCommandId(input) {
58
+ if (input.method !== 'item/completed' || !isRecord(input.params))
59
+ return null;
60
+ const item = input.params.item;
61
+ if (!isRecord(item) || item.type !== 'commandExecution')
62
+ return null;
63
+ return typeof item.id === 'string' && item.id.length > 0 && item.id.length <= 256
64
+ ? item.id
65
+ : null;
66
+ }
56
67
  export function isAutopilotWaitLeaseCall(input) {
57
68
  return (Number.isSafeInteger(input.id) &&
58
69
  input.method === 'item/tool/call' &&
@@ -15,16 +15,18 @@ export const autopilotWaitWakeConditions = [
15
15
  'processLimitBreached',
16
16
  'agentActivityChanged',
17
17
  ];
18
+ export const AUTOPILOT_WAIT_MIN_MS = 60_000;
19
+ export const AUTOPILOT_WAIT_MAX_MS = 86_400_000;
18
20
  export const gestaltAutopilotWaitLeaseDynamicTool = {
19
21
  type: 'function',
20
22
  name: GESTALT_AUTOPILOT_WAIT_LEASE_TOOL_NAME,
21
- description: 'Register a bounded observable wait for the current supervised session after an Autopilot probe. This cannot request human authority and never accepts transcript prose.',
23
+ description: 'Register one non-persistent Autopilot wait episode for the current supervised session. Version 2 may be called proactively for known long work and resumes on the first requested event or bounded maxWaitMs deadline; call it again in a later turn only if another long wait is justified. This cannot request human authority and never accepts transcript prose.',
22
24
  inputSchema: {
23
25
  type: 'object',
24
26
  additionalProperties: false,
25
27
  required: ['version', 'reportId', 'leaseId', 'wakeConditions'],
26
28
  properties: {
27
- version: { const: 1 },
29
+ version: { type: 'integer', enum: [1, 2] },
28
30
  reportId: { type: 'string', minLength: 1, maxLength: 128 },
29
31
  leaseId: { type: 'string', minLength: 1, maxLength: 128 },
30
32
  wakeConditions: {
@@ -34,11 +36,20 @@ export const gestaltAutopilotWaitLeaseDynamicTool = {
34
36
  uniqueItems: true,
35
37
  items: { type: 'string', enum: autopilotWaitWakeConditions },
36
38
  },
39
+ maxWaitMs: {
40
+ type: 'integer',
41
+ minimum: AUTOPILOT_WAIT_MIN_MS,
42
+ maximum: AUTOPILOT_WAIT_MAX_MS,
43
+ description: 'Version 2 safety deadline in milliseconds. An observable wake resumes earlier.',
44
+ },
37
45
  },
38
46
  },
39
47
  };
40
48
  export function parseAutopilotWaitLease(value) {
41
- if (!record(value) || Object.keys(value).length !== 4 || value.version !== 1)
49
+ if (!record(value) || (value.version !== 1 && value.version !== 2))
50
+ return null;
51
+ const expectedKeys = value.version === 1 ? 4 : 5;
52
+ if (Object.keys(value).length !== expectedKeys)
42
53
  return null;
43
54
  if (!bounded(value.reportId) || !bounded(value.leaseId) || !Array.isArray(value.wakeConditions))
44
55
  return null;
@@ -49,7 +60,19 @@ export function parseAutopilotWaitLease(value) {
49
60
  !wakeConditions.every((condition) => typeof condition === 'string' &&
50
61
  autopilotWaitWakeConditions.includes(condition)))
51
62
  return null;
52
- return { version: 1, reportId: value.reportId, leaseId: value.leaseId, wakeConditions };
63
+ if (value.version === 1)
64
+ return { version: 1, reportId: value.reportId, leaseId: value.leaseId, wakeConditions };
65
+ if (!Number.isSafeInteger(value.maxWaitMs) ||
66
+ value.maxWaitMs < AUTOPILOT_WAIT_MIN_MS ||
67
+ value.maxWaitMs > AUTOPILOT_WAIT_MAX_MS)
68
+ return null;
69
+ return {
70
+ version: 2,
71
+ reportId: value.reportId,
72
+ leaseId: value.leaseId,
73
+ wakeConditions,
74
+ maxWaitMs: value.maxWaitMs,
75
+ };
53
76
  }
54
77
  export function autopilotWaitLeaseToolResponse() {
55
78
  return { success: true, contentItems: [{ type: 'inputText', text: '{"accepted":true}' }] };
@@ -177,7 +177,15 @@ export function parseOrgPlanCheckpoint(value) {
177
177
  }
178
178
  /** Acknowledgement deliberately contains no plan path, findings, or model text. */
179
179
  export function toOrgPlanCheckpointToolResponse() {
180
- return { success: true, contentItems: [{ type: 'inputText', text: '{"accepted":true}' }] };
180
+ return {
181
+ success: true,
182
+ contentItems: [
183
+ {
184
+ type: 'inputText',
185
+ text: '{"accepted":true,"next":"emitBoundaryFinalAndEndTurn","allowFurtherTools":false}',
186
+ },
187
+ ],
188
+ };
181
189
  }
182
190
  function isPosition(value) {
183
191
  return typeof value === 'string' && /^L[1-9][0-9]*$/.test(value);
@@ -8,13 +8,13 @@ export function orgPlanPosition(l1Position, l2Position) {
8
8
  }
9
9
  export function parseOrgPlanAgentIdentity(nameOrPath) {
10
10
  const name = nameOrPath.split('/').filter(Boolean).at(-1) ?? nameOrPath;
11
- const match = /^(l([1-9]\d*)(?:_([1-9]\d*))?)(?:_g([1-9]\d*))?$/.exec(name);
11
+ const match = /^(l([1-9]\d*))(?:_g([1-9]\d*))?$/.exec(name);
12
12
  if (!match)
13
13
  return null;
14
14
  return {
15
15
  canonicalTaskName: match[1],
16
- canonicalPosition: orgPlanPosition(Number(match[2]), match[3] ? Number(match[3]) : undefined),
17
- generation: match[4] ? Number(match[4]) : 1,
16
+ canonicalPosition: orgPlanPosition(Number(match[2])),
17
+ generation: match[3] ? Number(match[3]) : 1,
18
18
  };
19
19
  }
20
20
  /** Converts the collaboration API's tool-safe task name into its canonical plan label. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.34.0",
3
+ "version": "0.35.1",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",