gestalt-mobile 0.66.2 → 0.66.3

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.
@@ -98,7 +98,7 @@ ${e}</tr>
98
98
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Xd(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?Xd(n,!0):this.parser.parseInline(r),o=Qd(e);if(o===null)return a;e=Xd(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+Xd(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Qd(e);if(i===null)return Xd(n);e=i;let a=`<img src="${Xd(e)}" alt="${Xd(n)}"`;return t&&(a+=` title="${Xd(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Xd(e.text)}},ff=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},pf=class e{options;renderer;textRenderer;constructor(e){this.options=e||Eu,this.options.renderer=this.options.renderer||new df,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ff}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},mf=class{options;block;constructor(e){this.options=e||Eu}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?uf.lex:uf.lexInline}provideParser(e=this.block){return e?pf.parse:pf.parseInline}},hf=new class{defaults=Tu();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=pf;Renderer=df;TextRenderer=ff;Lexer=uf;Tokenizer=lf;Hooks=mf;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new df(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new lf(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new mf;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];mf.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&mf.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return uf.lex(e,t??this.defaults)}parser(e,t){return pf.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?uf.lex:uf.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?pf.parse:pf.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?uf.lex:uf.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?pf.parse:pf.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
99
99
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Xd(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function gf(e,t){return hf.parse(e,t)}gf.options=gf.setOptions=function(e){return hf.setOptions(e),gf.defaults=hf.defaults,Du(gf.defaults),gf},gf.getDefaults=Tu,gf.defaults=Eu;function _f(...e){return hf.use(...e),gf.defaults=hf.defaults,Du(gf.defaults),gf}gf.use=_f,gf.walkTokens=function(e,t){return hf.walkTokens(e,t)},gf.parseInline=hf.parseInline,gf.Parser=pf,gf.parser=pf.parse,gf.Renderer=df,gf.TextRenderer=ff,gf.Lexer=uf,gf.lexer=uf.lex,gf.Tokenizer=lf,gf.Hooks=mf,gf.parse=gf,gf.options,gf.setOptions,gf.walkTokens,gf.parseInline,pf.parse,uf.lex;function vf(e){let t=[],n=0,r=null;for(let i of uf.lex(e)){let e=n;if(n+=i.raw.length,i.type===`space`){r&&(r.text+=i.raw);continue}if(i.type===`heading`){r?r.text+=i.raw:r={offset:e,text:i.raw};continue}t.push(r?{offset:r.offset,text:r.text+i.raw}:{offset:e,text:i.raw}),r=null}return r&&t.push(r),t.toReversed()}var yf=q(`<div class="working-content svelte-1wpqicu"></div>`);function bf(e,t){F(t,!0);let n=L(()=>vf(t.text));var r=yf();Z(r,21,()=>G(n),e=>e.offset,(e,n)=>{$c(e,{get text(){return G(n).text},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return t.oncopyresult},get clipboard(){return t.clipboard}})}),N(r),J(e,r),I()}var xf=q(`<time class="svelte-1im954t"> </time>`),Sf=q(`<span class="touch-unknown svelte-1im954t">time unknown</span>`),Cf=q(`<li class="svelte-1im954t"><code class="file-path svelte-1im954t"> </code> <span class="file-counts svelte-1im954t" aria-label="Line changes"><span class="additions svelte-1im954t"> </span> <span class="deletions svelte-1im954t"> </span></span> <!></li>`),wf=q(`<details class="file-changes svelte-1im954t"><summary class="svelte-1im954t"> <span class="additions svelte-1im954t"> </span> <span class="deletions svelte-1im954t"> </span></summary> <section aria-label="Files changed"><ul class="svelte-1im954t"></ul></section></details>`),Tf=q(`<!> <!>`,1),Ef=q(`<div class="entry-heading svelte-1im954t"><strong>working</strong></div> <!> <!>`,1),Df=q(`<li class="progress-item svelte-1im954t"><section><!></section></li>`),Of=q(`<li class="svelte-1im954t"><time class="svelte-1im954t"> </time></li>`),kf=q(`<details><summary class="svelte-1im954t"> </summary> <ul></ul></details>`),Af=q(`<aside class="autopilot-audit svelte-1im954t" aria-label="Autopilot audit entry"><strong>Autopilot</strong> <!> <!></aside>`),jf=q(`<time class="svelte-1im954t"> <!></time>`),Mf=q(`<section><!></section>`),Nf=q(`<div class="entry-heading svelte-1im954t"><strong>prompt</strong> <!></div> <div class="entry-content svelte-1im954t"><!></div> <!>`,1),Pf=q(`<div class="commentary-content live-commentary svelte-1im954t"><!></div>`),Ff=q(`<div class="entry-content svelte-1im954t"><!></div> <!> <!> <!>`,1),If=q(`<button class="commentary-toggle svelte-1im954t" type="button"><span aria-hidden="true"> </span> commentary</button>`),Lf=q(`<div class="answer-history svelte-1im954t"><!></div>`),Rf=q(`<div class="commentary-content svelte-1im954t"><!></div>`),zf=q(`<div class="entry-content svelte-1im954t"><!></div> <!>`,1),Bf=q(`<section class="answer-turn svelte-1im954t"><div class="entry-heading svelte-1im954t"><strong> </strong> <!></div> <!> <!> <!></section>`),Vf=q(`<div class="entry-content svelte-1im954t"><!></div>`),Hf=q(`<section class="progress-turn svelte-1im954t"><div class="entry-heading svelte-1im954t"><strong>working</strong> <!></div> <!> <!> <!></section>`),Uf=q(`<li><!></li>`),Wf=q(`<li class="audit-incomplete svelte-1im954t" role="status">Earlier Autopilot audit entries are not shown; this timeline contains the retained recent
100
100
  audit.</li>`),Gf=q(`<!> <ol aria-label="Chat messages" class="svelte-1im954t"><!> <!> <!></ol> <!>`,1);function Kf(e,t){F(t,!0);let n=(e,t=b)=>{let n=L(()=>_l(t())),r=L(()=>vl(G(n)));var i=Jr(),a=H(i),o=e=>{var t=wf(),i=V(t),a=V(i),o=U(a),s=V(o);N(o);var c=U(o,2),l=V(c);N(c),N(i);var u=U(i,2),d=V(u);Z(d,21,()=>G(n),e=>e.path,(e,t)=>{var n=Cf(),r=V(n),i=V(r,!0);N(r);var a=U(r,2),o=V(a),s=V(o);N(o);var c=U(o,2),l=V(c);N(c),N(a);var u=U(a,2),d=e=>{var n=xf(),r=V(n,!0);N(n),W((e,t)=>{Q(n,`datetime`,e),Y(r,t)},[()=>new Date(G(t).touchedAt).toISOString(),()=>xl(G(t).touchedAt,G(te))]),J(e,n)},f=e=>{J(e,Sf())};X(u,e=>{G(t).touchedAt===void 0?e(f,-1):e(d)}),N(n),W(()=>{Y(i,G(t).path),Y(s,`+${G(t).additions??`?`??``}`),Y(l,`−${G(t).deletions??`?`??``}`)}),J(e,n)}),N(d),N(u),N(t),W(()=>{Y(a,`${G(r).files??``}
101
- ${G(r).files===1?`file`:`files`} changed · `),Y(s,`+${G(r).additions??`?`??``}`),Y(l,`−${G(r).deletions??`?`??``}`)}),J(e,t)};X(a,e=>{G(n).length&&e(o)}),J(e,i)},r=(e,n=b)=>{$c(e,{get text(){return n()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()},get clipboard(){return m()}})},i=(e,n=b)=>{bf(e,{get text(){return n()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()},get clipboard(){return m()}})},a=$(t,`activeTurnId`,3,null),o=$(t,`autopilotAuditTruncated`,3,!1),s=$(t,`interactions`,19,()=>[]),c=$(t,`attention`,3,null),l=$(t,`attentionPending`,3,!1),u=$(t,`onattentionresolve`,3,()=>{}),d=$(t,`debugPending`,3,!1),f=$(t,`answers`,19,()=>({})),p=$(t,`submittedAnswers`,19,()=>({})),m=$(t,`clipboard`,19,()=>globalThis.navigator?.clipboard),h=$(t,`onanswer`,3,()=>{}),g=$(t,`onquiz`,3,()=>{}),_=$(t,`onpermission`,3,()=>{}),v=$(t,`ondecision`,3,()=>{}),y=$(t,`onretry`,3,()=>{}),x=$(t,`oncopyresult`,3,()=>{}),S=L(()=>t.activities.filter(e=>!vu(e))),C=L(()=>{let e=wu(t.messages);if(!c()||e.some(e=>e.kind===`audit`&&e.attention?.requestId===c().requestId))return e;let n=dl(c().attention);if(!n)return e;let r=c().requestedAt?Date.parse(c().requestedAt):void 0,i=r!==void 0&&Number.isFinite(r)?r:void 0,a=i===void 0?-1:e.findIndex(e=>e.occurredAt!==void 0&&e.occurredAt>i);return e.splice(a<0?e.length:a,0,{id:`attention:${c().requestId}`,kind:`audit`,text:`Needs attention`,attention:{...c(),attention:n},occurredAt:i,count:1,timestamps:i===void 0?[]:[i]}),e}),w=L(()=>G(C).flatMap(e=>e.kind===`audit`&&e.attention?[O(e.attention)]:[])),T=L(()=>s().filter(e=>Su(e)&&e.state!==`resolved`)),E=new Set;Fn(()=>{let e=new Set([...G(T).map(e=>`chat-request-${e.requestId}`),...c()?[`chat-attention-${c().requestId}`]:[]]);for(let t of E)!e.has(t)&&document.getElementById(t)?.contains(document.activeElement)&&Dr().then(()=>document.getElementById(t)?.focus({preventScroll:!0}));E=e});let D=L(()=>{let e=wu(Cu(t.messages,s(),G(w),p())).filter(e=>!c()||e.kind!==`audit`||e.attention?.requestId!==c().requestId).map(e=>{if(e.kind!==`audit`||!e.attention)return e;let t=s().find(t=>t.requestId===e.attention?.requestId)?.resolvedAt;return t===void 0?e:{...e,occurredAt:t}});for(let t of s().filter(e=>Su(e)&&e.state===`resolved`)){let n={id:t.key,kind:`interaction`,interaction:t,occurredAt:t.resolvedAt??t.occurredAt},r=n.occurredAt===void 0?-1:e.findIndex(e=>e.occurredAt!==void 0&&e.occurredAt>n.occurredAt);e.splice(r<0?e.length:r,0,n)}return e.map((e,t)=>({entry:e,index:t})).sort((e,t)=>e.entry.occurredAt!==void 0&&t.entry.occurredAt!==void 0&&e.entry.occurredAt-t.entry.occurredAt||e.index-t.index).map(({entry:e})=>e).toReversed()});function O(e){let n=e.requestedAt?Date.parse(e.requestedAt):NaN,r=t.messages.filter(t=>t.role===`assistant`&&t.turnId===e.turnId),i=r.findLast(e=>e.phase===`final_answer`&&e.occurredAt!==void 0&&e.occurredAt>=n),a=r.findLast(e=>e.phase===`commentary`&&e.occurredAt!==void 0&&e.occurredAt<=n),o=c()?.requestId===e.requestId&&c().supervisorReport?c().supervisorReport:bs(i?.text??a?.text);return{...e,...o?{supervisorReport:o}:{}}}let ee=sn({}),te=z(sn(Date.now()));qi(()=>{let e=globalThis.setInterval(()=>B(te,Date.now(),!0),1e3);return()=>globalThis.clearInterval(e)});let ne=L(()=>G(C).filter(e=>e.kind===`user`)),re=L(()=>G(D).filter(e=>e.kind===`assistant`).toReversed()),ie=L(()=>G(re).at(-1)?.id);function ae(e){if(e.turnId){let t=G(re).findLast(t=>t.turnId===e.turnId);if(t)return t.id}return e.occurredAt===void 0?G(ie)??null:G(re).find(t=>t.answer!==null&&t.occurredAt!==void 0&&t.occurredAt>=e.occurredAt)?.id??null}function oe(e){return e.kind===`assistant`?G(S).filter(t=>ae(t)===e.id):[]}function se(e){if(ae(e))return null;if(e.turnId){let t=G(ne).findLast(t=>t.turnId===e.turnId);if(t)return t.id}return e.occurredAt===void 0?null:G(ne).findLast(t=>t.occurredAt!==void 0&&t.occurredAt<=e.occurredAt)?.id??null}function ce(e){return e.kind===`user`?G(S).filter(t=>se(t)===e.id):[]}function le(){return G(S).filter(e=>!ae(e)&&!se(e))}let ue=L(le);function de(e){return e.filter(e=>!e.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))}function fe(e){return!!(e.kind===`assistant`&&a()&&(e.turnId===a()||!e.turnId&&e.id===G(ie)))}function k(e){return!!(e.kind===`user`&&a()&&(e.turnId===a()||!e.turnId))}function pe(e,t){return yl(G(D)[e+1]?.occurredAt,t)}var me=Gf(),he=H(me),ge=e=>{_u(e,{children:(e,n)=>{var r=Tf(),i=H(r),a=e=>{{let n=L(()=>O(c())),r=L(()=>`chat-attention-${c().requestId}`);sl(e,{get attention(){return G(n)},get pending(){return l()},get controlId(){return G(r)},get onresolve(){return u()},get ondebug(){return t.onattentiondebug},get debugPending(){return d()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}})}};X(i,e=>{c()&&e(a)}),hu(U(i,2),{get interactions(){return G(T)},get answers(){return f()},get submittedAnswers(){return p()},get onanswer(){return h()},get onquiz(){return g()},get onpermission(){return _()},get ondecision(){return v()},get onretry(){return y()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}}),J(e,r)},$$slots:{default:!0}})};X(he,e=>{(c()||G(T).length)&&e(ge)});var _e=U(he,2),ve=V(_e),ye=e=>{var t=Df(),r=V(t),i=V(r),o=e=>{var t=Ef(),r=U(H(t),2);{let e=L(()=>de(G(ue)));Ro(r,{get activities(){return G(e)},variant:`live`})}var i=U(r,2);n(i,()=>G(ue)),J(e,t)},s=e=>{Nl(e,{get activities(){return G(ue)},get now(){return G(te)}})};X(i,e=>{a()?e(o):e(s,-1)}),N(r),N(t),W(()=>wi(r,1,vi(a()?`progress-turn`:`orphan-activity-turn`),`svelte-1im954t`)),J(e,t)};X(ve,e=>{G(ue).length&&e(ye)});var be=U(ve,2);Z(be,19,()=>G(D),e=>e.id,(e,a,o)=>{var m=Uf(),b=V(m),S=e=>{{let n=L(()=>[G(a).interaction]);hu(e,{get interactions(){return G(n)},get answers(){return f()},get submittedAnswers(){return p()},get onanswer(){return h()},get onquiz(){return g()},get onpermission(){return _()},get ondecision(){return v()},get onretry(){return y()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}})}},C=e=>{var n=Jr(),r=H(n),i=e=>{{let n=L(()=>O(G(a).attention)),r=L(()=>c()?.requestId!==G(a).attention.requestId),i=L(()=>s().find(e=>e.requestId===G(a).attention?.requestId)?.resolvedAt),o=L(()=>`chat-attention-${G(a).attention.requestId}`);sl(e,{get attention(){return G(n)},get historical(){return G(r)},get resolvedAt(){return G(i)},get pending(){return l()},get controlId(){return G(o)},get onresolve(){return u()},get ondebug(){return t.onattentiondebug},get debugPending(){return d()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}})}},o=e=>{var t=Af(),n=U(V(t)),r=U(n),i=e=>{var t=xf(),n=V(t,!0);N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,r)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(r,e=>{G(a).occurredAt&&e(i)});var o=U(r,2),s=e=>{var t=kf(),n=V(t),r=V(n);N(n);var i=U(n,2);Z(i,21,()=>G(a).timestamps,e=>`${G(a).id}:${e}`,(e,t)=>{var n=Of(),r=V(n),i=V(r,!0);N(r),N(n),W((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t)).toISOString(),()=>bl(G(t))]),J(e,n)}),N(i),N(t),W(()=>Y(r,`Show ${G(a).count??``} timestamps`)),J(e,t)};X(o,e=>{G(a).count>1&&e(s)}),N(t),W(()=>Y(n,` ${G(a).text??``}${G(a).count>1?` · ${G(a).count} times`:``} `)),J(e,t)};X(r,e=>{G(a).attention?e(i):e(o,-1)}),J(e,n)},w=e=>{let t=L(()=>ce(G(a)));var i=Nf(),s=H(i),c=U(V(s),2),l=e=>{var t=jf(),n=V(t),r=U(n),i=e=>{var t=qr();W(e=>Y(t,`· ${e??``}`),[()=>pe(G(o),G(a).occurredAt)]),J(e,t)},s=L(()=>pe(G(o),G(a).occurredAt));X(r,e=>{G(s)&&e(i)}),N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,`${r??``} `)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(c,e=>{G(a).occurredAt&&e(l)}),N(s);var u=U(s,2),d=V(u);r(d,()=>G(a).text),N(u);var f=U(u,2),p=e=>{var r=Mf(),i=V(r),o=e=>{var r=Ef(),i=U(H(r),2);{let e=L(()=>de(G(t)));Ro(i,{get activities(){return G(e)},variant:`live`})}var a=U(i,2);n(a,()=>G(t)),J(e,r)},s=L(()=>k(G(a))),c=e=>{Nl(e,{get activities(){return G(t)},get now(){return G(te)}})};X(i,e=>{G(s)?e(o):e(c,-1)}),N(r),W(e=>wi(r,1,e,`svelte-1im954t`),[()=>vi(k(G(a))?`progress-turn`:`orphan-activity-turn`)]),J(e,r)};X(f,e=>{G(t).length&&e(p)}),J(e,i)},T=e=>{let t=L(()=>oe(G(a)));var s=Bf(),c=V(s),l=V(c),u=V(l,!0);N(l);var d=U(l,2),f=e=>{var t=jf(),n=V(t),r=U(n),i=e=>{var t=qr();W(e=>Y(t,`· ${e??``}`),[()=>pe(G(o),G(a).occurredAt)]),J(e,t)},s=L(()=>pe(G(o),G(a).occurredAt));X(r,e=>{G(s)&&e(i)}),N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,`${r??``} `)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(d,e=>{G(a).occurredAt&&e(f)}),N(c);var p=U(c,2),m=e=>{var r=Ff(),o=H(r),s=V(o);i(s,()=>G(a).answer),N(o);var c=U(o,2),l=e=>{var t=Pf(),n=V(t);i(n,()=>G(a).commentary),N(t),J(e,t)};X(c,e=>{G(a).commentary&&e(l)});var u=U(c,2);{let e=L(()=>de(G(t)));Ro(u,{get activities(){return G(e)},variant:`live`})}var d=U(u,2);n(d,()=>G(t)),J(e,r)},h=L(()=>fe(G(a))),g=e=>{var t=Lf(),n=V(t),r=e=>{var t=If(),n=V(t),r=V(n,!0);N(n),P(),N(t),W(e=>{Q(t,`aria-expanded`,e),Q(t,`aria-controls`,`commentary-${G(a).id}`),Y(r,ee[G(a).id]?`⌄`:`›`)},[()=>!!ee[G(a).id]]),K(`click`,t,()=>ee[G(a).id]=!ee[G(a).id]),J(e,t)};X(n,e=>{G(a).commentary&&e(r)}),N(t),J(e,t)},_=L(()=>G(a).commentary||de(G(t)).length);X(p,e=>{G(h)?e(m):G(_)&&e(g,1)});var v=U(p,2),y=e=>{var t=Rf(),n=V(t);r(n,()=>G(a).commentary),N(t),W(()=>Q(t,`id`,`commentary-${G(a).id}`)),J(e,t)},b=L(()=>!fe(G(a))&&G(a).commentary&&ee[G(a).id]);X(v,e=>{G(b)&&e(y)});var x=U(v,2),S=e=>{var n=zf(),i=H(n),o=V(i);r(o,()=>G(a).answer),N(i),Nl(U(i,2),{get activities(){return G(t)},get now(){return G(te)}}),J(e,n)},C=L(()=>!fe(G(a)));X(x,e=>{G(C)&&e(S)}),N(s),W(e=>Y(u,e),[()=>fe(G(a))?`working`:`answer`]),J(e,s)},E=e=>{let t=L(()=>oe(G(a)));var r=Hf(),s=V(r),c=U(V(s),2),l=e=>{var t=jf(),n=V(t),r=U(n),i=e=>{var t=qr();W(e=>Y(t,`· ${e??``}`),[()=>pe(G(o),G(a).occurredAt)]),J(e,t)},s=L(()=>pe(G(o),G(a).occurredAt));X(r,e=>{G(s)&&e(i)}),N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,`${r??``} `)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(c,e=>{G(a).occurredAt&&e(l)}),N(s);var u=U(s,2),d=e=>{var t=Vf(),n=V(t);i(n,()=>G(a).commentary),N(t),J(e,t)};X(u,e=>{G(a).commentary&&e(d)});var f=U(u,2),p=e=>{{let n=L(()=>de(G(t)));Ro(e,{get activities(){return G(n)},variant:`live`})}},m=L(()=>fe(G(a))),h=e=>{Nl(e,{get activities(){return G(t)},get now(){return G(te)}})};X(f,e=>{G(m)?e(p):e(h,-1)});var g=U(f,2),_=e=>{n(e,()=>G(t))},v=L(()=>fe(G(a)));X(g,e=>{G(v)&&e(_)}),N(r),J(e,r)};X(b,e=>{G(a).kind===`interaction`?e(S):G(a).kind===`audit`?e(C,1):G(a).kind===`user`?e(w,2):G(a).answer===null?G(a).commentary!==null&&e(E,4):e(T,3)}),N(m),W(()=>wi(m,1,vi(G(a).kind===`user`?`prompt-turn`:G(a).kind===`audit`?`audit-item`:`answer-item`),`svelte-1im954t`)),J(e,m)});var xe=U(be,2),Se=e=>{J(e,Wf())};X(xe,e=>{o()&&e(Se)}),N(_e),fi(U(_e,2),()=>t.footer??b),J(e,me),I()}Br([`click`]);var qf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0;function Jf(e,t){if(t.type!==`activity.updated`||!e?.runtimeId||!e.observedAt||!t.occurredAt||!Number.isFinite(Date.parse(e.observedAt))||!Number.isFinite(Date.parse(t.occurredAt))||Date.parse(t.occurredAt)<=Date.parse(e.observedAt))return e;let n=t.payload,r=n?.repositoryReadiness;if(n?.runtimeId!==e.runtimeId||!r?.readiness?.repository||typeof r.threadId!=`string`)return e;let i=e.repositories.find(e=>e.threadId===r.threadId&&e.readiness.repository?.id===r.readiness.repository?.id);if(!i&&e.repositories.length>=64)return e;let a=qf(t.sequence),o=i?.activityOrder;if(o){let n=Date.parse(t.occurredAt),r=Date.parse(o.occurredAt);if(n<r||o.sequence!==void 0&&(a===void 0||a<=o.sequence)||n===r&&(o.sequence===void 0||a===void 0))return e}return{...e,repositories:[...e.repositories.filter(e=>e.threadId!==r.threadId||e.readiness.repository?.id!==r.readiness.repository?.id),{...r,activityOrder:{occurredAt:t.occurredAt,...a===void 0?{}:{sequence:a}}}]}}var Yf=[150,300,600];function Xf(e){return new Promise(t=>setTimeout(t,e))}function Zf(e){return e.status===502||e.status===503||e.status===504}async function Qf(e=fetch){for(let t=0;t<=Yf.length;t+=1){let n;try{n=await e(`/api/bootstrap`)}catch(e){if(e instanceof Error&&e.name===`AbortError`)throw e;if(t===Yf.length)throw Error(`BOOTSTRAP_FAILED`);await Xf(Yf[t]);continue}if(n.ok)return n.json();if(!Zf(n)||t===Yf.length)throw Error(`BOOTSTRAP_FAILED`);await Xf(Yf[t])}throw Error(`BOOTSTRAP_FAILED`)}var $f=`gestalt-mobile`,ep=3,tp=[`settings`,`drafts`,`cursors`,`messages`,`chat-projections`];function np(e){return new Promise((t,n)=>{let r=e.open($f,ep);r.onupgradeneeded=()=>{for(let e of tp)r.result.objectStoreNames.contains(e)||r.result.createObjectStore(e)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}function rp(e,t,n){return op(e.transaction(t,`readonly`).objectStore(t).get(n))}function ip(e,t,n,r){return op(e.transaction(t,`readwrite`).objectStore(t).put(r,n))}function ap(e,t,n){return op(e.transaction(t,`readwrite`).objectStore(t).delete(n))}function op(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}var sp=`chat-projections`,cp=e=>({version:1,cursor:e.cursor,lifecycle:e.lifecycle,activeTurnId:e.activeTurnId,messages:e.messages.filter(e=>e.role===`user`).slice(-200),activities:[],prompts:e.prompts.slice(-200),interactions:e.interactions.map(({requestId:e,key:t,kind:n,turnId:r,state:i,operationId:a,attemptedOutcome:o})=>({requestId:e,key:t,kind:n,...r?{turnId:r}:{},state:i,...a?{operationId:a}:{},...i===`resolved`&&(o===`approved`||o===`denied`||o===`answered`||o===`dismissed`)?{attemptedOutcome:o}:{},...typeof o==`object`&&o&&(o.decision===`accept`||o.decision===`decline`)?{attemptedOutcome:{decision:o.decision}}:{}})).slice(-200),buffered:[]});function lp(e=globalThis.indexedDB){if(!e)return{read:async()=>null,write:async()=>{}};let t=np(e);return t.catch(()=>{}),{read:async e=>{try{return await rp(await t,sp,e)}catch{return null}},write:async(e,n)=>{try{await ip(await t,sp,e,cp(n))}catch{}}}}var up=`chat-session`;function dp(e){return new URLSearchParams(e).get(`chat-session`)?.trim()||null}function fp(e,t){let n=new URL(e);return n.search=``,n.hash=``,n.searchParams.set(up,t),n.toString()}function pp(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return`gestalt-chat-${(t>>>0).toString(36)}`}function mp(e){let t=gp(e,`requestId`),n=dl(gp(e,`payload`));if(typeof t!=`string`||t.length>256||!n)return;let r=gp(e,`turnId`),i=gp(e,`requestedAt`);return{requestId:t,turnId:typeof r==`string`?r:null,requestedAt:typeof i==`string`?i:null,attention:n}}function hp(e,t){if(e===`autopilot.turn-started`)return`Continued execution automatically`;if(e===`autopilot.final-rejected`)return`Kept incomplete supervised work active`;if(e===`autopilot.executor-resumed`)return`Resumed the assigned executor`;if(e===`autopilot.process-monitoring`)return`Monitoring executor background work`;if(e===`autopilot.process-result-consumed`)return`Consumed background work result`;if(e===`autopilot.process-terminated`)return gp(t,`reason`)===`resourceBudget`?`Stopped background work at its resource limit`:`Stopped executor background work`;if(e===`autopilot.turn-failed`)return gp(t,`code`)===`START_UNAVAILABLE`?`Automatic continuation could not start: session runtime unavailable`:`Automatic continuation failed`;if(e===`org-plan.attention-required`)return`Needs attention`;if(e===`org-plan.attention-resolved`)return gp(t,`outcome`)===`failed`?`Attention resolution failed`:`Attention resolved`;if(e!==`autopilot.updated`)return null;let n=gp(t,`state`),r=gp(t,`reason`),i=_s(gp(t,`providerFailure`));return n===`safetyPaused`&&i?`Autopilot paused: ${vs(i)}`:n===`safetyPaused`&&r===`usageLimitExceeded`?`Autopilot paused: Codex usage limit reached`:n===`completed`?`Completed the supervised plan`:n===`attentionRequired`&&r===`noPlanProgress`?`Automatic continuation stopped: no agent progress`:n===`attentionRequired`&&r===`reconcileFailed`?`Automatic continuation stopped: agent status unavailable`:n===`attentionRequired`&&r===`actionRateExceeded`?`Automatic continuation stopped: too many automatic actions`:null}function gp(e,t){return e&&typeof e==`object`?e[t]:void 0}var _p=()=>({sessionId:null,cursor:0,snapshotting:!1,lifecycle:`finished`,activeTurnId:null,messages:[],activities:[],prompts:[],interactions:[],autopilotAuditTruncated:!1,buffered:new Map}),vp=(e=null)=>({..._p(),sessionId:e});function yp(e){return e.kind===`autopilot`?{id:`item:${e.id}`,role:`audit`,text:`Continued execution automatically`,...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.controlId==`string`?{controlId:e.controlId}:{},complete:!0}:e.kind!==`user`&&e.kind!==`agent`||typeof e.text!=`string`?null:{id:`item:${e.id}`,role:e.kind===`user`?`user`:`assistant`,text:e.text,...e.phase===`commentary`||e.phase===`final_answer`?{phase:e.phase}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.turnId==`string`?{turnId:e.turnId}:{},complete:!0}}function bp(e){return{id:e.id,role:`audit`,text:e.label,occurredAt:e.occurredAt,...e.controlId?{controlId:e.controlId}:{},...e.attention?{attention:e.attention}:{},complete:!0}}function xp(e){let t=Sp(e.occurredAt),n=hp(e.type,e.payload),r=e.payload&&typeof e.payload==`object`&&typeof e.payload.controlId==`string`?e.payload.controlId:void 0;return n&&t!==void 0?bp({id:`audit:${e.sequence}`,label:n,occurredAt:t,...r?{controlId:r}:{},...e.type===`org-plan.attention-required`&&mp(e.payload)?{attention:mp(e.payload)}:{}}):null}function Sp(e){if(typeof e!=`string`)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Cp(e){let t=Sp(e.requestedAt),n=Sp(e.resolvedAt);return{requestId:e.requestId,key:`interaction:${e.requestId}`,kind:e.kind,turnId:e.turnId,payload:`payload`in e?e.payload:null,state:e.resolvedAt?e.outcome===`failed`?`failed`:`resolved`:`pending`,...e.resolvedAt?{attemptedOutcome:e.outcome}:{},...t===void 0?{}:{occurredAt:t},...n===void 0?{}:{resolvedAt:n}}}function wp(e,t){return t===`approved`||t===`denied`||t===`answered`||t===`dismissed`||t===`failed`?t:e?.kind===`quiz`||e?.kind===`userInput`?`answered`:typeof t==`object`&&t&&t.decision===`decline`?`denied`:e?`approved`:void 0}function Tp(e,t){return e?t===`finished`||t===`interrupted`?t:`working`:t===`working`||t===`starting`||t===`recoverable`?`finished`:t}function Ep(e){return[...new Map(e.map(e=>[e.key??e.id??``,e])).values()]}function Dp(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?{...t,...t.occurredAt===void 0&&e.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}}:e):[...e,t]}function Op(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map(n.map((e,t)=>[e.id,t])),a=new Set(t.filter(e=>e.state!==`canonical`).map(e=>e.operationId)),o=new Set,s=e.flatMap(e=>{let i=yp(e);if(!i)return[];if(e.kind===`user`){let n=t.find(t=>typeof e.operationId==`string`&&e.operationId===t.operationId||typeof e.turnId==`string`&&e.turnId===t.turnId),s=!n&&t.filter(t=>t.state!==`canonical`&&t.text===e.text).length===1?t.find(t=>t.state!==`canonical`&&t.text===e.text):void 0,c=n??s;if(c){a.delete(c.operationId);let e=r.get(c.key),t={...i,id:c.key,turnId:c.turnId??i.turnId,...i.occurredAt===void 0&&e?.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}};return o.add(t.id),[e&&e.text===t.text&&e.turnId===t.turnId&&e.complete===t.complete&&e.occurredAt===t.occurredAt?e:t]}}if(e.kind===`agent`&&typeof e.turnId==`string`){let t=r.get(`assistant:${e.id}`)??n.find(t=>t.role===`assistant`&&t.turnId===e.turnId&&t.text===i.text&&(t.phase===i.phase||!t.complete));if(t){o.add(t.id);let e={...i,id:t.id,turnId:i.turnId??t.turnId,...i.occurredAt===void 0&&t.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}};return[t.text===e.text&&t.phase===e.phase&&t.occurredAt===e.occurredAt?t:e]}}return o.add(i.id),[i]}),c=t.filter(e=>a.has(e.operationId)).map(e=>r.get(e.key)??{id:e.key,role:`user`,text:e.text,complete:e.state===`failed`,...e.turnId?{turnId:e.turnId}:{}}),l=n.filter(e=>e.role===`assistant`&&e.id.startsWith(`assistant:`)&&!o.has(e.id)),u=Ep([...c,...l]),d=new Map(s.map((e,t)=>[e.id,t])),f=new Map;for(let e of u){let t=null;if(e.turnId){for(let n=s.length-1;n>=0;--n)if(s[n]?.turnId===e.turnId){t=n;break}}if(t===null){let r=i.get(e.id);if(r!==void 0){for(let e=r-1;e>=0;--e){let r=d.get(n[e].id);if(r!==void 0){t=r;break}}if(t===null)for(let e=r+1;e<n.length;e+=1){let r=d.get(n[e].id);if(r!==void 0){t=r-1;break}}}}let r=t??s.length-1;f.set(r,[...f.get(r)??[],e])}return Ep([...f.get(-1)??[],...s.flatMap((e,t)=>[e,...f.get(t)??[]])])}function kp(e,t){if(!t||typeof t!=`object`)return vp(e);let n=t;if(!Number.isInteger(n.cursor)||n.cursor<0||!Array.isArray(n.messages)||!Array.isArray(n.prompts)||!Array.isArray(n.interactions))return vp(e);let r=[`submitting`,`accepted`,`failed`,`canonical`],i=[`pending`,`submitting`,`resolved`,`failed`],a=[`starting`,`working`,`finished`,`interrupted`,`recoverable`];return{...vp(e),sessionId:e,cursor:n.cursor,lifecycle:a.includes(n.lifecycle)?n.lifecycle:`finished`,activeTurnId:typeof n.activeTurnId==`string`||n.activeTurnId===null?n.activeTurnId:null,snapshotting:!1,buffered:new Map,messages:n.messages.filter(e=>!!(e&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`audit`)&&typeof e.text==`string`&&(e.attention===void 0||mp({...e.attention,payload:e.attention.attention}))&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),activities:Array.isArray(n.activities)?n.activities.filter(e=>!!(e&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0}))&&(e.turnId===void 0||typeof e.turnId==`string`))).map(e=>{let{mcpStartup:t,...n}=e,r=po(t);return{...n,...r?{mcpStartup:r}:{}}}).slice(-200):[],prompts:n.prompts.filter(e=>!!(e&&typeof e.operationId==`string`&&typeof e.key==`string`&&typeof e.text==`string`&&r.includes(e.state)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),interactions:n.interactions.filter(e=>!!(e&&typeof e.requestId==`string`&&typeof e.key==`string`&&typeof e.kind==`string`&&(e.turnId===void 0||e.turnId===null||typeof e.turnId==`string`)&&i.includes(e.state)&&(e.resolvedAt===void 0||typeof e.resolvedAt==`number`&&Number.isFinite(e.resolvedAt))&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200)}}function Ap(e,t){if(!Number.isInteger(t.baseSequence)||t.baseSequence<0)return e;if(t.baseSequence<e.cursor)return Hp({...e,snapshotting:!1});let n=t.items.filter(e=>e.kind===`user`),r=e.prompts.map(t=>{let r=n.some(e=>typeof e.turnId==`string`&&e.turnId===t.turnId||typeof e.operationId==`string`&&e.operationId===t.operationId),i=n.filter(e=>e.text===t.text),a=!t.turnId&&i.length===1&&e.prompts.filter(e=>e.state!==`canonical`&&e.text===t.text).length===1;return r||a?{...t,state:`canonical`}:t}),i=t.interactions.map(Cp),a=new Map(e.interactions.map(e=>[e.requestId,e])),o=Ep(i.map(e=>{let t=a.get(e.requestId);return t?.state===`resolved`?{...t,...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt},...e.resolvedAt===void 0?{}:{resolvedAt:e.resolvedAt}}:{...e,...e.occurredAt===void 0&&t?.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}}})),s=Ep(t.items.flatMap(e=>{let t=bu(e);return t?[{...t,key:`activity:${t.id}`}]:[]}).concat((t.activities??[]).map(e=>({...e,key:`activity:${e.id}`})))).map(e=>({id:e.id,label:e.label,detail:e.detail,...e.turnId?{turnId:e.turnId}:{},...e.actorTurnId?{actorTurnId:e.actorTurnId}:{},...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt},...e.changes?{changes:e.changes}:{},...po(e.mcpStartup)?{mcpStartup:po(e.mcpStartup)}:{}})).reduce(Dp,[...e.activities]),c=new Map(t.turns.map(e=>[e.id,e])),l=t.items.map(e=>{if(typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt))return e;let t=typeof e.turnId==`string`?c.get(e.turnId):void 0,n=e.kind===`agent`?t?.completedAt??t?.startedAt:t?.startedAt??t?.completedAt;return typeof n==`number`&&Number.isFinite(n)?{...e,occurredAt:n}:e}),u=(t.autopilotAudit??[]).filter(e=>typeof e?.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),d={...e,cursor:Math.max(e.cursor,t.baseSequence),snapshotting:!1,activeTurnId:t.activeTurnId,lifecycle:Tp(t.activeTurnId,e.cursor===0&&e.lifecycle===`finished`?`working`:e.lifecycle),prompts:r,messages:Ep(Op(l,r,e.messages).concat(u.map(bp))).sort((e,t)=>(e.occurredAt??2**53-1)-(t.occurredAt??2**53-1)),activities:s,interactions:o,autopilotAuditTruncated:t.autopilotAuditTruncated===!0,buffered:new Map([...e.buffered].filter(([e])=>e>t.baseSequence))};return Hp({...d,messages:jp(d.messages)})}function jp(e){let t=new Set;return e.filter(e=>e.role!==`audit`||!e.controlId?!0:t.has(e.controlId)?!1:(t.add(e.controlId),!0))}function Mp(e){return{...e,snapshotting:!0}}function Np(e,t,n,r){if(!n.trim()||e.prompts.some(e=>e.operationId===t))return e;let i={operationId:t,key:`prompt:${t}`,text:n,state:`submitting`,turnId:null,...typeof r==`number`&&Number.isFinite(r)?{occurredAt:r}:{}};return{...e,lifecycle:`starting`,prompts:[...e.prompts,i],messages:[...e.messages,{id:i.key,role:`user`,text:n,...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},complete:!1}]}}function Pp(e,t,n,r){let i=Np(e,t,n,r);return i===e?e:{...i,lifecycle:`working`}}function Fp(e,t,n){return{...e,activeTurnId:n??e.activeTurnId,lifecycle:n?`working`:e.lifecycle,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`accepted`,turnId:n}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0,...n?{turnId:n}:{}}:e)}}function Ip(e,t){return{...e,lifecycle:`recoverable`,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`failed`}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0}:e)}}function Lp(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&(e.state===`pending`||e.state===`failed`)?{...e,state:`submitting`,...n?{operationId:n}:{}}:e)}}function Rp(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&e.state!==`resolved`?{...e,state:`failed`,attemptedOutcome:n}:e)}}function zp(e,t,n,r){return{...e,interactions:e.interactions.map(e=>e.requestId===t?{...e,state:`resolved`,...r===void 0?{}:{resolvedAt:r},...wp(e,n)?{attemptedOutcome:wp(e,n)}:{}}:e)}}function Bp(e,t){if(!Number.isInteger(t.sequence)||t.sequence<=e.cursor)return e;if(e.snapshotting||t.sequence>e.cursor+1){let n=new Map(e.buffered);return n.set(t.sequence,t),{...e,snapshotting:!0,buffered:n}}let n={...e,cursor:t.sequence},r=t.payload,i=Sp(t.occurredAt);if(t.type===`agentMessageDelta`&&typeof r?.text==`string`){let e=typeof r.turnId==`string`?r.turnId:n.activeTurnId??void 0,t=`assistant:${typeof r.itemId==`string`?r.itemId:e??`live`}`,a=n.messages.find(e=>e.id===t);n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(e=>e.id===t?{...e,text:e.text+r.text,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},complete:r.phase===`final_answer`||e.complete,...e.occurredAt===void 0&&i!==void 0?{occurredAt:i}:{}}:e):[...n.messages,{id:t,role:`assistant`,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},text:r.text,...e?{turnId:e}:{},...i===void 0?{}:{occurredAt:i},complete:r.phase===`final_answer`}]}}else if((t.type===`agentMessageStarted`||t.type===`agentMessageCompleted`)&&typeof r.text==`string`){let e=`assistant:${typeof r.itemId==`string`?r.itemId:n.activeTurnId??`live`}`,a=n.messages.find(t=>t.id===e),o=t.type===`agentMessageCompleted`,s={id:e,role:`assistant`,text:o&&r.text?r.text:a?.text??r.text,complete:o,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:a?.phase?{phase:a.phase}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:a?.turnId?{turnId:a.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...a?.occurredAt===void 0?i===void 0?{}:{occurredAt:i}:{occurredAt:a.occurredAt}};n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(t=>t.id===e?s:t):[...n.messages,s]}}else if(t.type===`turnCompleted`||t.type===`turnInterrupted`)n={...n,activeTurnId:null,lifecycle:t.type===`turnCompleted`||n.lifecycle===`finished`?`finished`:`interrupted`,messages:n.messages.map(e=>e.role===`assistant`?{...e,complete:!0}:e)};else if(t.type===`interaction.requested`&&typeof r?.requestId==`string`&&typeof r.kind==`string`){let e=n.interactions.find(e=>e.requestId===r.requestId);if(!e||e.state===`resolved`){let t={requestId:r.requestId,key:`interaction:${r.requestId}`,kind:r.kind,turnId:typeof r.turnId==`string`?r.turnId:n.activeTurnId,payload:r.payload,state:`pending`,...i===void 0?{}:{occurredAt:i}};n={...n,interactions:e?n.interactions.map(e=>e.requestId===r.requestId?t:e):[...n.interactions,t]}}}else if(t.type===`interaction.resolved`&&typeof r?.requestId==`string`)n=zp(n,r.requestId,r.outcome,i);else if(t.type===`activity.updated`&&typeof r?.id==`string`&&typeof r.label==`string`&&typeof r.detail==`string`){let e=Vp(r.changes),t=po(r.mcpStartup);n={...n,activities:Dp(n.activities,{id:r.id,label:r.label,detail:r.detail,...i===void 0?{}:{occurredAt:i},...e.length?{changes:e}:{},...t?{mcpStartup:t}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...typeof r.actorTurnId==`string`?{actorTurnId:r.actorTurnId}:{}})}}else if(t.type===`session.updated`&&r?.activeTurnId!==void 0){let e=typeof r.activeTurnId==`string`?r.activeTurnId:null;n={...n,activeTurnId:e,lifecycle:e?`working`:Tp(e,n.lifecycle)}}let a=xp(t);return a&&!n.messages.some(e=>e.id===a.id)&&(n={...n,messages:jp([...n.messages,a])}),n}function Vp(e){return!Array.isArray(e)||e.length>1e3?[]:e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]})}function Hp(e){let t=new Map(e.buffered),n={...e,snapshotting:!1,buffered:t};for(;;){let e=t.get(n.cursor+1);if(!e)return{...n,buffered:t,snapshotting:t.size>0};t.delete(e.sequence),n=Bp({...n,buffered:t},e),t=new Map(n.buffered)}}function Up(e){return e.sessionId?e.lifecycle===`recoverable`?`Connection interrupted. Reconnecting…`:e.lifecycle===`starting`?`Starting Codex turn…`:e.lifecycle===`working`?`Codex is working…`:e.lifecycle===`interrupted`?`Codex turn interrupted.`:`Ready.`:`Choose a workspace and start a session.`}var Wp={read:async()=>null,write:async()=>{}},Gp=[250,750,1500],Kp=e=>!!e&&typeof e==`object`,qp=e=>Kp(e)&&typeof e.path==`string`&&Number.isInteger(e.additions)&&e.additions>=0&&Number.isInteger(e.deletions)&&e.deletions>=0,Jp=e=>Kp(e)&&typeof e.id==`string`&&typeof e.kind==`string`,Yp=e=>Kp(e)&&typeof e.id==`string`&&Array.isArray(e.items)&&e.items.every(Jp)&&(e.startedAt===null||typeof e.startedAt==`number`)&&(e.completedAt===null||typeof e.completedAt==`number`),Xp=e=>!Kp(e)||typeof e.requestId!=`string`||typeof e.kind!=`string`||!(e.turnId===null||typeof e.turnId==`string`)||!(e.requestedAt===null||typeof e.requestedAt==`string`)?!1:e.resolvedAt===null?Object.hasOwn(e,`payload`):typeof e.resolvedAt==`string`&&(e.outcome===`approved`||e.outcome===`denied`||e.outcome===`answered`||e.outcome===`dismissed`||e.outcome===`failed`)&&!Object.hasOwn(e,`payload`),Zp=e=>Kp(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)&&(e.controlId===void 0||typeof e.controlId==`string`)&&(e.attention===void 0||Kp(e.attention)&&!!mp({...e.attention,payload:e.attention.attention})),Qp=e=>Kp(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(qp))&&(e.turnId===void 0||typeof e.turnId==`string`)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),$p=e=>!Kp(e)||!Number.isInteger(e.baseSequence)||e.baseSequence<0||!(e.activeTurnId===null||typeof e.activeTurnId==`string`)||!Array.isArray(e.items)||!Array.isArray(e.turns)||!Array.isArray(e.interactions)||!e.items.every(Jp)||!e.turns.every(Yp)||!e.interactions.every(Xp)||e.activities!==void 0&&(!Array.isArray(e.activities)||!e.activities.every(Qp))||e.autopilotAudit!==void 0&&(!Array.isArray(e.autopilotAudit)||!e.autopilotAudit.every(Zp))||e.autopilotAuditTruncated!==void 0&&typeof e.autopilotAuditTruncated!=`boolean`||e.currentSequence!==void 0&&(!Number.isInteger(e.currentSequence)||e.currentSequence<0)?null:e,em=class{#e=vp();#t={attempts:0,coalesced:0,resyncs:0,socketOpens:0};get transportDiagnostics(){return{...this.#t}}#n=null;#r=null;#i=0;#a=-1;#o=null;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=0;#p=!1;#m=!1;#h=new Set;#g=null;#_=0;#v=!1;#y=new Set;#b=new Set;#x;constructor(e){this.#x={...e,websocket:e.websocket??(e=>new WebSocket(e)),cache:e.cache??Wp,location:e.location??location,document:e.document??document,window:e.window??window,setTimeout:e.setTimeout??((e,t)=>setTimeout(e,t)),clearTimeout:e.clearTimeout??(e=>clearTimeout(e)),createKey:e.createKey??hs,now:e.now??Date.now},this.#x.document.addEventListener(`visibilitychange`,this.#S),this.#x.window.addEventListener(`focus`,this.#S)}get view(){let e=this.#e.snapshotting&&this.#a!==this.#i&&!this.#m&&!tm(this.#e);return Object.freeze({...this.#e,status:this.#s?`Connection interrupted. Reconnecting…`:e?`Loading conversation…`:Up(this.#e),readySince:this.#r,starting:this.#e.lifecycle===`starting`,newEmpty:this.#m&&!tm(this.#e)})}canSubmit(e){return this.#n?e===`send`?!this.#e.activeTurnId:!!(this.#e.activeTurnId&&(e!==`queue`||this.#x.relay.queueTurnInput)):!1}select(e,t={}){if(this.#v||this.#n===e)return;this.#I(),this.#n=e,this.#r=null,e&&t.history===`empty`&&this.#h.add(e),this.#m=e!==null&&this.#h.has(e);let n=++this.#i;this.#e=vp(e),this.#j(),e&&this.#C(e,n)}async send(e,t=this.#x.createKey()){let n=this.#n,r=this.#i,i=`${n}:${r}:${t}`;if(!(!n||!e.trim()||this.#e.activeTurnId||this.#y.has(i))){this.#y.add(i),this.#A(Np(this.#e,t,e.trim(),this.#x.now()));try{let i=await this.#x.relay.startTurn(n,e.trim(),t);this.#N(n,r)&&(this.#M(n),this.#A(Fp(this.#e,t,i.activeTurnId??null))),this.#x.onSendAccepted?.(n,t)}catch(e){this.#N(n,r)&&(this.#A(Ip(this.#e,t)),this.#x.onSendError?.(e,t))}finally{this.#y.delete(i)}}}async retryPrompt(e){let t=this.#e.prompts.find(t=>t.operationId===e);t?.state===`failed`&&await this.send(t.text,e)}async queue(e,t=this.#x.createKey()){let n=this.#n,r=this.#e.activeTurnId,i=this.#x.relay.queueTurnInput,a=this.#i,o=`${n}:${a}:${t}`;if(!(!n||!r||!i||!e.trim()||this.#y.has(o))){this.#y.add(o),this.#A(Pp(this.#e,t,e.trim(),this.#x.now()));try{let o=await i(n,r,e.trim(),t);this.#N(n,a)&&this.#A(Fp(this.#e,t,o.activeTurnId)),this.#x.onSendAccepted?.(n,t)}catch(e){this.#N(n,a)&&(this.#A(Ip(this.#e,t)),this.#x.onSendError?.(e,t))}finally{this.#y.delete(o)}}}async interruptAndSend(e,t=this.#x.createKey()){let n=this.#n,r=this.#e.activeTurnId,i=this.#i,a=`${n}:${i}:${t}`;if(!(!n||!r||!e.trim()||this.#y.has(a))){this.#y.add(a),this.#A(Np(this.#e,t,e.trim(),this.#x.now()));try{await this.#x.relay.interruptTurn(n,r).catch(()=>void 0);let a=await this.#P(n,i,e.trim(),t);this.#N(n,i)&&this.#A(Fp(this.#e,t,a.activeTurnId??null)),this.#x.onSendAccepted?.(n,t)}catch(e){this.#N(n,i)&&(this.#A(Ip(this.#e,t)),this.#x.onSendError?.(e,t))}finally{this.#y.delete(a)}}}async interrupt(){let e=this.#n,t=this.#e.activeTurnId;if(!(!e||!t))try{await this.#x.relay.interruptTurn(e,t)}catch{}}async respond(e,t,n=this.#x.createKey()){let r=this.#n,i=this.#i,a=this.#e.interactions.find(t=>t.requestId===e),o=a?.operationId??n,s=`${r}:${i}:${o}`;if(!(!r||!a||a.state===`resolved`||a.state===`submitting`||this.#b.has(s))){this.#b.add(s),this.#A(Lp(this.#e,e,o));try{let n=await this.#x.relay.respondInteraction(r,e,t,o),a=n&&(n.outcome===`approved`||n.outcome===`denied`||n.outcome===`answered`||n.outcome===`dismissed`||n.outcome===`failed`)?n.outcome:t;this.#N(r,i)&&this.#e.interactions.find(t=>t.requestId===e)?.state!==`resolved`&&this.#A(zp(this.#e,e,a,this.#x.now()))}catch{this.#N(r,i)&&this.#A(Rp(this.#e,e,t))}finally{this.#b.delete(s)}}}async retryInteraction(e,t){let n=this.#e.interactions.find(t=>t.requestId===e);if(n?.state!==`failed`||!n.operationId)return;let r=t??n.attemptedOutcome,i=r===`approved`?{decision:`accept`}:r===`denied`?{decision:`decline`}:r;i!==void 0&&await this.respond(e,i,n.operationId)}refresh(){this.#n&&!this.#m&&this.#D(this.#n,this.#i)}dispose(){this.#v||(this.#v=!0,this.#I(),this.#x.document.removeEventListener(`visibilitychange`,this.#S),this.#x.window.removeEventListener(`focus`,this.#S))}#S=()=>{this.#x.document.visibilityState===`visible`&&this.refresh()};async#C(e,t){let n=this.#m;if(n||this.#D(e,t),this.#w(e,t,!1),n)return;let r=await this.#x.cache.read(e).catch(()=>null);!this.#N(e,t)||this.#a===t||!r||(this.#e={...kp(e,r),cursor:this.#e.cursor,snapshotting:this.#e.snapshotting,buffered:this.#e.buffered},this.#j())}#w(e,t,n=!0){if(!this.#N(e,t)||this.#o)return;let r=this.#x.location.protocol===`https:`?`wss:`:`ws:`,i;try{i=this.#x.websocket(`${r}//${this.#x.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#e.cursor}`)}catch{this.#x.onConnectionChange?.(!1),this.#s=!0,this.#j(),this.#g=this.#x.setTimeout(()=>this.#w(e,t),Math.min(1e3*2**this.#_++,1e4));return}this.#t.socketOpens++,this.#o=i,i.onopen=()=>{if(this.#N(e,t)&&this.#o===i){this.#x.onConnectionChange?.(!0);let r=this.#s;this.#s=!1,this.#_=0,r&&this.#j(),n&&!this.#m&&this.#D(e,t)}},i.onmessage=n=>this.#T(e,t,String(n.data)),i.onclose=()=>{if(!(!this.#N(e,t)||this.#o!==i)){if(this.#o=null,this.#x.onConnectionChange?.(!1),this.#c){this.#D(e,t);return}this.#s=!0,this.#j(),this.#g=this.#x.setTimeout(()=>this.#w(e,t),Math.min(1e3*2**this.#_++,1e4))}}}#T(e,t,n){if(!this.#N(e,t))return;let r;try{r=JSON.parse(n)}catch{return}if(r.type===`relay.resyncRequired`){this.#t.resyncs++,this.#c=!0,typeof r.currentSequence==`number`&&Number.isSafeInteger(r.currentSequence)&&r.currentSequence>=0&&(this.#l=Math.max(this.#l??0,r.currentSequence)),this.#D(e,t);return}if(r.type!==`relay.event`||!r.event||typeof r.event!=`object`)return;let i=r.event;if(!Number.isInteger(i.sequence)||typeof i.type!=`string`||!this.#E(i))return;if(i.type===`tool.efficiency.updated`){let e=i.sessionId;if(e!==void 0&&e!==this.#e.sessionId)return;let t=ps(i.payload,this.#e.sessionId??``);if(!t)return;i={sequence:i.sequence,type:i.type,payload:t}}([`agentMessageDelta`,`agentMessageStarted`,`agentMessageCompleted`,`interaction.requested`,`interaction.resolved`,`turnCompleted`,`turnInterrupted`].includes(i.type)||i.type===`activity.updated`&&nm(i.payload)||i.type===`session.updated`&&typeof i.payload.activeTurnId==`string`)&&this.#M(e);let a=Bp(this.#e,i);this.#A(a),this.#x.onRelayEvent?.(i),(i.type===`session.updated`||i.type===`plan.updated`||i.type===`plan.closed`||i.type===`agent.activity.updated`||i.type===`session.status.updated`||i.type===`autopilot.updated`||i.type===`org-plan.attention-required`||i.type===`org-plan.attention-resolved`)&&this.#x.onSessionEvent?.(i),a.snapshotting&&this.#D(e,t)}#E(e){let t=e.payload;if(!t||typeof t!=`object`)return e.type===`turnCompleted`||e.type===`turnInterrupted`||e.type===`plan.closed`;let n=t;return e.type===`agentMessageDelta`||e.type===`agentMessageStarted`||e.type===`agentMessageCompleted`?typeof n.text==`string`:e.type===`interaction.requested`?typeof n.requestId==`string`&&typeof n.kind==`string`:e.type===`interaction.resolved`?typeof n.requestId==`string`:e.type===`session.updated`?n.activeTurnId===null||typeof n.activeTurnId==`string`:e.type===`activity.updated`?typeof n.id==`string`&&typeof n.label==`string`&&typeof n.detail==`string`:e.type===`agent.activity.updated`?typeof n.sessionId==`string`&&!!n.root&&Array.isArray(n.subagents):e.type===`session.status.updated`?typeof n.state==`string`&&typeof n.reason==`string`:e.type===`tool.efficiency.updated`?ps(t,this.#e.sessionId??``)!==null:e.type===`plan.updated`||e.type===`plan.closed`||e.type.startsWith(`autopilot.`)||e.type.startsWith(`org-plan.`)}#D(e,t){if(this.#u?.id===e&&this.#u.generation===t)return this.#t.coalesced++,this.#u.promise;if(!this.#N(e,t))return Promise.resolve();let n=this.#e.snapshotting&&this.#e.buffered.size>0;this.#e=Mp(this.#e),this.#j(),this.#t.attempts++;let r=this.#x.relay.getHistory(e,{attempts:this.#t.attempts,coalesced:this.#t.coalesced}).then(r=>{let i=$p(r);if(this.#N(e,t)){if(!i){this.#A({...this.#e,snapshotting:!1,lifecycle:`recoverable`});return}if(this.#l!==null&&i.baseSequence<this.#l)throw Error(`CHAT_SNAPSHOT_BEHIND_RESYNC`);this.#f=0,this.#p=!1,this.#d&&this.#x.clearTimeout(this.#d),this.#d=null,this.#a=t,this.#A(Ap(this.#e,i));for(let t of i.items)t.kind===`user`&&typeof t.operationId==`string`&&this.#x.onHistoryPromptAccepted?.(e,t.operationId);(n||this.#c)&&(this.#c=!1,this.#l=null,this.#k(e,t))}}).catch(n=>{if(this.#N(e,t)){this.#A({...this.#e,snapshotting:!1,lifecycle:`recoverable`});let r=Gp[this.#f++];r===void 0?!this.#m&&!this.#p&&(this.#p=!0,this.#x.onHistoryError?.(n)):this.#O(e,t,r)}}).finally(()=>{this.#u?.promise===r&&(this.#u=null,this.#N(e,t)&&this.#e.snapshotting&&this.#D(e,t))});return this.#u={id:e,generation:t,promise:r},r}#O(e,t,n){this.#d&&this.#x.clearTimeout(this.#d);let r=this.#x.setTimeout(()=>{this.#d===r&&(this.#d=null,this.#N(e,t)&&this.#D(e,t))},n);this.#d=r}#k(e,t){let n=this.#o;this.#o=null,this.#x.onConnectionChange?.(!1),n?.close(),this.#g&&this.#x.clearTimeout(this.#g),this.#g=null,this.#w(e,t,!1)}#A(e){this.#n&&tm(e)&&this.#M(this.#n),this.#e=e,this.#j(),this.#n&&this.#x.cache.write(this.#n,this.#e).catch(()=>{})}#j(){this.#e.sessionId&&this.#e.lifecycle===`finished`&&!this.#e.activeTurnId?this.#r??=this.#x.now():this.#r=null,this.#x.publish(this.view)}#M(e){this.#h.delete(e),this.#n===e&&(this.#m=!1)}#N(e,t){return!this.#v&&this.#n===e&&this.#i===t}async#P(e,t,n,r){let i;for(let a of[0,50,150,300]){if(!this.#N(e,t))throw Error(`SESSION_CHANGED`);a&&await this.#F(a);try{return await this.#x.relay.startTurn(e,n,r)}catch(e){if(!rm(e,`SESSION_TURN_ACTIVE`))throw e;i=e}}throw i}#F(e){return new Promise(t=>this.#x.setTimeout(t,e))}#I(){this.#x.onConnectionChange?.(!1),this.#s=!1,this.#t={attempts:0,coalesced:0,resyncs:0,socketOpens:0},this.#c=!1,this.#l=null,this.#g&&this.#x.clearTimeout(this.#g),this.#g=null,this.#d&&this.#x.clearTimeout(this.#d),this.#d=null,this.#f=0,this.#p=!1,this.#m=!1;let e=this.#o;this.#o=null,e?.close()}};function tm(e){return!!(e.activeTurnId||e.messages.length||e.activities.some(nm)||e.prompts.length||e.interactions.length)}function nm(e){let t=e;return!po(t.mcpStartup)||typeof t.turnId==`string`||typeof t.actorTurnId==`string`}function rm(e,t){return Kp(e)&&e.code===t}function im(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.state===`working`||t.state===`idle`)&&[`needsYou`,`complete`,`rootTurn`,`agent`,`process`,`autopilot`,`incompleteWithoutContinuation`,`stopped`,`disconnected`,`unknown`].includes(t.reason)&&[`fresh`,`stale`,`reconciling`].includes(t.confidence)&&typeof t.observedAt==`string`&&!Number.isNaN(Date.parse(t.observedAt))&&typeof t.nextExpectedAction==`string`&&t.nextExpectedAction.length>0&&t.nextExpectedAction.length<=240}var am={FILE_PREVIEW_NOT_FOUND:`This file or folder no longer exists. Check the path and try again.`,FILE_PREVIEW_UNREADABLE:`This path could not be read. It must be inside the workspace and accessible without symbolic links.`,FILE_PREVIEW_UNSUPPORTED:`Preview supports UTF-8 text files and folders. This item cannot be displayed.`,FILE_PREVIEW_TOO_LARGE:`This file exceeds the 1 MiB preview limit. Open it locally to view its contents.`,INVALID_FILE_PREVIEW:`This file reference is invalid. Check its path and try again.`,RELAY_UNAVAILABLE:`The relay is unavailable. Check the connection and try again.`,SESSION_HISTORY_UNAVAILABLE:`Session history is unavailable. Check the relay connection and try opening the session again.`,SESSION_HISTORY_READ_FAILED:`Session history could not be loaded from its provider. Try again shortly; reopen the session if this persists.`,SESSION_WRITER_BUSY:`This thread is active in another Codex client. Release it there, then retry sending here.`,SESSION_WORKSPACE_UNAVAILABLE:`This session workspace is unavailable. Your message remains in the conversation for copying; restore workspace access before sending again.`,SESSION_RUNTIME_DEPENDENCY_FAILED:`A required Codex runtime dependency is unavailable. Check Codex, then retry.`,CODEX_PROTOCOL_INCOMPATIBLE:`The installed Codex runtime is incompatible with this relay. Update Codex before retrying.`,SESSION_ROLLOUT_MISSING:`This stored thread is no longer available.`,SESSION_RUNTIME_UNAVAILABLE:`The Codex runtime is unavailable. Retry shortly.`,SESSION_START_FAILED:`The session could not be started. Try again.`,ORG_EXECUTOR_PROFILE_UNAVAILABLE:`The Org-plan executor profile could not be read. Restore the installed Gestalt agent profile and try again.`,ORG_EXECUTOR_PROFILE_INVALID:`The Org-plan executor profile has invalid model settings. Repair the installed profile and try again.`,SESSION_CLOSE_FAILED:`The session could not be closed. Try again.`,SESSION_FORGET_FAILED:`The session could not be forgotten. It remains in Sessions; try Forget again.`,SESSION_RELEASE_UNCONFIRMED:`Session work could not be stopped. The session is retained; try Forget again.`,SESSION_CLEANUP_FAILED:`Temporary files could not be removed. The session is retained; try Forget again.`,SESSION_COPY_FAILED:`The CLI resume command could not be copied. Check clipboard access and try again.`,SESSION_DEFAULTS_READ_FAILED:`Saved session defaults could not be loaded. Using built-in defaults; check the configuration file and reload.`,SESSION_DEFAULTS_SAVE_FAILED:`Session defaults could not be saved. Try again.`,SESSION_MODELS_READ_FAILED:`Models could not be loaded for this provider. Select another provider and try again.`,SESSION_REFRESH_FAILED:`Sessions could not be refreshed. Try again.`,MESSAGE_SEND_FAILED:`The message was not sent. Your draft is preserved.`,GIT_SUMMARY_FAILED:`Repository status could not be loaded. Select it again to retry.`,GIT_PULL_FAILED:`The branch could not be refreshed. Resolve any Git conflicts and try again.`,GIT_CHECKOUT_FAILED:`The branch could not be selected. Refresh Git status and try again.`,GIT_PUSH_FAILED:`The push failed. Refresh Git status and resolve remote divergence first.`,GIT_CLONE_FAILED:`Clone failed.`,WORKSPACE_FILES_READ_FAILED:`Files could not be read. Try again.`,WORKSPACE_FILES_UPLOAD_FAILED:`The file could not be uploaded. Try dropping it again.`,WORKSPACE_FOLDER_CREATE_FAILED:`The folder could not be created. Check the name and try again.`,WORKSPACE_FOLDER_EXISTS:`An item with that name already exists. Choose a different folder name.`,QUIT_FAILED:`Gestalt Mobile could not quit cleanly. Try again or stop it from the terminal.`,TMP_CLEANUP_UNAVAILABLE:`Temporary files could not be checked. Try Clean TMP again.`,UPGRADE_FAILED:`Gestalt could not complete the upgrade and reconnect. Check update-restart.log and reload when Mobile is ready.`,UPGRADE_UNAVAILABLE:`Start Mobile with gestalt mobile to enable upgrades.`,DEBUG_CONTEXT_FAILED:`Session diagnostics could not be read. Reopen DEBUG to try again.`,DEBUG_ATTENTION_CHANGED:`This blocker is no longer active. Refresh the session and try again.`,DEBUG_CONTEXT_INVALID:`Select a valid blocker to debug.`,DEBUG_START_FAILED:`Self DEBUG could not start. Check Sessions for a saved debug session before trying again.`,DEBUG_TRACE_FAILED:`The diagnostic trace could not be opened. Check that the saved JSON file is still available.`,DEBUG_CONFIRMATION_EXPIRED:`The debug confirmation expired. Reopen DEBUG to confirm current session details.`,DEBUG_SOURCE_CHANGED:`The source session changed. Reopen DEBUG to confirm current session details.`};function om(e,t){let n=e instanceof Error?e.message:``,r=typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:``,i=Object.hasOwn(am,r)?r:Object.hasOwn(am,n)?n:t,a=typeof e==`object`&&e&&`retryable`in e?e.retryable===!0:!0;return{code:i,message:am[i],retryable:a}}var sm=q(`<small class="svelte-1izxxv2"> </small>`),cm=q(`<li class="svelte-1izxxv2"><div class="notification-meta svelte-1izxxv2"><strong class="svelte-1izxxv2"> </strong> <time class="svelte-1izxxv2"> </time></div> <p class="svelte-1izxxv2"> </p> <!></li>`),lm=q(`<ol aria-label="Recent notifications" class="svelte-1izxxv2"></ol>`),um=q(`<p class="empty svelte-1izxxv2" role="status">No recent notifications.</p>`),dm=q(`<main class="notification-history svelte-1izxxv2" aria-labelledby="notification-history-title"><header class="svelte-1izxxv2"><button type="button" class="svelte-1izxxv2">Back</button> <div><h1 id="notification-history-title" tabindex="-1" class="svelte-1izxxv2">Recent notifications</h1> <p class="svelte-1izxxv2">The latest notifications saved in this browser.</p></div></header> <!></main>`);function fm(e,t){F(t,!0);let n=z([]),r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});qi(()=>t.queue.subscribeHistory(e=>B(n,e)));function i(e){Dr().then(()=>e.focus())}var a=dm(),o=V(a),s=V(o),c=U(s,2);hi(V(c),()=>i),P(2),N(c),N(o);var l=U(o,2),u=e=>{var t=lm();Z(t,21,()=>G(n),e=>e.id,(e,t)=>{var n=cm(),i=V(n),a=V(i),o=V(a,!0);N(a);var s=U(a,2),c=V(s,!0);N(s),N(i);var l=U(i,2),u=V(l,!0);N(l);var d=U(l,2),f=e=>{var n=sm(),r=V(n);N(n),W(()=>Y(r,`Repeated ${G(t).occurrences??``} times.`)),J(e,n)};X(d,e=>{G(t).occurrences>1&&e(f)}),N(n),W((e,r)=>{Q(n,`data-kind`,G(t).kind),Y(o,G(t).kind),Q(s,`datetime`,e),Y(c,r),Y(u,G(t).message)},[()=>new Date(G(t).updatedAt).toISOString(),()=>r.format(G(t).updatedAt)]),J(e,n)}),N(t),J(e,t)},d=e=>{J(e,um())};X(l,e=>{G(n).length?e(u):e(d,-1)}),N(a),K(`click`,s,function(...e){t.onclose?.apply(this,e)}),J(e,a),I()}Br([`click`]);var pm={error:null,success:5e3,warning:1e4,info:7e3},mm=`gestalt-mobile.notification-history`;function hm(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function gm(e,t){try{let n=JSON.parse(e?.getItem(`gestalt-mobile.notification-history`)??`[]`);return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&[`error`,`success`,`warning`,`info`].includes(String(e.kind))&&typeof e.message==`string`&&typeof e.occurrences==`number`&&typeof e.createdAt==`number`&&typeof e.updatedAt==`number`).slice(-t):[]}catch{return[]}}function _m(e={}){let t=e.now??Date.now,n=e.setTimer??setTimeout,r=e.clearTimer??clearTimeout,i=new Set,a=new Set,o=new Map,s=[],c=e.historyLimit??50,l=gm(e.historyStorage,c),u=0,d=()=>s.map(e=>({...e})),f=()=>[...l].reverse().map(e=>({...e})),p=()=>i.forEach(e=>e(d())),m=()=>{try{e.historyStorage?.setItem(mm,JSON.stringify(l))}catch{}},h=()=>{m(),a.forEach(e=>e(f()))},g=e=>{let t=o.get(e);t?.handle&&r(t.handle),t&&(t.handle=null)},_=e=>{s.some(t=>t.id===e)&&(g(e),o.delete(e),s=s.filter(t=>t.id!==e),p())},v=e=>{let r=o.get(e);!r||r.pauseReasons.size>0||(r.startedAt=t(),r.handle=n(()=>_(e),r.remaining))};return{enqueue(e){if(e.code){let n=s.find(t=>t.kind===e.kind&&t.code===e.code);if(n)return s=s.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1}:e),l=l.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1,updatedAt:t()}:e),p(),h(),n.id}let n=t(),r=`toast-${n}-${++u}`,i={...e,id:r,occurrences:1};s=[...s,i],l=[...l,{...i,createdAt:n,updatedAt:n}].slice(-c);let a=pm[e.kind];return a!==null&&(o.set(r,{handle:null,remaining:a,startedAt:t(),pauseReasons:new Set}),v(r)),p(),h(),r},dismiss:_,pause(e,n){let r=o.get(e);!r||r.pauseReasons.has(n)||(r.pauseReasons.add(n),r.handle&&(r.remaining=Math.max(0,r.remaining-(t()-r.startedAt)),g(e)))},resume(e,t){let n=o.get(e);!n||!n.pauseReasons.delete(t)||n.pauseReasons.size>0||v(e)},snapshot:d,historySnapshot:f,subscribe(e){return i.add(e),e(d()),()=>i.delete(e)},subscribeHistory(e){return a.add(e),e(f()),()=>a.delete(e)}}}function vm(e){if(e.type!==`activity.updated`||!e.payload||typeof e.payload!=`object`)return null;let t=e.payload;return t.id===`gestalt-serena-availability`&&t.label===`Serena unavailable`?{kind:`warning`,code:`SERENA_UNAVAILABLE`,message:`Serena is unavailable in this session. Use native code tools. Connection availability will be checked when the runtime resumes.`}:t.id===`gestalt-xerj-availability`&&t.label===`Xerj unavailable`?{kind:`warning`,code:`XERJ_UNAVAILABLE`,message:`XERJ is unavailable in this session. Use rg and current source reads. Connection availability will be checked when the runtime resumes.`}:null}function ym(e){let t=new Map;return(n,r)=>{if(r.type!==`activity.updated`||!r.payload||typeof r.payload!=`object`)return;let i=po(r.payload.mcpStartup);if(!i)return;let a=JSON.stringify([n,i.threadId??i.runtimeId,i.serverName]),o=t.get(a);if(o&&(o.observedAt>i.observedAt||o.sequence!==void 0&&r.sequence!==void 0&&r.sequence<=o.sequence))return;if(t.size>=256&&!o){let n=t.entries().next().value;n&&(n[1].toastId&&e.dismiss(n[1].toastId),t.delete(n[0]))}if(i.status===`ready`){o?.toastId&&e.dismiss(o.toastId),t.set(a,{toastId:null,failureId:o?.failureId??null,observedAt:i.observedAt,sequence:r.sequence});return}if(!i.failure||o?.failureId===i.failure.failureId)return;o?.toastId&&e.dismiss(o.toastId);let s=i.failure.phase===`readiness`?`${ro(i.failure.readinessReason??`unknown`)} `:``,c=e.enqueue({kind:`warning`,code:`MCP_STARTUP_${n}_${i.failure.failureId}`,message:`${mo(i.serverName)} startup ${i.status}. ${s}${go(i.serverName)} Trace reference: ${i.failure.failureId}.`});t.set(a,{toastId:c,failureId:i.failure.failureId,observedAt:i.observedAt,sequence:r.sequence})}}var bm=q(`<small class="svelte-1a0rutm"> </small>`),xm=q(`<section aria-atomic="true"><span class="toast-symbol svelte-1a0rutm" aria-hidden="true"> </span> <span class="toast-copy svelte-1a0rutm"><strong class="svelte-1a0rutm"> </strong> <span> </span> <!></span> <button type="button" class="svelte-1a0rutm"><span aria-hidden="true">×</span></button></section>`),Sm=q(`<div class="toast-viewport svelte-1a0rutm" aria-label="Notifications"></div>`);function Cm(e,t){F(t,!0);let n=z([]),r=L(()=>G(n).slice(-3));qi(()=>t.queue.subscribe(e=>B(n,e)));var i=Sm();Z(i,21,()=>G(r),e=>e.id,(e,n)=>{var r=xm();let i;var a=V(r),o=V(a,!0);N(a);var s=U(a,2),c=V(s),l=V(c,!0);N(c);var u=U(c,2),d=V(u,!0);N(u);var f=U(u,2),p=e=>{var t=bm(),r=V(t);N(t),W(()=>Y(r,`Repeated ${G(n).occurrences??``} times.`)),J(e,t)};X(f,e=>{G(n).occurrences>1&&e(p)}),N(s);var m=U(s,2);N(r),W(()=>{i=wi(r,1,`toast svelte-1a0rutm`,null,i,{error:G(n).kind===`error`,success:G(n).kind===`success`,warning:G(n).kind===`warning`}),Q(r,`role`,G(n).kind===`error`?`alert`:`status`),Q(r,`aria-live`,G(n).kind===`error`?`assertive`:`polite`),Y(o,G(n).kind===`error`||G(n).kind===`warning`?`!`:G(n).kind===`success`?`✓`:`i`),Y(l,G(n).kind===`error`?`Error`:G(n).kind===`success`?`Success`:G(n).kind===`warning`?`Warning`:`Info`),Y(d,G(n).message),Q(m,`aria-label`,`Dismiss ${G(n).kind} notification`)}),zr(`pointerenter`,r,()=>t.queue.pause(G(n).id,`hover`)),zr(`pointerleave`,r,()=>t.queue.resume(G(n).id,`hover`)),K(`focusin`,r,()=>t.queue.pause(G(n).id,`focus`)),K(`focusout`,r,()=>t.queue.resume(G(n).id,`focus`)),K(`click`,m,()=>t.queue.dismiss(G(n).id)),J(e,r)}),N(i),J(e,i),I()}Br([`focusin`,`focusout`,`click`]);var wm=q(`<main class="evidence-page svelte-1j55xyh"><h1 class="svelte-1j55xyh">Git repository</h1> <p>Choose a destination and clone a repository.</p> <div class="evidence-composer svelte-1j55xyh"><label for="evidence-prompt">Prompt</label> <textarea id="evidence-prompt" class="evidence-prompt svelte-1j55xyh" rows="1">Review repository status</textarea></div></main> <nav class="evidence-nav svelte-1j55xyh" aria-label="Primary evidence navigation"><button type="button" class="svelte-1j55xyh">Sessions</button> <button type="button" aria-pressed="true" class="svelte-1j55xyh">Git</button> <button type="button" class="svelte-1j55xyh">Chat</button></nav> <!>`,1);function Tm(e,t){F(t,!0);let n=_m();qi(()=>{t.variant===`stacked`&&n.enqueue({kind:`success`,message:`Cloned.`}),n.enqueue({kind:`error`,code:`GIT_CLONE_FAILED`,message:`Clone failed.`})});var r=wm();Cm(U(H(r),4),{get queue(){return n}}),J(e,r),I()}var Em={sessionBase:()=>!0,gitRepositoryTarget:e=>e.isGitRepository,cloneDestination:e=>!e.isGitRepository};function Dm(e){let t=new Set,n=(e,r)=>{!e.isGitRepository&&r<=2&&t.add(e.id),e.children.forEach(e=>n(e,r+1))};return e.forEach(e=>n(e,1)),t}function Om(e,t){let n=new Set(e);return t.isGitRepository||(n.has(t.id)?n.delete(t.id):n.add(t.id)),n}function km(e,t){let n=[],r=(e,i,a)=>{n.push({node:e,level:i,parentId:a}),!e.isGitRepository&&t.has(e.id)&&e.children.forEach(t=>r(t,i+1,e.id))};return e.forEach(e=>r(e,1,null)),n}function Am(e,t){let n=(e,r)=>{if(e.id===t)return r;for(let t of e.children){let i=n(t,[...r,e.id]);if(i)return i}return null};for(let t of e){let e=n(t,[]);if(e)return e}return[]}function jm(e,t){for(let n of e){if(n.id===t)return n;let e=jm(n.children,t);if(e)return e}}function Mm(e,t,n,r){if(e){let i=jm(n,e);if(i&&r(i))return i.id;let a=Am(t,e);for(let e of a.toReversed()){let t=jm(n,e);if(t&&r(t))return t.id}}return Nm(n).find(r)?.id??null}function Nm(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}var Pm=q(`<button class="disclosure svelte-6z3q4v" type="button" tabindex="-1"><span aria-hidden="true"> </span></button>`),Fm=q(`<span class="disclosure-spacer svelte-6z3q4v" aria-hidden="true"></span>`),Im=q(`<span class="repository-badge svelte-6z3q4v">Git</span>`),Lm=q(`<div class="tree-row svelte-6z3q4v"><!> <button type="button" role="treeitem"><span class="selection-mark svelte-6z3q4v" aria-hidden="true"> </span> <span class="node-copy svelte-6z3q4v"><span class="node-name svelte-6z3q4v"> </span> <span class="node-path svelte-6z3q4v"> </span></span> <!></button></div>`),Rm=q(`<div class="filesystem-tree svelte-6z3q4v" role="tree"></div>`);function zm(e,t){F(t,!0);let n=$(t,`isSelectable`,3,()=>!0),r=z(null),i=sn({}),a=L(()=>km(t.roots,t.expandedIds)),o=L(()=>G(r)&&G(a).some(({node:e})=>e.id===G(r))?G(r):t.selectedId&&G(a).some(({node:e})=>e.id===t.selectedId)?t.selectedId:G(a)[0]?.node.id??null);function s(e){return!e.isGitRepository&&e.children.length>0}function c(e){return e===`.`?`~/`:`~/${e}`}function l(e){B(r,e,!0),i[e]?.focus()}function u(e,t){let n=Math.max(0,Math.min(G(a).length-1,t)),r=G(a)[n];r&&n!==e&&l(r.node.id)}function d(e){n()(e)&&t.onselect(e)}function f(e){s(e)&&t.onexpandedchange(Om(t.expandedIds,e))}function p(e,n,r){let{node:i,parentId:o}=n;switch(e.key){case`ArrowUp`:e.preventDefault(),u(r,r-1);break;case`ArrowDown`:e.preventDefault(),u(r,r+1);break;case`ArrowRight`:if(!s(i))return;e.preventDefault(),t.expandedIds.has(i.id)?G(a)[r+1]?.parentId===i.id&&u(r,r+1):f(i);break;case`ArrowLeft`:if(!t.expandedIds.has(i.id)&&!o)return;e.preventDefault(),s(i)&&t.expandedIds.has(i.id)?f(i):o&&l(o);break;case`Home`:e.preventDefault(),u(r,0);break;case`End`:e.preventDefault(),u(r,G(a).length-1);break;case`Enter`:case` `:e.preventDefault(),d(i);break}}var m=Rm();Z(m,23,()=>G(a),e=>e.node.id,(e,a,l)=>{let u=L(()=>G(a).node),m=L(()=>s(G(u)));var h=Lm();let g;var _=V(h),v=e=>{var n=Pm(),r=V(n),i=V(r,!0);N(r),N(n),W((e,t)=>{Q(n,`aria-label`,e),Y(i,t)},[()=>`${t.expandedIds.has(G(u).id)?`Collapse`:`Expand`} ${G(u).name}`,()=>t.expandedIds.has(G(u).id)?`−`:`+`]),K(`click`,n,()=>f(G(u))),J(e,n)},y=e=>{J(e,Fm())};X(_,e=>{G(m)?e(v):e(y,-1)});var b=U(_,2);let x;var S=V(b),C=V(S,!0);N(S);var w=U(S,2),T=V(w),E=V(T,!0);N(T);var D=U(T,2),O=V(D,!0);N(D),N(w);var ee=U(w,2),te=e=>{J(e,Im())};X(ee,e=>{G(u).isGitRepository&&e(te)}),N(b),Gi(b,(e,t)=>i[t.id]=e,e=>i?.[e.id],()=>[G(u)]),N(h),W((e,n,r,i,s)=>{g=Ei(h,``,g,e),x=wi(b,1,`tree-item svelte-6z3q4v`,null,x,{selected:t.selectedId===G(u).id,repository:G(u).isGitRepository}),Q(b,`aria-level`,G(a).level),Q(b,`aria-expanded`,n),Q(b,`aria-selected`,t.selectedId===G(u).id),Q(b,`aria-disabled`,r),Q(b,`tabindex`,G(o)===G(u).id?0:-1),Q(b,`title`,i),Y(C,t.selectedId===G(u).id?`✓`:``),Y(E,G(u).name),Y(O,s)},[()=>({"--tree-level":Math.min(G(a).level-1,6)}),()=>G(m)?t.expandedIds.has(G(u).id):void 0,()=>!n()(G(u)),()=>c(G(u).relativePath),()=>c(G(u).relativePath)]),zr(`focus`,b,()=>B(r,G(u).id,!0)),K(`keydown`,b,e=>p(e,G(a),G(l))),K(`click`,b,()=>d(G(u))),J(e,h)}),N(m),W(()=>Q(m,`aria-label`,t.label)),J(e,m),I()}Br([`click`,`keydown`]);var Bm=q(`<section class="evidence-shell svelte-1d6w4ti" aria-labelledby="evidence-title"><p class="eyebrow svelte-1d6w4ti"> </p> <h1 id="evidence-title" class="svelte-1d6w4ti"> </h1> <p class="instructions svelte-1d6w4ti"> </p> <!></section>`);function Vm(e,t){F(t,!0);let n=(e,t)=>({id:e,name:t,relativePath:e,isGitRepository:!0,children:[]}),r=[{id:`.`,name:`development-workspace-with-a-long-name`,relativePath:`.`,isGitRepository:!1,children:[{id:`dyne`,name:`dyne`,relativePath:`dyne`,isGitRepository:!1,children:[{id:`dyne/mobile-applications`,name:`mobile-applications-and-experiments`,relativePath:`dyne/mobile-applications`,isGitRepository:!1,children:[n(`dyne/mobile-applications/gestalt-mobile`,`gestalt-mobile-with-an-extraordinarily-long-repository-name`)]},n(`dyne/zenroom`,`zenroom`),n(`dyne/zenflows`,`zenflows`),n(`dyne/did`,`did-toolkit`),n(`dyne/api`,`api-gateway`),n(`dyne/docs`,`documentation-portal`)]},{id:`personal`,name:`personal-projects`,relativePath:`personal`,isGitRepository:!1,children:[]}]}],i=z(sn(new Set([`.`,`dyne`,`dyne/mobile-applications`]))),a=z(null),o=L(()=>t.context===`sessions`?`dyne/mobile-applications`:`dyne/mobile-applications/gestalt-mobile`),s=L(()=>G(a)??G(o));var c=Bm(),l=V(c),u=V(l,!0);N(l);var d=U(l,2),f=V(d,!0);N(d);var p=U(d,2),m=V(p,!0);N(p);var h=U(p,2);{let e=L(()=>t.context===`sessions`?`Session base`:`Git repository`),n=L(()=>t.context===`sessions`?Em.sessionBase:Em.gitRepositoryTarget);zm(h,{get roots(){return r},get expandedIds(){return G(i)},get selectedId(){return G(s)},get label(){return G(e)},get isSelectable(){return G(n)},onexpandedchange:e=>B(i,e,!0),onselect:e=>B(a,e.id,!0)})}N(c),W(()=>{Y(u,t.context===`sessions`?`Sessions`:`Git`),Y(f,t.context===`sessions`?`Session base`:`Git repository`),Y(m,t.context===`sessions`?`Select the folder Codex should use as its working directory.`:`Select a repository for Git actions.`)}),J(e,c),I()}function Hm(e){return e.branch===null?{enabled:!1,reason:`Select a local branch to push.`}:e.upstream?(e.behind??0)>0?{enabled:!1,reason:`Pull upstream changes before pushing.`}:e.ahead<1?{enabled:!1,reason:`There are no commits to push.`}:{enabled:!0,reason:null}:e.branch?e.originUrl?{enabled:!0,reason:null}:{enabled:!1,reason:`No origin remote is configured.`}:{enabled:!1,reason:`Select a local branch to push.`}}function Um(e,t=Date.now()){if(!e)return`Not fetched yet`;let n=Math.max(0,t-new Date(e).getTime()),r=Math.floor(n/6e4);if(r<1)return`Fetched just now`;if(r<60)return`Fetched ${r}m ago`;let i=Math.floor(r/60);return i<24?`Fetched ${i}h ago`:`Fetched ${Math.floor(i/24)}d ago`}function Wm(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown time`;let r=Math.round((n-t)/1e3),i=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60],[`second`,1]],[a,o]=i.find(([,e])=>Math.abs(r)>=e)??i.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(r/o),a)}var Gm=q(`<p class="clone-status svelte-pudr3t" role="status"> </p>`),Km=q(`<option> </option>`),qm=q(`<p class="svelte-pudr3t"> </p>`),Jm=q(`<p id="git-push-help" class="action-help svelte-pudr3t"> </p>`),Ym=q(`<section aria-label="Confirm push"><p> </p> <button type="button"> </button> <button type="button">Cancel</button></section>`),Xm=q(`<li class="commit-entry svelte-pudr3t"><div class="commit-subject svelte-pudr3t"><code class="svelte-pudr3t"> </code><span> </span></div> <div class="commit-meta svelte-pudr3t"><span> </span><time class="svelte-pudr3t"> </time></div></li>`),Zm=q(`<section class="commit-history svelte-pudr3t" aria-labelledby="recent-commits-title"><h3 id="recent-commits-title" class="svelte-pudr3t">Recent commits</h3> <ol class="commit-list svelte-pudr3t" aria-label="Recent commits"></ol></section>`),Qm=q(`<div class="git-overview svelte-pudr3t"><div class="git-status svelte-pudr3t"><label for="git-branch">Branch</label> <select id="git-branch"></select> <p class="svelte-pudr3t"> </p> <!> <p class="svelte-pudr3t"><time> </time></p> <p class="svelte-pudr3t"> </p></div> <div class="git-actions svelte-pudr3t"><button type="button" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" class="svelte-pudr3t"><span aria-hidden="true">↓</span> </button> <!></div></div> <!> <!>`,1),$m=q(`<p>This workspace is not a Git repository.</p>`),eh=q(`<p role="status">Loading repository status…</p>`),th=q(`<p><strong> </strong> is available as a Clone destination. Select a Git repository
101
+ ${G(r).files===1?`file`:`files`} changed · `),Y(s,`+${G(r).additions??`?`??``}`),Y(l,`−${G(r).deletions??`?`??``}`)}),J(e,t)};X(a,e=>{G(n).length&&e(o)}),J(e,i)},r=(e,n=b)=>{$c(e,{get text(){return n()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()},get clipboard(){return m()}})},i=(e,n=b)=>{bf(e,{get text(){return n()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()},get clipboard(){return m()}})},a=$(t,`activeTurnId`,3,null),o=$(t,`autopilotAuditTruncated`,3,!1),s=$(t,`interactions`,19,()=>[]),c=$(t,`attention`,3,null),l=$(t,`attentionPending`,3,!1),u=$(t,`onattentionresolve`,3,()=>{}),d=$(t,`debugPending`,3,!1),f=$(t,`answers`,19,()=>({})),p=$(t,`submittedAnswers`,19,()=>({})),m=$(t,`clipboard`,19,()=>globalThis.navigator?.clipboard),h=$(t,`onanswer`,3,()=>{}),g=$(t,`onquiz`,3,()=>{}),_=$(t,`onpermission`,3,()=>{}),v=$(t,`ondecision`,3,()=>{}),y=$(t,`onretry`,3,()=>{}),x=$(t,`oncopyresult`,3,()=>{}),S=L(()=>t.activities.filter(e=>!vu(e))),C=L(()=>{let e=wu(t.messages);if(!c()||e.some(e=>e.kind===`audit`&&e.attention?.requestId===c().requestId))return e;let n=dl(c().attention);if(!n)return e;let r=c().requestedAt?Date.parse(c().requestedAt):void 0,i=r!==void 0&&Number.isFinite(r)?r:void 0,a=i===void 0?-1:e.findIndex(e=>e.occurredAt!==void 0&&e.occurredAt>i);return e.splice(a<0?e.length:a,0,{id:`attention:${c().requestId}`,kind:`audit`,text:`Needs attention`,attention:{...c(),attention:n},occurredAt:i,count:1,timestamps:i===void 0?[]:[i]}),e}),w=L(()=>G(C).flatMap(e=>e.kind===`audit`&&e.attention?[O(e.attention)]:[])),T=L(()=>s().filter(e=>Su(e)&&e.state!==`resolved`)),E=new Set;Fn(()=>{let e=new Set([...G(T).map(e=>`chat-request-${e.requestId}`),...c()?[`chat-attention-${c().requestId}`]:[]]);for(let t of E)!e.has(t)&&document.getElementById(t)?.contains(document.activeElement)&&Dr().then(()=>document.getElementById(t)?.focus({preventScroll:!0}));E=e});let D=L(()=>{let e=wu(Cu(t.messages,s(),G(w),p())).filter(e=>!c()||e.kind!==`audit`||e.attention?.requestId!==c().requestId).map(e=>{if(e.kind!==`audit`||!e.attention)return e;let t=s().find(t=>t.requestId===e.attention?.requestId)?.resolvedAt;return t===void 0?e:{...e,occurredAt:t}});for(let t of s().filter(e=>Su(e)&&e.state===`resolved`)){let n={id:t.key,kind:`interaction`,interaction:t,occurredAt:t.resolvedAt??t.occurredAt},r=n.occurredAt===void 0?-1:e.findIndex(e=>e.occurredAt!==void 0&&e.occurredAt>n.occurredAt);e.splice(r<0?e.length:r,0,n)}return e.map((e,t)=>({entry:e,index:t})).sort((e,t)=>e.entry.occurredAt!==void 0&&t.entry.occurredAt!==void 0&&e.entry.occurredAt-t.entry.occurredAt||e.index-t.index).map(({entry:e})=>e).toReversed()});function O(e){let n=e.requestedAt?Date.parse(e.requestedAt):NaN,r=t.messages.filter(t=>t.role===`assistant`&&t.turnId===e.turnId),i=r.findLast(e=>e.phase===`final_answer`&&e.occurredAt!==void 0&&e.occurredAt>=n),a=r.findLast(e=>e.phase===`commentary`&&e.occurredAt!==void 0&&e.occurredAt<=n),o=c()?.requestId===e.requestId&&c().supervisorReport?c().supervisorReport:bs(i?.text??a?.text);return{...e,...o?{supervisorReport:o}:{}}}let ee=sn({}),te=z(sn(Date.now()));qi(()=>{let e=globalThis.setInterval(()=>B(te,Date.now(),!0),1e3);return()=>globalThis.clearInterval(e)});let ne=L(()=>G(C).filter(e=>e.kind===`user`)),re=L(()=>G(D).filter(e=>e.kind===`assistant`).toReversed()),ie=L(()=>G(re).at(-1)?.id),ae=L(()=>new Map(G(re).filter(e=>e.turnId).map(e=>[e.turnId,e.id]))),oe=L(()=>new Map(G(ne).filter(e=>e.turnId).map(e=>[e.turnId,e.id])));function se(e){if(e.turnId){let t=G(ae).get(e.turnId);if(t)return t}return e.occurredAt===void 0?G(ie)??null:G(re).find(t=>t.answer!==null&&t.occurredAt!==void 0&&t.occurredAt>=e.occurredAt)?.id??null}function ce(e){if(e.turnId){let t=G(oe).get(e.turnId);if(t)return t}return e.occurredAt===void 0?null:G(ne).findLast(t=>t.occurredAt!==void 0&&t.occurredAt<=e.occurredAt)?.id??null}let le=L(()=>{let e=new Map;for(let t of G(S)){let n=se(t)??ce(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return e}),ue=L(()=>G(le).get(null)??[]);function de(e){return e.filter(e=>!e.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))}function fe(e){return!!(e.kind===`assistant`&&a()&&(e.turnId===a()||!e.turnId&&e.id===G(ie)))}function k(e){return!!(e.kind===`user`&&a()&&(e.turnId===a()||!e.turnId))}function pe(e,t){return yl(G(D)[e+1]?.occurredAt,t)}var me=Gf(),he=H(me),ge=e=>{_u(e,{children:(e,n)=>{var r=Tf(),i=H(r),a=e=>{{let n=L(()=>O(c())),r=L(()=>`chat-attention-${c().requestId}`);sl(e,{get attention(){return G(n)},get pending(){return l()},get controlId(){return G(r)},get onresolve(){return u()},get ondebug(){return t.onattentiondebug},get debugPending(){return d()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}})}};X(i,e=>{c()&&e(a)}),hu(U(i,2),{get interactions(){return G(T)},get answers(){return f()},get submittedAnswers(){return p()},get onanswer(){return h()},get onquiz(){return g()},get onpermission(){return _()},get ondecision(){return v()},get onretry(){return y()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}}),J(e,r)},$$slots:{default:!0}})};X(he,e=>{(c()||G(T).length)&&e(ge)});var _e=U(he,2),ve=V(_e),ye=e=>{var t=Df(),r=V(t),i=V(r),o=e=>{var t=Ef(),r=U(H(t),2);{let e=L(()=>de(G(ue)));Ro(r,{get activities(){return G(e)},variant:`live`})}var i=U(r,2);n(i,()=>G(ue)),J(e,t)},s=e=>{Nl(e,{get activities(){return G(ue)},get now(){return G(te)}})};X(i,e=>{a()?e(o):e(s,-1)}),N(r),N(t),W(()=>wi(r,1,vi(a()?`progress-turn`:`orphan-activity-turn`),`svelte-1im954t`)),J(e,t)};X(ve,e=>{G(ue).length&&e(ye)});var be=U(ve,2);Z(be,19,()=>G(D),e=>e.id,(e,a,o)=>{var m=Uf(),b=V(m),S=e=>{{let n=L(()=>[G(a).interaction]);hu(e,{get interactions(){return G(n)},get answers(){return f()},get submittedAnswers(){return p()},get onanswer(){return h()},get onquiz(){return g()},get onpermission(){return _()},get ondecision(){return v()},get onretry(){return y()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}})}},C=e=>{var n=Jr(),r=H(n),i=e=>{{let n=L(()=>O(G(a).attention)),r=L(()=>c()?.requestId!==G(a).attention.requestId),i=L(()=>s().find(e=>e.requestId===G(a).attention?.requestId)?.resolvedAt),o=L(()=>`chat-attention-${G(a).attention.requestId}`);sl(e,{get attention(){return G(n)},get historical(){return G(r)},get resolvedAt(){return G(i)},get pending(){return l()},get controlId(){return G(o)},get onresolve(){return u()},get ondebug(){return t.onattentiondebug},get debugPending(){return d()},get onopenorg(){return t.onopenorg},get onopenfile(){return t.onopenfile},get oncopyresult(){return x()}})}},o=e=>{var t=Af(),n=U(V(t)),r=U(n),i=e=>{var t=xf(),n=V(t,!0);N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,r)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(r,e=>{G(a).occurredAt&&e(i)});var o=U(r,2),s=e=>{var t=kf(),n=V(t),r=V(n);N(n);var i=U(n,2);Z(i,21,()=>G(a).timestamps,e=>`${G(a).id}:${e}`,(e,t)=>{var n=Of(),r=V(n),i=V(r,!0);N(r),N(n),W((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t)).toISOString(),()=>bl(G(t))]),J(e,n)}),N(i),N(t),W(()=>Y(r,`Show ${G(a).count??``} timestamps`)),J(e,t)};X(o,e=>{G(a).count>1&&e(s)}),N(t),W(()=>Y(n,` ${G(a).text??``}${G(a).count>1?` · ${G(a).count} times`:``} `)),J(e,t)};X(r,e=>{G(a).attention?e(i):e(o,-1)}),J(e,n)},w=e=>{let t=L(()=>G(le).get(G(a).id)??[]);var i=Nf(),s=H(i),c=U(V(s),2),l=e=>{var t=jf(),n=V(t),r=U(n),i=e=>{var t=qr();W(e=>Y(t,`· ${e??``}`),[()=>pe(G(o),G(a).occurredAt)]),J(e,t)},s=L(()=>pe(G(o),G(a).occurredAt));X(r,e=>{G(s)&&e(i)}),N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,`${r??``} `)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(c,e=>{G(a).occurredAt&&e(l)}),N(s);var u=U(s,2),d=V(u);r(d,()=>G(a).text),N(u);var f=U(u,2),p=e=>{var r=Mf(),i=V(r),o=e=>{var r=Ef(),i=U(H(r),2);{let e=L(()=>de(G(t)));Ro(i,{get activities(){return G(e)},variant:`live`})}var a=U(i,2);n(a,()=>G(t)),J(e,r)},s=L(()=>k(G(a))),c=e=>{Nl(e,{get activities(){return G(t)},get now(){return G(te)}})};X(i,e=>{G(s)?e(o):e(c,-1)}),N(r),W(e=>wi(r,1,e,`svelte-1im954t`),[()=>vi(k(G(a))?`progress-turn`:`orphan-activity-turn`)]),J(e,r)};X(f,e=>{G(t).length&&e(p)}),J(e,i)},T=e=>{let t=L(()=>G(le).get(G(a).id)??[]);var s=Bf(),c=V(s),l=V(c),u=V(l,!0);N(l);var d=U(l,2),f=e=>{var t=jf(),n=V(t),r=U(n),i=e=>{var t=qr();W(e=>Y(t,`· ${e??``}`),[()=>pe(G(o),G(a).occurredAt)]),J(e,t)},s=L(()=>pe(G(o),G(a).occurredAt));X(r,e=>{G(s)&&e(i)}),N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,`${r??``} `)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(d,e=>{G(a).occurredAt&&e(f)}),N(c);var p=U(c,2),m=e=>{var r=Ff(),o=H(r),s=V(o);i(s,()=>G(a).answer),N(o);var c=U(o,2),l=e=>{var t=Pf(),n=V(t);i(n,()=>G(a).commentary),N(t),J(e,t)};X(c,e=>{G(a).commentary&&e(l)});var u=U(c,2);{let e=L(()=>de(G(t)));Ro(u,{get activities(){return G(e)},variant:`live`})}var d=U(u,2);n(d,()=>G(t)),J(e,r)},h=L(()=>fe(G(a))),g=e=>{var t=Lf(),n=V(t),r=e=>{var t=If(),n=V(t),r=V(n,!0);N(n),P(),N(t),W(e=>{Q(t,`aria-expanded`,e),Q(t,`aria-controls`,`commentary-${G(a).id}`),Y(r,ee[G(a).id]?`⌄`:`›`)},[()=>!!ee[G(a).id]]),K(`click`,t,()=>ee[G(a).id]=!ee[G(a).id]),J(e,t)};X(n,e=>{G(a).commentary&&e(r)}),N(t),J(e,t)},_=L(()=>G(a).commentary||de(G(t)).length);X(p,e=>{G(h)?e(m):G(_)&&e(g,1)});var v=U(p,2),y=e=>{var t=Rf(),n=V(t);r(n,()=>G(a).commentary),N(t),W(()=>Q(t,`id`,`commentary-${G(a).id}`)),J(e,t)},b=L(()=>!fe(G(a))&&G(a).commentary&&ee[G(a).id]);X(v,e=>{G(b)&&e(y)});var x=U(v,2),S=e=>{var n=zf(),i=H(n),o=V(i);r(o,()=>G(a).answer),N(i),Nl(U(i,2),{get activities(){return G(t)},get now(){return G(te)}}),J(e,n)},C=L(()=>!fe(G(a)));X(x,e=>{G(C)&&e(S)}),N(s),W(e=>Y(u,e),[()=>fe(G(a))?`working`:`answer`]),J(e,s)},E=e=>{let t=L(()=>G(le).get(G(a).id)??[]);var r=Hf(),s=V(r),c=U(V(s),2),l=e=>{var t=jf(),n=V(t),r=U(n),i=e=>{var t=qr();W(e=>Y(t,`· ${e??``}`),[()=>pe(G(o),G(a).occurredAt)]),J(e,t)},s=L(()=>pe(G(o),G(a).occurredAt));X(r,e=>{G(s)&&e(i)}),N(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,`${r??``} `)},[()=>new Date(G(a).occurredAt).toISOString(),()=>bl(G(a).occurredAt)]),J(e,t)};X(c,e=>{G(a).occurredAt&&e(l)}),N(s);var u=U(s,2),d=e=>{var t=Vf(),n=V(t);i(n,()=>G(a).commentary),N(t),J(e,t)};X(u,e=>{G(a).commentary&&e(d)});var f=U(u,2),p=e=>{{let n=L(()=>de(G(t)));Ro(e,{get activities(){return G(n)},variant:`live`})}},m=L(()=>fe(G(a))),h=e=>{Nl(e,{get activities(){return G(t)},get now(){return G(te)}})};X(f,e=>{G(m)?e(p):e(h,-1)});var g=U(f,2),_=e=>{n(e,()=>G(t))},v=L(()=>fe(G(a)));X(g,e=>{G(v)&&e(_)}),N(r),J(e,r)};X(b,e=>{G(a).kind===`interaction`?e(S):G(a).kind===`audit`?e(C,1):G(a).kind===`user`?e(w,2):G(a).answer===null?G(a).commentary!==null&&e(E,4):e(T,3)}),N(m),W(()=>wi(m,1,vi(G(a).kind===`user`?`prompt-turn`:G(a).kind===`audit`?`audit-item`:`answer-item`),`svelte-1im954t`)),J(e,m)});var xe=U(be,2),Se=e=>{J(e,Wf())};X(xe,e=>{o()&&e(Se)}),N(_e),fi(U(_e,2),()=>t.footer??b),J(e,me),I()}Br([`click`]);var qf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0;function Jf(e,t){if(t.type!==`activity.updated`||!e?.runtimeId||!e.observedAt||!t.occurredAt||!Number.isFinite(Date.parse(e.observedAt))||!Number.isFinite(Date.parse(t.occurredAt))||Date.parse(t.occurredAt)<=Date.parse(e.observedAt))return e;let n=t.payload,r=n?.repositoryReadiness;if(n?.runtimeId!==e.runtimeId||!r?.readiness?.repository||typeof r.threadId!=`string`)return e;let i=e.repositories.find(e=>e.threadId===r.threadId&&e.readiness.repository?.id===r.readiness.repository?.id);if(!i&&e.repositories.length>=64)return e;let a=qf(t.sequence),o=i?.activityOrder;if(o){let n=Date.parse(t.occurredAt),r=Date.parse(o.occurredAt);if(n<r||o.sequence!==void 0&&(a===void 0||a<=o.sequence)||n===r&&(o.sequence===void 0||a===void 0))return e}return{...e,repositories:[...e.repositories.filter(e=>e.threadId!==r.threadId||e.readiness.repository?.id!==r.readiness.repository?.id),{...r,activityOrder:{occurredAt:t.occurredAt,...a===void 0?{}:{sequence:a}}}]}}var Yf=[150,300,600];function Xf(e){return new Promise(t=>setTimeout(t,e))}function Zf(e){return e.status===502||e.status===503||e.status===504}async function Qf(e=fetch){for(let t=0;t<=Yf.length;t+=1){let n;try{n=await e(`/api/bootstrap`)}catch(e){if(e instanceof Error&&e.name===`AbortError`)throw e;if(t===Yf.length)throw Error(`BOOTSTRAP_FAILED`);await Xf(Yf[t]);continue}if(n.ok)return n.json();if(!Zf(n)||t===Yf.length)throw Error(`BOOTSTRAP_FAILED`);await Xf(Yf[t])}throw Error(`BOOTSTRAP_FAILED`)}var $f=`gestalt-mobile`,ep=3,tp=[`settings`,`drafts`,`cursors`,`messages`,`chat-projections`];function np(e){return new Promise((t,n)=>{let r=e.open($f,ep);r.onupgradeneeded=()=>{for(let e of tp)r.result.objectStoreNames.contains(e)||r.result.createObjectStore(e)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}function rp(e,t,n){return op(e.transaction(t,`readonly`).objectStore(t).get(n))}function ip(e,t,n,r){return op(e.transaction(t,`readwrite`).objectStore(t).put(r,n))}function ap(e,t,n){return op(e.transaction(t,`readwrite`).objectStore(t).delete(n))}function op(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}var sp=`chat-projections`,cp=e=>({version:1,cursor:e.cursor,lifecycle:e.lifecycle,activeTurnId:e.activeTurnId,messages:e.messages.filter(e=>e.role===`user`).slice(-200),activities:[],prompts:e.prompts.slice(-200),interactions:e.interactions.map(({requestId:e,key:t,kind:n,turnId:r,state:i,operationId:a,attemptedOutcome:o})=>({requestId:e,key:t,kind:n,...r?{turnId:r}:{},state:i,...a?{operationId:a}:{},...i===`resolved`&&(o===`approved`||o===`denied`||o===`answered`||o===`dismissed`)?{attemptedOutcome:o}:{},...typeof o==`object`&&o&&(o.decision===`accept`||o.decision===`decline`)?{attemptedOutcome:{decision:o.decision}}:{}})).slice(-200),buffered:[]});function lp(e=globalThis.indexedDB){if(!e)return{read:async()=>null,write:async()=>{}};let t=np(e);return t.catch(()=>{}),{read:async e=>{try{return await rp(await t,sp,e)}catch{return null}},write:async(e,n)=>{try{await ip(await t,sp,e,cp(n))}catch{}}}}var up=`chat-session`;function dp(e){return new URLSearchParams(e).get(`chat-session`)?.trim()||null}function fp(e,t){let n=new URL(e);return n.search=``,n.hash=``,n.searchParams.set(up,t),n.toString()}function pp(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return`gestalt-chat-${(t>>>0).toString(36)}`}function mp(e){let t=gp(e,`requestId`),n=dl(gp(e,`payload`));if(typeof t!=`string`||t.length>256||!n)return;let r=gp(e,`turnId`),i=gp(e,`requestedAt`);return{requestId:t,turnId:typeof r==`string`?r:null,requestedAt:typeof i==`string`?i:null,attention:n}}function hp(e,t){if(e===`autopilot.turn-started`)return`Continued execution automatically`;if(e===`autopilot.final-rejected`)return`Kept incomplete supervised work active`;if(e===`autopilot.executor-resumed`)return`Resumed the assigned executor`;if(e===`autopilot.process-monitoring`)return`Monitoring executor background work`;if(e===`autopilot.process-result-consumed`)return`Consumed background work result`;if(e===`autopilot.process-terminated`)return gp(t,`reason`)===`resourceBudget`?`Stopped background work at its resource limit`:`Stopped executor background work`;if(e===`autopilot.turn-failed`)return gp(t,`code`)===`START_UNAVAILABLE`?`Automatic continuation could not start: session runtime unavailable`:`Automatic continuation failed`;if(e===`org-plan.attention-required`)return`Needs attention`;if(e===`org-plan.attention-resolved`)return gp(t,`outcome`)===`failed`?`Attention resolution failed`:`Attention resolved`;if(e!==`autopilot.updated`)return null;let n=gp(t,`state`),r=gp(t,`reason`),i=_s(gp(t,`providerFailure`));return n===`safetyPaused`&&i?`Autopilot paused: ${vs(i)}`:n===`safetyPaused`&&r===`usageLimitExceeded`?`Autopilot paused: Codex usage limit reached`:n===`completed`?`Completed the supervised plan`:n===`attentionRequired`&&r===`noPlanProgress`?`Automatic continuation stopped: no agent progress`:n===`attentionRequired`&&r===`reconcileFailed`?`Automatic continuation stopped: agent status unavailable`:n===`attentionRequired`&&r===`actionRateExceeded`?`Automatic continuation stopped: too many automatic actions`:null}function gp(e,t){return e&&typeof e==`object`?e[t]:void 0}var _p=()=>({sessionId:null,cursor:0,snapshotting:!1,lifecycle:`finished`,activeTurnId:null,messages:[],activities:[],prompts:[],interactions:[],autopilotAuditTruncated:!1,buffered:new Map}),vp=(e=null)=>({..._p(),sessionId:e});function yp(e){return e.kind===`autopilot`?{id:`item:${e.id}`,role:`audit`,text:`Continued execution automatically`,...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.controlId==`string`?{controlId:e.controlId}:{},complete:!0}:e.kind!==`user`&&e.kind!==`agent`||typeof e.text!=`string`?null:{id:`item:${e.id}`,role:e.kind===`user`?`user`:`assistant`,text:e.text,...e.phase===`commentary`||e.phase===`final_answer`?{phase:e.phase}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.turnId==`string`?{turnId:e.turnId}:{},complete:!0}}function bp(e){return{id:e.id,role:`audit`,text:e.label,occurredAt:e.occurredAt,...e.controlId?{controlId:e.controlId}:{},...e.attention?{attention:e.attention}:{},complete:!0}}function xp(e){let t=Sp(e.occurredAt),n=hp(e.type,e.payload),r=e.payload&&typeof e.payload==`object`&&typeof e.payload.controlId==`string`?e.payload.controlId:void 0;return n&&t!==void 0?bp({id:`audit:${e.sequence}`,label:n,occurredAt:t,...r?{controlId:r}:{},...e.type===`org-plan.attention-required`&&mp(e.payload)?{attention:mp(e.payload)}:{}}):null}function Sp(e){if(typeof e!=`string`)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Cp(e){let t=Sp(e.requestedAt),n=Sp(e.resolvedAt);return{requestId:e.requestId,key:`interaction:${e.requestId}`,kind:e.kind,turnId:e.turnId,payload:`payload`in e?e.payload:null,state:e.resolvedAt?e.outcome===`failed`?`failed`:`resolved`:`pending`,...e.resolvedAt?{attemptedOutcome:e.outcome}:{},...t===void 0?{}:{occurredAt:t},...n===void 0?{}:{resolvedAt:n}}}function wp(e,t){return t===`approved`||t===`denied`||t===`answered`||t===`dismissed`||t===`failed`?t:e?.kind===`quiz`||e?.kind===`userInput`?`answered`:typeof t==`object`&&t&&t.decision===`decline`?`denied`:e?`approved`:void 0}function Tp(e,t){return e?t===`finished`||t===`interrupted`?t:`working`:t===`working`||t===`starting`||t===`recoverable`?`finished`:t}function Ep(e){return[...new Map(e.map(e=>[e.key??e.id??``,e])).values()]}function Dp(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?{...t,...t.occurredAt===void 0&&e.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}}:e):[...e,t]}function Op(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map(n.map((e,t)=>[e.id,t])),a=new Set(t.filter(e=>e.state!==`canonical`).map(e=>e.operationId)),o=new Set,s=e.flatMap(e=>{let i=yp(e);if(!i)return[];if(e.kind===`user`){let n=t.find(t=>typeof e.operationId==`string`&&e.operationId===t.operationId||typeof e.turnId==`string`&&e.turnId===t.turnId),s=!n&&t.filter(t=>t.state!==`canonical`&&t.text===e.text).length===1?t.find(t=>t.state!==`canonical`&&t.text===e.text):void 0,c=n??s;if(c){a.delete(c.operationId);let e=r.get(c.key),t={...i,id:c.key,turnId:c.turnId??i.turnId,...i.occurredAt===void 0&&e?.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}};return o.add(t.id),[e&&e.text===t.text&&e.turnId===t.turnId&&e.complete===t.complete&&e.occurredAt===t.occurredAt?e:t]}}if(e.kind===`agent`&&typeof e.turnId==`string`){let t=r.get(`assistant:${e.id}`)??n.find(t=>t.role===`assistant`&&t.turnId===e.turnId&&t.text===i.text&&(t.phase===i.phase||!t.complete));if(t){o.add(t.id);let e={...i,id:t.id,turnId:i.turnId??t.turnId,...i.occurredAt===void 0&&t.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}};return[t.text===e.text&&t.phase===e.phase&&t.occurredAt===e.occurredAt?t:e]}}return o.add(i.id),[i]}),c=t.filter(e=>a.has(e.operationId)).map(e=>r.get(e.key)??{id:e.key,role:`user`,text:e.text,complete:e.state===`failed`,...e.turnId?{turnId:e.turnId}:{}}),l=n.filter(e=>e.role===`assistant`&&e.id.startsWith(`assistant:`)&&!o.has(e.id)),u=Ep([...c,...l]),d=new Map(s.map((e,t)=>[e.id,t])),f=new Map;for(let e of u){let t=null;if(e.turnId){for(let n=s.length-1;n>=0;--n)if(s[n]?.turnId===e.turnId){t=n;break}}if(t===null){let r=i.get(e.id);if(r!==void 0){for(let e=r-1;e>=0;--e){let r=d.get(n[e].id);if(r!==void 0){t=r;break}}if(t===null)for(let e=r+1;e<n.length;e+=1){let r=d.get(n[e].id);if(r!==void 0){t=r-1;break}}}}let r=t??s.length-1;f.set(r,[...f.get(r)??[],e])}return Ep([...f.get(-1)??[],...s.flatMap((e,t)=>[e,...f.get(t)??[]])])}function kp(e,t){if(!t||typeof t!=`object`)return vp(e);let n=t;if(!Number.isInteger(n.cursor)||n.cursor<0||!Array.isArray(n.messages)||!Array.isArray(n.prompts)||!Array.isArray(n.interactions))return vp(e);let r=[`submitting`,`accepted`,`failed`,`canonical`],i=[`pending`,`submitting`,`resolved`,`failed`],a=[`starting`,`working`,`finished`,`interrupted`,`recoverable`];return{...vp(e),sessionId:e,cursor:n.cursor,lifecycle:a.includes(n.lifecycle)?n.lifecycle:`finished`,activeTurnId:typeof n.activeTurnId==`string`||n.activeTurnId===null?n.activeTurnId:null,snapshotting:!1,buffered:new Map,messages:n.messages.filter(e=>!!(e&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`audit`)&&typeof e.text==`string`&&(e.attention===void 0||mp({...e.attention,payload:e.attention.attention}))&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),activities:Array.isArray(n.activities)?n.activities.filter(e=>!!(e&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0}))&&(e.turnId===void 0||typeof e.turnId==`string`))).map(e=>{let{mcpStartup:t,...n}=e,r=po(t);return{...n,...r?{mcpStartup:r}:{}}}).slice(-200):[],prompts:n.prompts.filter(e=>!!(e&&typeof e.operationId==`string`&&typeof e.key==`string`&&typeof e.text==`string`&&r.includes(e.state)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),interactions:n.interactions.filter(e=>!!(e&&typeof e.requestId==`string`&&typeof e.key==`string`&&typeof e.kind==`string`&&(e.turnId===void 0||e.turnId===null||typeof e.turnId==`string`)&&i.includes(e.state)&&(e.resolvedAt===void 0||typeof e.resolvedAt==`number`&&Number.isFinite(e.resolvedAt))&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200)}}function Ap(e,t){if(!Number.isInteger(t.baseSequence)||t.baseSequence<0)return e;if(t.baseSequence<e.cursor)return Hp({...e,snapshotting:!1});let n=t.items.filter(e=>e.kind===`user`),r=e.prompts.map(t=>{let r=n.some(e=>typeof e.turnId==`string`&&e.turnId===t.turnId||typeof e.operationId==`string`&&e.operationId===t.operationId),i=n.filter(e=>e.text===t.text),a=!t.turnId&&i.length===1&&e.prompts.filter(e=>e.state!==`canonical`&&e.text===t.text).length===1;return r||a?{...t,state:`canonical`}:t}),i=t.interactions.map(Cp),a=new Map(e.interactions.map(e=>[e.requestId,e])),o=Ep(i.map(e=>{let t=a.get(e.requestId);return t?.state===`resolved`?{...t,...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt},...e.resolvedAt===void 0?{}:{resolvedAt:e.resolvedAt}}:{...e,...e.occurredAt===void 0&&t?.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}}})),s=Ep(t.items.flatMap(e=>{let t=bu(e);return t?[{...t,key:`activity:${t.id}`}]:[]}).concat((t.activities??[]).map(e=>({...e,key:`activity:${e.id}`})))).map(e=>({id:e.id,label:e.label,detail:e.detail,...e.turnId?{turnId:e.turnId}:{},...e.actorTurnId?{actorTurnId:e.actorTurnId}:{},...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt},...e.changes?{changes:e.changes}:{},...po(e.mcpStartup)?{mcpStartup:po(e.mcpStartup)}:{}})).reduce(Dp,[...e.activities]),c=new Map(t.turns.map(e=>[e.id,e])),l=t.items.map(e=>{if(typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt))return e;let t=typeof e.turnId==`string`?c.get(e.turnId):void 0,n=e.kind===`agent`?t?.completedAt??t?.startedAt:t?.startedAt??t?.completedAt;return typeof n==`number`&&Number.isFinite(n)?{...e,occurredAt:n}:e}),u=(t.autopilotAudit??[]).filter(e=>typeof e?.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),d={...e,cursor:Math.max(e.cursor,t.baseSequence),snapshotting:!1,activeTurnId:t.activeTurnId,lifecycle:Tp(t.activeTurnId,e.cursor===0&&e.lifecycle===`finished`?`working`:e.lifecycle),prompts:r,messages:Ep(Op(l,r,e.messages).concat(u.map(bp))).sort((e,t)=>(e.occurredAt??2**53-1)-(t.occurredAt??2**53-1)),activities:s,interactions:o,autopilotAuditTruncated:t.autopilotAuditTruncated===!0,buffered:new Map([...e.buffered].filter(([e])=>e>t.baseSequence))};return Hp({...d,messages:jp(d.messages)})}function jp(e){let t=new Set;return e.filter(e=>e.role!==`audit`||!e.controlId?!0:t.has(e.controlId)?!1:(t.add(e.controlId),!0))}function Mp(e){return{...e,snapshotting:!0}}function Np(e,t,n,r){if(!n.trim()||e.prompts.some(e=>e.operationId===t))return e;let i={operationId:t,key:`prompt:${t}`,text:n,state:`submitting`,turnId:null,...typeof r==`number`&&Number.isFinite(r)?{occurredAt:r}:{}};return{...e,lifecycle:`starting`,prompts:[...e.prompts,i],messages:[...e.messages,{id:i.key,role:`user`,text:n,...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},complete:!1}]}}function Pp(e,t,n,r){let i=Np(e,t,n,r);return i===e?e:{...i,lifecycle:`working`}}function Fp(e,t,n){return{...e,activeTurnId:n??e.activeTurnId,lifecycle:n?`working`:e.lifecycle,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`accepted`,turnId:n}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0,...n?{turnId:n}:{}}:e)}}function Ip(e,t){return{...e,lifecycle:`recoverable`,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`failed`}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0}:e)}}function Lp(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&(e.state===`pending`||e.state===`failed`)?{...e,state:`submitting`,...n?{operationId:n}:{}}:e)}}function Rp(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&e.state!==`resolved`?{...e,state:`failed`,attemptedOutcome:n}:e)}}function zp(e,t,n,r){return{...e,interactions:e.interactions.map(e=>e.requestId===t?{...e,state:`resolved`,...r===void 0?{}:{resolvedAt:r},...wp(e,n)?{attemptedOutcome:wp(e,n)}:{}}:e)}}function Bp(e,t){if(!Number.isInteger(t.sequence)||t.sequence<=e.cursor)return e;if(e.snapshotting||t.sequence>e.cursor+1){let n=new Map(e.buffered);return n.set(t.sequence,t),{...e,snapshotting:!0,buffered:n}}let n={...e,cursor:t.sequence},r=t.payload,i=Sp(t.occurredAt);if(t.type===`agentMessageDelta`&&typeof r?.text==`string`){let e=typeof r.turnId==`string`?r.turnId:n.activeTurnId??void 0,t=`assistant:${typeof r.itemId==`string`?r.itemId:e??`live`}`,a=n.messages.find(e=>e.id===t);n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(e=>e.id===t?{...e,text:e.text+r.text,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},complete:r.phase===`final_answer`||e.complete,...e.occurredAt===void 0&&i!==void 0?{occurredAt:i}:{}}:e):[...n.messages,{id:t,role:`assistant`,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},text:r.text,...e?{turnId:e}:{},...i===void 0?{}:{occurredAt:i},complete:r.phase===`final_answer`}]}}else if((t.type===`agentMessageStarted`||t.type===`agentMessageCompleted`)&&typeof r.text==`string`){let e=`assistant:${typeof r.itemId==`string`?r.itemId:n.activeTurnId??`live`}`,a=n.messages.find(t=>t.id===e),o=t.type===`agentMessageCompleted`,s={id:e,role:`assistant`,text:o&&r.text?r.text:a?.text??r.text,complete:o,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:a?.phase?{phase:a.phase}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:a?.turnId?{turnId:a.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...a?.occurredAt===void 0?i===void 0?{}:{occurredAt:i}:{occurredAt:a.occurredAt}};n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(t=>t.id===e?s:t):[...n.messages,s]}}else if(t.type===`turnCompleted`||t.type===`turnInterrupted`)n={...n,activeTurnId:null,lifecycle:t.type===`turnCompleted`||n.lifecycle===`finished`?`finished`:`interrupted`,messages:n.messages.map(e=>e.role===`assistant`?{...e,complete:!0}:e)};else if(t.type===`interaction.requested`&&typeof r?.requestId==`string`&&typeof r.kind==`string`){let e=n.interactions.find(e=>e.requestId===r.requestId);if(!e||e.state===`resolved`){let t={requestId:r.requestId,key:`interaction:${r.requestId}`,kind:r.kind,turnId:typeof r.turnId==`string`?r.turnId:n.activeTurnId,payload:r.payload,state:`pending`,...i===void 0?{}:{occurredAt:i}};n={...n,interactions:e?n.interactions.map(e=>e.requestId===r.requestId?t:e):[...n.interactions,t]}}}else if(t.type===`interaction.resolved`&&typeof r?.requestId==`string`)n=zp(n,r.requestId,r.outcome,i);else if(t.type===`activity.updated`&&typeof r?.id==`string`&&typeof r.label==`string`&&typeof r.detail==`string`){let e=Vp(r.changes),t=po(r.mcpStartup);n={...n,activities:Dp(n.activities,{id:r.id,label:r.label,detail:r.detail,...i===void 0?{}:{occurredAt:i},...e.length?{changes:e}:{},...t?{mcpStartup:t}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...typeof r.actorTurnId==`string`?{actorTurnId:r.actorTurnId}:{}})}}else if(t.type===`session.updated`&&r?.activeTurnId!==void 0){let e=typeof r.activeTurnId==`string`?r.activeTurnId:null;n={...n,activeTurnId:e,lifecycle:e?`working`:Tp(e,n.lifecycle)}}let a=xp(t);return a&&!n.messages.some(e=>e.id===a.id)&&(n={...n,messages:jp([...n.messages,a])}),n}function Vp(e){return!Array.isArray(e)||e.length>1e3?[]:e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]})}function Hp(e){let t=new Map(e.buffered),n={...e,snapshotting:!1,buffered:t};for(;;){let e=t.get(n.cursor+1);if(!e)return{...n,buffered:t,snapshotting:t.size>0};t.delete(e.sequence),n=Bp({...n,buffered:t},e),t=new Map(n.buffered)}}function Up(e){return e.sessionId?e.lifecycle===`recoverable`?`Connection interrupted. Reconnecting…`:e.lifecycle===`starting`?`Starting Codex turn…`:e.lifecycle===`working`?`Codex is working…`:e.lifecycle===`interrupted`?`Codex turn interrupted.`:`Ready.`:`Choose a workspace and start a session.`}var Wp={read:async()=>null,write:async()=>{}},Gp=[250,750,1500],Kp=e=>!!e&&typeof e==`object`,qp=e=>Kp(e)&&typeof e.path==`string`&&Number.isInteger(e.additions)&&e.additions>=0&&Number.isInteger(e.deletions)&&e.deletions>=0,Jp=e=>Kp(e)&&typeof e.id==`string`&&typeof e.kind==`string`,Yp=e=>Kp(e)&&typeof e.id==`string`&&Array.isArray(e.items)&&e.items.every(Jp)&&(e.startedAt===null||typeof e.startedAt==`number`)&&(e.completedAt===null||typeof e.completedAt==`number`),Xp=e=>!Kp(e)||typeof e.requestId!=`string`||typeof e.kind!=`string`||!(e.turnId===null||typeof e.turnId==`string`)||!(e.requestedAt===null||typeof e.requestedAt==`string`)?!1:e.resolvedAt===null?Object.hasOwn(e,`payload`):typeof e.resolvedAt==`string`&&(e.outcome===`approved`||e.outcome===`denied`||e.outcome===`answered`||e.outcome===`dismissed`||e.outcome===`failed`)&&!Object.hasOwn(e,`payload`),Zp=e=>Kp(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)&&(e.controlId===void 0||typeof e.controlId==`string`)&&(e.attention===void 0||Kp(e.attention)&&!!mp({...e.attention,payload:e.attention.attention})),Qp=e=>Kp(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(qp))&&(e.turnId===void 0||typeof e.turnId==`string`)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),$p=e=>!Kp(e)||!Number.isInteger(e.baseSequence)||e.baseSequence<0||!(e.activeTurnId===null||typeof e.activeTurnId==`string`)||!Array.isArray(e.items)||!Array.isArray(e.turns)||!Array.isArray(e.interactions)||!e.items.every(Jp)||!e.turns.every(Yp)||!e.interactions.every(Xp)||e.activities!==void 0&&(!Array.isArray(e.activities)||!e.activities.every(Qp))||e.autopilotAudit!==void 0&&(!Array.isArray(e.autopilotAudit)||!e.autopilotAudit.every(Zp))||e.autopilotAuditTruncated!==void 0&&typeof e.autopilotAuditTruncated!=`boolean`||e.currentSequence!==void 0&&(!Number.isInteger(e.currentSequence)||e.currentSequence<0)?null:e,em=class{#e=vp();#t={attempts:0,coalesced:0,resyncs:0,socketOpens:0};get transportDiagnostics(){return{...this.#t}}#n=null;#r=null;#i=0;#a=-1;#o=null;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=0;#p=!1;#m=!1;#h=new Set;#g=null;#_=0;#v=!1;#y=new Set;#b=new Set;#x;constructor(e){this.#x={...e,websocket:e.websocket??(e=>new WebSocket(e)),cache:e.cache??Wp,location:e.location??location,document:e.document??document,window:e.window??window,setTimeout:e.setTimeout??((e,t)=>setTimeout(e,t)),clearTimeout:e.clearTimeout??(e=>clearTimeout(e)),createKey:e.createKey??hs,now:e.now??Date.now},this.#x.document.addEventListener(`visibilitychange`,this.#S),this.#x.window.addEventListener(`focus`,this.#S)}get view(){let e=this.#e.snapshotting&&this.#a!==this.#i&&!this.#m&&!tm(this.#e);return Object.freeze({...this.#e,status:this.#s?`Connection interrupted. Reconnecting…`:e?`Loading conversation…`:Up(this.#e),readySince:this.#r,starting:this.#e.lifecycle===`starting`,newEmpty:this.#m&&!tm(this.#e)})}canSubmit(e){return this.#n?e===`send`?!this.#e.activeTurnId:!!(this.#e.activeTurnId&&(e!==`queue`||this.#x.relay.queueTurnInput)):!1}select(e,t={}){if(this.#v||this.#n===e)return;this.#I(),this.#n=e,this.#r=null,e&&t.history===`empty`&&this.#h.add(e),this.#m=e!==null&&this.#h.has(e);let n=++this.#i;this.#e=vp(e),this.#j(),e&&this.#C(e,n)}async send(e,t=this.#x.createKey()){let n=this.#n,r=this.#i,i=`${n}:${r}:${t}`;if(!(!n||!e.trim()||this.#e.activeTurnId||this.#y.has(i))){this.#y.add(i),this.#A(Np(this.#e,t,e.trim(),this.#x.now()));try{let i=await this.#x.relay.startTurn(n,e.trim(),t);this.#N(n,r)&&(this.#M(n),this.#A(Fp(this.#e,t,i.activeTurnId??null))),this.#x.onSendAccepted?.(n,t)}catch(e){this.#N(n,r)&&(this.#A(Ip(this.#e,t)),this.#x.onSendError?.(e,t))}finally{this.#y.delete(i)}}}async retryPrompt(e){let t=this.#e.prompts.find(t=>t.operationId===e);t?.state===`failed`&&await this.send(t.text,e)}async queue(e,t=this.#x.createKey()){let n=this.#n,r=this.#e.activeTurnId,i=this.#x.relay.queueTurnInput,a=this.#i,o=`${n}:${a}:${t}`;if(!(!n||!r||!i||!e.trim()||this.#y.has(o))){this.#y.add(o),this.#A(Pp(this.#e,t,e.trim(),this.#x.now()));try{let o=await i(n,r,e.trim(),t);this.#N(n,a)&&this.#A(Fp(this.#e,t,o.activeTurnId)),this.#x.onSendAccepted?.(n,t)}catch(e){this.#N(n,a)&&(this.#A(Ip(this.#e,t)),this.#x.onSendError?.(e,t))}finally{this.#y.delete(o)}}}async interruptAndSend(e,t=this.#x.createKey()){let n=this.#n,r=this.#e.activeTurnId,i=this.#i,a=`${n}:${i}:${t}`;if(!(!n||!r||!e.trim()||this.#y.has(a))){this.#y.add(a),this.#A(Np(this.#e,t,e.trim(),this.#x.now()));try{await this.#x.relay.interruptTurn(n,r).catch(()=>void 0);let a=await this.#P(n,i,e.trim(),t);this.#N(n,i)&&this.#A(Fp(this.#e,t,a.activeTurnId??null)),this.#x.onSendAccepted?.(n,t)}catch(e){this.#N(n,i)&&(this.#A(Ip(this.#e,t)),this.#x.onSendError?.(e,t))}finally{this.#y.delete(a)}}}async interrupt(){let e=this.#n,t=this.#e.activeTurnId;if(!(!e||!t))try{await this.#x.relay.interruptTurn(e,t)}catch{}}async respond(e,t,n=this.#x.createKey()){let r=this.#n,i=this.#i,a=this.#e.interactions.find(t=>t.requestId===e),o=a?.operationId??n,s=`${r}:${i}:${o}`;if(!(!r||!a||a.state===`resolved`||a.state===`submitting`||this.#b.has(s))){this.#b.add(s),this.#A(Lp(this.#e,e,o));try{let n=await this.#x.relay.respondInteraction(r,e,t,o),a=n&&(n.outcome===`approved`||n.outcome===`denied`||n.outcome===`answered`||n.outcome===`dismissed`||n.outcome===`failed`)?n.outcome:t;this.#N(r,i)&&this.#e.interactions.find(t=>t.requestId===e)?.state!==`resolved`&&this.#A(zp(this.#e,e,a,this.#x.now()))}catch{this.#N(r,i)&&this.#A(Rp(this.#e,e,t))}finally{this.#b.delete(s)}}}async retryInteraction(e,t){let n=this.#e.interactions.find(t=>t.requestId===e);if(n?.state!==`failed`||!n.operationId)return;let r=t??n.attemptedOutcome,i=r===`approved`?{decision:`accept`}:r===`denied`?{decision:`decline`}:r;i!==void 0&&await this.respond(e,i,n.operationId)}refresh(){this.#n&&!this.#m&&this.#D(this.#n,this.#i)}dispose(){this.#v||(this.#v=!0,this.#I(),this.#x.document.removeEventListener(`visibilitychange`,this.#S),this.#x.window.removeEventListener(`focus`,this.#S))}#S=()=>{this.#x.document.visibilityState===`visible`&&this.refresh()};async#C(e,t){let n=this.#m;if(n||this.#D(e,t),this.#w(e,t,!1),n)return;let r=await this.#x.cache.read(e).catch(()=>null);!this.#N(e,t)||this.#a===t||!r||(this.#e={...kp(e,r),cursor:this.#e.cursor,snapshotting:this.#e.snapshotting,buffered:this.#e.buffered},this.#j())}#w(e,t,n=!0){if(!this.#N(e,t)||this.#o)return;let r=this.#x.location.protocol===`https:`?`wss:`:`ws:`,i;try{i=this.#x.websocket(`${r}//${this.#x.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#e.cursor}`)}catch{this.#x.onConnectionChange?.(!1),this.#s=!0,this.#j(),this.#g=this.#x.setTimeout(()=>this.#w(e,t),Math.min(1e3*2**this.#_++,1e4));return}this.#t.socketOpens++,this.#o=i,i.onopen=()=>{if(this.#N(e,t)&&this.#o===i){this.#x.onConnectionChange?.(!0);let r=this.#s;this.#s=!1,this.#_=0,r&&this.#j(),n&&!this.#m&&this.#D(e,t)}},i.onmessage=n=>this.#T(e,t,String(n.data)),i.onclose=()=>{if(!(!this.#N(e,t)||this.#o!==i)){if(this.#o=null,this.#x.onConnectionChange?.(!1),this.#c){this.#D(e,t);return}this.#s=!0,this.#j(),this.#g=this.#x.setTimeout(()=>this.#w(e,t),Math.min(1e3*2**this.#_++,1e4))}}}#T(e,t,n){if(!this.#N(e,t))return;let r;try{r=JSON.parse(n)}catch{return}if(r.type===`relay.resyncRequired`){this.#t.resyncs++,this.#c=!0,typeof r.currentSequence==`number`&&Number.isSafeInteger(r.currentSequence)&&r.currentSequence>=0&&(this.#l=Math.max(this.#l??0,r.currentSequence)),this.#D(e,t);return}if(r.type!==`relay.event`||!r.event||typeof r.event!=`object`)return;let i=r.event;if(!Number.isInteger(i.sequence)||typeof i.type!=`string`||!this.#E(i))return;if(i.type===`tool.efficiency.updated`){let e=i.sessionId;if(e!==void 0&&e!==this.#e.sessionId)return;let t=ps(i.payload,this.#e.sessionId??``);if(!t)return;i={sequence:i.sequence,type:i.type,payload:t}}([`agentMessageDelta`,`agentMessageStarted`,`agentMessageCompleted`,`interaction.requested`,`interaction.resolved`,`turnCompleted`,`turnInterrupted`].includes(i.type)||i.type===`activity.updated`&&nm(i.payload)||i.type===`session.updated`&&typeof i.payload.activeTurnId==`string`)&&this.#M(e);let a=Bp(this.#e,i);this.#A(a),this.#x.onRelayEvent?.(i),(i.type===`session.updated`||i.type===`plan.updated`||i.type===`plan.closed`||i.type===`agent.activity.updated`||i.type===`session.status.updated`||i.type===`autopilot.updated`||i.type===`org-plan.attention-required`||i.type===`org-plan.attention-resolved`)&&this.#x.onSessionEvent?.(i),a.snapshotting&&this.#D(e,t)}#E(e){let t=e.payload;if(!t||typeof t!=`object`)return e.type===`turnCompleted`||e.type===`turnInterrupted`||e.type===`plan.closed`;let n=t;return e.type===`agentMessageDelta`||e.type===`agentMessageStarted`||e.type===`agentMessageCompleted`?typeof n.text==`string`:e.type===`interaction.requested`?typeof n.requestId==`string`&&typeof n.kind==`string`:e.type===`interaction.resolved`?typeof n.requestId==`string`:e.type===`session.updated`?n.activeTurnId===null||typeof n.activeTurnId==`string`:e.type===`activity.updated`?typeof n.id==`string`&&typeof n.label==`string`&&typeof n.detail==`string`:e.type===`agent.activity.updated`?typeof n.sessionId==`string`&&!!n.root&&Array.isArray(n.subagents):e.type===`session.status.updated`?typeof n.state==`string`&&typeof n.reason==`string`:e.type===`tool.efficiency.updated`?ps(t,this.#e.sessionId??``)!==null:e.type===`plan.updated`||e.type===`plan.closed`||e.type.startsWith(`autopilot.`)||e.type.startsWith(`org-plan.`)}#D(e,t){if(this.#u?.id===e&&this.#u.generation===t)return this.#t.coalesced++,this.#u.promise;if(!this.#N(e,t))return Promise.resolve();let n=this.#e.snapshotting&&this.#e.buffered.size>0;this.#e=Mp(this.#e),this.#j(),this.#t.attempts++;let r=this.#x.relay.getHistory(e,{attempts:this.#t.attempts,coalesced:this.#t.coalesced}).then(r=>{let i=$p(r);if(this.#N(e,t)){if(!i){this.#A({...this.#e,snapshotting:!1,lifecycle:`recoverable`});return}if(this.#l!==null&&i.baseSequence<this.#l)throw Error(`CHAT_SNAPSHOT_BEHIND_RESYNC`);this.#f=0,this.#p=!1,this.#d&&this.#x.clearTimeout(this.#d),this.#d=null,this.#a=t,this.#A(Ap(this.#e,i));for(let t of i.items)t.kind===`user`&&typeof t.operationId==`string`&&this.#x.onHistoryPromptAccepted?.(e,t.operationId);(n||this.#c)&&(this.#c=!1,this.#l=null,this.#k(e,t))}}).catch(n=>{if(this.#N(e,t)){this.#A({...this.#e,snapshotting:!1,lifecycle:`recoverable`});let r=Gp[this.#f++];r===void 0?!this.#m&&!this.#p&&(this.#p=!0,this.#x.onHistoryError?.(n)):this.#O(e,t,r)}}).finally(()=>{this.#u?.promise===r&&(this.#u=null,this.#N(e,t)&&this.#e.snapshotting&&this.#D(e,t))});return this.#u={id:e,generation:t,promise:r},r}#O(e,t,n){this.#d&&this.#x.clearTimeout(this.#d);let r=this.#x.setTimeout(()=>{this.#d===r&&(this.#d=null,this.#N(e,t)&&this.#D(e,t))},n);this.#d=r}#k(e,t){let n=this.#o;this.#o=null,this.#x.onConnectionChange?.(!1),n?.close(),this.#g&&this.#x.clearTimeout(this.#g),this.#g=null,this.#w(e,t,!1)}#A(e){this.#n&&tm(e)&&this.#M(this.#n),this.#e=e,this.#j(),this.#n&&this.#x.cache.write(this.#n,this.#e).catch(()=>{})}#j(){this.#e.sessionId&&this.#e.lifecycle===`finished`&&!this.#e.activeTurnId?this.#r??=this.#x.now():this.#r=null,this.#x.publish(this.view)}#M(e){this.#h.delete(e),this.#n===e&&(this.#m=!1)}#N(e,t){return!this.#v&&this.#n===e&&this.#i===t}async#P(e,t,n,r){let i;for(let a of[0,50,150,300]){if(!this.#N(e,t))throw Error(`SESSION_CHANGED`);a&&await this.#F(a);try{return await this.#x.relay.startTurn(e,n,r)}catch(e){if(!rm(e,`SESSION_TURN_ACTIVE`))throw e;i=e}}throw i}#F(e){return new Promise(t=>this.#x.setTimeout(t,e))}#I(){this.#x.onConnectionChange?.(!1),this.#s=!1,this.#t={attempts:0,coalesced:0,resyncs:0,socketOpens:0},this.#c=!1,this.#l=null,this.#g&&this.#x.clearTimeout(this.#g),this.#g=null,this.#d&&this.#x.clearTimeout(this.#d),this.#d=null,this.#f=0,this.#p=!1,this.#m=!1;let e=this.#o;this.#o=null,e?.close()}};function tm(e){return!!(e.activeTurnId||e.messages.length||e.activities.some(nm)||e.prompts.length||e.interactions.length)}function nm(e){let t=e;return!po(t.mcpStartup)||typeof t.turnId==`string`||typeof t.actorTurnId==`string`}function rm(e,t){return Kp(e)&&e.code===t}function im(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.state===`working`||t.state===`idle`)&&[`needsYou`,`complete`,`rootTurn`,`agent`,`process`,`autopilot`,`incompleteWithoutContinuation`,`stopped`,`disconnected`,`unknown`].includes(t.reason)&&[`fresh`,`stale`,`reconciling`].includes(t.confidence)&&typeof t.observedAt==`string`&&!Number.isNaN(Date.parse(t.observedAt))&&typeof t.nextExpectedAction==`string`&&t.nextExpectedAction.length>0&&t.nextExpectedAction.length<=240}var am={FILE_PREVIEW_NOT_FOUND:`This file or folder no longer exists. Check the path and try again.`,FILE_PREVIEW_UNREADABLE:`This path could not be read. It must be inside the workspace and accessible without symbolic links.`,FILE_PREVIEW_UNSUPPORTED:`Preview supports UTF-8 text files and folders. This item cannot be displayed.`,FILE_PREVIEW_TOO_LARGE:`This file exceeds the 1 MiB preview limit. Open it locally to view its contents.`,INVALID_FILE_PREVIEW:`This file reference is invalid. Check its path and try again.`,RELAY_UNAVAILABLE:`The relay is unavailable. Check the connection and try again.`,SESSION_HISTORY_UNAVAILABLE:`Session history is unavailable. Check the relay connection and try opening the session again.`,SESSION_HISTORY_READ_FAILED:`Session history could not be loaded from its provider. Try again shortly; reopen the session if this persists.`,SESSION_WRITER_BUSY:`This thread is active in another Codex client. Release it there, then retry sending here.`,SESSION_WORKSPACE_UNAVAILABLE:`This session workspace is unavailable. Your message remains in the conversation for copying; restore workspace access before sending again.`,SESSION_RUNTIME_DEPENDENCY_FAILED:`A required Codex runtime dependency is unavailable. Check Codex, then retry.`,CODEX_PROTOCOL_INCOMPATIBLE:`The installed Codex runtime is incompatible with this relay. Update Codex before retrying.`,SESSION_ROLLOUT_MISSING:`This stored thread is no longer available.`,SESSION_RUNTIME_UNAVAILABLE:`The Codex runtime is unavailable. Retry shortly.`,SESSION_START_FAILED:`The session could not be started. Try again.`,ORG_EXECUTOR_PROFILE_UNAVAILABLE:`The Org-plan executor profile could not be read. Restore the installed Gestalt agent profile and try again.`,ORG_EXECUTOR_PROFILE_INVALID:`The Org-plan executor profile has invalid model settings. Repair the installed profile and try again.`,SESSION_CLOSE_FAILED:`The session could not be closed. Try again.`,SESSION_FORGET_FAILED:`The session could not be forgotten. It remains in Sessions; try Forget again.`,SESSION_RELEASE_UNCONFIRMED:`Session work could not be stopped. The session is retained; try Forget again.`,SESSION_CLEANUP_FAILED:`Temporary files could not be removed. The session is retained; try Forget again.`,SESSION_COPY_FAILED:`The CLI resume command could not be copied. Check clipboard access and try again.`,SESSION_DEFAULTS_READ_FAILED:`Saved session defaults could not be loaded. Using built-in defaults; check the configuration file and reload.`,SESSION_DEFAULTS_SAVE_FAILED:`Session defaults could not be saved. Try again.`,SESSION_MODELS_READ_FAILED:`Models could not be loaded for this provider. Select another provider and try again.`,SESSION_REFRESH_FAILED:`Sessions could not be refreshed. Try again.`,MESSAGE_SEND_FAILED:`The message was not sent. Your draft is preserved.`,GIT_SUMMARY_FAILED:`Repository status could not be loaded. Select it again to retry.`,GIT_PULL_FAILED:`The branch could not be refreshed. Resolve any Git conflicts and try again.`,GIT_CHECKOUT_FAILED:`The branch could not be selected. Refresh Git status and try again.`,GIT_PUSH_FAILED:`The push failed. Refresh Git status and resolve remote divergence first.`,GIT_CLONE_FAILED:`Clone failed.`,WORKSPACE_FILES_READ_FAILED:`Files could not be read. Try again.`,WORKSPACE_FILES_UPLOAD_FAILED:`The file could not be uploaded. Try dropping it again.`,WORKSPACE_FOLDER_CREATE_FAILED:`The folder could not be created. Check the name and try again.`,WORKSPACE_FOLDER_EXISTS:`An item with that name already exists. Choose a different folder name.`,QUIT_FAILED:`Gestalt Mobile could not quit cleanly. Try again or stop it from the terminal.`,TMP_CLEANUP_UNAVAILABLE:`Temporary files could not be checked. Try Clean TMP again.`,UPGRADE_FAILED:`Gestalt could not complete the upgrade and reconnect. Check update-restart.log and reload when Mobile is ready.`,UPGRADE_UNAVAILABLE:`Start Mobile with gestalt mobile to enable upgrades.`,DEBUG_CONTEXT_FAILED:`Session diagnostics could not be read. Reopen DEBUG to try again.`,DEBUG_ATTENTION_CHANGED:`This blocker is no longer active. Refresh the session and try again.`,DEBUG_CONTEXT_INVALID:`Select a valid blocker to debug.`,DEBUG_START_FAILED:`Self DEBUG could not start. Check Sessions for a saved debug session before trying again.`,DEBUG_TRACE_FAILED:`The diagnostic trace could not be opened. Check that the saved JSON file is still available.`,DEBUG_CONFIRMATION_EXPIRED:`The debug confirmation expired. Reopen DEBUG to confirm current session details.`,DEBUG_SOURCE_CHANGED:`The source session changed. Reopen DEBUG to confirm current session details.`};function om(e,t){let n=e instanceof Error?e.message:``,r=typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:``,i=Object.hasOwn(am,r)?r:Object.hasOwn(am,n)?n:t,a=typeof e==`object`&&e&&`retryable`in e?e.retryable===!0:!0;return{code:i,message:am[i],retryable:a}}var sm=q(`<small class="svelte-1izxxv2"> </small>`),cm=q(`<li class="svelte-1izxxv2"><div class="notification-meta svelte-1izxxv2"><strong class="svelte-1izxxv2"> </strong> <time class="svelte-1izxxv2"> </time></div> <p class="svelte-1izxxv2"> </p> <!></li>`),lm=q(`<ol aria-label="Recent notifications" class="svelte-1izxxv2"></ol>`),um=q(`<p class="empty svelte-1izxxv2" role="status">No recent notifications.</p>`),dm=q(`<main class="notification-history svelte-1izxxv2" aria-labelledby="notification-history-title"><header class="svelte-1izxxv2"><button type="button" class="svelte-1izxxv2">Back</button> <div><h1 id="notification-history-title" tabindex="-1" class="svelte-1izxxv2">Recent notifications</h1> <p class="svelte-1izxxv2">The latest notifications saved in this browser.</p></div></header> <!></main>`);function fm(e,t){F(t,!0);let n=z([]),r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});qi(()=>t.queue.subscribeHistory(e=>B(n,e)));function i(e){Dr().then(()=>e.focus())}var a=dm(),o=V(a),s=V(o),c=U(s,2);hi(V(c),()=>i),P(2),N(c),N(o);var l=U(o,2),u=e=>{var t=lm();Z(t,21,()=>G(n),e=>e.id,(e,t)=>{var n=cm(),i=V(n),a=V(i),o=V(a,!0);N(a);var s=U(a,2),c=V(s,!0);N(s),N(i);var l=U(i,2),u=V(l,!0);N(l);var d=U(l,2),f=e=>{var n=sm(),r=V(n);N(n),W(()=>Y(r,`Repeated ${G(t).occurrences??``} times.`)),J(e,n)};X(d,e=>{G(t).occurrences>1&&e(f)}),N(n),W((e,r)=>{Q(n,`data-kind`,G(t).kind),Y(o,G(t).kind),Q(s,`datetime`,e),Y(c,r),Y(u,G(t).message)},[()=>new Date(G(t).updatedAt).toISOString(),()=>r.format(G(t).updatedAt)]),J(e,n)}),N(t),J(e,t)},d=e=>{J(e,um())};X(l,e=>{G(n).length?e(u):e(d,-1)}),N(a),K(`click`,s,function(...e){t.onclose?.apply(this,e)}),J(e,a),I()}Br([`click`]);var pm={error:null,success:5e3,warning:1e4,info:7e3},mm=`gestalt-mobile.notification-history`;function hm(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function gm(e,t){try{let n=JSON.parse(e?.getItem(`gestalt-mobile.notification-history`)??`[]`);return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&[`error`,`success`,`warning`,`info`].includes(String(e.kind))&&typeof e.message==`string`&&typeof e.occurrences==`number`&&typeof e.createdAt==`number`&&typeof e.updatedAt==`number`).slice(-t):[]}catch{return[]}}function _m(e={}){let t=e.now??Date.now,n=e.setTimer??setTimeout,r=e.clearTimer??clearTimeout,i=new Set,a=new Set,o=new Map,s=[],c=e.historyLimit??50,l=gm(e.historyStorage,c),u=0,d=()=>s.map(e=>({...e})),f=()=>[...l].reverse().map(e=>({...e})),p=()=>i.forEach(e=>e(d())),m=()=>{try{e.historyStorage?.setItem(mm,JSON.stringify(l))}catch{}},h=()=>{m(),a.forEach(e=>e(f()))},g=e=>{let t=o.get(e);t?.handle&&r(t.handle),t&&(t.handle=null)},_=e=>{s.some(t=>t.id===e)&&(g(e),o.delete(e),s=s.filter(t=>t.id!==e),p())},v=e=>{let r=o.get(e);!r||r.pauseReasons.size>0||(r.startedAt=t(),r.handle=n(()=>_(e),r.remaining))};return{enqueue(e){if(e.code){let n=s.find(t=>t.kind===e.kind&&t.code===e.code);if(n)return s=s.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1}:e),l=l.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1,updatedAt:t()}:e),p(),h(),n.id}let n=t(),r=`toast-${n}-${++u}`,i={...e,id:r,occurrences:1};s=[...s,i],l=[...l,{...i,createdAt:n,updatedAt:n}].slice(-c);let a=pm[e.kind];return a!==null&&(o.set(r,{handle:null,remaining:a,startedAt:t(),pauseReasons:new Set}),v(r)),p(),h(),r},dismiss:_,pause(e,n){let r=o.get(e);!r||r.pauseReasons.has(n)||(r.pauseReasons.add(n),r.handle&&(r.remaining=Math.max(0,r.remaining-(t()-r.startedAt)),g(e)))},resume(e,t){let n=o.get(e);!n||!n.pauseReasons.delete(t)||n.pauseReasons.size>0||v(e)},snapshot:d,historySnapshot:f,subscribe(e){return i.add(e),e(d()),()=>i.delete(e)},subscribeHistory(e){return a.add(e),e(f()),()=>a.delete(e)}}}function vm(e){if(e.type!==`activity.updated`||!e.payload||typeof e.payload!=`object`)return null;let t=e.payload;return t.id===`gestalt-serena-availability`&&t.label===`Serena unavailable`?{kind:`warning`,code:`SERENA_UNAVAILABLE`,message:`Serena is unavailable in this session. Use native code tools. Connection availability will be checked when the runtime resumes.`}:t.id===`gestalt-xerj-availability`&&t.label===`Xerj unavailable`?{kind:`warning`,code:`XERJ_UNAVAILABLE`,message:`XERJ is unavailable in this session. Use rg and current source reads. Connection availability will be checked when the runtime resumes.`}:null}function ym(e){let t=new Map;return(n,r)=>{if(r.type!==`activity.updated`||!r.payload||typeof r.payload!=`object`)return;let i=po(r.payload.mcpStartup);if(!i)return;let a=JSON.stringify([n,i.threadId??i.runtimeId,i.serverName]),o=t.get(a);if(o&&(o.observedAt>i.observedAt||o.sequence!==void 0&&r.sequence!==void 0&&r.sequence<=o.sequence))return;if(t.size>=256&&!o){let n=t.entries().next().value;n&&(n[1].toastId&&e.dismiss(n[1].toastId),t.delete(n[0]))}if(i.status===`ready`){o?.toastId&&e.dismiss(o.toastId),t.set(a,{toastId:null,failureId:o?.failureId??null,observedAt:i.observedAt,sequence:r.sequence});return}if(!i.failure||o?.failureId===i.failure.failureId)return;o?.toastId&&e.dismiss(o.toastId);let s=i.failure.phase===`readiness`?`${ro(i.failure.readinessReason??`unknown`)} `:``,c=e.enqueue({kind:`warning`,code:`MCP_STARTUP_${n}_${i.failure.failureId}`,message:`${mo(i.serverName)} startup ${i.status}. ${s}${go(i.serverName)} Trace reference: ${i.failure.failureId}.`});t.set(a,{toastId:c,failureId:i.failure.failureId,observedAt:i.observedAt,sequence:r.sequence})}}var bm=q(`<small class="svelte-1a0rutm"> </small>`),xm=q(`<section aria-atomic="true"><span class="toast-symbol svelte-1a0rutm" aria-hidden="true"> </span> <span class="toast-copy svelte-1a0rutm"><strong class="svelte-1a0rutm"> </strong> <span> </span> <!></span> <button type="button" class="svelte-1a0rutm"><span aria-hidden="true">×</span></button></section>`),Sm=q(`<div class="toast-viewport svelte-1a0rutm" aria-label="Notifications"></div>`);function Cm(e,t){F(t,!0);let n=z([]),r=L(()=>G(n).slice(-3));qi(()=>t.queue.subscribe(e=>B(n,e)));var i=Sm();Z(i,21,()=>G(r),e=>e.id,(e,n)=>{var r=xm();let i;var a=V(r),o=V(a,!0);N(a);var s=U(a,2),c=V(s),l=V(c,!0);N(c);var u=U(c,2),d=V(u,!0);N(u);var f=U(u,2),p=e=>{var t=bm(),r=V(t);N(t),W(()=>Y(r,`Repeated ${G(n).occurrences??``} times.`)),J(e,t)};X(f,e=>{G(n).occurrences>1&&e(p)}),N(s);var m=U(s,2);N(r),W(()=>{i=wi(r,1,`toast svelte-1a0rutm`,null,i,{error:G(n).kind===`error`,success:G(n).kind===`success`,warning:G(n).kind===`warning`}),Q(r,`role`,G(n).kind===`error`?`alert`:`status`),Q(r,`aria-live`,G(n).kind===`error`?`assertive`:`polite`),Y(o,G(n).kind===`error`||G(n).kind===`warning`?`!`:G(n).kind===`success`?`✓`:`i`),Y(l,G(n).kind===`error`?`Error`:G(n).kind===`success`?`Success`:G(n).kind===`warning`?`Warning`:`Info`),Y(d,G(n).message),Q(m,`aria-label`,`Dismiss ${G(n).kind} notification`)}),zr(`pointerenter`,r,()=>t.queue.pause(G(n).id,`hover`)),zr(`pointerleave`,r,()=>t.queue.resume(G(n).id,`hover`)),K(`focusin`,r,()=>t.queue.pause(G(n).id,`focus`)),K(`focusout`,r,()=>t.queue.resume(G(n).id,`focus`)),K(`click`,m,()=>t.queue.dismiss(G(n).id)),J(e,r)}),N(i),J(e,i),I()}Br([`focusin`,`focusout`,`click`]);var wm=q(`<main class="evidence-page svelte-1j55xyh"><h1 class="svelte-1j55xyh">Git repository</h1> <p>Choose a destination and clone a repository.</p> <div class="evidence-composer svelte-1j55xyh"><label for="evidence-prompt">Prompt</label> <textarea id="evidence-prompt" class="evidence-prompt svelte-1j55xyh" rows="1">Review repository status</textarea></div></main> <nav class="evidence-nav svelte-1j55xyh" aria-label="Primary evidence navigation"><button type="button" class="svelte-1j55xyh">Sessions</button> <button type="button" aria-pressed="true" class="svelte-1j55xyh">Git</button> <button type="button" class="svelte-1j55xyh">Chat</button></nav> <!>`,1);function Tm(e,t){F(t,!0);let n=_m();qi(()=>{t.variant===`stacked`&&n.enqueue({kind:`success`,message:`Cloned.`}),n.enqueue({kind:`error`,code:`GIT_CLONE_FAILED`,message:`Clone failed.`})});var r=wm();Cm(U(H(r),4),{get queue(){return n}}),J(e,r),I()}var Em={sessionBase:()=>!0,gitRepositoryTarget:e=>e.isGitRepository,cloneDestination:e=>!e.isGitRepository};function Dm(e){let t=new Set,n=(e,r)=>{!e.isGitRepository&&r<=2&&t.add(e.id),e.children.forEach(e=>n(e,r+1))};return e.forEach(e=>n(e,1)),t}function Om(e,t){let n=new Set(e);return t.isGitRepository||(n.has(t.id)?n.delete(t.id):n.add(t.id)),n}function km(e,t){let n=[],r=(e,i,a)=>{n.push({node:e,level:i,parentId:a}),!e.isGitRepository&&t.has(e.id)&&e.children.forEach(t=>r(t,i+1,e.id))};return e.forEach(e=>r(e,1,null)),n}function Am(e,t){let n=(e,r)=>{if(e.id===t)return r;for(let t of e.children){let i=n(t,[...r,e.id]);if(i)return i}return null};for(let t of e){let e=n(t,[]);if(e)return e}return[]}function jm(e,t){for(let n of e){if(n.id===t)return n;let e=jm(n.children,t);if(e)return e}}function Mm(e,t,n,r){if(e){let i=jm(n,e);if(i&&r(i))return i.id;let a=Am(t,e);for(let e of a.toReversed()){let t=jm(n,e);if(t&&r(t))return t.id}}return Nm(n).find(r)?.id??null}function Nm(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}var Pm=q(`<button class="disclosure svelte-6z3q4v" type="button" tabindex="-1"><span aria-hidden="true"> </span></button>`),Fm=q(`<span class="disclosure-spacer svelte-6z3q4v" aria-hidden="true"></span>`),Im=q(`<span class="repository-badge svelte-6z3q4v">Git</span>`),Lm=q(`<div class="tree-row svelte-6z3q4v"><!> <button type="button" role="treeitem"><span class="selection-mark svelte-6z3q4v" aria-hidden="true"> </span> <span class="node-copy svelte-6z3q4v"><span class="node-name svelte-6z3q4v"> </span> <span class="node-path svelte-6z3q4v"> </span></span> <!></button></div>`),Rm=q(`<div class="filesystem-tree svelte-6z3q4v" role="tree"></div>`);function zm(e,t){F(t,!0);let n=$(t,`isSelectable`,3,()=>!0),r=z(null),i=sn({}),a=L(()=>km(t.roots,t.expandedIds)),o=L(()=>G(r)&&G(a).some(({node:e})=>e.id===G(r))?G(r):t.selectedId&&G(a).some(({node:e})=>e.id===t.selectedId)?t.selectedId:G(a)[0]?.node.id??null);function s(e){return!e.isGitRepository&&e.children.length>0}function c(e){return e===`.`?`~/`:`~/${e}`}function l(e){B(r,e,!0),i[e]?.focus()}function u(e,t){let n=Math.max(0,Math.min(G(a).length-1,t)),r=G(a)[n];r&&n!==e&&l(r.node.id)}function d(e){n()(e)&&t.onselect(e)}function f(e){s(e)&&t.onexpandedchange(Om(t.expandedIds,e))}function p(e,n,r){let{node:i,parentId:o}=n;switch(e.key){case`ArrowUp`:e.preventDefault(),u(r,r-1);break;case`ArrowDown`:e.preventDefault(),u(r,r+1);break;case`ArrowRight`:if(!s(i))return;e.preventDefault(),t.expandedIds.has(i.id)?G(a)[r+1]?.parentId===i.id&&u(r,r+1):f(i);break;case`ArrowLeft`:if(!t.expandedIds.has(i.id)&&!o)return;e.preventDefault(),s(i)&&t.expandedIds.has(i.id)?f(i):o&&l(o);break;case`Home`:e.preventDefault(),u(r,0);break;case`End`:e.preventDefault(),u(r,G(a).length-1);break;case`Enter`:case` `:e.preventDefault(),d(i);break}}var m=Rm();Z(m,23,()=>G(a),e=>e.node.id,(e,a,l)=>{let u=L(()=>G(a).node),m=L(()=>s(G(u)));var h=Lm();let g;var _=V(h),v=e=>{var n=Pm(),r=V(n),i=V(r,!0);N(r),N(n),W((e,t)=>{Q(n,`aria-label`,e),Y(i,t)},[()=>`${t.expandedIds.has(G(u).id)?`Collapse`:`Expand`} ${G(u).name}`,()=>t.expandedIds.has(G(u).id)?`−`:`+`]),K(`click`,n,()=>f(G(u))),J(e,n)},y=e=>{J(e,Fm())};X(_,e=>{G(m)?e(v):e(y,-1)});var b=U(_,2);let x;var S=V(b),C=V(S,!0);N(S);var w=U(S,2),T=V(w),E=V(T,!0);N(T);var D=U(T,2),O=V(D,!0);N(D),N(w);var ee=U(w,2),te=e=>{J(e,Im())};X(ee,e=>{G(u).isGitRepository&&e(te)}),N(b),Gi(b,(e,t)=>i[t.id]=e,e=>i?.[e.id],()=>[G(u)]),N(h),W((e,n,r,i,s)=>{g=Ei(h,``,g,e),x=wi(b,1,`tree-item svelte-6z3q4v`,null,x,{selected:t.selectedId===G(u).id,repository:G(u).isGitRepository}),Q(b,`aria-level`,G(a).level),Q(b,`aria-expanded`,n),Q(b,`aria-selected`,t.selectedId===G(u).id),Q(b,`aria-disabled`,r),Q(b,`tabindex`,G(o)===G(u).id?0:-1),Q(b,`title`,i),Y(C,t.selectedId===G(u).id?`✓`:``),Y(E,G(u).name),Y(O,s)},[()=>({"--tree-level":Math.min(G(a).level-1,6)}),()=>G(m)?t.expandedIds.has(G(u).id):void 0,()=>!n()(G(u)),()=>c(G(u).relativePath),()=>c(G(u).relativePath)]),zr(`focus`,b,()=>B(r,G(u).id,!0)),K(`keydown`,b,e=>p(e,G(a),G(l))),K(`click`,b,()=>d(G(u))),J(e,h)}),N(m),W(()=>Q(m,`aria-label`,t.label)),J(e,m),I()}Br([`click`,`keydown`]);var Bm=q(`<section class="evidence-shell svelte-1d6w4ti" aria-labelledby="evidence-title"><p class="eyebrow svelte-1d6w4ti"> </p> <h1 id="evidence-title" class="svelte-1d6w4ti"> </h1> <p class="instructions svelte-1d6w4ti"> </p> <!></section>`);function Vm(e,t){F(t,!0);let n=(e,t)=>({id:e,name:t,relativePath:e,isGitRepository:!0,children:[]}),r=[{id:`.`,name:`development-workspace-with-a-long-name`,relativePath:`.`,isGitRepository:!1,children:[{id:`dyne`,name:`dyne`,relativePath:`dyne`,isGitRepository:!1,children:[{id:`dyne/mobile-applications`,name:`mobile-applications-and-experiments`,relativePath:`dyne/mobile-applications`,isGitRepository:!1,children:[n(`dyne/mobile-applications/gestalt-mobile`,`gestalt-mobile-with-an-extraordinarily-long-repository-name`)]},n(`dyne/zenroom`,`zenroom`),n(`dyne/zenflows`,`zenflows`),n(`dyne/did`,`did-toolkit`),n(`dyne/api`,`api-gateway`),n(`dyne/docs`,`documentation-portal`)]},{id:`personal`,name:`personal-projects`,relativePath:`personal`,isGitRepository:!1,children:[]}]}],i=z(sn(new Set([`.`,`dyne`,`dyne/mobile-applications`]))),a=z(null),o=L(()=>t.context===`sessions`?`dyne/mobile-applications`:`dyne/mobile-applications/gestalt-mobile`),s=L(()=>G(a)??G(o));var c=Bm(),l=V(c),u=V(l,!0);N(l);var d=U(l,2),f=V(d,!0);N(d);var p=U(d,2),m=V(p,!0);N(p);var h=U(p,2);{let e=L(()=>t.context===`sessions`?`Session base`:`Git repository`),n=L(()=>t.context===`sessions`?Em.sessionBase:Em.gitRepositoryTarget);zm(h,{get roots(){return r},get expandedIds(){return G(i)},get selectedId(){return G(s)},get label(){return G(e)},get isSelectable(){return G(n)},onexpandedchange:e=>B(i,e,!0),onselect:e=>B(a,e.id,!0)})}N(c),W(()=>{Y(u,t.context===`sessions`?`Sessions`:`Git`),Y(f,t.context===`sessions`?`Session base`:`Git repository`),Y(m,t.context===`sessions`?`Select the folder Codex should use as its working directory.`:`Select a repository for Git actions.`)}),J(e,c),I()}function Hm(e){return e.branch===null?{enabled:!1,reason:`Select a local branch to push.`}:e.upstream?(e.behind??0)>0?{enabled:!1,reason:`Pull upstream changes before pushing.`}:e.ahead<1?{enabled:!1,reason:`There are no commits to push.`}:{enabled:!0,reason:null}:e.branch?e.originUrl?{enabled:!0,reason:null}:{enabled:!1,reason:`No origin remote is configured.`}:{enabled:!1,reason:`Select a local branch to push.`}}function Um(e,t=Date.now()){if(!e)return`Not fetched yet`;let n=Math.max(0,t-new Date(e).getTime()),r=Math.floor(n/6e4);if(r<1)return`Fetched just now`;if(r<60)return`Fetched ${r}m ago`;let i=Math.floor(r/60);return i<24?`Fetched ${i}h ago`:`Fetched ${Math.floor(i/24)}d ago`}function Wm(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown time`;let r=Math.round((n-t)/1e3),i=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60],[`second`,1]],[a,o]=i.find(([,e])=>Math.abs(r)>=e)??i.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(r/o),a)}var Gm=q(`<p class="clone-status svelte-pudr3t" role="status"> </p>`),Km=q(`<option> </option>`),qm=q(`<p class="svelte-pudr3t"> </p>`),Jm=q(`<p id="git-push-help" class="action-help svelte-pudr3t"> </p>`),Ym=q(`<section aria-label="Confirm push"><p> </p> <button type="button"> </button> <button type="button">Cancel</button></section>`),Xm=q(`<li class="commit-entry svelte-pudr3t"><div class="commit-subject svelte-pudr3t"><code class="svelte-pudr3t"> </code><span> </span></div> <div class="commit-meta svelte-pudr3t"><span> </span><time class="svelte-pudr3t"> </time></div></li>`),Zm=q(`<section class="commit-history svelte-pudr3t" aria-labelledby="recent-commits-title"><h3 id="recent-commits-title" class="svelte-pudr3t">Recent commits</h3> <ol class="commit-list svelte-pudr3t" aria-label="Recent commits"></ol></section>`),Qm=q(`<div class="git-overview svelte-pudr3t"><div class="git-status svelte-pudr3t"><label for="git-branch">Branch</label> <select id="git-branch"></select> <p class="svelte-pudr3t"> </p> <!> <p class="svelte-pudr3t"><time> </time></p> <p class="svelte-pudr3t"> </p></div> <div class="git-actions svelte-pudr3t"><button type="button" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" class="svelte-pudr3t"><span aria-hidden="true">↓</span> </button> <!></div></div> <!> <!>`,1),$m=q(`<p>This workspace is not a Git repository.</p>`),eh=q(`<p role="status">Loading repository status…</p>`),th=q(`<p><strong> </strong> is available as a Clone destination. Select a Git repository
102
102
  to inspect branches and enable repository actions.</p> <div class="git-actions svelte-pudr3t" aria-label="Repository actions unavailable"><button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↓</span> Pull</button></div>`,1),nh=q(`<p>Select a folder above to choose a Clone destination or inspect a Git repository.</p> <div class="git-actions svelte-pudr3t" aria-label="Repository actions unavailable"><button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↓</span> Pull</button></div>`,1),rh=q(`<p role="alert"> </p>`),ih=q(`<section class="git-view svelte-pudr3t" aria-labelledby="git-title"><h2 id="git-title" class="visually-hidden">Git</h2> <section class="git-tree svelte-pudr3t" aria-labelledby="git-tree-title"><div class="section-heading svelte-pudr3t"><h3 id="git-tree-title" class="svelte-pudr3t">Repository and clone destination</h3> <p class="svelte-pudr3t">Select any folder. Git repositories enable repository actions; other folders are clone
103
103
  destinations.</p></div> <!> <button id="browse-files" type="button" class="svelte-pudr3t">Browse files</button></section> <form class="clone-form svelte-pudr3t"><div class="clone-controls svelte-pudr3t"><div class="clone-field svelte-pudr3t"><label for="git-clone-address" class="svelte-pudr3t">Git address</label> <input id="git-clone-address" name="address" autocomplete="url" inputmode="url" enterkeyhint="done" aria-describedby="clone-help"/></div> <button type="submit" class="svelte-pudr3t"> </button></div> <p id="clone-help" class="svelte-pudr3t"> </p> <!></form> <section class="repository-details svelte-pudr3t" aria-labelledby="repository-details-title"><h3 id="repository-details-title" class="svelte-pudr3t">Repository details</h3> <!> <!></section></section>`);function ah(e,t){F(t,!0);let n=$(t,`pushing`,3,!1),r=z(``),i=L(()=>t.selectedWorkspace&&!t.selectedWorkspace.isGitRepository?t.selectedWorkspace:null),a=L(()=>!!t.selectedWorkspace?.isGitRepository),o=L(()=>G(a)?t.summary?.originUrl??``:G(r)),s=L(()=>t.summary?Hm(t.summary):{enabled:!1,reason:null});function c(e){e.preventDefault(),!(!G(i)||!G(r).trim()||t.cloning)&&t.onclone(G(r).trim())}var l=ih(),u=U(V(l),2),d=U(V(u),2);{let e=L(()=>t.selectedWorkspace?.id??null);zm(d,{get roots(){return t.workspaceTree},get expandedIds(){return t.expandedIds},get selectedId(){return G(e)},label:`Git repository and clone destination`,get onexpandedchange(){return t.onexpandedchange},get onselect(){return t.onselect}})}var f=U(d,2);N(u);var p=U(u,2),m=V(p),h=V(m),g=U(V(h),2);Fi(g),N(h);var _=U(h,2),v=V(_,!0);N(_),N(m);var y=U(m,2),b=V(y,!0);N(y);var x=U(y,2),S=e=>{var n=Gm(),r=V(n,!0);N(n),W(()=>Y(r,t.cloneStatus)),J(e,n)};X(x,e=>{t.cloneStatus&&e(S)}),N(p);var C=U(p,2),w=U(V(C),2),T=e=>{var r=Jr(),i=H(r),a=e=>{var r=Jr(),i=H(r),a=e=>{var r=Qm(),i=H(r),a=V(i),o=U(V(a),2);Z(o,20,()=>t.summary.branches??[],e=>e,(e,t)=>{var n=Km(),r=V(n,!0);N(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),N(o);var c;Oi(o);var l=U(o,2),u=V(l);N(l);var d=U(l,2),f=e=>{var n=qm(),r=V(n);N(n),W(()=>Y(r,`Ahead ${t.summary.ahead??``}; behind ${t.summary.behind??``}.`)),J(e,n)};X(d,e=>{t.summary.upstream&&e(f)});var p=U(d,2),m=V(p),h=V(m,!0);N(m),N(p);var g=U(p,2),_=V(g);N(g),N(a);var v=U(a,2),y=V(v),b=U(y,2),x=U(V(b));N(b);var S=U(b,2),C=e=>{var t=Jm(),n=V(t,!0);N(t),W(()=>Y(n,G(s).reason)),J(e,t)};X(S,e=>{!G(s).enabled&&G(s).reason&&e(C)}),N(v),N(i);var w=U(i,2),T=e=>{var r=Ym(),i=V(r),a=V(i,!0);N(i);var o=U(i,2),s=V(o,!0);N(o);var c=U(o,2);N(r),W(()=>{Y(a,t.summary.upstream?`Push ${t.summary.branch??`HEAD`} to ${t.summary.upstream}?`:`Publish ${t.summary.branch} to origin and set its upstream?`),o.disabled=n(),Y(s,n()?`Pushing…`:`Confirm push`),c.disabled=n()}),K(`click`,o,function(...e){t.onpush?.apply(this,e)}),K(`click`,c,function(...e){t.oncancelpush?.apply(this,e)}),J(e,r)};X(w,e=>{t.confirmingPush&&e(T)});var E=U(w,2),D=e=>{var n=Zm(),r=U(V(n),2);Z(r,21,()=>t.summary.commits,e=>e.hash,(e,t)=>{var n=Xm(),r=V(n),i=V(r),a=V(i,!0);N(i);var o=U(i),s=V(o,!0);N(o),N(r);var c=U(r,2),l=V(c),u=V(l,!0);N(l);var d=U(l),f=V(d,!0);N(d),N(c),N(n),W(e=>{Q(i,`title`,G(t).hash),Y(a,G(t).shortHash),Y(s,G(t).subject),Y(u,G(t).author),Q(d,`datetime`,G(t).authoredAt),Q(d,`title`,G(t).authoredAt),Y(f,e)},[()=>Wm(G(t).authoredAt)]),J(e,n)}),N(r),N(n),J(e,n)};X(E,e=>{t.summary.commits.length&&e(D)}),W(e=>{o.disabled=t.refreshing||t.checkingOut||!t.summary.branches?.length,c!==(c=t.summary.branch??``)&&(o.value=(o.__value=t.summary.branch??``)??``,Di(o,t.summary.branch??``)),Y(u,`Upstream: ${t.summary.upstream??`not configured`??``}`),Q(m,`datetime`,t.summary.fetchedAt??void 0),Y(h,e),Y(_,`Changes: ${t.summary.dirty.staged??``} staged, ${t.summary.dirty.unstaged??``} unstaged, ${t.summary.dirty.untracked??``} untracked.`),y.disabled=t.refreshing||t.checkingOut||n()||!G(s).enabled,Q(y,`aria-describedby`,G(s).enabled?void 0:`git-push-help`),b.disabled=t.refreshing||t.checkingOut||n()||!t.summary.upstream,Y(x,` ${t.refreshing?`Pulling…`:`Pull`}`)},[()=>Um(t.summary.fetchedAt)]),K(`change`,o,e=>t.oncheckout(e.currentTarget.value)),K(`click`,y,function(...e){t.onopenpushconfirmation?.apply(this,e)}),K(`click`,b,function(...e){t.onpull?.apply(this,e)}),J(e,r)},o=e=>{J(e,$m())};X(i,e=>{t.summary.available?e(a):e(o,-1)}),J(e,r)},o=e=>{J(e,eh())};X(i,e=>{t.summary?e(a):t.error||e(o,1)}),J(e,r)},E=e=>{var n=th(),r=H(n),i=V(r),a=V(i,!0);N(i),P(),N(r),P(2),W(()=>Y(a,t.selectedWorkspace.name)),J(e,n)},D=e=>{var t=nh();P(2),J(e,t)};X(w,e=>{t.selectedWorkspace?.isGitRepository?e(T):t.selectedWorkspace?e(E,1):e(D,-1)});var O=U(w,2),ee=e=>{var n=rh(),r=V(n,!0);N(n),W(()=>Y(r,t.error)),J(e,n)};X(O,e=>{t.error&&e(ee)}),N(C),N(l),W(e=>{f.disabled=!t.selectedWorkspace,Ii(g,G(o)),g.readOnly=G(a),g.required=!G(a),Q(g,`placeholder`,G(a)?`No origin remote`:`https://example.com/owner/repository.git`),_.disabled=e,Y(v,t.cloning?`Cloning…`:`Clone`),Y(b,G(a)?t.summary?.originUrl?`Origin remote. Select a folder to clone another repository.`:`No origin remote is configured for this repository.`:t.selectedWorkspace?`Clone into ${t.selectedWorkspace.name}.`:`Select a folder to clone a repository.`)},[()=>t.cloning||!G(i)||!G(r).trim()]),K(`click`,f,e=>t.onbrowsefiles(e.currentTarget)),zr(`submit`,p,c),K(`input`,g,e=>B(r,e.currentTarget.value,!0)),J(e,l),I()}Br([`click`,`input`,`change`]);var oh=class{transport;isRepository;onChange;errorMessage;#e={workspaceId:null,summary:null,loading:!1,refreshing:!1,checkingOut:!1,error:null};#t=0;#n=null;#r=!1;constructor(e,t,n,r){this.transport=e,this.isRepository=t,this.onChange=n,this.errorMessage=r}get state(){return this.#e}select(e){this.#a();let t=e,n=!!(t&&this.isRepository(t));this.#s({workspaceId:t,summary:null,loading:n,refreshing:!1,checkingOut:!1,error:null}),n&&this.refresh()}async refresh(){let e=this.#e.workspaceId;if(!e||!this.isRepository(e))return;let t=this.#i(),n=this.#t;this.#s({...this.#e,loading:!0,error:null});try{let r=await this.transport.getSummary(e,t.signal);this.#o(n,e,t)&&this.#s({...this.#e,summary:r,loading:!1})}catch(r){this.#o(n,e,t)&&!t.signal.aborted&&this.#s({...this.#e,summary:null,loading:!1,error:this.errorMessage(r,`GIT_SUMMARY_FAILED`)})}}async pull(e){let t=this.#e.workspaceId;if(!t||this.#e.refreshing)return;let n=this.#i(),r=this.#t;this.#s({...this.#e,refreshing:!0,error:null});try{await this.transport.pull(t,e,n.signal),this.#o(r,t,n)&&(this.#s({...this.#e,refreshing:!1}),await this.refresh())}catch(e){this.#o(r,t,n)&&!n.signal.aborted&&this.#s({...this.#e,refreshing:!1,error:this.errorMessage(e,`GIT_PULL_FAILED`)})}}async checkout(e){let t=this.#e.workspaceId;if(!t||this.#e.checkingOut||e===this.#e.summary?.branch)return;let n=this.#i(),r=this.#t;this.#s({...this.#e,checkingOut:!0,error:null});try{await this.transport.checkout(t,e,n.signal),this.#o(r,t,n)&&(this.#s({...this.#e,checkingOut:!1}),await this.refresh())}catch(e){this.#o(r,t,n)&&!n.signal.aborted&&this.#s({...this.#e,checkingOut:!1,error:this.errorMessage(e,`GIT_CHECKOUT_FAILED`)})}}dispose(){this.#r=!0,this.#a()}#i(){return this.#a(),this.#n=new AbortController,++this.#t,this.#n}#a(){this.#n?.abort(),this.#n=null,++this.#t}#o(e,t,n){return!this.#r&&e===this.#t&&this.#e.workspaceId===t&&this.#n===n}#s(e){this.#r||(this.#e=e,this.onChange(e))}};function sh(e,t,n,r,i){let a=new Set(ch(e).filter(e=>e.isGitRepository).map(e=>e.id)),o=jm(t,n),s=o?ch(o.children).filter(e=>e.isGitRepository&&!a.has(e.id)):[],c=lh(r),l=s.find(e=>e.name===c)??(s.length===1?s[0]:void 0),u=l?.id??o?.id??null,d=new Set(i);return u&&Am(t,u).forEach(e=>d.add(e)),!l&&o&&d.add(o.id),{selectedId:u,expandedIds:d}}function ch(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}function lh(e){return(e.trim().replace(/[?#].*$/,``).replace(/\/+$/,``).split(/[/:]/).at(-1)??``).replace(/\.git$/i,``)}function uh(e){if(typeof e!=`object`||!e)return null;let t=e.permissions;if(typeof t!=`object`||!t)return null;let n=t;return{permissions:{...n.network===null||n.network===void 0?{}:{network:n.network},...n.fileSystem===null||n.fileSystem===void 0?{}:{fileSystem:n.fileSystem}},scope:`turn`}}function dh(e){return{answers:Object.fromEntries(e.filter(e=>e.answer.trim()).map(e=>[e.id,{answers:[e.answer]}]))}}function fh(e=fetch){async function t(e){let t=await e.json().catch(()=>null),n=typeof t?.code==`string`&&/^[A-Z0-9_]+$/.test(t.code)?t.code:void 0,r=n?.startsWith(`AUTOPILOT_`)&&e.status===409?`Relay request failed (${e.status}).`:typeof t?.detail==`string`&&t.detail.length<=600?t.detail:typeof t?.title==`string`?t.title:`Relay request failed (${e.status}).`;return Object.assign(Error(r),{...n?{code:n}:{},...typeof t?.replaceAllowed==`boolean`?{replaceAllowed:t.replaceAllowed}:{},status:e.status})}async function n(n,r,i={},a){let o=await e(n,{method:`POST`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r),signal:a});if(!o.ok)throw await t(o);return o.json()}async function r(n,r,i={}){let a=await e(n,{method:`PUT`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function i(n,r,i,a){let o=await e(n,{method:`PUT`,headers:{"content-type":`application/octet-stream`,"idempotency-key":i},body:r,signal:a});if(!o.ok)throw await t(o);return o.json()}async function a(n,r,i){let a=await e(n,{method:`DELETE`,headers:{"content-type":`application/json`,"idempotency-key":i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function o(n){let r=await e(n,{method:`DELETE`});if(!r.ok)throw await t(r)}async function s(n,r){let i=await e(n,r?{signal:r}:void 0);if(!i.ok)throw await t(i);return i.json()}async function c(n,r){let i=await e(n,{signal:r});if(i.status===204)return null;if(!i.ok)throw await t(i);return i.json()}return{debugConfirmation:(e,t)=>s(`/api/sessions/${encodeURIComponent(e)}/debug${t?`?attentionRequestId=${encodeURIComponent(t)}`:``}`),startSelfDebug:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/debug`,{confirmationId:t}),readDebugTrace:(e,t)=>s(`/api/sessions/${encodeURIComponent(e)}/debug/trace`,t),quit:()=>n(`/api/maintenance/quit`,{}),upgrade:()=>n(`/api/maintenance/upgrade`,{}),cleanTmp:()=>n(`/api/maintenance/clean-tmp`,{}),upgradeStatus:e=>s(`/api/maintenance/upgrade`,e),listSessions:e=>s(`/api/sessions`,e),checkWorkspaceFileReferences:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/references`,{paths:t},{},r),getSessionFilePreview:(e,t,n)=>s(`/api/sessions/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),getWorkspaceFilePreview:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),listWorkspaceDirectory:(e,t={},n)=>{let r=new URLSearchParams;t.directory!==void 0&&r.set(`directory`,t.directory),t.cursor!==void 0&&r.set(`cursor`,t.cursor),t.limit!==void 0&&r.set(`limit`,String(t.limit));let i=r.size===0?``:`?${r}`;return s(`/api/workspaces/${encodeURIComponent(e)}/files${i}`,n)},copyWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/copy`,t,{"idempotency-key":r}),moveWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/move`,t,{"idempotency-key":r}),uploadWorkspaceFile:(e,t,n,r)=>{let a=new URLSearchParams({directory:t.directory,filename:t.filename,conflict:t.conflict});return i(`/api/workspaces/${encodeURIComponent(e)}/files/upload?${a}`,t.file,n,r)},createWorkspaceDirectory:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/directories`,t,{"idempotency-key":r}),deleteWorkspaceEntry:(e,t,n)=>a(`/api/workspaces/${encodeURIComponent(e)}/files`,{path:t,recursive:!0},n),getSession:e=>s(`/api/sessions/${encodeURIComponent(e)}`),refreshActivity:e=>n(`/api/sessions/${encodeURIComponent(e)}/activity/refresh`,{}),setAutopilot:(e,t,n)=>r(`/api/sessions/${encodeURIComponent(e)}/autopilot`,{enabled:t},n?{"idempotency-key":n}:{}),resolveAttention:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/attention/${encodeURIComponent(t)}/resolve`,r),listRecentSessions:()=>s(`/api/sessions/recent-threads`),openRecentSession:(e,t,r=`codex`)=>n(`/api/sessions/recent-threads/open`,{threadId:e,cwd:t,provider:r}),listSessionModels:e=>n(`/api/session-models/${encodeURIComponent(e)}`,{}),startSession:(e,t={},r)=>n(`/api/sessions`,{workspaceId:e,profile:`default`,provider:`codex`,...t},r?{"idempotency-key":r}:{}),startTurn:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/turns`,{text:t},r?{"idempotency-key":r}:{}),selectModel:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/model`,{model:t}),interruptTurn:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/interrupt`,{}),queueTurnInput:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/queue`,{text:r},i?{"idempotency-key":i}:{}),restoreSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/restore`,{}),releaseSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/release`,{}),forgetSession:n=>e(`/api/sessions/${encodeURIComponent(n)}`,{method:`DELETE`}).then(async e=>{if(!e.ok)throw await t(e)}),getHistory:async(n,r)=>{let i=await e(`/api/sessions/${encodeURIComponent(n)}/history`,r?{headers:{"x-gestalt-history-attempts":String(r.attempts),"x-gestalt-history-coalesced":String(r.coalesced)}}:void 0);if(!i.ok)throw await t(i);return i.json()},getPlan:(e,t)=>c(`/api/sessions/${encodeURIComponent(e)}/plan`,t),closePlan:e=>o(`/api/sessions/${encodeURIComponent(e)}/plan`),listWorkspacePlans:(e,t)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans`,t),archiveWorkspacePlan:(e,t)=>n(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}/archive`,{}),getWorkspacePlan:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}`,n),openSessionPlan:(e,t)=>r(`/api/sessions/${encodeURIComponent(e)}/plan`,{planName:t}),getGitSummary:(e,t)=>s(`/api/git/repositories/${encodeURIComponent(e)}`,t),cloneGitRepository:(e,t)=>n(`/api/git/clone`,{workspaceId:e,address:t}),refreshGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/refresh`,{},t?{"idempotency-key":t}:{}),pullGit:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/pull`,{},t?{"idempotency-key":t}:{},r),checkoutGitBranch:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/checkout`,{branch:t},{},r),pushGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/push`,{},t?{"idempotency-key":t}:{}),listAvailableSkills:(e,t,n=!1,r)=>s(`/api/skills?${new URLSearchParams({workspaceId:e,profile:t,...n?{refresh:`true`}:{}}).toString()}`,r),listSkillProfiles:e=>s(`/api/skill-profiles`,e),replaceSkillProfile:(e,t)=>r(`/api/skill-profiles/${encodeURIComponent(e)}`,t),deleteSkillProfile:e=>o(`/api/skill-profiles/${encodeURIComponent(e)}`),respondInteraction:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/interactions/${encodeURIComponent(t)}`,r,i?{"idempotency-key":i}:{})}}var ph=[`authoring-start`,`work-start`,`checkpoint`,`update`,`supervision-start`,`resync`];function mh(e){return typeof e==`string`&&(ph.includes(e)||/^review:[A-Za-z0-9._-]{1,128}:REVIEWED$/.test(e)||/^measure:(start|checkpoint|finish):[A-Za-z0-9._-]{1,128}$/.test(e)||/^l2:[A-Za-z0-9._-]{1,128}:(WIP|DONE)$/.test(e))}function hh(e){if(!e||typeof e!=`object`)return!1;let t=e;return gh(t.plan)&&(t.reason===null||mh(t.reason))}function gh(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.title==`string`&&Array.isArray(t.steps)&&typeof t.totalSteps==`number`&&typeof t.doneSteps==`number`&&typeof t.allDone==`boolean`&&typeof t.currentStepId==`string`}function _h(e){return e instanceof Error?e.message:`Could not load the plan.`}function vh(e){return{...e,...e.skills?{skills:[...e.skills]}:{},description:{...e.description},children:e.children.map(vh)}}function yh(e){return{...e,steps:e.steps.map(vh)}}function bh(e,t){return e.kind===`unavailable`&&e.sessionId===t}function xh(e,t){let n=null,r={kind:`unavailable`,sessionId:null},i=0,a=0,o=null,s=0,c=e=>{++a,r=e,t(e)},l=(t,r)=>{o?.abort(),o=new AbortController;let a=++i,l=s;r||c({kind:`loading`,sessionId:t}),e.getPlan(t,o.signal).then(e=>{a!==i||n!==t||s===l&&c(e?{kind:`ready`,sessionId:t,plan:yh(e)}:{kind:`unavailable`,sessionId:t})}).catch(e=>{o?.signal.aborted||a!==i||n!==t||c({kind:`error`,sessionId:t,error:_h(e),...r?{plan:r}:{}})})};return{select(e){if(o?.abort(),n=e,s=0,!e){++i,c({kind:`unavailable`,sessionId:null});return}l(e,void 0)},refresh(e){if(n!==e)return;let t=r.kind===`ready`||r.kind===`closing`||r.kind===`error`?r.plan:void 0;l(e,t)},applyEvent(e,t){if(!(n!==e||t.sequence<=s)){if(t.type===`plan.updated`&&(gh(t.payload)||hh(t.payload))){let n=hh(t.payload)?t.payload.plan:t.payload;s=t.sequence,c({kind:`ready`,sessionId:e,plan:yh(n)})}t.type===`plan.closed`&&(s=t.sequence,c({kind:`unavailable`,sessionId:e}))}},async close(){if(r.kind!==`ready`&&r.kind!==`error`||!r.plan?.allDone)return null;let{sessionId:t,plan:i}=r;c({kind:`closing`,sessionId:t,plan:i});let o=a;try{return await e.closePlan(t),n===t?a===o?(c({kind:`unavailable`,sessionId:t}),`chat`):bh(r,t)?`chat`:null:null}catch(e){return n===t?a===o?(c({kind:`error`,sessionId:t,plan:i,error:_h(e)}),null):bh(r,t)?`chat`:null:null}},dispose(){o?.abort(),o=null,n=null,++i,c({kind:`unavailable`,sessionId:null})}}}function Sh(e){if(!e)return null;let t=Ch(e.steps,e.currentStepId)?.measurement?.weeklyRemainingCurrent;return typeof t==`number`&&Number.isFinite(t)&&t>=0&&t<=100?Math.round(t):null}function Ch(e,t){for(let n of e){if(n.id===t)return n;let e=Ch(n.children,t);if(e)return e}}function wh(e){let t=new Set,n=e=>{for(let n of e.matchAll(/=([^=\n]+)=/g)){let e=n[1].trim();e&&t.add(e)}};if(e?.kind===`org-source`)n(e.source);else if(e&&`plan`in e&&e.plan){let t=[...e.plan.steps];for(;t.length;){let e=t.pop();Object.values(e.description).forEach(e=>{e&&n(e)}),t.push(...e.children)}}return[...t]}var Th=q(`<a class="svelte-nywawl"><code class="svelte-nywawl"> </code></a>`),Eh=q(`<code class="svelte-nywawl"> </code>`),Dh=q(`<span class="notes svelte-nywawl"></span>`);function Oh(e,t){F(t,!0);let n=$(t,`verifiedReferences`,19,()=>new Set),r=L(()=>t.text.split(/(=[^=\n]+=)/g));var i=Dh();Z(i,21,()=>G(r),ni,(e,r)=>{var i=Jr(),a=H(i),o=e=>{var i=Jr(),a=H(i),o=e=>{var n=Th(),i=V(n),a=V(i,!0);N(i),N(n),W((e,t)=>{Q(n,`href`,e),Y(a,t)},[()=>`#file-preview=${encodeURIComponent(G(r).slice(1,-1).trim())}`,()=>G(r).slice(1,-1)]),K(`click`,n,e=>{e.preventDefault(),t.onreference?.(G(r).slice(1,-1).trim())}),J(e,n)},s=L(()=>t.onreference&&n().has(G(r).slice(1,-1).trim())),c=e=>{var t=Eh(),n=V(t,!0);N(t),W(e=>Y(n,e),[()=>G(r).slice(1,-1)]),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)},s=L(()=>G(r).startsWith(`=`)&&G(r).endsWith(`=`)&&G(r).length>2),c=e=>{var t=qr();W(()=>Y(t,G(r))),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)}),N(i),J(e,i),I()}Br([`click`]);function kh(e,t){return t===void 0?`L${e}`:`L${e}.${t}`}function Ah(e){let t=e.steps.filter(e=>e.reviewStatus===`REVIEWED`).length,n=e.steps.length,r=jh(e),i=e.steps.find(e=>e.state===`DONE`&&e.reviewStatus===`UNREVIEWED`);return i?{phase:`awaiting review`,label:`Awaiting ${kh(e.steps.indexOf(i)+1)} review`,current:r,reviewedL1s:t,totalL1s:n}:n>0&&t===n?{phase:`terminal review`,label:`Terminal review`,current:r,reviewedL1s:t,totalL1s:n}:t>0&&!r?{phase:`milestone reported`,label:`Preparing milestone summary`,current:r,reviewedL1s:t,totalL1s:n}:r?.state===`SUSPENDED`?{phase:`suspended`,label:`Resume ${r.position} after dependency review`,current:r,reviewedL1s:t,totalL1s:n}:r?{phase:`implementing`,label:`Implementing ${r.position} ${r.title}`,current:r,reviewedL1s:t,totalL1s:n}:{phase:e.allDone?`terminal review`:`implementing`,label:e.allDone?`Terminal review`:`Implementing`,current:r,reviewedL1s:t,totalL1s:n}}function jh(e){for(let[t,n]of e.steps.entries()){if(n.id===e.currentStepId)return{id:n.id,position:kh(t+1),title:n.title,state:n.state};let r=n.children.findIndex(t=>t.id===e.currentStepId);if(r>=0){let e=n.children[r];return{id:e.id,position:kh(t+1,r+1),title:e.title,state:e.state}}}}var Mh=q(`<span class="wip-effort svelte-hmxg46"> </span>`),Nh=q(`<li class="svelte-hmxg46"><span class="wip-position svelte-hmxg46" aria-hidden="true"> </span> <span class="wip-title svelte-hmxg46"> </span> <!></li>`),Ph=q(`<ol class="wip-steps svelte-hmxg46" aria-label="Work in progress plan steps"></ol>`),Fh=q(`<li class="svelte-hmxg46"><span aria-hidden="true" class="position svelte-hmxg46"> </span> <span aria-hidden="true" class="state"> </span></li>`),Ih=q(`<ol class="step-markers svelte-hmxg46" aria-label="Plan step progress"></ol>`),Lh=q(`<div><div class="progress-heading svelte-hmxg46"><span> </span> <span> </span></div> <progress class="svelte-hmxg46"> </progress> <span class="review-status"> </span> <!></div>`);function Rh(e,t){F(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`label`,3,`Plan progress`),i=L(()=>t.plan.steps.flatMap((e,t)=>[{id:e.id,position:kh(t+1),state:e.state,level:e.level,title:e.title,...e.description.effort?{effort:e.description.effort}:{}},...e.children.map((e,n)=>({id:e.id,position:kh(t+1,n+1),state:e.state,level:e.level,title:e.title}))])),a=L(()=>G(i).filter(e=>e.state===`WIP`)),o=L(()=>Ah(t.plan)),s=L(()=>Math.max(t.plan.totalSteps,1));var c=Lh(),l=V(c),u=V(l),d=V(u);N(u);var f=U(u,2),p=V(f);N(f),N(l);var m=U(l,2),h=V(m);N(m);var g=U(m,2),_=V(g,!0);N(g);var v=U(g,2),y=e=>{var n=Ph();Z(n,21,()=>G(a),e=>e.id,(e,n)=>{var r=Nh(),i=V(r),a=V(i);N(i);var o=U(i,2),s=V(o,!0);N(o);var c=U(o,2),l=e=>{var t=Mh(),r=V(t);N(t),W(()=>Y(r,`Effort: ${G(n).effort??``}`)),J(e,t)};X(c,e=>{G(n).level===1&&G(n).effort&&e(l)}),N(r),W(()=>{Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).title}, WIP${G(n).level===1&&G(n).effort?`, effort ${G(n).effort}`:``}`),Y(a,`${G(n).position??``} · WIP`),Y(s,G(n).title)}),J(e,r)}),N(n),J(e,n)},b=e=>{var n=Ih();Z(n,21,()=>G(i),e=>e.id,(e,n)=>{var r=Fh(),i=V(r),a=V(i,!0);N(i);var o=U(i,2),s=V(o,!0);N(o),N(r),W(()=>{Q(r,`data-state`,G(n).state),Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).state}`),Y(a,G(n).position),Y(s,G(n).state)}),J(e,r)}),N(n),J(e,n)};X(v,e=>{n()&&G(a).length?e(y):!n()&&G(i).length&&e(b,1)}),N(c),W(()=>{wi(c,1,vi([`plan-progress`,{compact:n()}]),`svelte-hmxg46`),Y(d,`${t.plan.doneSteps??``} / ${t.plan.totalSteps??``} work items done`),Y(p,`· ${G(o).reviewedL1s??``} / ${G(o).totalL1s??``} reviewed`),Q(m,`aria-label`,r()),Ii(m,t.plan.doneSteps),Q(m,`max`,G(s)),Y(h,`${t.plan.doneSteps??``} of ${t.plan.totalSteps??``} work items done`),Q(g,`data-phase`,G(o).phase),Y(_,G(o).label)}),J(e,c),I()}var zh=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">Loading plan…</p></section>`),Bh=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">No retained plan for this session.</p></section>`),Vh=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg"> </p></section>`),Hh=q(`<button type="button" class="svelte-3rmyvg">Full plan</button>`),Uh=q(`<button class="close svelte-3rmyvg" aria-label="Close plan and return to list">×</button>`),Wh=q(`<p class="svelte-3rmyvg"> </p>`),Gh=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Subtitle</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Kh=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Date</dt> <dd class="svelte-3rmyvg"> </dd></div>`),qh=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Keywords</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Jh=q(`<dl class="metadata svelte-3rmyvg"><!> <!> <!></dl>`),Yh=q(`<p class="svelte-3rmyvg">No plan steps have been retained yet.</p>`),Xh=q(`<span class="svelte-3rmyvg"> </span>`),Zh=q(`<span class="measurement svelte-3rmyvg"> </span>`),Qh=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg"> </strong> <!></p>`),$h=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg">Skills:</strong> </p>`),eg=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <!></summary> <!> <!></details></li>`),tg=q(`<ol class="svelte-3rmyvg"></ol>`),ng=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <!> <!></summary> <!> <!> <!></details></li>`),rg=q(`<ol class="plan-steps svelte-3rmyvg"></ol>`),ig=q(`<section aria-labelledby="plan-title"><header class="svelte-3rmyvg"><div class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg"> </h2></div> <!></header> <!> <!> <!> <!> <!></section>`),ag=q(`<p class="visually-hidden svelte-3rmyvg" aria-live="polite" aria-atomic="true"> </p> <!>`,1);function og(e,t){F(t,!0);let n={effort:`Effort`,goal:`Goal`,notes:`Notes`,why:`Why`,change:`Change`,tests:`Tests`,doneWhen:`Done when`},r=$(t,`onclose`,3,()=>{}),i=$(t,`compact`,3,!1),a=$(t,`verifiedReferences`,19,()=>new Set),o=sn({}),s=null,c=0,l=L(()=>t.state.kind===`ready`||t.state.kind===`closing`||t.state.kind===`error`?t.state.plan:void 0),u=L(()=>G(l)?h(G(l).steps,G(l).currentStepId):void 0),d=L(()=>G(l)?g(G(l).steps,G(l).currentStepId):void 0),f=L(()=>G(l)?Ah(G(l)):void 0),p=L(()=>G(l)?_(G(l).steps,G(l).currentStepId):new Set),m=L(()=>t.state.kind===`loading`?`Loading plan.`:t.state.kind===`unavailable`?`No retained plan for this session.`:t.state.kind===`error`&&!G(l)?t.state.error:t.state.kind===`closing`?`Closing completed plan.`:G(l)?G(u)?`${G(f)?.label??`Current step: ${G(d)} ${G(u).title}`}. ${G(l).doneSteps} of ${G(l).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:`${G(f)?.label??`Plan progress`}. ${G(l).doneSteps} of ${G(l).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:``);Nn(()=>{let e=G(l)?.currentStepId||null;if(!e||s===e)return;let t=s===null;s=e;let n=++c;t||Dr().then(()=>{if(!(n!==c||G(l)?.currentStepId!==e)){for(let e of G(p)){let t=o[e];t&&(t.open=!0)}i()||o[e]?.scrollIntoView({behavior:`auto`,block:`nearest`,inline:`nearest`})}})});function h(e,t){for(let n of e){if(n.id===t)return n;let e=h(n.children,t);if(e)return e}}function g(e,t){for(let[n,r]of e.entries()){if(r.id===t)return kh(n+1);let e=r.children.findIndex(e=>e.id===t);if(e>=0)return kh(n+1,e+1)}}function _(e,t,n=[]){for(let r of e){if(r.id===t)return new Set([...n,r.id]);let e=_(r.children,t,[...n,r.id]);if(e.size)return e}return new Set}function v(e){return o[e]?.open??G(p).has(e)}function y(e){return b(e.description.goal??e.description.why??e.title)}function b(e){if(!i())return e;let t=e.replace(/\s+/g,` `).trim();return t.length>120?`${t.slice(0,117)}…`:t}function x(e){let t=e.measurement;if(!t)return`Measurements unavailable`;let n=[];return t.elapsedSeconds!==void 0&&n.push(`${Math.floor(t.elapsedSeconds/60)}m ${t.elapsedSeconds%60}s elapsed`),t.weeklyPercentUsed!==void 0&&n.push(`${t.weeklyPercentUsed}% observed account-wide usage`),t.tokensUsed!==void 0&&n.push(`${t.tokensUsed.toLocaleString()} tokens used`),n.join(` · `)||`Measurements unavailable`}function S(e){return Object.keys(n).flatMap(t=>{let r=e.description[t];return r?[[n[t],r]]:[]})}var C=ag(),T=H(C),E=V(T,!0);N(T);var D=U(T,2),O=e=>{J(e,zh())},ee=e=>{J(e,Bh())},te=e=>{var n=Vh(),r=U(V(n),2),i=V(r,!0);N(r),N(n),W(()=>Y(i,t.state.error)),J(e,n)},ne=e=>{var n=ig();let s;var c=V(n),p=V(c),m=V(p),h=V(m,!0);N(m),N(p);var g=U(p,2),_=e=>{var n=Jr(),r=H(n),i=e=>{var n=Hh();K(`click`,n,function(...e){t.onopenfull?.apply(this,e)}),J(e,n)};X(r,e=>{t.onopenfull&&e(i)}),J(e,n)},C=e=>{var t=Uh();K(`click`,t,function(...e){r()?.apply(this,e)}),J(e,t)};X(g,e=>{i()?e(_):e(C,-1)}),N(c);var T=U(c,2);Rh(T,{get plan(){return G(l)},get compact(){return i()}});var E=U(T,2),D=e=>{var t=Wh(),n=V(t);N(t),W(()=>Y(n,`${G(f)?.label??``}. Current: ${G(u)?`${G(d)} ${G(u).title} (${G(u).state})`:`No current step`}`)),J(e,t)};X(E,e=>{i()||e(D)});var O=U(E,2),ee=e=>{var n=Wh(),r=V(n,!0);N(n),W(()=>Y(r,t.state.error)),J(e,n)};X(O,e=>{t.state.kind===`error`&&e(ee)});var te=U(O,2),ne=e=>{var t=Jh(),n=V(t),r=e=>{var t=Gh(),n=U(V(t),2),r=V(n,!0);N(n),N(t),W(()=>Y(r,G(l).subtitle)),J(e,t)};X(n,e=>{G(l).subtitle&&e(r)});var i=U(n,2),a=e=>{var t=Kh(),n=U(V(t),2),r=V(n,!0);N(n),N(t),W(()=>Y(r,G(l).date)),J(e,t)};X(i,e=>{G(l).date&&e(a)});var o=U(i,2),s=e=>{var t=qh(),n=U(V(t),2),r=V(n,!0);N(n),N(t),W(()=>Y(r,G(l).keywords)),J(e,t)};X(o,e=>{G(l).keywords&&e(s)}),N(t),J(e,t)};X(te,e=>{!i()&&(G(l).subtitle||G(l).date||G(l).keywords)&&e(ne)});var re=U(te,2),ie=e=>{J(e,Yh())},ae=e=>{var n=rg();Z(n,23,()=>G(l).steps,e=>e.id,(e,n,r)=>{var s=ng(),c=V(s),l=V(c),u=V(l),d=V(u),f=V(d,!0);N(d);var p=U(d);N(u);var m=U(u,2),h=V(m);N(m);var g=U(m,2),_=e=>{var t=Xh(),r=V(t,!0);N(t),W(e=>Y(r,e),[()=>y(G(n))]),J(e,t)};X(g,e=>{i()||e(_)});var C=U(g,2),T=e=>{var t=Zh(),r=V(t,!0);N(t),W(e=>Y(r,e),[()=>x(G(n))]),J(e,t)};X(C,e=>{i()||e(T)}),N(l);var E=U(l,2);Z(E,17,()=>S(G(n)),([e,t])=>e,(e,n)=>{var r=L(()=>w(G(n),2));let i=()=>G(r)[0],o=()=>G(r)[1];var s=Qh(),c=V(s),l=V(c);N(c);var u=U(c,2);{let e=L(()=>b(o()));Oh(u,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return a()}})}N(s),W(()=>Y(l,`${i()??``}:`)),J(e,s)});var D=U(E,2),O=e=>{var t=$h(),r=U(V(t));N(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(D,e=>{G(n).skills?.length&&e(O)});var ee=U(D,2),te=e=>{var s=tg();Z(s,23,()=>G(n).children,e=>e.id,(e,n,s)=>{var c=eg(),l=V(c),u=V(l),d=V(u),f=V(d),p=V(f,!0);N(f);var m=U(f);N(d);var h=U(d,2),g=V(h);N(h);var _=U(h,2),x=e=>{var t=Xh(),r=V(t,!0);N(t),W(e=>Y(r,e),[()=>y(G(n))]),J(e,t)};X(_,e=>{i()||e(x)}),N(u);var C=U(u,2);Z(C,17,()=>S(G(n)),([e,t])=>e,(e,n)=>{var r=L(()=>w(G(n),2));let i=()=>G(r)[0],o=()=>G(r)[1];var s=Qh(),c=V(s),l=V(c);N(c);var u=U(c,2);{let e=L(()=>b(o()));Oh(u,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return a()}})}N(s),W(()=>Y(l,`${i()??``}:`)),J(e,s)});var T=U(C,2),E=e=>{var t=$h(),r=U(V(t));N(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(T,e=>{G(n).skills?.length&&e(E)}),N(l),Gi(l,(e,t)=>o[t.id]=e,e=>o?.[e.id],()=>[G(n)]),N(c),W((e,t)=>{Q(l,`data-step-id`,G(n).id),l.open=e,Y(p,t),Y(m,` ${G(n).title??``}`),Y(g,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`)},[()=>v(G(n).id),()=>kh(G(r)+1,G(s)+1)]),J(e,c)}),N(s),J(e,s)};X(ee,e=>{G(n).children.length&&e(te)}),N(c),Gi(c,(e,t)=>o[t.id]=e,e=>o?.[e.id],()=>[G(n)]),N(s),W((e,t)=>{Q(c,`data-step-id`,G(n).id),c.open=e,Y(f,t),Y(p,` ${G(n).title??``}`),Y(h,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`)},[()=>v(G(n).id),()=>kh(G(r)+1)]),J(e,s)}),N(n),J(e,n)};X(re,e=>{G(l).steps.length===0?e(ie):e(ae,-1)}),N(n),W(()=>{s=wi(n,1,`plan svelte-3rmyvg`,null,s,{compact:i()}),Y(h,G(l).title)}),J(e,n)};X(D,e=>{t.state.kind===`loading`?e(O):t.state.kind===`unavailable`?e(ee,1):t.state.kind===`error`&&!G(l)?e(te,2):G(l)&&e(ne,3)}),W(()=>Y(E,G(m))),J(e,C),I()}Br([`click`]);var sg=/^(\*+)\s+(?:(TODO|WIP|DONE|SUSPENDED)\s+)?(?:\[#([ABC])\]\s+)?(.+)$/,cg=/^#\+([A-Z][A-Z0-9_-]*):\s*(.*)$/i,lg=/^:([A-Z][A-Z0-9_]*):\s*(.*)$/,ug=/^-\s+([^:]+?)\s+::\s*(.*)$/;function dg(e){let t=[],n=[],r=[],i=e.replace(/\r\n?/g,`
104
104
  `).split(`
@@ -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-BDsGojoG.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-Dp2s0z9f.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DxsD-jG4.css">
21
21
  </head>
22
22
  <body>
@@ -107,7 +107,7 @@ function diagnose(events) {
107
107
  const checkpointIndex = events.findLastIndex((event) => event.type.endsWith('-checkpointed'));
108
108
  const currentHandoff = checkpointIndex < 0 ? events : events.slice(checkpointIndex);
109
109
  const types = new Set(currentHandoff.map((event) => event.type));
110
- if ([...types].some((type) => type.endsWith('-checkpointed')) &&
110
+ if ((types.has('org-plan.step-checkpointed') || types.has('org-plan.milestone-checkpointed')) &&
111
111
  !types.has('autopilot.continuation-scheduled'))
112
112
  diagnoses.push('checkpoint persisted, but no continuation was scheduled');
113
113
  if (types.has('autopilot.continuation-scheduled') &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.66.2",
3
+ "version": "0.66.3",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",