@hyperdreamer/pi-webui 1.19.0 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{J as e,P as t,S as n,X as r,Z as i,l as a,tt as o,y as s}from"./vendor-editor-core-vyMPzMNA.js";import{c,i as l,l as u,n as d,r as f,s as p,t as m,u as h}from"./vendor-editor-languages-DlEQaRIv.js";import{a as g,c as _,i as v,o as y,r as b,s as x,t as S}from"./index-C8fQLkMH.js";import{t as C}from"./vendor-editor-legacy-CYBnW6ZU.js";var w=class extends y{constructor(...e){super(...e),this.content=``}firstUpdated(){this.recreateEditor()}updated(e){(e.has(`content`)||e.has(`language`))&&this.recreateEditor()}disconnectedCallback(){this.view?.destroy(),this.view=void 0,super.disconnectedCallback()}render(){return x`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new e({parent:this.editorHost,state:o.create({doc:this.content,extensions:[i(),r.of(a),t(n,{fallback:!0}),o.readOnly.of(!0),e.editable.of(!1),e.lineWrapping,T,...D(this.language),...O(this.language)]})}))}static{this.styles=_`
1
+ import{J as e,P as t,S as n,X as r,Z as i,l as a,tt as o,y as s}from"./vendor-editor-core-vyMPzMNA.js";import{c,i as l,l as u,n as d,r as f,s as p,t as m,u as h}from"./vendor-editor-languages-DlEQaRIv.js";import{a as g,c as _,i as v,o as y,r as b,s as x,t as S}from"./index-BsI-Foow.js";import{t as C}from"./vendor-editor-legacy-CYBnW6ZU.js";var w=class extends y{constructor(...e){super(...e),this.content=``}firstUpdated(){this.recreateEditor()}updated(e){(e.has(`content`)||e.has(`language`))&&this.recreateEditor()}disconnectedCallback(){this.view?.destroy(),this.view=void 0,super.disconnectedCallback()}render(){return x`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new e({parent:this.editorHost,state:o.create({doc:this.content,extensions:[i(),r.of(a),t(n,{fallback:!0}),o.readOnly.of(!0),e.editable.of(!1),e.lineWrapping,T,...D(this.language),...O(this.language)]})}))}static{this.styles=_`
2
2
  :host { display: block; min-height: 0; height: 100%; }
3
3
  .host { height: 100%; min-height: 0; overflow: auto; }
4
4
  `}};S([v()],w.prototype,`content`,void 0),S([v()],w.prototype,`language`,void 0),S([b(`.host`)],w.prototype,`editorHost`,void 0),w=S([g(`code-viewer`)],w);var T=e.theme({"&":{height:`100%`,color:`var(--pi-text)`,backgroundColor:`var(--pi-bg)`,fontSize:`12px`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,lineHeight:`1.45`},".cm-gutters":{backgroundColor:`var(--pi-bg)`,color:`var(--pi-dim)`,borderRight:`1px solid var(--pi-border-muted)`},".cm-activeLineGutter":{backgroundColor:`transparent`},".cm-activeLine":{backgroundColor:`transparent`},".cm-content":{caretColor:`transparent`},"&.cm-focused":{outline:`none`}}),E=e.theme({".cm-content":{textAlign:`start`},".cm-line":{unicodeBidi:`plaintext`}});function D(t){return t===`markdown`?[e.contentAttributes.of({dir:`auto`}),E]:[]}function O(e){if(e===void 0)return[];switch(e){case`typescript`:return[u({typescript:!0})];case`javascript`:return[u()];case`json`:return[l()];case`markdown`:return[p()];case`css`:return[h()];case`html`:return[c()];case`python`:return[f()];case`rust`:return[d()];case`go`:return[m()];case`diff`:return[s.define(C)];default:return[]}}export{w as CodeViewer};
@@ -1,4 +1,4 @@
1
- import{a as e,c as t,i as n,o as r,s as i,t as a}from"./index-C8fQLkMH.js";var o=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},s=new class extends o{};function c(e,t,n){return s.diff(e,t,n)}function l(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function u(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function d(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function f(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function p(e,t){return d(e,t,``)}function m(e,t){return f(e,t,``)}function h(e,t){return t.slice(0,g(e,t))}function g(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function _(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function v(e,t){if(t)return b(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function y(e,t){if(t)return b(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function b(e,t){if(!t)return[y(e),v(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=_(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var x=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,S=RegExp(`[${x}]+|\\s+|[^${x}]`,`ug`);new class extends o{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=_(e,r)}else n=e.match(S)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&C(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&C(n,i,r,null,t.intlSegmenter),e}};function C(e,t,n,r,i){if(t&&n){let[a,o]=b(t.value,i),[s,c]=b(n.value,i);if(e){let r=l(a,s);e.value=f(e.value,s,r),t.value=p(t.value,r),n.value=p(n.value,r)}if(r){let e=u(o,c);r.value=d(r.value,c,e),t.value=m(t.value,e),n.value=m(n.value,e)}}else if(n){if(e){let e=y(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=y(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=y(r.value,i),[a,o]=b(t.value,i),s=l(n,a);t.value=p(t.value,s);let c=u(p(n,s),o);t.value=m(t.value,c),r.value=d(r.value,n,c),e.value=f(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=y(r.value,i),n=h(v(t.value,i),e);t.value=m(t.value,n)}else if(e){let n=h(v(e.value,i),y(t.value,i));t.value=p(t.value,n)}}new class extends o{tokenize(e){let t=RegExp(`(\\r?\\n)|[${x}]+|[^\\S\\n\\r]+|[^${x}]`,`ug`);return e.match(t)||[]}},new class extends o{constructor(){super(...arguments),this.tokenize=w}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
1
+ import{a as e,c as t,i as n,o as r,s as i,t as a}from"./index-BsI-Foow.js";var o=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},s=new class extends o{};function c(e,t,n){return s.diff(e,t,n)}function l(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function u(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function d(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function f(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function p(e,t){return d(e,t,``)}function m(e,t){return f(e,t,``)}function h(e,t){return t.slice(0,g(e,t))}function g(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function _(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function v(e,t){if(t)return b(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function y(e,t){if(t)return b(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function b(e,t){if(!t)return[y(e),v(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=_(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var x=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,S=RegExp(`[${x}]+|\\s+|[^${x}]`,`ug`);new class extends o{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=_(e,r)}else n=e.match(S)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&C(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&C(n,i,r,null,t.intlSegmenter),e}};function C(e,t,n,r,i){if(t&&n){let[a,o]=b(t.value,i),[s,c]=b(n.value,i);if(e){let r=l(a,s);e.value=f(e.value,s,r),t.value=p(t.value,r),n.value=p(n.value,r)}if(r){let e=u(o,c);r.value=d(r.value,c,e),t.value=m(t.value,e),n.value=m(n.value,e)}}else if(n){if(e){let e=y(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=y(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=y(r.value,i),[a,o]=b(t.value,i),s=l(n,a);t.value=p(t.value,s);let c=u(p(n,s),o);t.value=m(t.value,c),r.value=d(r.value,n,c),e.value=f(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=y(r.value,i),n=h(v(t.value,i),e);t.value=m(t.value,n)}else if(e){let n=h(v(e.value,i),y(t.value,i));t.value=p(t.value,n)}}new class extends o{tokenize(e){let t=RegExp(`(\\r?\\n)|[${x}]+|[^\\S\\n\\r]+|[^${x}]`,`ug`);return e.match(t)||[]}},new class extends o{constructor(){super(...arguments),this.tokenize=w}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
2
2
  `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
3
3
  `))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
4
4
  `)&&(e=e.slice(0,-1)),t.endsWith(`
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-3Y40kwMd.js","./vendor-editor-core-vyMPzMNA.js","./vendor-editor-languages-DlEQaRIv.js","./vendor-editor-legacy-CYBnW6ZU.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-SGnd_OTg.js","./vendor-editor-core-vyMPzMNA.js","./vendor-editor-languages-DlEQaRIv.js","./vendor-editor-legacy-CYBnW6ZU.js"])))=>i.map(i=>d[i]);
2
2
  import{$ as e,A as t,J as n,P as r,Q as i,S as a,X as o,Y as s,d as c,et as l,f as u,it as d,j as f,l as p,p as m,q as ee,rt as te,tt as ne,u as re}from"./vendor-editor-core-vyMPzMNA.js";import{a as ie,o as ae,s as oe}from"./vendor-editor-languages-DlEQaRIv.js";import{n as se,t as ce}from"./vendor-terminal-D8k4UKM2.js";var le=Object.defineProperty,ue=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),de=(e,t)=>{let n={};for(var r in e)le(n,r,{get:e[r],enumerable:!0});return t||le(n,Symbol.toStringTag,{value:`Module`}),n};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var fe=globalThis,pe=fe.ShadowRoot&&(fe.ShadyCSS===void 0||fe.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,me=Symbol(),he=new WeakMap,ge=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==me)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(pe&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=he.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&he.set(t,e))}return e}toString(){return this.cssText}},_e=e=>new ge(typeof e==`string`?e:e+``,void 0,me),h=(e,...t)=>new ge(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,me),ve=(e,t)=>{if(pe)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=fe.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},ye=pe?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return _e(t)})(e):e,{is:be,defineProperty:xe,getOwnPropertyDescriptor:Se,getOwnPropertyNames:Ce,getOwnPropertySymbols:we,getPrototypeOf:Te}=Object,Ee=globalThis,De=Ee.trustedTypes,Oe=De?De.emptyScript:``,ke=Ee.reactiveElementPolyfillSupport,Ae=(e,t)=>e,je={toAttribute(e,t){switch(t){case Boolean:e=e?Oe:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Me=(e,t)=>!be(e,t),Ne={attribute:!0,type:String,converter:je,reflect:!1,useDefault:!1,hasChanged:Me};Symbol.metadata??=Symbol(`metadata`),Ee.litPropertyMetadata??=new WeakMap;var Pe=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Ne){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&xe(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=Se(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ne}static _$Ei(){if(this.hasOwnProperty(Ae(`elementProperties`)))return;let e=Te(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ae(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ae(`properties`))){let e=this.properties,t=[...Ce(e),...we(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(ye(e))}else e!==void 0&&t.push(ye(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ve(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?je:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?je:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??Me)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};Pe.elementStyles=[],Pe.shadowRootOptions={mode:`open`},Pe[Ae(`elementProperties`)]=new Map,Pe[Ae(`finalized`)]=new Map,ke?.({ReactiveElement:Pe}),(Ee.reactiveElementVersions??=[]).push(`2.1.2`);var Fe=globalThis,Ie=e=>e,Le=Fe.trustedTypes,Re=Le?Le.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,ze=`$lit$`,Be=`lit$${Math.random().toFixed(9).slice(2)}$`,Ve=`?`+Be,He=`<${Ve}>`,Ue=document,We=()=>Ue.createComment(``),Ge=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Ke=Array.isArray,qe=e=>Ke(e)||typeof e?.[Symbol.iterator]==`function`,Je=`[
3
3
  \f\r]`,Ye=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Xe=/-->/g,Ze=/>/g,Qe=RegExp(`>|${Je}(?:([^\\s"'>=/]+)(${Je}*=${Je}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),$e=/'/g,et=/"/g,tt=/^(?:script|style|textarea|title)$/i,nt=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),g=nt(1),_=nt(2),rt=Symbol.for(`lit-noChange`),v=Symbol.for(`lit-nothing`),it=new WeakMap,at=Ue.createTreeWalker(Ue,129);function ot(e,t){if(!Ke(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Re===void 0?t:Re.createHTML(t)}var st=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=Ye;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===Ye?c[1]===`!--`?o=Xe:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=Qe):(tt.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=Qe):o=Ze:o===Qe?c[0]===`>`?(o=i??Ye,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?Qe:c[3]===`"`?et:$e):o===et||o===$e?o=Qe:o===Xe||o===Ze?o=Ye:(o=Qe,i=void 0);let d=o===Qe&&e[t+1].startsWith(`/>`)?` `:``;a+=o===Ye?n+He:l>=0?(r.push(s),n.slice(0,l)+ze+n.slice(l)+Be+d):n+Be+(l===-2?t:d)}return[ot(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},ct=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=st(t,n);if(this.el=e.createElement(l,r),at.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=at.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(ze)){let t=u[o++],n=i.getAttribute(e).split(Be),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?pt:r[1]===`?`?mt:r[1]===`@`?ht:ft}),i.removeAttribute(e)}else e.startsWith(Be)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(tt.test(i.tagName)){let e=i.textContent.split(Be),t=e.length-1;if(t>0){i.textContent=Le?Le.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],We()),at.nextNode(),c.push({type:2,index:++a});i.append(e[t],We())}}}else if(i.nodeType===8)if(i.data===Ve)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(Be,e+1))!==-1;)c.push({type:7,index:a}),e+=Be.length-1}a++}}static createElement(e,t){let n=Ue.createElement(`template`);return n.innerHTML=e,n}};function lt(e,t,n=e,r){if(t===rt)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=Ge(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=lt(e,i._$AS(e,t.values),i,r)),t}var ut=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??Ue).importNode(t,!0);at.currentNode=r;let i=at.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new dt(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new gt(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=at.nextNode(),a++)}return at.currentNode=Ue,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},dt=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=v,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=lt(this,e,t),Ge(e)?e===v||e==null||e===``?(this._$AH!==v&&this._$AR(),this._$AH=v):e!==this._$AH&&e!==rt&&this._(e):e._$litType$===void 0?e.nodeType===void 0?qe(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==v&&Ge(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ue.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=ct.createElement(ot(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new ut(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=it.get(e.strings);return t===void 0&&it.set(e.strings,t=new ct(e)),t}k(t){Ke(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(We()),this.O(We()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=Ie(e).nextSibling;Ie(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ft=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=v,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=v}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=lt(this,e,t,0),a=!Ge(e)||e!==this._$AH&&e!==rt,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=lt(this,r[n+o],t,o),s===rt&&(s=this._$AH[o]),a||=!Ge(s)||s!==this._$AH[o],s===v?e=v:e!==v&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===v?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},pt=class extends ft{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===v?void 0:e}},mt=class extends ft{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==v)}},ht=class extends ft{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=lt(this,e,t,0)??v)===rt)return;let n=this._$AH,r=e===v&&n!==v||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==v&&(n===v||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},gt=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){lt(this,e)}},_t={M:ze,P:Be,A:Ve,C:1,L:st,R:ut,D:qe,V:lt,I:dt,H:ft,N:mt,U:ht,B:pt,F:gt},vt=Fe.litHtmlPolyfillSupport;vt?.(ct,dt),(Fe.litHtmlVersions??=[]).push(`3.3.3`);var yt=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new dt(t.insertBefore(We(),e),e,void 0,n??{})}return i._$AI(e),i},bt=globalThis,y=class extends Pe{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=yt(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return rt}};y._$litElement$=!0,y.finalized=!0,bt.litElementHydrateSupport?.({LitElement:y});var xt=bt.litElementPolyfillSupport;xt?.({LitElement:y}),(bt.litElementVersions??=[]).push(`4.2.2`);var St={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ct=e=>(...t)=>({_$litDirective$:e,values:t}),wt=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},{I:Tt}=_t,Et=e=>e,Dt=()=>document.createComment(``),Ot=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new Tt(r.insertBefore(Dt(),i),r.insertBefore(Dt(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=Et(e).nextSibling;Et(r).insertBefore(e,i),e=t}}}return n},kt=(e,t,n=e)=>(e._$AI(t,n),e),At={},jt=(e,t=At)=>e._$AH=t,Mt=e=>e._$AH,Nt=e=>{e._$AR(),e._$AA.remove()},Pt=Ct(class extends wt{constructor(){super(...arguments),this.key=v}render(e,t){return this.key=e,t}update(e,[t,n]){return t!==this.key&&(jt(e),this.key=t),n}}),b=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},Ft={attribute:!0,type:String,converter:je,reflect:!1,hasChanged:Me},It=(e=Ft,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function x(e){return(t,n)=>typeof n==`object`?It(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function S(e){return x({...e,state:!0,attribute:!1})}var Lt=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function C(e,t){return(n,r,i)=>{let a=t=>t.renderRoot?.querySelector(e)??null;if(t){let{get:e,set:t}=typeof r==`object`?n:i??(()=>{let e=Symbol();return{get(){return this[e]},set(t){this[e]=t}}})();return Lt(n,r,{get(){let n=e.call(this);return n===void 0&&(n=a(this),(n!==null||this.hasUpdated)&&t.call(this,n)),n}})}return Lt(n,r,{get(){return a(this)}})}}var Rt=/^\s*([!#$%&'*+.^_`|~0-9A-Za-z-]+)\/([!#$%&'*+.^_`|~0-9A-Za-z-]+)(?:\s*;\s*([!#$%&'*+.^_`|~0-9A-Za-z-]+)\s*=\s*([!#$%&'*+.^_`|~0-9A-Za-z.-]+))?\s*$/u;function zt(e){if(e===void 0)return;let t=Rt.exec(e);if(t===null)return;let n=t[1]?.toLowerCase(),r=t[2]?.toLowerCase(),i=t[3]?.toLowerCase(),a=t[4]?.toLowerCase(),o=n===void 0||r===void 0?void 0:`${n}/${r}`;if(o===`audio/webm`&&i===`codecs`&&a===`opus`)return`audio/webm;codecs=opus`;if(o===`audio/ogg`&&i===`codecs`&&a===`opus`)return`audio/ogg;codecs=opus`;if(o===`audio/mp4`&&i===`codecs`&&a===`mp4a.40.2`)return`audio/mp4;codecs=mp4a.40.2`;if(o===`audio/mp4`&&i===void 0)return`audio/mp4`}var w={sessionsDeleteArchived:`sessions.deleteArchived`,sessionsBulkMutations:`sessions.bulkMutations`,sessionsCleanup:`sessions.cleanup`,sessionsReload:`sessions.reload`,sessionsClearQueue:`sessions.clearQueue`,sessionsMessageActions:`sessions.messageActions`,sessionsSystemPrompt:`sessions.systemPrompt`,sessionsPersistedState:`sessions.persistedState`,sessionsNotifications:`sessions.notifications`,sessionsUnread:`sessions.unread`,promptAttachments:`prompt.attachments`,workspaceFileSuggestions:`workspace.fileSuggestions`,piPackagesManage:`piPackages.manage`,selectedMachineSettings:`settings.selectedMachine`,agentProfileConfig:`settings.agentProfile`,modelTierSettings:`settings.modelTiers`,utilityModelSettings:`settings.utilityModels`,sessionsModelPolicy:`sessions.modelPolicy`,sessionsModelPolicyDefaults:`sessions.modelPolicyDefaults`,sessionsModelPolicyStarterSelection:`sessions.modelPolicyStarterSelection`,sessionsReorder:`sessions.reorder`,projectUsageStatistics:`project.usageStatistics`},Bt=[`economy`,`fast`,`standard`,`advanced`,`capable`,`frontier`],Vt=[`lightweight`,`context`],Ht=1e3,Ut=1e3,Wt=32*1024,Gt=8*1024,Kt=1e4;function qt(e,t=Yt()){let n=new URL(t.viteBaseUrl,t.documentBaseUrl);return new URL(Xt(e),n).toString()}function Jt(e,t=Yt()){let n=new URL(qt(e,t));if(n.protocol===`http:`)n.protocol=`ws:`;else if(n.protocol===`https:`)n.protocol=`wss:`;else throw Error(`Cannot create a WebSocket URL from ${n.protocol}`);return n.toString()}function Yt(){return{viteBaseUrl:`./`,documentBaseUrl:document.baseURI}}function Xt(e){return e.startsWith(`/`)?`.${e}`:e}var Zt=class extends Error{constructor(e,t){super(e),this.status=t,this.name=`HttpRequestError`}};async function T(e,t,n){let r=new Headers(n?.headers);n?.body!==void 0&&!r.has(`content-type`)&&r.set(`content-type`,`application/json`);let i=await fetch(qt(e),{...n,headers:r});if(!i.ok)throw new Zt(en(await i.json().catch(()=>({})))??i.statusText,i.status);return t(await i.json())}async function Qt(e,t){let n=new Headers(t?.headers);t?.body!==void 0&&!n.has(`content-type`)&&n.set(`content-type`,`application/json`);let r=await fetch(qt(e),{...t,headers:n}),i=await r.json().catch(e=>{if(t?.signal?.aborted===!0||$t(e))throw e});return{status:r.status,body:i}}function $t(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`}function en(e){if(tn(e))return typeof e.error==`string`?e.error:void 0}function tn(e){return typeof e==`object`&&!!e}var nn=class extends Zt{constructor(e,t,n={}){super(e,t),this.name=`ModelsConfigRequestError`,this.details=n}},rn=[`MODELS_CONFIG_PARSE_FAILED`,`MODELS_CONFIG_IO_FAILED`,`MODELS_CONFIG_SAVE_INVALID`,`MODELS_CONFIG_INVALID_LIMITS`,`MODELS_CONFIG_UNREADABLE`,`MODELS_CONFIG_PERSIST_FAILED`,`MODELS_CONFIG_REFRESH_FAILED`,`MODELS_CONFIG_INTERNAL`],an=[`not-a-number`,`not-finite`,`not-an-integer`,`negative`,`unsafe-integer`,`missing-model-id`];function on(e,t,n){let r=un(e)?e:{};return new nn(typeof r.error==`string`&&r.error!==``?r.error:n,t,sn(r))}function sn(e){let t={},n=e.code;cn(n)&&(t.code=n),typeof e.file==`string`&&(t.file=e.file),typeof e.provider==`string`&&(t.provider=e.provider),typeof e.modelId==`string`&&(t.modelId=e.modelId);let r=e.field;(r===`tpm`||r===`rpm`)&&(t.field=r),typeof e.occurrence==`number`&&(t.occurrence=e.occurrence);let i=e.reason;return ln(i)&&(t.reason=i),typeof e.persisted==`boolean`&&(t.persisted=e.persisted),t}function cn(e){return typeof e==`string`&&rn.some(t=>t===e)}function ln(e){return typeof e==`string`&&an.some(t=>t===e)}function un(e){return typeof e==`object`&&!!e}function dn(e){return(e.split(/[\\/]/u).at(-1)?.toLowerCase()??e.toLowerCase()).replace(/(?:\.[cm]?js|\.exe|\.cmd)$/iu,``)===`pi`}function fn(e){return!e.includes(`/`)&&!e.includes(`\\`)&&dn(e)}var pn=new Set([`schemaVersion`,`revision`,`command`,`dir`,`sessionDirEnvKeys`]),mn=/^sha256:[0-9a-f]{64}$/u,hn=/^[A-Za-z0-9_][A-Za-z0-9._+-]*$/u,gn=new Set([`PI_WEBUI_AGENT_SESSION_DIR`,`PI_CODING_AGENT_SESSION_DIR`]);function _n(e){if(!Sn(e)||Object.keys(e).some(e=>!pn.has(e)))return;let t=e.schemaVersion,n=e.revision,r=e.command,i=e.dir,a=e.sessionDirEnvKeys;if(t===1&&!(typeof n!=`string`||!mn.test(n))&&!(typeof r!=`string`||!vn(r))&&!(typeof i!=`string`||!yn(i))&&xn(a)&&new Set(a).size===a.length&&!(a[0]!==`PI_WEBUI_AGENT_SESSION_DIR`||a.some(e=>!gn.has(e))))return Object.freeze({schemaVersion:t,revision:n,command:r,dir:i,sessionDirEnvKeys:Object.freeze([...a])})}function vn(e){return e!==e.trim()||/[\s;&|`$<>]/u.test(e)?!1:yn(e)?!e.endsWith(`/`)&&!e.endsWith(`\\`):hn.test(e)}function yn(e){if(e===``||e!==e.trim()||bn(e))return!1;let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function bn(e){for(let t of e){let e=t.charCodeAt(0);if(e<32||e===127)return!0}return!1}function xn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function Sn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Cn=Object.values(w),wn=new Set(Cn);w.sessionsDeleteArchived,w.sessionsBulkMutations,w.sessionsCleanup,w.sessionsReload,w.sessionsClearQueue,w.sessionsMessageActions,w.sessionsSystemPrompt,w.sessionsPersistedState,w.sessionsNotifications,w.sessionsUnread,w.promptAttachments,w.workspaceFileSuggestions,w.piPackagesManage,w.selectedMachineSettings,w.agentProfileConfig,w.modelTierSettings,w.utilityModelSettings,w.sessionsModelPolicy,w.sessionsModelPolicyDefaults,w.sessionsModelPolicyStarterSelection,w.sessionsReorder,w.sessionsDeleteArchived,w.sessionsBulkMutations,w.sessionsCleanup,w.sessionsReload,w.sessionsClearQueue,w.sessionsMessageActions,w.sessionsSystemPrompt,w.sessionsPersistedState,w.sessionsNotifications,w.sessionsUnread,w.promptAttachments,w.modelTierSettings,w.utilityModelSettings,w.sessionsModelPolicy,w.sessionsModelPolicyDefaults,w.sessionsModelPolicyStarterSelection,w.sessionsReorder,w.projectUsageStatistics,w.sessionsDeleteArchived,w.sessionsBulkMutations,w.sessionsCleanup,w.sessionsReload,w.sessionsClearQueue,w.sessionsMessageActions,w.sessionsSystemPrompt,w.sessionsPersistedState,w.sessionsNotifications,w.sessionsUnread,w.promptAttachments,w.workspaceFileSuggestions,w.piPackagesManage,w.selectedMachineSettings,w.agentProfileConfig,w.modelTierSettings,w.utilityModelSettings,w.sessionsModelPolicy,w.sessionsModelPolicyDefaults,w.sessionsModelPolicyStarterSelection,w.sessionsReorder,w.projectUsageStatistics;function Tn(e){return typeof e==`string`&&wn.has(e)}function E(e,t){return e?.capabilities?.includes(t)===!0}function En(e){if(!(!Array.isArray(e)||!e.every(e=>typeof e==`string`)))return e.filter(Tn)}var Dn=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;function On(e){return Dn.test(e)}function kn(e){try{let t=Intl.getCanonicalLocales(e);return t.length===1?t[0]:void 0}catch{return}}var An=4e3;function jn(e){return{...e?.voice===void 0?{}:{voice:e.voice},rate:e?.rate??0}}function Mn(e){let t=e.replace(/\r\n|\r/gu,`
4
4
  `).replace(/(?!\t|\n)\p{Cc}/gu,``),n=t.slice(0,An);if(n.length===4e3){let e=n.charCodeAt(n.length-1),r=t.charCodeAt(An);e>=55296&&e<=56319&&r>=56320&&r<=57343&&(n=n.slice(0,-1))}return n.trimEnd()}var Nn=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;function Pn(e){return Nn.test(e)}var Fn=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function In(e){return Fn.some(t=>t===e)}function Ln(e){return e===void 0||e===``?`off`:e}function Rn(e,t){let n=t.length>=2?t:Fn,r=n.length-1,i=Ln(e),a=n.indexOf(i);return{total:r,filled:a<=0?0:Math.min(a,r)}}function zn(e){return typeof e==`object`&&!!e}function D(e){if(!zn(e))throw Error(`Expected object response`);return e}function O(e,t){let n=e[t];if(typeof n!=`string`)throw Error(`Expected string field: ${t}`);return n}function k(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw Error(`Expected optional string field: ${t}`);return n}}function A(e,t){let n=e[t];if(typeof n!=`number`)throw Error(`Expected number field: ${t}`);return n}function j(e,t){let n=e[t];if(typeof n!=`boolean`)throw Error(`Expected boolean field: ${t}`);return n}function M(e){return t=>{if(!Array.isArray(t))throw Error(`Expected array response`);return t.map(e)}}function Bn(e){let t=Ar(e,`host speech status`);Mr(t,[`available`,`reason`,`voices`],`host speech status`);let n=j(t,`available`),r=Object.hasOwn(t,`reason`)?es(t,`reason`):void 0;if(!n&&r===void 0)throw Error(`Unavailable host speech status requires a reason`);let i=Vn(t.voices);return{available:n,...P(`reason`,r),voices:i}}function Vn(e){if(!Array.isArray(e))throw Error(`Expected host speech voices array`);let t=e.map(Hn),n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Duplicate host speech voice name`);n.add(e.name)}return t}function Hn(e){let t=Ar(e,`host speech voice`);Mr(t,[`name`,`language`,`variant`],`host speech voice`);let n=Object.hasOwn(t,`variant`)?es(t,`variant`):void 0;return{name:es(t,`name`),language:es(t,`language`),...P(`variant`,n)}}function Un(e){let t=Ar(e,`host speech terminal result`);Mr(t,[`runId`,`outcome`],`host speech terminal result`);let n=Kn(t,`runId`),r=t.outcome;if(r!==`ended`&&r!==`canceled`)throw Error(`Invalid host speech terminal outcome`);return{runId:n,outcome:r}}function Wn(e){let t=Ar(e,`host speech stop response`);return Mr(t,[`runId`,`stopped`],`host speech stop response`),{runId:Kn(t,`runId`),stopped:j(t,`stopped`)}}function Gn(e){let t=Ar(e,`speech input transcription response`);Mr(t,[`text`],`speech input transcription response`);let n=es(t,`text`);if(new TextEncoder().encode(n).byteLength>1048576)throw Error(`Speech input transcription exceeds the maximum size`);return{text:n}}function Kn(e,t){let n=O(e,t);if(!Pn(n))throw Error(`Invalid host speech run ID field: ${t}`);return n}function qn(e){if(!Array.isArray(e))throw Error(`Expected array response`);return e}function Jn(e,t){if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`Expected string array field: ${t}`);return e}function Yn(e){if(!zn(e)||typeof e.kind!=`string`)throw Error(`Invalid memory snapshot response`);if(e.kind===`unavailable`)return{kind:`unavailable`};if(e.kind!==`data`)throw Error(`Invalid memory snapshot response`);return{kind:`data`,globalEntries:Xn(e.globalEntries),projectEntries:Xn(e.projectEntries),...typeof e.projectUnavailableMessage==`string`?{projectUnavailableMessage:e.projectUnavailableMessage}:{}}}function Xn(e){if(!Array.isArray(e))throw Error(`Invalid memory snapshot response`);return e.map(e=>{if(!zn(e)||typeof e.id!=`string`||typeof e.content!=`string`)throw Error(`Invalid memory snapshot response`);return{id:e.id,content:e.content,...typeof e.category==`string`?{category:e.category}:{},...typeof e.created==`string`?{created:e.created}:{},...typeof e.last==`string`?{last:e.last}:{},...typeof e.failureReason==`string`?{failureReason:e.failureReason}:{}}})}function Zn(e){if(!zn(e)||typeof e.kind!=`string`)throw Error(`Invalid learned skills snapshot response`);if(e.kind===`unavailable`)return{kind:`unavailable`};if(e.kind!==`data`)throw Error(`Invalid learned skills snapshot response`);let t=e.projectUnavailableMessage;if(t!==void 0&&typeof t!=`string`)throw Error(`Invalid learned skills snapshot response`);return{kind:`data`,globalSkills:Qn(e.globalSkills),projectSkills:Qn(e.projectSkills),...t===void 0?{}:{projectUnavailableMessage:t}}}function Qn(e){if(!Array.isArray(e))throw Error(`Invalid learned skills snapshot response`);return e.map($n)}function $n(e){let t=D(e),n=N(t,`version`),r=k(t,`created`),i=k(t,`updated`);return{id:O(t,`id`),name:O(t,`name`),description:O(t,`description`),filePath:O(t,`filePath`),...n===void 0?{}:{version:n},...r===void 0?{}:{created:r},...i===void 0?{}:{updated:i}}}function er(e){if(Array.isArray(e))return{messages:e,start:0,total:e.length};let t=D(e);return{messages:qn(t.messages),start:A(t,`start`),total:A(t,`total`)}}function tr(e){let t=D(e);return M(nr)(t.machines)}function nr(e){let t=D(e),n=ar(t,`kind`),r=k(t,`baseUrl`),i=or(t,`status`),a=k(t,`statusMessage`);return{id:O(t,`id`),name:O(t,`name`),kind:n,...r===void 0?{}:{baseUrl:r},createdAt:O(t,`createdAt`),updatedAt:O(t,`updatedAt`),...i===void 0?{}:{status:i},...a===void 0?{}:{statusMessage:a}}}function rr(e){let t=D(e),n=or(t,`status`),r=k(t,`error`);return{machineId:O(t,`machineId`),ok:j(t,`ok`),checkedAt:O(t,`checkedAt`),...n===void 0?{}:{status:n},...t.web===void 0?{}:{web:Ro(t.web)},...t.sessiond===void 0?{}:{sessiond:Ro(t.sessiond)},...r===void 0?{}:{error:r}}}function ir(e){let t=D(e),n=k(t,`error`);return{machineId:O(t,`machineId`),ok:j(t,`ok`),checkedAt:O(t,`checkedAt`),...P(`packageName`,k(t,`packageName`)),...P(`generatedAt`,k(t,`generatedAt`)),...t.components===void 0?{}:{components:Io(t.components)},...t.capabilities===void 0?{}:{capabilities:Wo(t.capabilities)},...n===void 0?{}:{error:n}}}function ar(e,t){let n=O(e,t);if(n!==`local`&&n!==`remote`)throw Error(`Expected machine kind field: ${t}`);return n}function or(e,t){let n=k(e,t);if(n!==void 0){if(n!==`unknown`&&n!==`online`&&n!==`offline`&&n!==`error`)throw Error(`Expected machine status field: ${t}`);return n}}function sr(e){let t=D(e),n=Mo(t.pinned,`pinned`);return{id:O(t,`id`),name:O(t,`name`),path:O(t,`path`),createdAt:O(t,`createdAt`),...n===void 0?{}:{pinned:n}}}function cr(e){let t=D(e),n=O(t,`lastUsedAt`),r=new Date(n);if(!Number.isFinite(r.getTime())||r.toISOString()!==n)throw Error(`Invalid canonical recent project timestamp`);return{id:O(t,`id`),name:O(t,`name`),path:O(t,`path`),lastUsedAt:n}}function lr(e){let t=Zr(e,cr,20,`recentProjects`),n=new Set,r=new Set;for(let e of t){if(n.has(e.id))throw Error(`Duplicate recent project id`);if(r.has(e.path))throw Error(`Duplicate recent project path`);n.add(e.id),r.add(e.path)}return t}function ur(e){let t=D(e),n=k(t,`branch`);return{id:O(t,`id`),projectId:O(t,`projectId`),path:O(t,`path`),label:O(t,`label`),...n===void 0?{}:{branch:n},isMain:j(t,`isMain`),isGitRepo:j(t,`isGitRepo`),isGitWorktree:j(t,`isGitWorktree`),...P(`effectiveConfig`,dr(t.effectiveConfig))}}function dr(e){if(e!==void 0){if(!zn(e)||Array.isArray(e))throw Error(`Invalid workspace effectiveConfig field`);return{...P(`uploads`,co(e.uploads))}}}function fr(e){let t=D(e),n=k(t,`name`),r=Mo(t.persisted,`persisted`),i=k(t,`parentSessionPath`),a=k(t,`archivedAt`),o=Mo(t.pinned,`pinned`),s=t.creationSource===`session-list-plus`?t.creationSource:void 0,c=t.manualOrder===void 0?void 0:ei(t,`manualOrder`);return{id:O(t,`id`),path:O(t,`path`),cwd:O(t,`cwd`),...r===void 0?{}:{persisted:r},...n===void 0?{}:{name:n},created:O(t,`created`),modified:O(t,`modified`),messageCount:A(t,`messageCount`),firstMessage:O(t,`firstMessage`),...i===void 0?{}:{parentSessionPath:i},...t.archived===!0?{archived:!0}:{},...a===void 0?{}:{archivedAt:a},...o===void 0?{}:{pinned:o},...s===void 0?{}:{creationSource:s},...c===void 0?{}:{manualOrder:c}}}function pr(e){let t=D(e);return{id:O(t,`id`),cwd:O(t,`cwd`),manualOrder:ei(t,`manualOrder`)}}function mr(e){let t=D(e);return{orderedSessions:M(pr)(t.orderedSessions)}}function hr(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid session warning severity`);return e}function gr(e){if(e!==void 0)return{id:O(D(e),`id`)}}function _r(e){let t=D(e),n=gr(t.dismiss);return{severity:hr(t.severity),message:O(t,`message`),...P(`source`,k(t,`source`)),...P(`path`,k(t,`path`)),...n===void 0?{}:{dismiss:n}}}function vr(e){return e===void 0?{}:{warnings:M(_r)(e)}}function yr(e){let t=D(e);return{sessionId:O(t,`sessionId`),...P(`persisted`,Mo(t.persisted,`persisted`)),isStreaming:j(t,`isStreaming`),isCompacting:j(t,`isCompacting`),isBashRunning:j(t,`isBashRunning`),pendingMessageCount:A(t,`pendingMessageCount`),queuedMessages:t.queuedMessages===void 0?[]:M(pi)(t.queuedMessages),...P(`messageCount`,N(t,`messageCount`)),tokens:mi(t.tokens),cost:A(t,`cost`),...oa(t.generation),...gi(t.model),...P(`modelPolicy`,t.modelPolicy===void 0?void 0:Tr(t.modelPolicy)),...sa(t.contextUsage),...P(`thinkingLevel`,k(t,`thinkingLevel`)),...vr(t.warnings)}}function br(e){let t=Ar(e,`session model policy response`);if(Mr(t,[`contractVersion`,`policy`,`session`],`session model policy response`),t.contractVersion!==1)throw Error(`Invalid session model policy contract version`);let n=yr(t.session);if(!Object.hasOwn(t,`policy`)){let e=n.modelPolicy?.blockedReason;if(e===void 0||e.trim()===``)throw Error(`Expected non-blank string field: blockedReason`);return{contractVersion:1,session:n}}return{contractVersion:1,policy:xr(t.policy),session:n}}function xr(e){let t=Ar(e,`session model policy`);Mr(t,[`mode`,`exact`,`tier`],`session model policy`);let n=Or(t.mode),r=kr(t,`session model policy`);if(n===`tiered`&&r===void 0)throw Error(`Tiered session model policy requires a tier`);return{mode:n,exact:Er(t.exact),...P(`tier`,r)}}function Sr(e){let t=Ar(e,`starter model policy preference`);Mr(t,[`mode`,`tier`],`starter model policy preference`);let n=Or(t.mode),r=kr(t,`starter model policy preference`);if(n===`tiered`&&r===void 0)throw Error(`Tiered starter model policy preference requires a tier`);return{mode:n,...P(`tier`,r)}}function Cr(e){let t=Ar(e,`starter model policy preference`);return Object.hasOwn(t,`exact`)?wr(t):Sr(t)}function wr(e){let t=Ar(e,`confirmed starter model policy preference`);Mr(t,[`mode`,`exact`,`tier`],`confirmed starter model policy preference`);let n=Or(t.mode),r=kr(t,`confirmed starter model policy preference`);if(n===`tiered`&&r===void 0)throw Error(`Tiered confirmed starter model policy preference requires a tier`);return{mode:n,exact:Er(t.exact),...P(`tier`,r)}}function Tr(e){let t=Ar(e,`session model policy status`);Mr(t,[`mode`,`tier`,`resolved`,`ladderValid`,`blockedReason`],`session model policy status`);let n=Or(t.mode),r=kr(t,`session model policy status`);if(n===`tiered`&&r===void 0)throw Error(`Tiered session model policy status requires a tier`);return{mode:n,...P(`tier`,r),resolved:Er(t.resolved),ladderValid:j(t,`ladderValid`),...P(`blockedReason`,k(t,`blockedReason`))}}function Er(e){let t=Ar(e,`exact selection`);return Mr(t,[`model`,`thinkingLevel`],`exact selection`),{model:Dr(t.model),thinkingLevel:es(t,`thinkingLevel`)}}function Dr(e){let t=Ar(e,`model reference`);return Mr(t,[`provider`,`id`],`model reference`),{provider:es(t,`provider`),id:es(t,`id`)}}function Or(e){if(e!==`exact`&&e!==`tiered`)throw Error(`Invalid session model policy mode`);return e}function kr(e,t){if(!Object.hasOwn(e,`tier`))return;let n=e.tier;if(typeof n!=`string`||!qa(n))throw Error(`Invalid ${t} tier`);return n}function Ar(e,t){if(!jr(e))throw Error(`Expected ${t} object`);return e}function jr(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Reflect.getPrototypeOf(e);return t===Object.prototype||t===null}function Mr(e,t,n){let r=Object.keys(e).find(e=>!t.includes(e));if(r!==void 0)throw Error(`Invalid ${n} field: ${r}`)}function Nr(e){let t=D(e);return{seq:A(t,`seq`),partial:t.partial??null}}function Pr(e){let t=k(D(e),`systemPrompt`);return t===void 0?{}:{systemPrompt:t}}function Fr(e){let t=D(e),n=ei(t,`catalogRevision`),r=Zr(t.sessions,Lr,Ut,`sessions`);if(Rr(r),zr(r),r.some(e=>e.completionOrder>n))throw Error(`Session unread completion order exceeds catalog revision`);return{catalogId:Br(t,`catalogId`,512),catalogRevision:n,sessions:r}}function Ir(e){let t=D(e);if(t.type!==`sessions.unread`)throw Error(`Invalid session unread event type`);let n=Br(t,`sessionId`,512),r=Br(t,`cwd`,Wt),i=Vr(t,`catalogRevision`),a=t.unread===null?null:Lr(t.unread);if(a!==null&&(a.sessionId!==n||a.cwd!==r))throw Error(`Session unread event identity mismatch`);if(a!==null&&a.completionOrder>i)throw Error(`Session unread completion order exceeds catalog revision`);return{type:`sessions.unread`,catalogId:Br(t,`catalogId`,512),catalogRevision:i,sessionId:n,cwd:r,unread:a}}function Lr(e){let t=D(e),n=Br(t,`completedAt`,64),r=new Date(n);if(!Number.isFinite(r.getTime())||r.toISOString()!==n)throw Error(`Invalid canonical session unread completion time`);return{sessionId:Br(t,`sessionId`,512),cwd:Br(t,`cwd`,Wt),completionOrder:Vr(t,`completionOrder`),completedAt:n}}function Rr(e){let t=e.map(e=>JSON.stringify([e.sessionId,e.cwd]));if(new Set(t).size!==t.length)throw Error(`Duplicate session unread identity`);let n=e.map(e=>e.completionOrder);if(new Set(n).size!==n.length)throw Error(`Duplicate session unread completion order`)}function zr(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.completionOrder<=r.completionOrder)throw Error(`Session unread summaries are not newest-first`)}}function Br(e,t,n){let r=$r(e,t);if(r.length>n)throw Error(`String field exceeds limit: ${t}`);return r}function Vr(e,t){let n=ei(e,t);if(n===0)throw Error(`Expected positive safe integer field: ${t}`);return n}function Hr(e){let t=D(e),n=Wr(t.summary),r=Zr(t.notifications,Gr,100,`notifications`);if(ti(r),ni(r),n.retainedCount!==r.length)throw Error(`Notification snapshot retained count mismatch`);if(n.highestSeverity!==ii(r))throw Error(`Notification snapshot severity mismatch`);let i=Kr(t.dismissThrough),a=r[0]?.order??0;if(i.order!==a)throw Error(`Notification snapshot dismiss cutoff mismatch`);if(i.overflowWatermark<n.discardedCount)throw Error(`Notification snapshot overflow cutoff mismatch`);return{daemonInstanceId:$r(t,`daemonInstanceId`),catalogRevision:ei(t,`catalogRevision`),summary:n,notifications:r,dismissThrough:i}}function Ur(e){let t=D(e);if(t.type!==`notifications.inbox`)throw Error(`Invalid notification inbox event type`);let n=Wr(t.summary),r=Kr(t.dismissThrough);if(r.overflowWatermark<n.discardedCount)throw Error(`Notification event overflow cutoff mismatch`);let i=qr(t.delta);if(i.kind===`cleared`&&!ri(n))throw Error(`Notification clear event summary mismatch`);if(i.kind===`added`&&n.retainedCount===0)throw Error(`Notification add event summary mismatch`);return{type:`notifications.inbox`,daemonInstanceId:$r(t,`daemonInstanceId`),catalogRevision:ei(t,`catalogRevision`),summary:n,dismissThrough:r,delta:i}}function Wr(e){let t=D(e),n=ei(t,`retainedCount`);if(n>100)throw Error(`Notification retained count exceeds limit`);let r=ei(t,`discardedCount`),i=Yr(t.highestSeverity);if(n===0!=(i===void 0))throw Error(`Notification summary severity mismatch`);return{sessionId:$r(t,`sessionId`),cwd:$r(t,`cwd`),inboxRevision:ei(t,`inboxRevision`),retainedCount:n,discardedCount:r,...i===void 0?{}:{highestSeverity:i}}}function Gr(e){let t=D(e),n=O(t,`message`);if(new TextEncoder().encode(n).byteLength>8192)throw Error(`Notification message exceeds byte limit`);let r=O(t,`receivedAt`);if(!Number.isFinite(Date.parse(r)))throw Error(`Invalid notification receive time`);let i=ei(t,`order`);if(i===0)throw Error(`Invalid notification order`);return{id:$r(t,`id`),message:n,truncated:j(t,`truncated`),severity:Jr(t.severity),receivedAt:r,order:i}}function Kr(e){let t=D(e);return{order:ei(t,`order`),overflowWatermark:ei(t,`overflowWatermark`)}}function qr(e){let t=D(e);switch(t.kind){case`added`:{let e=k(t,`evictedNotificationId`);return{kind:`added`,notification:Gr(t.notification),...e===void 0?{}:{evictedNotificationId:e}}}case`dismissed`:{let e=Zr(t.notificationIds,Qr,100,`notificationIds`);if(new Set(e).size!==e.length)throw Error(`Duplicate dismissed notification id`);return{kind:`dismissed`,notificationIds:e}}case`cleared`:return{kind:`cleared`,reason:Xr(t.reason)};case`resync`:return{kind:`resync`};default:throw Error(`Invalid notification inbox delta`)}}function Jr(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid notification severity`);return e}function Yr(e){return e===void 0?void 0:Jr(e)}function Xr(e){switch(e){case`runtime-close`:case`archive`:case`delete`:case`restore`:case`archive-reconcile`:case`replacement`:case`initialization-failed`:case`service-dispose`:return e;default:throw Error(`Invalid notification clear reason`)}}function Zr(e,t,n,r){if(!Array.isArray(e))throw Error(`Expected array field: ${r}`);if(e.length>n)throw Error(`Array field exceeds limit: ${r}`);return e.map(t)}function Qr(e){if(typeof e!=`string`||e===``)throw Error(`Expected non-empty string`);return e}function $r(e,t){let n=O(e,t);if(n===``)throw Error(`Expected non-empty string field: ${t}`);return n}function ei(e,t){let n=e[t];if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0)throw Error(`Expected non-negative safe integer field: ${t}`);return n}function ti(e){if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate notification id`);if(new Set(e.map(e=>e.order)).size!==e.length)throw Error(`Duplicate notification order`)}function ni(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.order<=r.order)throw Error(`Notifications are not newest-first`)}}function ri(e){return e.retainedCount===0&&e.discardedCount===0}function ii(e){let t;for(let n of e){if(n.severity===`error`)return`error`;n.severity===`warning`?t=`warning`:t??=`info`}return t}function ai(e){let t=D(e),n=t.skippedBusySessionIds===void 0?void 0:Jn(t.skippedBusySessionIds,`skippedBusySessionIds`);return{generatedAt:O(t,`generatedAt`),thresholds:ui(t.thresholds),projects:M(di)(t.projects),totals:fi(t.totals),...n===void 0?{}:{skippedBusySessionIds:n}}}function oi(e){let t=D(e);return{...ai(t),archivedSessionIds:Jn(t.archivedSessionIds,`archivedSessionIds`),deletedSessionIds:Jn(t.deletedSessionIds,`deletedSessionIds`)}}function si(e){let t=D(e);if(t.archived!==!0)throw Error(`Expected bulk archived response`);return{archived:!0,archivedSessionIds:Jn(t.archivedSessionIds,`archivedSessionIds`),failures:M(li)(t.failures),generatedAt:O(t,`generatedAt`)}}function ci(e){let t=D(e);if(t.deleted!==!0)throw Error(`Expected bulk deleted response`);return{deleted:!0,deletedSessionIds:Jn(t.deletedSessionIds,`deletedSessionIds`),failures:M(li)(t.failures),generatedAt:O(t,`generatedAt`)}}function li(e){let t=D(e);return{sessionId:O(t,`sessionId`),error:O(t,`error`)}}function ui(e){let t=D(e);return{...P(`archiveIdleDays`,N(t,`archiveIdleDays`)),...P(`deleteArchivedDays`,N(t,`deleteArchivedDays`))}}function di(e){let t=D(e);return{cwd:O(t,`cwd`),archiveCount:A(t,`archiveCount`),deleteCount:A(t,`deleteCount`)}}function fi(e){let t=D(e);return{archiveCount:A(t,`archiveCount`),deleteCount:A(t,`deleteCount`)}}function pi(e){let t=D(e),n=O(t,`kind`);if(n!==`steer`&&n!==`followUp`)throw Error(`Invalid queued message kind`);return{kind:n,text:O(t,`text`)}}function mi(e){let t=D(e);return{input:A(t,`input`),output:A(t,`output`),cacheRead:A(t,`cacheRead`),cacheWrite:A(t,`cacheWrite`),total:A(t,`total`)}}function hi(e){let t=D(e);return{...P(`provider`,k(t,`provider`)),...P(`id`,k(t,`id`)),...P(`name`,k(t,`name`)),...P(`contextWindow`,N(t,`contextWindow`)),...P(`reasoning`,t.reasoning)}}function gi(e){return e===void 0?{}:{model:hi(e)}}function _i(e){let t=D(e);return{models:M(hi)(t.models)}}function vi(e){let t=D(e),n=t.starterModelPolicyPreference===void 0?void 0:Sr(t.starterModelPolicyPreference),r=k(t,`starterModelPolicyPreferenceError`);if(n!==void 0&&r!==void 0)throw Error(`Session defaults cannot contain both a starter preference and preference error`);return{...t.model===void 0?{}:{model:hi(t.model)},thinkingLevel:O(t,`thinkingLevel`),models:M(hi)(t.models),thinkingLevels:Jn(t.thinkingLevels,`thinkingLevels`),...P(`starterModelPolicyPreference`,n),...P(`starterModelPolicyPreferenceError`,r)}}function yi(e){let t=Ar(e,`version-two session defaults response`);if(Mr(t,[`starterModelPolicyContractVersion`,`model`,`thinkingLevel`,`models`,`thinkingLevels`,`starterModelPolicyPreference`,`starterModelPolicyPreferenceError`],`version-two session defaults response`),t.starterModelPolicyContractVersion!==2)throw Error(`Invalid starter model policy contract version`);let n=t.starterModelPolicyPreference===void 0?void 0:Cr(t.starterModelPolicyPreference),r=k(t,`starterModelPolicyPreferenceError`);if(n!==void 0&&r!==void 0)throw Error(`Session defaults cannot contain both a starter preference and preference error`);return{starterModelPolicyContractVersion:2,...t.model===void 0?{}:{model:hi(t.model)},thinkingLevel:O(t,`thinkingLevel`),models:M(hi)(t.models),thinkingLevels:Jn(t.thinkingLevels,`thinkingLevels`),...P(`starterModelPolicyPreference`,n),...P(`starterModelPolicyPreferenceError`,r)}}function bi(e){let t=Ci(e,`models configuration`),n=t.providers;if(n===void 0)return{...t,providers:{}};let r=Ci(n,`models configuration providers`),i={};for(let[e,t]of Object.entries(r))i[e]=xi(t);return{...t,providers:i}}function xi(e){let t=Ci(e,`models configuration provider`),n={};for(let[e,r]of Object.entries(t))n[e]=r;let r=k(t,`baseUrl`);r!==void 0&&(n.baseUrl=r);let i=k(t,`api`);i!==void 0&&(n.api=i);let a=k(t,`apiKey`);a!==void 0&&(n.apiKey=a);let o=wi(t.headers,`models configuration provider headers`);o!==void 0&&(n.headers=Ti(o,`models configuration provider headers`));let s=wi(t.compat,`models configuration provider compatibility`);s!==void 0&&(n.compat={...s});let c=wi(t.modelOverrides,`models configuration provider model overrides`);c!==void 0&&(n.modelOverrides={...c});let l=t.models;if(l!==void 0){if(!Array.isArray(l))throw Error(`Expected models configuration models array`);n.models=l.map(Si)}return n}function Si(e){let t=Ci(e,`models configuration model`),n={id:O(t,`id`)};for(let[e,r]of Object.entries(t))n[e]=r;n.id=O(t,`id`);let r=k(t,`name`);r!==void 0&&(n.name=r);let i=k(t,`api`);i!==void 0&&(n.api=i);let a=_s(t,`reasoning`);a!==void 0&&(n.reasoning=a);let o=wi(t.thinkingLevelMap,`models configuration thinking level map`);o!==void 0&&(n.thinkingLevelMap=Ei(o));let s=t.input;if(s!==void 0){if(!Array.isArray(s)||!s.every(e=>typeof e==`string`))throw Error(`Expected models configuration model input array of strings`);n.input=[...s]}let c=N(t,`contextWindow`);c!==void 0&&(n.contextWindow=c);let l=N(t,`maxTokens`);l!==void 0&&(n.maxTokens=l);let u=wi(t.cost,`models configuration model cost`);u!==void 0&&(n.cost=Di(u));let d=wi(t.compat,`models configuration model compatibility`);d!==void 0&&(n.compat={...d});let f=t.tpm;typeof f==`number`&&(n.tpm=f);let p=t.rpm;return typeof p==`number`&&(n.rpm=p),n}function Ci(e,t){if(!zn(e)||Array.isArray(e))throw Error(`Expected ${t} object`);return e}function wi(e,t){if(e!==void 0)return Ci(e,t)}function Ti(e,t){let n={};for(let[r,i]of Object.entries(e)){if(typeof i!=`string`)throw Error(`Expected ${t} values to be strings`);n[r]=i}return n}function Ei(e){let t={};for(let[n,r]of Object.entries(e)){if(r!==null&&typeof r!=`string`)throw Error(`Expected models configuration thinking level map values to be strings or null`);t[n]=r}return t}function Di(e){let t={};for(let n of[`input`,`output`,`cacheRead`,`cacheWrite`]){let r=e[n];if(r!==void 0){if(typeof r!=`number`)throw Error(`Expected models configuration model cost ${n} to be a number`);t[n]=r}}return t}function Oi(e){let t=D(e);if(t.success!==!0)throw Error(`Expected successful models configuration save`);let n=t.contractVersion;if(n!==void 0&&n!==1)throw Error(`Expected models configuration save contract version 1`);let r=t.revision===void 0?void 0:A(t,`revision`);return{success:!0,...n===void 0?{}:{contractVersion:1},...r===void 0?{}:{revision:r}}}function ki(e){let t=D(e),n=new Set([`contractVersion`,`revision`,`admission`,`source`,`error`]);for(let e of Object.keys(t))if(!n.has(e))throw Error(`Unexpected models configuration limits status key: ${e}`);if(t.contractVersion!==1)throw Error(`Expected models configuration limits status contract version 1`);let r=A(t,`revision`),i=t.admission;if(i!==`ready`&&i!==`blocked`)throw Error(`Expected models configuration limits admission state`);let a=t.source;if(a!==`none`&&a!==`missing-file`&&a!==`accepted-document`&&a!==`last-known-good`)throw Error(`Expected models configuration limits source`);let o=k(t,`error`);return{contractVersion:1,revision:r,admission:i,source:a,...o===void 0?{}:{error:o}}}function Ai(e){let t=D(e);return{models:M(ji)(t.models)}}function ji(e){let t=D(e),n=O(t,`id`),r=k(t,`name`);return r===void 0?{id:n}:{id:n,name:r}}function Mi(e){let t=D(e),n=j(t,`ok`),r=k(t,`error`),i=t.latencyMs===void 0?void 0:A(t,`latencyMs`),a=t.status===void 0?void 0:A(t,`status`),o=k(t,`responseText`);return{ok:n,...r===void 0?{}:{error:r},...i===void 0?{}:{latencyMs:i},...a===void 0?{}:{status:a},...o===void 0?{}:{responseText:o}}}function Ni(e){let t=D(e);return{skills:M(Pi)(t.skills)}}function Pi(e){let t=D(e),n=D(t.sourceInfo),r=k(n,`source`),i=k(n,`scope`);return{name:O(t,`name`),description:O(t,`description`),filePath:O(t,`filePath`),baseDir:O(t,`baseDir`),disableModelInvocation:j(t,`disableModelInvocation`),sourceInfo:{...r===void 0?{}:{source:r},...i===void 0?{}:{scope:i}},...t.install===void 0?{}:{install:Fi(t.install)}}}function Fi(e){let t=D(e),n=k(t,`sourceType`),r=k(t,`skillsShUrl`),i=k(t,`skillPath`),a=k(t,`ref`),o=k(t,`versionHash`);return{package:O(t,`package`),scope:Ii(t.scope),source:O(t,`source`),...n===void 0?{}:{sourceType:n},...r===void 0?{}:{skillsShUrl:r},...i===void 0?{}:{skillPath:i},...a===void 0?{}:{ref:a},...o===void 0?{}:{versionHash:o},canCheckForUpdates:j(t,`canCheckForUpdates`)}}function Ii(e){if(e!==`global`&&e!==`project`)throw Error(`Expected skill install scope`);return e}function Li(e){if(D(e).success!==!0)throw Error(`Expected successful Skills mutation`);return{success:!0}}function Ri(e){let t=D(e);return{results:M(zi)(t.results)}}function zi(e){let t=D(e);return{package:O(t,`package`),installs:O(t,`installs`),url:O(t,`url`)}}function Bi(e){let t=D(e);return{updates:M(Vi)(t.updates)}}function Vi(e){let t=D(e),n=k(t,`currentVersion`),r=k(t,`latestVersion`),i=k(t,`message`);return{package:O(t,`package`),scope:Ii(t.scope),state:Hi(t.state),...n===void 0?{}:{currentVersion:n},...r===void 0?{}:{latestVersion:r},...i===void 0?{}:{message:i}}}function Hi(e){if(e!==`up-to-date`&&e!==`update-available`&&e!==`unsupported`&&e!==`error`)throw Error(`Expected skill update state`);return e}function Ui(e){let t=D(e);if(t.success!==!0)throw Error(`Expected successful Skills update`);let n=k(t,`output`);return{success:!0,...t.skill===void 0?{}:{skill:Pi(t.skill)},...n===void 0?{}:{output:n}}}function Wi(e){if(typeof e!=`string`)throw Error(`Invalid thinking level`);return e}function Gi(e){let t=D(e);return{levels:M(Wi)(t.levels)}}function Ki(e){if(e!==`oauth`&&e!==`api_key`)throw Error(`Invalid auth type`);return e}function qi(e){if(e!==`stored`&&e!==`runtime`&&e!==`environment`&&e!==`fallback`&&e!==`models_json_key`&&e!==`models_json_command`)throw Error(`Invalid auth status source`);return e}function Ji(e){let t=D(e),n=t.source===void 0?void 0:qi(t.source);return{configured:j(t,`configured`),...P(`source`,n),...P(`label`,k(t,`label`))}}function Yi(e){let t=D(e),n=t.loginFlow;if(n!==void 0&&n!==`interactive`)throw Error(`Invalid auth provider login flow`);return{id:O(t,`id`),name:O(t,`name`),authType:Ki(t.authType),status:Ji(t.status),...n===void 0?{}:{loginFlow:n}}}function Xi(e){let t=D(e);return{providers:M(Yi)(t.providers)}}function Zi(e){let t=D(e);return{flowId:O(t,`flowId`),providerId:O(t,`providerId`),providerName:O(t,`providerName`),status:Qi(t.status),progress:M(e=>{if(typeof e!=`string`)throw Error(`Expected progress item string`);return e})(t.progress),...P(`error`,k(t,`error`)),...P(`auth`,$i(t.auth)),...P(`prompt`,ta(t.prompt)),...P(`select`,ra(t.select)),...P(`info`,ia(t.info))}}function Qi(e){if(e!==`running`&&e!==`complete`&&e!==`error`&&e!==`cancelled`)throw Error(`Invalid OAuth flow status`);return e}function $i(e){if(e===void 0)return;let t=D(e);return{url:O(t,`url`),...P(`instructions`,k(t,`instructions`)),...P(`deviceCode`,ea(t.deviceCode))}}function ea(e){if(e===void 0)return;let t=D(e);return{userCode:O(t,`userCode`),...P(`intervalSeconds`,N(t,`intervalSeconds`)),...P(`expiresInSeconds`,N(t,`expiresInSeconds`))}}function ta(e){if(e===void 0)return;let t=D(e),n=O(t,`kind`);if(n!==`prompt`&&n!==`manual`)throw Error(`Invalid OAuth prompt kind`);let r=t.promptType===void 0?n===`manual`?`manual_code`:`text`:na(t.promptType);return{requestId:O(t,`requestId`),message:O(t,`message`),kind:n,promptType:r,...P(`placeholder`,k(t,`placeholder`)),...P(`allowEmpty`,_s(t,`allowEmpty`))}}function na(e){if(e!==`text`&&e!==`secret`&&e!==`manual_code`)throw Error(`Invalid OAuth prompt type`);return e}function ra(e){if(e===void 0)return;let t=D(e);return{requestId:O(t,`requestId`),message:O(t,`message`),options:M(ns)(t.options)}}function ia(e){if(e!==void 0)return M(e=>{let t=D(e);return{message:O(t,`message`),...P(`links`,t.links===void 0?void 0:M(aa)(t.links))}})(e)}function aa(e){let t=D(e);return{url:O(t,`url`),...P(`label`,k(t,`label`))}}function oa(e){if(e===void 0)return{};let t=D(e);return{generation:{outputTokens:A(t,`outputTokens`),...P(`tokensPerSecond`,N(t,`tokensPerSecond`)),...P(`estimated`,_s(t,`estimated`))}}}function sa(e){if(e===void 0)return{};let t=D(e);return{contextUsage:{tokens:vs(t,`tokens`),contextWindow:A(t,`contextWindow`),percent:vs(t,`percent`)}}}function ca(e){let t=D(e),n=O(t,`source`);if(n!==`extension`&&n!==`prompt`&&n!==`skill`&&n!==`builtin`)throw Error(`Invalid command source`);return{name:O(t,`name`),source:n,...P(`description`,k(t,`description`))}}function la(e){let t=D(e),n=O(t,`kind`);if(n!==`tracked`&&n!==`untracked`&&n!==`other`)throw Error(`Invalid file kind`);return{path:O(t,`path`),kind:n}}function ua(e){let t=D(e);return{path:O(t,`path`),entries:M(da)(t.entries),scannedAt:O(t,`scannedAt`),truncated:j(t,`truncated`)}}function da(e){let t=D(e),n=O(t,`type`);if(n!==`file`&&n!==`directory`&&n!==`symlink`)throw Error(`Invalid file tree entry type`);return{name:O(t,`name`),path:O(t,`path`),type:n,...P(`size`,N(t,`size`)),...P(`modifiedAt`,k(t,`modifiedAt`))}}function fa(e){let t=D(e),n=O(t,`encoding`);if(n!==`utf8`)throw Error(`Invalid file encoding`);return{path:O(t,`path`),...P(`language`,k(t,`language`)),...P(`mediaType`,ga(t.mediaType)),...P(`mimeType`,k(t,`mimeType`)),encoding:n,size:A(t,`size`),modifiedAt:O(t,`modifiedAt`),content:O(t,`content`),truncated:j(t,`truncated`),binary:j(t,`binary`)}}function pa(e){let t=D(e);return{path:O(t,`path`),size:A(t,`size`),modifiedAt:O(t,`modifiedAt`),created:j(t,`created`)}}function ma(e){let t=D(e);return{path:O(t,`path`),existed:j(t,`existed`)}}function ha(e){let t=D(e);return{fromPath:O(t,`fromPath`),toPath:O(t,`toPath`),size:A(t,`size`),modifiedAt:O(t,`modifiedAt`)}}function ga(e){if(e!==void 0){if(e!==`image`)throw Error(`Invalid file media type`);return e}}function _a(e){let t=D(e);return{isGitRepo:j(t,`isGitRepo`),hash:O(t,`hash`),...P(`branch`,k(t,`branch`)),...P(`latestTag`,k(t,`latestTag`)),...P(`upstream`,k(t,`upstream`)),...P(`ahead`,N(t,`ahead`)),...P(`behind`,N(t,`behind`)),files:M(va)(t.files)}}function va(e){let t=D(e);return{path:O(t,`path`),...P(`oldPath`,k(t,`oldPath`)),index:ya(t.index),workingTree:ya(t.workingTree)}}function ya(e){switch(e){case`unmodified`:case`modified`:case`added`:case`deleted`:case`renamed`:case`copied`:case`untracked`:case`ignored`:case`conflicted`:return e;default:throw Error(`Invalid git file state`)}}function ba(e){let t=D(e);return{...P(`path`,k(t,`path`)),staged:j(t,`staged`),hash:O(t,`hash`),diff:O(t,`diff`),truncated:j(t,`truncated`)}}function xa(e){let t=D(e);return{id:O(t,`id`),cwd:O(t,`cwd`),name:O(t,`name`),createdAt:O(t,`createdAt`),exited:j(t,`exited`),...P(`exitCode`,N(t,`exitCode`)),...P(`commandRunId`,k(t,`commandRunId`))}}function Sa(e){let t=D(e);return{id:O(t,`id`),origin:O(t,`origin`),projectId:O(t,`projectId`),workspaceId:O(t,`workspaceId`),terminalId:O(t,`terminalId`),title:O(t,`title`),command:O(t,`command`),status:Ca(t.status),...P(`exitCode`,N(t,`exitCode`)),createdAt:O(t,`createdAt`),...P(`startedAt`,k(t,`startedAt`)),...P(`completedAt`,k(t,`completedAt`)),metadata:wa(t.metadata,`metadata`)}}function Ca(e){if(e!==`queued`&&e!==`running`&&e!==`succeeded`&&e!==`failed`)throw Error(`Invalid terminal command run status`);return e}function wa(e,t){let n=D(e);return Object.fromEntries(Object.entries(n).map(([e,n])=>{if(typeof n!=`string`)throw Error(`Expected string record field: ${t}.${e}`);return[e,n]}))}function Ta(e){let t=D(e);return{cwd:O(t,`cwd`),hasSessionActivity:j(t,`hasSessionActivity`),hasTerminalActivity:j(t,`hasTerminalActivity`),updatedAt:O(t,`updatedAt`)}}function Ea(e){let t=D(e);return{workspaces:M(Ta)(t.workspaces),generatedAt:O(t,`generatedAt`)}}function Da(e){let t=Ya(e,`utility model settings response`),n=Object.keys(t).find(e=>!Aa(e));if(n!==void 0)throw Error(`Invalid utility model settings response field: ${n}`);if(t.contractVersion===1)return Oa(t);if(t.contractVersion===2)return ka(t);throw Error(`Invalid utility model settings contract version`)}function Oa(e){let t=k(e,`configError`);return{contractVersion:1,settings:ja(e.settings),models:M(Pa)(e.models),slots:Ia(e.slots),valid:j(e,`valid`),...P(`configError`,t)}}function ka(e){let t=k(e,`configError`);return{contractVersion:2,settings:Ma(e.settings),models:M(Fa)(e.models),slots:Ia(e.slots),valid:j(e,`valid`),...P(`configError`,t)}}function Aa(e){return e===`contractVersion`||e===`settings`||e===`models`||e===`slots`||e===`valid`||e===`configError`}function ja(e){let t=Ya(e,`settings`),n=Object.keys(t).find(e=>!Ra(e));if(n!==void 0)throw Error(`Invalid utility model settings field: settings.${n}`);return{...P(`lightweight`,t.lightweight===void 0?void 0:Ua(t.lightweight,`settings.lightweight`)),...P(`context`,t.context===void 0?void 0:Ua(t.context,`settings.context`))}}function Ma(e){let t=Ya(e,`settings`),n=Object.keys(t).find(e=>!Ra(e));if(n!==void 0)throw Error(`Invalid utility model settings field: settings.${n}`);return{...P(`lightweight`,t.lightweight===void 0?void 0:Na(t.lightweight,`settings.lightweight`)),...P(`context`,t.context===void 0?void 0:Na(t.context,`settings.context`))}}function Na(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>e!==`provider`&&e!==`id`&&e!==`thinkingLevel`);if(r!==void 0)throw Error(`Invalid utility model binding field: ${t}.${r}`);let i=$r(n,`provider`),a=$r(n,`id`),o=k(n,`thinkingLevel`);if(o===void 0)return{provider:i,id:a};if(!In(o))throw Error(`Invalid utility model thinking level: ${t}.thinkingLevel`);return{provider:i,id:a,thinkingLevel:o}}function Pa(e){let t=Ya(e,`models`),n=Object.keys(t).find(e=>e!==`model`&&e!==`name`);if(n!==void 0)throw Error(`Invalid utility model option field: models.${n}`);return{model:Ua(t.model,`models.model`),...P(`name`,k(t,`name`))}}function Fa(e){let t=Ya(e,`models`),n=Object.keys(t).find(e=>e!==`model`&&e!==`name`&&e!==`thinkingLevels`);if(n!==void 0)throw Error(`Invalid utility model option field: models.${n}`);let r=Jn(t.thinkingLevels,`models.thinkingLevels`).map(e=>{if(!In(e))throw Error(`Invalid utility model thinking levels: models.thinkingLevels`);return e});return{model:Ua(t.model,`models.model`),...P(`name`,k(t,`name`)),thinkingLevels:r}}function Ia(e){let t=za(e,`slots`);return{lightweight:La(t.lightweight,`slots.lightweight`),context:La(t.context,`slots.context`)}}function La(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>e!==`valid`&&e!==`reason`);if(r!==void 0)throw Error(`Invalid utility model validation field: ${t}.${r}`);return{valid:j(n,`valid`),...P(`reason`,k(n,`reason`))}}function Ra(e){return Vt.some(t=>t===e)}function za(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>!Ra(e));if(r!==void 0)throw Error(`Invalid utility model ${t} field: unknown slot ${r}`);let i=Vt.find(e=>n[e]===void 0);if(i!==void 0)throw Error(`Invalid utility model ${t} field: missing slot ${i}`);return n}function Ba(e){let t=D(e);if(t.contractVersion!==1)throw Error(`Invalid model-tier settings contract version`);let n=t.ladder===void 0?void 0:Va(t.ladder),r=k(t,`configError`);return{contractVersion:1,...P(`ladder`,n),models:M(Wa)(t.models),rows:Ga(t.rows),valid:j(t,`valid`),...P(`configError`,r)}}function Va(e){let t=Ja(e,`ladder`);return{economy:Ha(t.economy,`ladder.economy`),fast:Ha(t.fast,`ladder.fast`),standard:Ha(t.standard,`ladder.standard`),advanced:Ha(t.advanced,`ladder.advanced`),capable:Ha(t.capable,`ladder.capable`),frontier:Ha(t.frontier,`ladder.frontier`)}}function Ha(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>e!==`model`&&e!==`thinkingLevel`);if(r!==void 0)throw Error(`Invalid model-tier entry field: ${t}.${r}`);return{model:Ua(n.model,`${t}.model`),thinkingLevel:$r(n,`thinkingLevel`)}}function Ua(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>e!==`provider`&&e!==`id`);if(r!==void 0)throw Error(`Invalid model reference field: ${t}.${r}`);return{provider:$r(n,`provider`),id:$r(n,`id`)}}function Wa(e){let t=Ya(e,`models`);return{model:Ua(t.model,`models.model`),...P(`name`,k(t,`name`)),thinkingLevels:Jn(t.thinkingLevels,`models.thinkingLevels`)}}function Ga(e){let t=Ja(e,`rows`);return{economy:Ka(t.economy,`rows.economy`),fast:Ka(t.fast,`rows.fast`),standard:Ka(t.standard,`rows.standard`),advanced:Ka(t.advanced,`rows.advanced`),capable:Ka(t.capable,`rows.capable`),frontier:Ka(t.frontier,`rows.frontier`)}}function Ka(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>e!==`valid`&&e!==`reason`);if(r!==void 0)throw Error(`Invalid model-tier row field: ${t}.${r}`);return{valid:j(n,`valid`),...P(`reason`,k(n,`reason`))}}function qa(e){return Bt.some(t=>t===e)}function Ja(e,t){let n=Ya(e,t),r=Object.keys(n).find(e=>!qa(e));if(r!==void 0)throw Error(`Invalid model-tier ${t} field: unknown tier ${r}`);let i=Bt.find(e=>n[e]===void 0);if(i!==void 0)throw Error(`Invalid model-tier ${t} field: missing tier ${i}`);return n}function Ya(e,t){if(!zn(e)||Array.isArray(e))throw Error(`Expected object field: ${t}`);return e}function Xa(e){let t=D(e);return{path:O(t,`path`),exists:j(t,`exists`),config:no(t.config),effectiveConfig:no(t.effectiveConfig),envOverrides:mo(t.envOverrides)}}function Za(e){let t=Ar(e,`speech input settings response`);Mr(t,[`contractVersion`,`revision`,`settings`,`credential`],`speech input settings response`);let n=t.contractVersion;if(n!==1&&n!==2)throw Error(`Invalid speech input settings contract version`);let r=O(t,`revision`);if(!On(r))throw Error(`Invalid speech input settings revision`);return{contractVersion:n,revision:r,settings:Qa(t.settings,n===2),credential:to(t.credential)}}function Qa(e,t){let n=Ya(e,`speech input settings`);Mr(n,[`provider`,`language`,`polishVoiceInput`,`cloud`],`speech input settings`);let r=n.provider;if(r!==`auto`&&r!==`browser`&&r!==`cloud`)throw Error(`Invalid speech input settings provider`);let i=k(n,`language`);if(i!==void 0&&kn(i)!==i)throw Error(`Invalid speech input settings language`);let a=Object.hasOwn(n,`polishVoiceInput`);if(t&&!a)throw Error(`Version-two speech input settings require polishVoiceInput`);let o=!a||j(n,`polishVoiceInput`);return{provider:r,...P(`language`,i),polishVoiceInput:o,cloud:$a(n.cloud)}}function $a(e){let t=Ya(e,`speech input cloud settings`);Mr(t,[`baseUrl`,`model`],`speech input cloud settings`);let n=es(t,`baseUrl`);if(!eo(n))throw Error(`Invalid speech input cloud base URL`);return{baseUrl:n,model:es(t,`model`)}}function eo(e){try{let t=new URL(e);return t.protocol===`https:`&&t.username===``&&t.password===``&&t.search===``&&t.hash===``}catch{return!1}}function to(e){let t=Ya(e,`speech input credential status`);Mr(t,[`configured`,`source`,`resolution`],`speech input credential status`);let n=j(t,`configured`),r=t.source,i=t.resolution;if(typeof i!=`string`)throw Error(`Invalid speech input credential status`);if(!n){if(r!==void 0||i!==`missing`)throw Error(`Invalid speech input credential status`);return{configured:!1,resolution:`missing`}}if(r!==`literal`&&r!==`environment`&&r!==`command`)throw Error(`Invalid speech input credential status`);if(r===`command`){if(i!==`unchecked`)throw Error(`Invalid speech input credential status`)}else if(r===`literal`){if(i!==`resolved`)throw Error(`Invalid speech input credential status`)}else if(i!==`resolved`&&i!==`unresolved`)throw Error(`Invalid speech input credential status`);return{configured:!0,source:r,resolution:i}}function no(e){let t=D(e);return{...P(`host`,k(t,`host`)),...P(`port`,N(t,`port`)),...P(`allowedHosts`,ao(t.allowedHosts)),...P(`shortcuts`,fo(t.shortcuts)),...P(`plugins`,po(t.plugins)),...P(`pathAccess`,oo(t.pathAccess)),...P(`uploads`,co(t.uploads)),...P(`maxUploadBytes`,N(t,`maxUploadBytes`)),...P(`agent`,ro(t.agent)),...P(`tts`,io(t.tts)),...P(`spawnSessions`,_s(t,`spawnSessions`)),...P(`subsessions`,_s(t,`subsessions`))}}function ro(e){if(e!==void 0){if(!zn(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI agent field`);return{...P(`command`,k(e,`command`)),...P(`dir`,k(e,`dir`))}}}function io(e){if(e===void 0)return;if(!zn(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI tts field`);Mr(e,[`voice`,`rate`],`PI WEBUI tts`);let t=k(e,`voice`)?.trim();if(t===``)throw Error(`Invalid PI WEBUI tts voice field`);let n=N(e,`rate`);if(n!==void 0&&(!Number.isInteger(n)||n<-100||n>100))throw Error(`Invalid PI WEBUI tts rate field`);return{...P(`voice`,t),...P(`rate`,n)}}function ao(e){if(e!==void 0){if(e===!0)return!0;if(lo(e))return e;throw Error(`Invalid PI WEBUI allowedHosts field`)}}function oo(e){if(e===void 0)return;if(!zn(e))throw Error(`Invalid PI WEBUI pathAccess field`);let t=e.allowedPaths;return{...P(`allowedPaths`,so(t,`pathAccess.allowedPaths`))}}function so(e,t){if(e!==void 0){if(uo(e))return e;throw Error(`Invalid PI WEBUI ${t} field`)}}function co(e){if(e!==void 0){if(!zn(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI uploads field`);return{...P(`defaultFolder`,k(e,`defaultFolder`))}}}function lo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function uo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function fo(e){if(e!==void 0){if(!zn(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI shortcuts field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t!==null&&(typeof t!=`string`||t===``))throw Error(`Invalid PI WEBUI shortcut field`);return[e,t]}))}}function po(e){if(e!==void 0){if(!zn(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI plugins field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(!zn(t)||Array.isArray(t))throw Error(`Invalid PI WEBUI plugin config field`);let n=t.enabled;if(n!==void 0&&typeof n!=`boolean`)throw Error(`Invalid PI WEBUI plugin enabled field`);let r=t.settings;if(r!==void 0&&(!zn(r)||Array.isArray(r)))throw Error(`Invalid PI WEBUI plugin settings field`);return[e,t]}))}}function mo(e){let t=D(e);return{host:j(t,`host`),port:j(t,`port`),allowedHosts:j(t,`allowedHosts`),spawnSessions:j(t,`spawnSessions`),subsessions:j(t,`subsessions`),agentCommand:_s(t,`agentCommand`)??!1,agentDir:_s(t,`agentDir`)??!1,...ho(t),agentSessionDir:_s(t,`agentSessionDir`)??!1}}function ho(e){let t=e.agentDirSource;if(t===void 0)return{};if(t!==`pi-webui`&&t!==`pi-compatibility`)throw Error(`Invalid PI WEBUI agentDirSource field`);return{agentDirSource:t}}function go(e){let t=D(e);return{packages:M(vo)(t.packages)}}function _o(e){let t=D(e),n=k(t,`source`),r=t.scope===void 0?void 0:yo(t.scope),i=Mo(t.removed,`removed`);return{action:bo(t.action),...P(`source`,n),...P(`scope`,r),...P(`removed`,i),packages:M(vo)(t.packages)}}function vo(e){let t=D(e);return{source:O(t,`source`),scope:yo(t.scope),filtered:j(t,`filtered`),...P(`installedPath`,k(t,`installedPath`))}}function yo(e){if(e!==`user`&&e!==`project`)throw Error(`Invalid Pi package scope`);return e}function bo(e){if(e!==`install`&&e!==`remove`&&e!==`update`)throw Error(`Invalid Pi package mutation action`);return e}function xo(e){let t=D(e);return{packages:M(So)(t.packages),totals:To(t.totals),diagnostics:M(Oo)(t.diagnostics)}}function So(e){let t=D(e);return{source:O(t,`source`),scope:Co(t.scope),filtered:j(t,`filtered`),disabled:j(t,`disabled`),...P(`installedPath`,k(t,`installedPath`)),...P(`packageName`,k(t,`packageName`)),...P(`version`,k(t,`version`)),...P(`configuredVersion`,k(t,`configuredVersion`)),counts:To(t.counts),resources:M(Eo)(t.resources),status:wo(t.status)}}function Co(e){if(e!==`global`&&e!==`project`)throw Error(`Invalid Pi package plugin scope`);return e}function wo(e){if(e!==`loaded`&&e!==`installed`&&e!==`missing`&&e!==`disabled`)throw Error(`Invalid Pi package plugin status`);return e}function To(e){let t=D(e);return{extensions:A(t,`extensions`),skills:A(t,`skills`),prompts:A(t,`prompts`),themes:A(t,`themes`)}}function Eo(e){let t=D(e);return{kind:Do(t.kind),name:O(t,`name`),path:O(t,`path`),relativePath:O(t,`relativePath`)}}function Do(e){if(e!==`extension`&&e!==`skill`&&e!==`prompt`&&e!==`theme`)throw Error(`Invalid Pi package plugin resource kind`);return e}function Oo(e){let t=D(e),n=t.type;if(n!==`warning`&&n!==`error`)throw Error(`Invalid Pi package plugin diagnostic type`);return{type:n,message:O(t,`message`),...P(`source`,k(t,`source`)),...P(`path`,k(t,`path`))}}function ko(e){let t=D(e);return{plugins:M(Ao)(t.plugins)}}function Ao(e){let t=D(e);return{id:O(t,`id`),module:O(t,`module`),source:O(t,`source`),scope:jo(t.scope),machineSpecific:Mo(t.machineSpecific,`machineSpecific`)??!1,enabled:j(t,`enabled`)}}function jo(e){if(e!==`bundled`&&e!==`local`&&e!==`user`&&e!==`project`)throw Error(`Invalid PI WEBUI plugin scope`);return e}function Mo(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`Expected optional boolean field: ${t}`);return e}}function No(e){let t=D(e);return{packageName:O(t,`packageName`),generatedAt:O(t,`generatedAt`),components:Fo(t.components),release:Bo(t.release),commands:Vo(t.commands),messages:M(Ho)(t.messages)}}function Po(e){let t=D(e);return{packageName:O(t,`packageName`),generatedAt:O(t,`generatedAt`),components:Io(t.components),capabilities:Wo(t.capabilities)}}function Fo(e){let t=D(e);return{web:Ro(t.web),sessiond:Ro(t.sessiond)}}function Io(e){let t=D(e);return{web:Lo(t.web),sessiond:Lo(t.sessiond)}}function Lo(e){let t=D(e),n=Uo(t.component),r=t.activeAgentProfile,i=r===void 0?void 0:_n(r);if(r!==void 0&&(n!==`sessiond`||i===void 0))throw Error(`Invalid active agent profile descriptor`);return{component:n,label:O(t,`label`),...P(`runtimeVersion`,k(t,`runtimeVersion`)),available:j(t,`available`),capabilities:Wo(t.capabilities),...P(`activeAgentProfile`,i),...P(`error`,k(t,`error`))}}function Ro(e){let t=D(e);return{component:Uo(t.component),label:O(t,`label`),...P(`runtimeVersion`,k(t,`runtimeVersion`)),...P(`installedVersion`,k(t,`installedVersion`)),stale:j(t,`stale`),available:j(t,`available`),...P(`installation`,zo(t.installation)),...P(`error`,k(t,`error`))}}function zo(e){if(e===void 0)return;let t=D(e),n=O(t,`kind`);if(n!==`pi-package`&&n!==`npm-global`&&n!==`local`&&n!==`docker`&&n!==`unknown`)throw Error(`Invalid PI WEBUI installation kind`);let r=t.scope;if(r!==void 0&&r!==`user`&&r!==`project`)throw Error(`Invalid PI WEBUI installation scope`);let i=t.dockerMode;if(i!==void 0&&i!==`runtime`&&i!==`dev`)throw Error(`Invalid PI WEBUI Docker mode`);return{kind:n,...P(`path`,k(t,`path`)),...P(`source`,k(t,`source`)),...r===void 0?{}:{scope:r},...P(`npmRoot`,k(t,`npmRoot`)),...i===void 0?{}:{dockerMode:i}}}function Bo(e){let t=D(e);return{packageName:O(t,`packageName`),...P(`latestVersion`,k(t,`latestVersion`)),updateAvailable:j(t,`updateAvailable`),...P(`checkedAt`,k(t,`checkedAt`)),...t.skipped===!0?{skipped:!0}:{},...P(`error`,k(t,`error`))}}function Vo(e){let t=D(e);return{...P(`update`,k(t,`update`)),...P(`restart`,k(t,`restart`)),...P(`restartWeb`,k(t,`restartWeb`)),...P(`restartSessiond`,k(t,`restartSessiond`)),...P(`status`,k(t,`status`))}}function Ho(e){let t=D(e);return{id:O(t,`id`),severity:Go(t.severity),title:O(t,`title`),body:O(t,`body`),...P(`command`,k(t,`command`))}}function Uo(e){if(e!==`web`&&e!==`sessiond`)throw Error(`Invalid PI WEBUI service component`);return e}function Wo(e){let t=En(e);if(t===void 0)throw Error(`Invalid PI WEBUI capabilities`);return t}function Go(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid PI WEBUI status severity`);return e}function Ko(e){let t=D(e),n=O(t,`type`);if(n===`unsupported`)return{type:n,message:O(t,`message`)};if(n===`select`)return{type:n,requestId:O(t,`requestId`),title:O(t,`title`),options:M(ns)(t.options)};if(n===`tree`)return{type:n,tree:qo(t.tree)};if(n===`done`)return{type:n,...P(`message`,k(t,`message`)),...rs(t.session),...P(`promptDraft`,k(t,`promptDraft`))};throw Error(`Invalid command result type`)}function qo(e){let t=D(e),n=M(Jo)(t.nodes),r=new Set(n.map(e=>e.id));if(r.size!==n.length)throw Error(`Duplicate session tree node id`);let i=$o(t,`activeLeafId`);if(i!==null&&!r.has(i))throw Error(`Invalid session tree activeLeafId`);return{nodes:n,activeLeafId:i,activePathIds:ts(t.activePathIds,`activePathIds`)}}function Jo(e){let t=D(e);return{id:es(t,`id`),parentId:$o(t,`parentId`),kind:Yo(t.kind),summary:O(t,`summary`),...P(`timestamp`,k(t,`timestamp`)),...P(`label`,k(t,`label`))}}function Yo(e){switch(e){case`user`:case`assistant`:case`tool-result`:case`bash`:case`custom-message`:case`compaction`:case`branch-summary`:case`model-change`:case`thinking-level-change`:case`session-info`:case`label`:case`custom`:case`other`:return e;default:throw Error(`Invalid session tree node kind`)}}function Xo(e){let t=D(e),n=j(t,`cancelled`);if(Object.hasOwn(t,`summaryEntry`))throw Error(`Invalid session tree navigation result field: summaryEntry`);if(n){Qo(t,`editorText`,`session tree cancellation result`);let e=t.aborted;if(e!==void 0&&typeof e!=`boolean`)throw Error(`Expected optional boolean field: aborted`);return{cancelled:n,...e===void 0?{}:{aborted:e}}}return Qo(t,`aborted`,`session tree navigation result`),{cancelled:n,...P(`editorText`,k(t,`editorText`))}}function Zo(e){let t=D(e);return j(t,`cancelled`)?(Qo(t,`session`,`session fork cancellation result`),{cancelled:!0}):{cancelled:!1,session:fr(t.session)}}function Qo(e,t,n){if(Object.hasOwn(e,t))throw Error(`Invalid ${n} field: ${t}`)}function $o(e,t){let n=e[t];if(n!==null&&typeof n!=`string`)throw Error(`Expected string or null field: ${t}`);if(typeof n==`string`&&n.trim()===``)throw Error(`Expected non-blank string or null field: ${t}`);return n}function es(e,t){let n=O(e,t);if(n.trim()===``)throw Error(`Expected non-blank string field: ${t}`);return n}function ts(e,t){let n=Jn(e,t);if(n.some(e=>e.trim()===``))throw Error(`Expected non-blank string array field: ${t}`);return n}function ns(e){let t=D(e);return{value:O(t,`value`),label:O(t,`label`),...P(`description`,k(t,`description`))}}function rs(e){return e===void 0?{}:{session:fr(e)}}function is(e){if(D(e).accepted!==!0)throw Error(`Expected accepted response`);return{accepted:!0}}function as(e){let t=D(e);return M(os)(t.attachments)}function os(e){let t=D(e);return{path:O(t,`path`),mimeType:O(t,`mimeType`),size:A(t,`size`)}}function ss(e){if(D(e).closed!==!0)throw Error(`Expected closed response`);return{closed:!0}}function cs(e){if(typeof e!=`string`)throw Error(`Expected string value`);return e}function ls(e){let t=D(e);return{closedProjectIds:M(cs)(t.closedProjectIds)}}function us(e){if(D(e).aborted!==!0)throw Error(`Expected aborted response`);return{aborted:!0}}function ds(e){if(D(e).stopped!==!0)throw Error(`Expected stopped response`);return{stopped:!0}}function fs(e){let t=D(e);if(t.archived!==!0)throw Error(`Expected archived response`);let n=t.sessionIds===void 0?void 0:Jn(t.sessionIds,`sessionIds`),r=N(t,`archivedCount`),i=N(t,`skippedAlreadyArchivedCount`);return{archived:!0,...n===void 0?{}:{sessionIds:n},...r===void 0?{}:{archivedCount:r},...i===void 0?{}:{skippedAlreadyArchivedCount:i}}}function ps(e){if(D(e).restored!==!0)throw Error(`Expected restored response`);return{restored:!0}}function ms(e){if(D(e).deleted!==!0)throw Error(`Expected deleted response`);return{deleted:!0}}function hs(e){if(D(e).detached!==!0)throw Error(`Expected detached response`);return{detached:!0}}function gs(e){if(D(e).reloaded!==!0)throw Error(`Expected reloaded response`);return{reloaded:!0}}function _s(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw Error(`Invalid PI WEBUI ${t} field`);return n}}function N(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`number`)throw Error(`Expected optional number field: ${t}`);return n}}function vs(e,t){let n=e[t];if(n===null)return null;if(typeof n!=`number`)throw Error(`Expected number|null field: ${t}`);return n}function P(e,t){return t===void 0?{}:{[e]:t}}function ys(e){let t=D(e),n=D(t.memory),r=D(t.network);return{generatedAt:O(t,`generatedAt`),memory:{totalBytes:A(n,`totalBytes`),usedBytes:A(n,`usedBytes`),freeBytes:A(n,`freeBytes`),usagePercent:A(n,`usagePercent`)},network:Ss(r)}}function bs(e){let t=D(e),n=D(t.os),r=D(t.cpu),i=D(t.memory),a=D(t.network),o=t.gpu,s;if(o!=null){let e=D(o),t={name:O(e,`name`)},n=k(e,`driverVersion`);n!==void 0&&(t.driverVersion=n);let r=N(e,`memoryTotalBytes`);r!==void 0&&(t.memoryTotalBytes=r);let i=N(e,`memoryUsedBytes`);i!==void 0&&(t.memoryUsedBytes=i);let a=N(e,`utilizationPercent`);a!==void 0&&(t.utilizationPercent=a);let c=N(e,`temperatureCelsius`);c!==void 0&&(t.temperatureCelsius=c),s=t}let c={generatedAt:O(t,`generatedAt`),os:{platform:O(n,`platform`),release:O(n,`release`),arch:O(n,`arch`),uptimeSeconds:A(n,`uptimeSeconds`)},cpu:{model:O(r,`model`),cores:A(r,`cores`),usagePercent:A(r,`usagePercent`)},memory:{totalBytes:A(i,`totalBytes`),usedBytes:A(i,`usedBytes`),freeBytes:A(i,`freeBytes`),usagePercent:A(i,`usagePercent`)},network:xs(a)};s!==void 0&&(c.gpu=s);let l=k(t,`piVersion`);l!==void 0&&(c.piVersion=l);let u=k(t,`piWebUiVersion`);return u!==void 0&&(c.piWebUiVersion=u),c}function xs(e){let t={hostname:O(e,`hostname`),localIpv4Addresses:Jn(e.localIpv4Addresses,`localIpv4Addresses`),...Ss(e)},n=k(e,`publicIpv4`);n!==void 0&&(t.publicIpv4=n);let r=k(e,`publicIpv6`);return r!==void 0&&(t.publicIpv6=r),t}function Ss(e){let t={},n=N(e,`downloadSpeedBytesPerSecond`);n!==void 0&&(t.downloadSpeedBytesPerSecond=n);let r=N(e,`uploadSpeedBytesPerSecond`);return r!==void 0&&(t.uploadSpeedBytesPerSecond=r),t}function Cs(e){let t=Ar(e,`project usage count response`);return Mr(t,[`sessionCount`],`project usage count response`),{sessionCount:ei(t,`sessionCount`)}}function ws(e){let t=D(e);return{input:A(t,`input`),output:A(t,`output`),cacheRead:A(t,`cacheRead`),cacheWrite:A(t,`cacheWrite`),cost:A(t,`cost`),sessionCount:A(t,`sessionCount`)}}function Ts(e){let t=D(e),n=D(t.buckets);return{projectPath:O(t,`projectPath`),buckets:{live:ws(n.live),retired:ws(n.retired),archived:ws(n.archived)},total:ws(t.total),generatedAt:O(t,`generatedAt`)}}function Es(e){return typeof e==`string`?e:e.id}function Ds(e){return typeof e==`string`?void 0:e.cwd}function Os(e,t,n,r){let i=new URLSearchParams;r?.path!==void 0&&i.set(`path`,r.path),r?.staged===!0&&i.set(`staged`,`true`);let a=i.toString();return`api/machines/${encodeURIComponent(e)}/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(n)}/git/diff${a?`?${a}`:``}`}function ks(e,t,n=`local`){let r=new URLSearchParams,i=Ds(e);i!==void 0&&i!==``&&r.set(`cwd`,i),t?.limit!==void 0&&r.set(`limit`,String(t.limit)),t?.before!==void 0&&r.set(`before`,String(t.before));let a=r.toString();return`api/machines/${encodeURIComponent(n)}/sessions/${encodeURIComponent(Es(e))}/messages${a===``?``:`?${a}`}`}function As(e,t=`local`){let n=new URLSearchParams,r=Ds(e);r!==void 0&&r!==``&&n.set(`cwd`,r);let i=n.toString();return`api/machines/${encodeURIComponent(t)}/sessions/${encodeURIComponent(Es(e))}/export${i===``?``:`?${i}`}`}function js(e,t,n,r){let i=new URLSearchParams({path:n});return r?.createDirs===!1&&i.set(`createDirs`,`false`),r?.overwrite===!1&&i.set(`overwrite`,`false`),qt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`)}function Ms(e,t,n,r){let i=new URLSearchParams;return i.set(`path`,n),r?.modifiedAt!==void 0&&i.set(`v`,r.modifiedAt),qt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${i.toString()}`)}var F=(e=`local`)=>`api/machines/${encodeURIComponent(e)}`,Ns=e=>e===void 0?void 0:{signal:e};function Ps(e){return typeof e==`string`?e:e.id}function Fs(e){return typeof e==`string`?void 0:e.cwd}function Is(e,t=`local`){return`${F(t)}/sessions/${encodeURIComponent(Ps(e))}`}function I(e,t,n=`local`){return`${Is(e,n)}/${t}`}function Ls(e,t,n=`local`){return`${I(e,t,n)}${zs(e)}`}function Rs(e,t=`local`){return`${Is(e,t)}${zs(e)}`}function zs(e){let t=Fs(e);return t===void 0||t===``?``:`?${new URLSearchParams({cwd:t}).toString()}`}function L(e,t={}){let n=Fs(e);return JSON.stringify(n===void 0||n===``?t:{cwd:n,...t})}function Bs(e){return JSON.stringify({sessions:e.map(Vs)})}function Vs(e){let t=Ps(e),n=Fs(e);return n===void 0||n===``?{id:t}:{id:t,cwd:n}}function Hs(e){return e===`local`?`api/pi-webui/status`:`${F(e)}/pi-webui/status`}var Us={piWebUiStatus:(e=`local`)=>T(Hs(e),No),checkForUpdates:(e=`local`)=>T(`${Hs(e)}?refresh=1`,No,{cache:`no-store`}),piWebUiRuntime:()=>T(`api/pi-webui/runtime`,Po),systemInfo:(e=`local`)=>T(`${F(e)}/pi-webui/system-info`,bs),systemMetrics:(e=`local`)=>T(`${F(e)}/pi-webui/system-metrics`,ys,{cache:`no-store`})},Ws={status:()=>T(`api/tts`,Bn,{cache:`no-store`}),speak:(e,t)=>T(`api/tts/speak`,Un,{method:`POST`,body:JSON.stringify(e),...t===void 0?{}:{signal:t}}),stop:e=>T(`api/tts/stop`,Wn,{method:`POST`,body:JSON.stringify({runId:e})})},Gs={settings:()=>T(`api/speech-input/settings`,Za,{cache:`no-store`}),saveSettings:e=>T(`api/speech-input/settings`,Za,{method:`PUT`,body:JSON.stringify(e)}),transcribe:(e,t,n)=>T(`api/speech-input/transcribe`,Gn,{method:`POST`,body:e,headers:{"content-type":t},...n===void 0?{}:{signal:n}}),polish:async(e,t)=>{try{return await T(`api/speech-input/polish`,Ks,{method:`POST`,body:JSON.stringify({text:e}),...t===void 0?{}:{signal:t}})}catch{throw Error(`Speech input polishing failed.`)}}};function Ks(e){if(!Ec(e)||Array.isArray(e))throw Error(`Invalid speech input polishing response`);let t=Object.keys(e);if(t.length!==1||t[0]!==`text`)throw Error(`Invalid speech input polishing response`);let n=e.text;if(typeof n!=`string`||n.trim()===``||new TextEncoder().encode(n).byteLength>1048576)throw Error(`Invalid speech input polishing response`);return n}var qs={machines:()=>T(`api/machines`,tr),addMachine:e=>T(`api/machines`,nr,{method:`POST`,body:JSON.stringify(e)}),deleteMachine:e=>T(`api/machines/${encodeURIComponent(e)}`,e=>e,{method:`DELETE`}),health:e=>T(`api/machines/${encodeURIComponent(e)}/health`,rr),runtime:(e,t=!1)=>T(`api/machines/${encodeURIComponent(e)}/runtime${t?`?refresh=1`:``}`,ir,t?{cache:`no-store`}:{})};function Js(e,t=`local`){let n=new URLSearchParams({projectPath:e});return`${F(t)}/agent-memory/snapshot?${n.toString()}`}var Ys={snapshot:(e,t=`local`)=>T(Js(e,t),Yn,{cache:`no-store`})};function Xs(e,t=`local`){let n=new URLSearchParams({projectPath:e});return`${F(t)}/agent-skills/snapshot?${n.toString()}`}var Zs={snapshot:(e,t=`local`)=>T(Xs(e,t),Zn,{cache:`no-store`})};function Qs(e){return e===void 0?`api/config`:`${F(e)}/config`}function $s(e){return e===void 0?`api/plugins`:`${F(e)}/plugins`}var ec={config:e=>T(Qs(e),Xa),saveConfig:(e,t)=>T(Qs(t),Xa,{method:`PUT`,body:JSON.stringify({config:e})})},tc={plugins:e=>T($s(e),ko)};function nc(e=`local`){return`${F(e)}/models-config`}var rc={config:(e=`local`)=>T(nc(e),bi),limitsStatus:(e=`local`)=>T(`${nc(e)}/limits`,ki),save:async(e,t=`local`)=>{let{status:n,body:r}=await Qt(nc(t),{method:`PUT`,body:JSON.stringify(e)});if(n<200||n>=300)throw on(r,n,`Failed to save models configuration.`);return Oi(r)},test:(e,t=`local`)=>T(`${nc(t)}/test`,Mi,{method:`POST`,body:JSON.stringify(e)}),discover:(e,t=`local`)=>T(`${nc(t)}/discover`,Ai,{method:`POST`,body:JSON.stringify(e)})};function ic(e=`local`){return`${F(e)}/model-tiers`}var ac={settings:(e=`local`)=>T(ic(e),Ba),save:(e,t=`local`)=>T(ic(t),Ba,{method:`PUT`,body:JSON.stringify({ladder:e})})};function oc(e=`local`){return`${F(e)}/utility-models`}function sc(e,t){if(t===2)return e;let n={};for(let t of Vt){if(!Object.prototype.hasOwnProperty.call(e,t))continue;let r=e[t];r===null?n[t]=null:r!==void 0&&(n[t]={provider:r.provider,id:r.id})}return n}var cc={settings:(e=`local`)=>T(oc(e),Da),save:(e,t,n=`local`)=>T(oc(n),Da,{method:`PUT`,body:JSON.stringify({settings:sc(e,t)})})};function lc(e=`local`){return`${F(e)}/skills`}function uc(e,t=`local`){return`${lc(t)}?${new URLSearchParams({cwd:e}).toString()}`}var dc={list:(e,t=`local`)=>T(uc(e,t),Ni),toggle:(e,t=`local`)=>T(lc(t),Li,{method:`PATCH`,body:JSON.stringify(e)}),search:(e,t=`local`)=>T(`${lc(t)}/search`,Ri,{method:`POST`,body:JSON.stringify(e)}),install:(e,t=`local`)=>T(`${lc(t)}/install`,Li,{method:`POST`,body:JSON.stringify(e)}),check:(e,t=`local`)=>T(`${lc(t)}/check`,Bi,{method:`POST`,body:JSON.stringify(e)}),update:(e,t=`local`)=>T(`${lc(t)}/update`,Ui,{method:`POST`,body:JSON.stringify(e)})};function fc(e=``,t){let n=t===void 0?`api/pi-packages`:`${F(t)}/pi-packages`;return e===``?n:`${n}/${e}`}var pc={packages:e=>T(fc(``,e),go),install:(e,t)=>{let n={source:e};return T(fc(`install`,t),_o,{method:`POST`,body:JSON.stringify(n)})},remove:(e,t,n)=>{let r=t===void 0?{source:e}:{source:e,scope:t};return T(fc(`remove`,n),_o,{method:`POST`,body:JSON.stringify(r)})},update:(e,t)=>{let n=e===void 0?void 0:{source:e};return T(fc(`update`,t),_o,{method:`POST`,...n===void 0?{}:{body:JSON.stringify(n)}})}};function mc(e=`local`){return`${F(e)}/package-plugins`}function hc(e,t=`local`){return`${mc(t)}?${new URLSearchParams({cwd:e}).toString()}`}var gc={list:(e,t=`local`)=>T(hc(e,t),xo),mutate:(e,t=`local`)=>T(mc(t),xo,{method:`POST`,body:JSON.stringify(e)})},_c={workspaceActivity:(e=`local`)=>T(`${F(e)}/activity`,Ea)},vc={projects:(e=`local`)=>T(`${F(e)}/projects`,M(sr)),addProject:(e,t,n,r=`local`)=>T(`${F(r)}/projects`,sr,{method:`POST`,body:JSON.stringify({path:e,name:t,create:n})}),closeProject:(e,t=`local`)=>T(`${F(t)}/projects/${encodeURIComponent(e)}`,ss,{method:`DELETE`}),closeProjectTree:(e,t=`local`)=>T(`${F(t)}/projects/${encodeURIComponent(e)}/close-tree`,ls,{method:`POST`}),pinProject:(e,t=`local`)=>T(`${F(t)}/projects/${encodeURIComponent(e)}/pin`,M(sr),{method:`POST`}),unpinProject:(e,t=`local`)=>T(`${F(t)}/projects/${encodeURIComponent(e)}/unpin`,M(sr),{method:`POST`}),projectDirectories:(e,t=`local`)=>T(`${F(t)}/project-directories?q=${encodeURIComponent(e)}`,M(la)),projectUsageCount:(e,t=`local`)=>T(`${F(t)}/sessions/project-usage/count`,Cs,{method:`POST`,body:JSON.stringify(e)}),projectUsage:(e,t=`local`)=>T(`${F(t)}/sessions/project-usage`,Ts,{method:`POST`,body:JSON.stringify(e)})},yc={recentProjects:(e=`local`)=>T(`${F(e)}/recent-projects`,lr),recordRecentProject:(e,t=`local`)=>T(`${F(t)}/projects/${encodeURIComponent(e)}/recent`,lr,{method:`POST`}),removeRecentProject:(e,t=`local`)=>T(`${F(t)}/recent-projects/${encodeURIComponent(e)}`,lr,{method:`DELETE`})},bc={workspaces:(e,t=`local`,n)=>T(`${F(t)}/projects/${encodeURIComponent(e)}/workspaces`,M(ur),Ns(n)),deleteWorkspace:(e,t,n=`local`)=>T(`${F(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}`,Sa,{method:`DELETE`}),workspaceTree:(e,t,n=``,r=`local`)=>T(`${F(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(n)}`,ua),workspaceFile:(e,t,n,r=`local`)=>T(`${F(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`,fa),writeWorkspaceFile:(e,t,n,r,i,a=`local`)=>{let o=new URLSearchParams({path:n});i?.createDirs===!1&&o.set(`createDirs`,`false`),i?.overwrite===!1&&o.set(`overwrite`,`false`);let s=r instanceof Uint8Array,c=s?new Uint8Array(r):new TextEncoder().encode(r);return T(`${F(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${o.toString()}`,pa,{method:`PUT`,body:c,headers:{"Content-Type":s?`application/octet-stream`:`text/plain`}})},deleteWorkspaceFile:(e,t,n,r=`local`)=>{let i=new URLSearchParams({path:n});return T(`${F(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`,ma,{method:`DELETE`})},moveWorkspaceFile:(e,t,n,r,i,a=`local`)=>{let o=new URLSearchParams({fromPath:n,toPath:r});return i?.createDirs===!1&&o.set(`createDirs`,`false`),i?.overwrite===!0&&o.set(`overwrite`,`true`),T(`${F(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/move?${o.toString()}`,ha,{method:`POST`})}},xc={sessions:(e,t=`local`,n)=>T(`${F(t)}/sessions?cwd=${encodeURIComponent(e)}`,M(fr),Ns(n)),reorder:(e,t,n=`local`)=>T(I(e,`reorder`,n),mr,{method:`POST`,body:JSON.stringify(t)}),unreadCatalog:(e=`local`)=>T(`${F(e)}/sessions/unread`,Fr,{cache:`no-store`}),acknowledgeUnread:(e,t,n,r=`local`)=>{let i={cwd:e.cwd,catalogId:t,throughCompletionOrder:n};return T(I(e,`unread/acknowledge`,r),Fr,{method:`POST`,body:JSON.stringify(i)})},notificationInbox:(e,t=`local`)=>T(Ls(e,`notifications`,t),Hr),dismissNotification:(e,t,n,r=`local`)=>T(I(e,`notifications/dismiss`,r),Hr,{method:`POST`,body:L(e,{daemonInstanceId:t,notificationId:n})}),dismissAllNotifications:(e,t,n,r=`local`)=>T(I(e,`notifications/dismiss-all`,r),Hr,{method:`POST`,body:L(e,{daemonInstanceId:t,throughOrder:n.order,throughOverflowWatermark:n.overflowWatermark})}),startSession:(e,t=`local`,n)=>T(`${F(t)}/sessions`,fr,{method:`POST`,body:JSON.stringify({cwd:e,...n===void 0?{}:{modelPolicy:n}})}),startPlusSession:(e,t,n=`local`)=>T(`${F(n)}/sessions`,fr,{method:`POST`,body:JSON.stringify({cwd:e,creationSource:`session-list-plus`,initialModelPolicy:t})}),sessionDefaults:(e,t=`local`)=>T(`${F(t)}/session-defaults?cwd=${encodeURIComponent(e)}`,vi),sessionDefaultsV2:(e,t=`local`)=>{let n=new URLSearchParams({cwd:e,starterModelPolicyContract:`2`});return T(`${F(t)}/session-defaults?${n.toString()}`,yi)},updateSessionDefaults:(e,t,n=`local`)=>T(`${F(n)}/session-defaults`,vi,{method:`PUT`,body:JSON.stringify({cwd:e,...t})}),cleanupPreview:(e,t=`local`)=>T(`${F(t)}/sessions/cleanup/preview`,ai,{method:`POST`,body:JSON.stringify(e)}),cleanup:(e,t=`local`)=>T(`${F(t)}/sessions/cleanup`,oi,{method:`POST`,body:JSON.stringify(e)}),forceCleanup:(e=`local`)=>T(`${F(e)}/sessions/cleanup/force`,oi,{method:`POST`}),archiveMany:(e,t=`local`)=>T(`${F(t)}/sessions/bulk/archive`,si,{method:`POST`,body:Bs(e)}),deleteArchivedMany:(e,t=`local`)=>T(`${F(t)}/sessions/bulk/delete-archived`,ci,{method:`POST`,body:Bs(e)}),messages:(e,t,n=`local`,r)=>T(ks(e,t,n),er,Ns(r)),status:(e,t=`local`,n)=>T(Ls(e,`status`,t),yr,Ns(n)),systemPrompt:(e,t=`local`)=>T(Ls(e,`system-prompt`,t),Pr),streamSnapshot:(e,t=`local`,n)=>T(Ls(e,`stream-snapshot`,t),Nr,Ns(n)),clearQueue:(e,t=`local`)=>T(I(e,`queue/clear`,t),yr,{method:`POST`,body:L(e)}),dismissWarning:(e,t,n=`local`)=>T(I(e,`warnings/dismiss`,n),yr,{method:`POST`,body:L(e,{dismissId:t})}),modelPolicy:(e,t=`local`)=>T(Ls(e,`model-policy`,t),br),rememberCurrentModelPolicy:(e,t=`local`)=>T(Ls(e,`model-policy/remember`,t),wr,{method:`POST`}),setModelPolicy:(e,t,n=`local`)=>T(I(e,`model-policy`,n),br,{method:`PUT`,body:L(e,{policy:t})}),models:(e,t=`local`)=>T(Ls(e,`models`,t),_i),setModel:(e,t,n,r=`local`)=>T(I(e,`model`,r),yr,{method:`POST`,body:L(e,{provider:t,modelId:n})}),cycleModel:(e,t,n=`local`)=>T(I(e,`model/cycle`,n),yr,{method:`POST`,body:L(e,{direction:t})}),thinkingLevels:(e,t=`local`)=>T(Ls(e,`thinking-levels`,t),Gi),setThinkingLevel:(e,t,n=`local`)=>T(I(e,`thinking-level`,n),yr,{method:`POST`,body:L(e,{level:t})}),cycleThinkingLevel:(e,t=`local`)=>T(I(e,`thinking-level/cycle`,t),yr,{method:`POST`,body:L(e)}),commands:(e,t=`local`)=>T(Ls(e,`commands`,t),M(ca)),prompt:(e,t,n,r=`local`,i)=>T(I(e,`prompt`,r),is,{method:`POST`,body:L(e,{text:t,...n===void 0?{}:{streamingBehavior:n},...i!==void 0&&i.length>0?{attachments:i}:{}})}),saveAttachments:(e,t,n=`local`,r)=>T(I(e,`attachments`,n),as,{method:`POST`,body:L(e,{attachments:t,...r===void 0?{}:{folder:r}})}),shell:(e,t,n=`local`)=>T(I(e,`shell`,n),is,{method:`POST`,body:L(e,{text:t})}),runCommand:(e,t,n=`local`)=>T(I(e,`commands/run`,n),Ko,{method:`POST`,body:L(e,{text:t})}),respondToCommand:(e,t,n,r=`local`)=>T(I(e,`commands/respond`,r),Ko,{method:`POST`,body:L(e,{requestId:t,value:n})}),navigateTree:(e,t,n=`local`)=>T(I(e,`tree/navigate`,n),Xo,{method:`POST`,body:L(e,{targetId:t.targetId,expectedLeafId:t.expectedLeafId,summary:t.summary})}),editFromHere:(e,t,n=`local`)=>T(I(e,`messages/edit-from-here`,n),Xo,{method:`POST`,body:L(e,{entryId:t})}),forkFromHere:(e,t,n=`local`)=>T(I(e,`messages/fork`,n),Zo,{method:`POST`,body:L(e,{entryId:t})}),abort:(e,t=`local`)=>T(I(e,`abort`,t),us,{method:`POST`,body:L(e)}),stop:(e,t=`local`)=>T(I(e,`stop`,t),ds,{method:`POST`,body:L(e)}),archive:(e,t=`local`)=>T(I(e,`archive`,t),fs,{method:`POST`,body:L(e)}),archiveWithDescendants:(e,t=`local`)=>T(I(e,`archive-tree`,t),fs,{method:`POST`,body:L(e)}),restore:(e,t=`local`)=>T(I(e,`restore`,t),ps,{method:`POST`,body:L(e)}),deleteArchived:(e,t=`local`)=>T(Rs(e,t),ms,{method:`DELETE`}),detachParent:(e,t=`local`)=>T(I(e,`detach-parent`,t),hs,{method:`POST`,body:L(e)}),reloadSession:(e,t=`local`)=>T(I(e,`reload`,t),gs,{method:`POST`,body:L(e)}),pin:(e,t=`local`)=>T(I(e,`pin`,t),fr,{method:`POST`,body:L(e)}),unpin:(e,t=`local`)=>T(I(e,`unpin`,t),fr,{method:`POST`,body:L(e)}),authProviders:e=>{let t=new URLSearchParams;e?.mode!==void 0&&t.set(`mode`,e.mode),e?.authType!==void 0&&t.set(`authType`,e.authType);let n=t.toString();return T(`${F(e?.machineId)}/auth/providers${n===``?``:`?${n}`}`,Xi)},saveApiKey:(e,t,n=`local`)=>T(`${F(n)}/auth/api-key`,is,{method:`POST`,body:JSON.stringify({providerId:e,key:t})}),startInteractiveApiKeyLogin:(e,t=`local`)=>T(`${F(t)}/auth/api-key/interactive`,Zi,{method:`POST`,body:JSON.stringify({providerId:e})}),logoutProvider:(e,t=`local`)=>T(`${F(t)}/auth/logout`,is,{method:`POST`,body:JSON.stringify({providerId:e})}),startOAuthLogin:(e,t=`local`)=>T(`${F(t)}/auth/oauth`,Zi,{method:`POST`,body:JSON.stringify({providerId:e})}),oauthFlow:(e,t=`local`)=>T(`${F(t)}/auth/oauth/${encodeURIComponent(e)}`,Zi),respondOAuthFlow:(e,t,n,r=`local`)=>T(`${F(r)}/auth/oauth/${encodeURIComponent(e)}/respond`,Zi,{method:`POST`,body:JSON.stringify({requestId:t,value:n})}),cancelOAuthFlow:(e,t=`local`)=>T(`${F(t)}/auth/oauth/${encodeURIComponent(e)}/cancel`,Zi,{method:`POST`})},Sc={terminals:(e,t,n=`local`)=>T(`${F(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,M(xa)),startTerminal:(e,t,n,r=`local`)=>T(`${F(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,xa,{method:`POST`,body:JSON.stringify(n??{})}),closeWorkspaceTerminals:(e,t,n=`local`)=>T(`${F(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,ss,{method:`DELETE`}),closeTerminal:(e,t,n,r=`local`)=>T(`${F(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}`,ss,{method:`DELETE`}),continueTerminal:(e,t,n,r=`local`)=>T(`${F(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/continue`,xa,{method:`POST`}),runTerminalCommand:(e,t,n=`local`)=>T(`${F(n)}/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,Sa,{method:`POST`,body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:(e,t=`local`)=>T(`${F(t)}/terminal-command-runs${wc(e)}`,M(Sa)),getCommandRun:(e,t=`local`)=>Cc(e,t),cancelCommandRun:(e,t=`local`)=>T(`${F(t)}/terminal-command-runs/${encodeURIComponent(e)}/cancel`,Sa,{method:`POST`})};async function Cc(e,t){let n=await fetch(qt(`${F(t)}/terminal-command-runs/${encodeURIComponent(e)}`));if(n.status!==404){if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(Tc(e)??n.statusText)}return Sa(await n.json())}}function wc(e){if(e===void 0)return``;let t=new URLSearchParams;e.projectId!==void 0&&t.set(`projectId`,e.projectId),e.workspaceId!==void 0&&t.set(`workspaceId`,e.workspaceId),e.terminalId!==void 0&&t.set(`terminalId`,e.terminalId),e.statuses!==void 0&&e.statuses.length>0&&t.set(`statuses`,e.statuses.join(`,`)),e.metadata!==void 0&&Object.keys(e.metadata).length>0&&t.set(`metadata`,JSON.stringify(e.metadata));let n=t.toString();return n===``?``:`?${n}`}function Tc(e){if(!Ec(e))return;let t=e.error;return typeof t==`string`?t:void 0}function Ec(e){return typeof e==`object`&&!!e}var Dc={files:(e,t,n={})=>{let r=new URLSearchParams({q:t});return n.kind!==void 0&&r.set(`kind`,n.kind),n.mode!==void 0&&r.set(`mode`,n.mode),n.scope!==void 0&&r.set(`scope`,n.scope),n.workspaceScoped===!0&&n.projectId!==void 0&&n.workspaceId!==void 0?T(`${F(n.machineId)}/projects/${encodeURIComponent(n.projectId)}/workspaces/${encodeURIComponent(n.workspaceId)}/files?${r.toString()}`,M(la)):(r.set(`cwd`,e),T(`${F(n.machineId)}/files?${r.toString()}`,M(la)))}},Oc={gitStatus:(e,t,n=`local`)=>T(`${F(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/status`,_a),gitDiff:(e,t,n,r=`local`)=>T(Os(r,e,t,n),ba)},kc={...Us,...Ws,...qs,...Ys,learnedSkills:Zs,...ac,utilityModels:cc,...ec,...tc,...pc,...gc,..._c,...vc,...yc,...bc,...xc,...Sc,...Dc,...Oc};function Ac(e,t=`local`){let n=typeof e==`string`?void 0:e.cwd,r=n===void 0||n===``?``:`?${new URLSearchParams({cwd:n}).toString()}`,i=typeof e==`string`?e:e.id;return new WebSocket(Jt(`${Nc(t)}/sessions/${encodeURIComponent(i)}/events${r}`))}function jc(e,t,n,r,i=`local`){let a=r===void 0?``:`?${new URLSearchParams({cols:String(r.cols),rows:String(r.rows)}).toString()}`;return new WebSocket(Jt(`${Nc(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/socket${a}`))}function Mc(e=`local`){return new WebSocket(Jt(`${Nc(e)}/events`))}function Nc(e){return`api/machines/${encodeURIComponent(e)}`}var Pc=512*1024,Fc=/^[a-z][a-z0-9.-]*$/u;function Ic(e){if(!$c(e))return Qc(`Config must be an object`);if(e.version!==1)return Qc(`Config version must be 1`);let t=e.tasks;if(!Array.isArray(t))return Qc(`Config tasks must be an array`);let n=new Set,r=[];for(let[e,i]of t.entries()){let t=Gc(i,e);if(!t.ok)return t;if(n.has(t.task.id))return Qc(`Duplicate task id: ${t.task.id}`);n.add(t.task.id),r.push(t.task)}return{ok:!0,config:{version:1,tasks:r}}}function Lc(e){let t={version:e.version,tasks:e.tasks.map(e=>({id:e.id,title:e.title,command:e.command,...e.description===void 0?{}:{description:e.description},...e.group===void 0?{}:{group:e.group},confirm:e.confirm}))};return`${JSON.stringify(t,null,2)}\n`}function Rc(e){return new TextEncoder().encode(Lc(e)).byteLength}function zc(e){let t=Rc(e);if(t>524288)throw RangeError(`Workspace tasks catalog is ${String(t)} bytes; maximum is ${String(Pc)} bytes`)}function Bc(e){return Fc.test(e)}function Vc(e,t){return{version:e.version,tasks:[...e.tasks,t]}}function Hc(e,t,n){return Jc(e,t),{version:e.version,tasks:[...e.tasks.slice(0,t),n,...e.tasks.slice(t+1)]}}function Uc(e,t){return Jc(e,t),{version:e.version,tasks:[...e.tasks.slice(0,t),...e.tasks.slice(t+1)]}}function Wc(e){if(Yc(e.source.ref.scope),Xc(e.source.ref.id),Yc(e.destination.scope),Xc(e.destination.task.id),e.source.ref.scope===e.destination.scope)throw Error(`Workspace task moves must cross scopes`);let t=e.source.config.tasks.findIndex(t=>t.id===e.source.ref.id);if(t===-1)throw Error(`Source workspace task not found: ${e.source.ref.id}`);if(e.destination.config.tasks.some(t=>t.id===e.destination.task.id))throw Error(`Destination workspace task already exists: ${e.destination.task.id}`);let n=Uc(e.source.config,t),r=Vc(e.destination.config,e.destination.task);return zc(n),zc(r),{sourceAfter:n,destinationAfter:r}}function Gc(e,t){let n=`Task ${String(t+1)}`;if(!$c(e))return Qc(`${n} must be an object`);let r=Kc(e,`id`,n);if(!r.ok)return r;if(!Bc(r.value))return Qc(`${n} id must match ${Fc.source}`);let i=Kc(e,`title`,n);if(!i.ok)return i;let a=Kc(e,`command`,n);if(!a.ok)return a;let o=qc(e,`description`,n);if(!o.ok)return o;let s=qc(e,`group`,n);if(!s.ok)return s;let c=e.confirm;return c!==void 0&&typeof c!=`boolean`?Qc(`${n} confirm must be a boolean`):{ok:!0,task:{id:r.value,title:i.value,command:a.value,...o.value===void 0?{}:{description:o.value},...s.value===void 0?{}:{group:s.value},confirm:c??!1}}}function Kc(e,t,n){let r=e[t];return typeof r!=`string`||r.trim()===``?Qc(`${n} ${t} must be a non-empty string`):{ok:!0,value:r}}function qc(e,t,n){let r=e[t];return r===void 0?{ok:!0,value:void 0}:typeof r!=`string`||r.trim()===``?Qc(`${n} ${t} must be a non-empty string when provided`):{ok:!0,value:r}}function Jc(e,t){if(!Number.isInteger(t)||t<0||t>=e.tasks.length)throw RangeError(`Task index ${String(t)} is out of range`)}function Yc(e){if(!Zc(e))throw Error(`Invalid workspace task scope: ${String(e)}`)}function Xc(e){if(typeof e!=`string`||!Bc(e))throw Error(`Invalid workspace task id: ${String(e)}`)}function Zc(e){return e===`global`||e===`workspace`}function Qc(e){return{ok:!1,error:e}}function $c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var el=new Set([`source-changed`,`destination-collision`,`invalid-catalog`,`unrecognized-state`,`unowned-intermediate-state`,`move-in-progress`,`retry-pristine`]),tl=new Set([`revision-conflict`,`invalid-catalog`,`move-in-progress`,`move-recovery-pending`,`unowned-intermediate-state`]);function nl(e){switch(_l(e,[`kind`,`config`,`revision`,`message`,`hint`,`detail`],`workspace tasks catalog response`).kind){case`loaded`:{let t=_l(e,[`kind`,`config`,`revision`],`workspace tasks loaded response`);return{kind:`loaded`,config:ol(t.config,`workspace tasks loaded catalog`),revision:cl(t,`revision`,`workspace tasks loaded response`)}}case`missing`:{let t=_l(e,[`kind`,`message`,`hint`,`revision`],`workspace tasks missing response`);return{kind:`missing`,message:pl(t,`message`,`workspace tasks missing response`),hint:pl(t,`hint`,`workspace tasks missing response`),revision:cl(t,`revision`,`workspace tasks missing response`)}}case`invalid`:{let t=_l(e,[`kind`,`message`,`hint`,`detail`],`workspace tasks invalid response`);return{kind:`invalid`,message:pl(t,`message`,`workspace tasks invalid response`),hint:pl(t,`hint`,`workspace tasks invalid response`),detail:pl(t,`detail`,`workspace tasks invalid response`)}}case`unavailable`:{let t=_l(e,[`kind`,`message`,`hint`,`detail`],`workspace tasks unavailable response`),n=ml(t,`workspace tasks unavailable response`);return{kind:`unavailable`,message:pl(t,`message`,`workspace tasks unavailable response`),hint:pl(t,`hint`,`workspace tasks unavailable response`),...n===void 0?{}:{detail:n}}}default:throw vl(`workspace tasks catalog response`)}}function rl(e){switch(_l(e,[`kind`,`config`,`revision`,`message`,`hint`,`detail`],`global workspace tasks response`).kind){case`loaded`:{let t=_l(e,[`kind`,`config`,`revision`],`global workspace tasks loaded response`);return{kind:`loaded`,config:ol(t.config,`global workspace tasks loaded catalog`),revision:cl(t,`revision`,`global workspace tasks loaded response`)}}case`invalid`:{let t=_l(e,[`kind`,`message`,`hint`,`detail`],`global workspace tasks invalid response`);return{kind:`invalid`,message:pl(t,`message`,`global workspace tasks invalid response`),hint:pl(t,`hint`,`global workspace tasks invalid response`),detail:pl(t,`detail`,`global workspace tasks invalid response`)}}default:throw vl(`global workspace tasks response`)}}function il(e){switch(_l(e,[`kind`,`operationId`,`phase`,`workspace`,`global`,`reason`,`message`],`workspace task move result`).kind){case`completed`:{let t=_l(e,[`kind`,`operationId`,`workspace`,`global`],`workspace task completed result`);return{kind:`completed`,operationId:sl(t,`operationId`,`workspace task completed result`),workspace:nl(t.workspace),global:rl(t.global)}}case`partial`:{let t=_l(e,[`kind`,`operationId`,`phase`,`workspace`,`global`],`workspace task partial result`);if(t.phase!==`destination-written`)throw vl(`workspace task partial result`);return{kind:`partial`,operationId:sl(t,`operationId`,`workspace task partial result`),phase:`destination-written`,workspace:nl(t.workspace),global:rl(t.global)}}case`conflict`:{let t=_l(e,[`kind`,`reason`,`message`],`workspace task move conflict result`);return{kind:`conflict`,reason:ll(t.reason),message:pl(t,`message`,`workspace task move conflict result`)}}case`validation`:return{kind:`validation`,message:pl(_l(e,[`kind`,`message`],`workspace task move validation result`),`message`,`workspace task move validation result`)};case`unavailable`:return{kind:`unavailable`,message:pl(_l(e,[`kind`,`message`],`workspace task move unavailable result`),`message`,`workspace task move unavailable result`)};case`unknown-outcome`:return{kind:`unknown-outcome`,message:pl(_l(e,[`kind`,`message`],`workspace task move unknown-outcome result`),`message`,`workspace task move unknown-outcome result`)};default:throw vl(`workspace task move result`)}}function al(e){switch(_l(e,[`kind`,`reason`,`message`,`retryable`],`workspace tasks failure response`).kind){case`validation`:return{kind:`validation`,message:pl(_l(e,[`kind`,`message`],`workspace tasks validation failure`),`message`,`workspace tasks validation failure`)};case`conflict`:{let t=_l(e,[`kind`,`reason`,`message`],`workspace tasks conflict failure`);return{kind:`conflict`,reason:ul(t.reason),message:pl(t,`message`,`workspace tasks conflict failure`)}}case`unavailable`:{let t=_l(e,[`kind`,`message`,`retryable`],`workspace tasks unavailable failure`);return{kind:`unavailable`,message:pl(t,`message`,`workspace tasks unavailable failure`),retryable:hl(t,`retryable`,`workspace tasks unavailable failure`)}}case`unknown-outcome`:return{kind:`unknown-outcome`,message:pl(_l(e,[`kind`,`message`],`workspace tasks unknown-outcome failure`),`message`,`workspace tasks unknown-outcome failure`)};default:throw vl(`workspace tasks failure response`)}}function ol(e,t){let n=Ic(e);if(!n.ok)throw vl(t);try{zc(n.config)}catch{throw vl(t)}return n.config}function sl(e,t,n){let r=gl(e,t,n);if(!On(r))throw vl(n);return r}function cl(e,t,n){return gl(e,t,n)}function ll(e){if(!dl(e))throw vl(`workspace task move conflict result`);return e}function ul(e){if(!fl(e))throw vl(`workspace tasks conflict failure`);return e}function dl(e){return typeof e==`string`&&el.has(e)}function fl(e){return typeof e==`string`&&tl.has(e)}function pl(e,t,n){return gl(e,t,n)}function ml(e,t){if(Object.hasOwn(e,`detail`))return gl(e,`detail`,t)}function hl(e,t,n){let r=e[t];if(typeof r!=`boolean`)throw vl(n);return r}function gl(e,t,n){let r=e[t];if(typeof r!=`string`||r.trim()===``)throw vl(n);return r}function _l(e,t,n){if(!yl(e)||Reflect.ownKeys(e).some(e=>typeof e!=`string`||!t.includes(e)))throw vl(n);return e}function vl(e){return Error(`Invalid ${e}`)}function yl(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Reflect.getPrototypeOf(e);return t===Object.prototype||t===null}var bl=`Workspace Tasks are unavailable on the selected machine.`,xl=`Workspace Tasks could not be loaded. Refresh and try again.`,Sl=`Workspace task write outcome is unknown. Refresh before trying again.`,Cl={readWorkspace(e,t){return wl(Il(e),nl,t)},replaceWorkspace(e){return Tl(Il(e),{expectedRevision:e.expectedRevision,config:e.config},nl)},readGlobal(e,t){return wl(Rl(e),rl,t)},replaceGlobal(e){return Tl(Rl(e.machineId),{expectedRevision:e.expectedRevision,config:e.config},rl)},move(e){return El(Ll(e),{operationId:e.operationId,intent:e.intent,source:e.source,destination:e.destination})}};async function wl(e,t,n){try{return Dl(await Qt(e,Nl(n)),t)}catch(e){if(n?.aborted===!0||Pl(e))throw e;return zl()}}async function Tl(e,t,n){try{return Ol(await Qt(e,{method:`PUT`,body:JSON.stringify(t)}),n)}catch{return Vl()}}async function El(e,t){try{return kl(await Qt(e,{method:`POST`,body:JSON.stringify(t)}))}catch{return Hl()}}function Dl(e,t){return e.status===200?{kind:`success`,value:t(e.body)}:e.status===404?Bl():Al(e,zl)}function Ol(e,t){return e.status===200?{kind:`success`,value:t(e.body)}:e.status===404?Bl():Al(e,Vl)}function kl(e){if(e.status===404)return{kind:`unavailable`,message:bl};switch(e.status){case 200:return Ml(e.body,[`completed`]);case 400:case 413:return Ml(e.body,[`validation`]);case 409:return Ml(e.body,[`partial`,`conflict`]);case 500:return Ml(e.body,[`unknown-outcome`]);case 503:return Ml(e.body,[`unavailable`]);default:return Hl()}}function Al(e,t){let n=jl(e.status);if(n===void 0)return t();let r=al(e.body);return r.kind===n?r:t()}function jl(e){switch(e){case 400:case 413:return`validation`;case 409:return`conflict`;case 500:return`unknown-outcome`;case 503:return`unavailable`;default:return}}function Ml(e,t){let n=il(e);return t.includes(n.kind)?n:Hl()}function Nl(e){return e===void 0?void 0:{signal:e}}function Pl(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`}function Fl(e){return`api/machines/${encodeURIComponent(e)}`}function Il(e){return`${Fl(e.machineId)}/projects/${encodeURIComponent(e.projectId)}/workspaces/${encodeURIComponent(e.workspaceId)}/workspace-tasks`}function Ll(e){return`${Il(e)}/move`}function Rl(e){return`${Fl(e)}/workspace-tasks/global`}function zl(){return{kind:`unavailable`,message:xl,retryable:!0}}function Bl(){return{kind:`unavailable`,message:bl,retryable:!1}}function Vl(){return{kind:`unknown-outcome`,message:Sl}}function Hl(){return{kind:`unknown-outcome`,message:Sl}}var Ul=`.pi-webui/uploads`,Wl=class extends Error{constructor(e=`Workspace upload cancelled`){super(e),this.name=`WorkspaceUploadCancelledError`}},Gl=class extends Error{constructor(e,t){super(nu(e)),this.name=`WorkspaceUploadBatchError`,this.failures=e.map(e=>({...e})),this.responses=t.map(e=>({...e}))}};function Kl(e){return e?.uploads?.defaultFolder??`.pi-webui/uploads`}function ql(e,t){return e?.uploads?.defaultFolder??t}function Jl(e,t){let n=au(e,`upload destination`,{allowEmpty:!0}),r=au(t,`upload file name`,{allowEmpty:!1});return n===``?r:`${n}/${r}`}function Yl(e,t,n,r={}){let i=r.xhrFactory?.()??new XMLHttpRequest,a=!1,o=!1;return{promise:new Promise((s,c)=>{let l=e=>{a||(a=!0,c(e))},u=e=>{a||(a=!0,s(e))};i.open(`PUT`,js(e,t,n.path,Ql(r)),!0),i.responseType=`json`,i.setRequestHeader(`Content-Type`,(n.contentType??n.file.type)||`application/octet-stream`),i.upload.onprogress=e=>{r.onProgress?.($l(e,n.file.size))},i.onload=()=>{if(i.status>=200&&i.status<300){try{r.onProgress?.({loaded:n.file.size,total:n.file.size,percent:1,lengthComputable:!0}),u(pa(su(i)))}catch(e){l(e instanceof Error?e:Error(String(e)))}return}l(Error(cu(i)))},i.onerror=()=>{l(Error(`Workspace upload failed`))},i.onabort=()=>{l(new Wl(o?void 0:`Workspace upload aborted`))},i.send(n.file)}),cancel:()=>{a||(o=!0,i.abort())}}}function Xl(e,t,n,r={}){let i=r.destinationFolder??`.pi-webui/uploads`,a=n.map((e,t)=>({index:t,name:e.name,path:Jl(i,e.name),loaded:0,total:e.size,percent:tu(0,e.size),lengthComputable:!0,done:!1})),o,s=0,c={requested:!1},l=()=>{r.onProgress?.(eu(a,s,a.every(e=>e.done)))};return{promise:(async()=>{let i=[],u=[];for(let d=0;d<n.length;d+=1){if(c.requested)throw new Wl;s=d;let f=n[d],p=a[d];if(!(f===void 0||p===void 0)){o=Yl(e,t,{path:p.path,file:f},{...Zl(r),onProgress:e=>{p.total=e.total,p.loaded=Math.min(e.loaded,p.total),p.percent=e.percent,p.lengthComputable=e.lengthComputable,l()}});try{let e=await o.promise;p.loaded=p.total,p.percent=1,p.lengthComputable=!0,p.done=!0,i.push(e),l()}catch(e){if(iu(e,c))throw e;let t=ru(e);p.loaded=p.total,p.percent=1,p.lengthComputable=!0,p.done=!0,p.error=t,u.push({index:d,name:f.name,path:p.path,error:t}),l()}finally{o=void 0}}}if(u.length>0)throw new Gl(u,i);return i})(),cancel:()=>{c.requested=!0,o?.cancel()}}}function Zl(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId},...e.xhrFactory===void 0?{}:{xhrFactory:e.xhrFactory}}}function Ql(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId}}}function $l(e,t){let n=e.lengthComputable?e.total:t;return{loaded:e.loaded,total:n,percent:tu(e.loaded,n),lengthComputable:e.lengthComputable}}function eu(e,t,n){let r=e.reduce((e,t)=>e+t.total,0),i=e.reduce((e,t)=>e+t.loaded,0);return{currentFileIndex:t,files:e.map(e=>({...e})),loaded:i,total:r,percent:tu(i,r),done:n}}function tu(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}function nu(e){return e.length===1?e[0]?.error??`Workspace upload failed`:`${String(e.length)} files failed to upload`}function ru(e){return e instanceof Error?e.message:String(e)}function iu(e,t){return t.requested||e instanceof Wl}function au(e,t,n){let r=e.trim();if(r===``){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(ou(r))throw Error(`${t} must be workspace-relative`);let i=r.split(/[\\/]+/u).filter(e=>e!==``&&e!==`.`);if(i.length===0){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(i.some(e=>e===`..`))throw Error(`${t} must not contain path traversal`);return i.join(`/`)}function ou(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function su(e){return e.response!==void 0&&e.response!==null&&e.response!==``?e.response:e.responseText===``?{}:JSON.parse(e.responseText)}function cu(e){let t=lu(e);return uu(t)&&typeof t.error==`string`?t.error:e.statusText||`HTTP ${String(e.status)}`}function lu(e){try{return su(e)}catch{return}}function uu(e){return typeof e==`object`&&!!e}function du(e){return e.closesActionPalette===!0}function fu(e){return{mode:e.mode,exact:Gu(e.exact),...e.tier===void 0?{}:{tier:e.tier}}}function pu(e){let t=mu(e);if(t.mode!==`tiered`||t.tier!==void 0)return t;let n=e.catalog?.rows;return n===void 0||!Object.hasOwn(n,`standard`)||!n.standard.valid?t:{...t,tier:`standard`}}function mu(e){if(e.policy!==void 0)return fu(e.policy);let t=e.liveResolved;return t===void 0?{mode:`exact`,exact:{model:{provider:``,id:``},thinkingLevel:``}}:{mode:`exact`,exact:Gu(t)}}function hu(e){let t=e.model?.provider,n=e.model?.id;if(!(t===void 0||n===void 0||!Wu(t)||!Wu(n))&&Wu(e.thinkingLevel))return{model:{provider:t,id:n},thinkingLevel:e.thinkingLevel}}function gu(e){let t=hu(e)??Fu(),n=e.starterModelPolicyPreference;return Mu(e)?Nu(n)?{mode:n.mode,exact:Gu(n.exact),...n.tier===void 0?{}:{tier:n.tier}}:n===void 0?{mode:`tiered`,exact:Gu(t),tier:`standard`}:ju(n,t,n.mode):ju(n,t,`exact`)}function _u(e,t){let n=hu(t);return n===void 0||e.mode===`tiered`||yu(e.exact,n)?e:{...e,exact:Gu(n)}}function vu(e){if(!(e.mode===`tiered`&&e.tier===void 0))return{mode:e.mode,...e.tier===void 0?{}:{tier:e.tier}}}function yu(e,t){return e.model.provider===t.model.provider&&e.model.id===t.model.id&&e.thinkingLevel===t.thinkingLevel}function bu(e,t){return{...e,mode:`tiered`,tier:t}}function xu(e){return{...e,mode:`exact`}}function Su(e,t){let n=t.thinkingLevels.includes(e.exact.thinkingLevel)?e.exact.thinkingLevel:``;return{...e,exact:{model:{...t.model},thinkingLevel:n}}}function Cu(e,t){return{...e,exact:{...e.exact,thinkingLevel:t}}}function wu(e,t){if(e.mode===`exact`)return Ou(e.exact,t.models)?{mode:`exact`,exact:Gu(e.exact)}:void 0;let n=e.tier;if(!(n===void 0||!t.valid||!Vu(t)||!Hu(t,n)))return{mode:`tiered`,tier:n}}function Tu(e,t){return t!==void 0&&wu(e,t)!==void 0}function Eu(e,t,n){let r=Iu(e);if(Pu(t)||e.mode!==`tiered`||Ru(e.exact)||!zu(e.tier)||!Vu(n)||!Hu(n,e.tier))return r;let i=n.ladder?.[e.tier];return i===void 0||!Ru(i)?r:{...r,exact:Gu(i)}}function Du(e,t){let n=e.mode===`exact`?ku(e.exact,t):Au(e,t);if(n.kind===`blocked`)return n;let r=Lu(e.exact);return r===void 0?{kind:`ready`,initialModelPolicy:{mode:e.mode,exact:Gu(e.exact),...e.tier===void 0?{}:{tier:e.tier}},resolved:Gu(n.resolved)}:{kind:`blocked`,reason:r}}function Ou(e,t){return Lu(e)===void 0&&t.find(t=>Uu(t.model,e.model))?.thinkingLevels.includes(e.thinkingLevel)===!0}function ku(e,t){let n=Lu(e);if(n!==void 0)return{kind:`blocked`,reason:n};let r=t.models.find(t=>Uu(t.model,e.model));return r===void 0?{kind:`blocked`,reason:`Selected provider/model is unavailable`}:r.thinkingLevels.includes(e.thinkingLevel)?{kind:`ready`,resolved:Gu(e)}:{kind:`blocked`,reason:`Selected thinking level is unsupported by the selected model`}}function Au(e,t){let n=e.tier;if(!zu(n))return{kind:`blocked`,reason:Bu(void 0,t)};let r=Object.hasOwn(t.rows,n)?t.rows[n]:void 0;if(r?.valid!==!0)return{kind:`blocked`,reason:Bu(r,t)};let i=t.ladder?.[n];return i===void 0||!Ru(i)?{kind:`blocked`,reason:Bu(r,t)}:{kind:`ready`,resolved:Gu(i)}}function ju(e,t,n){return{mode:e?.mode??n,exact:Gu(t),...e?.tier===void 0?{}:{tier:e.tier}}}function Mu(e){return`starterModelPolicyContractVersion`in e}function Nu(e){return e!==void 0&&Object.hasOwn(e,`exact`)}function Pu(e){return Mu(e)&&Nu(e.starterModelPolicyPreference)}function Fu(){return{model:{provider:``,id:``},thinkingLevel:``}}function Iu(e){return{mode:e.mode,exact:Gu(e.exact),...e.tier===void 0?{}:{tier:e.tier}}}function Lu(e){return Ru(e)?void 0:`Choose a provider, model, and thinking level before starting`}function Ru(e){return Wu(e.model.provider)&&Wu(e.model.id)&&Wu(e.thinkingLevel)}function zu(e){return e!==void 0&&Bt.includes(e)}function Bu(e,t){return e?.reason!==void 0&&Wu(e.reason)?e.reason:t.configError!==void 0&&Wu(t.configError)?t.configError:`Selected model tier is unavailable`}function Vu(e){let t=e.ladder;return t!==void 0&&Bt.every(e=>Object.hasOwn(t,e))}function Hu(e,t){return Object.hasOwn(e.rows,t)&&e.rows[t].valid}function Uu(e,t){return e.provider===t.provider&&e.id===t.id}function Wu(e){return e.trim()!==``}function Gu(e){return{model:{...e.model},thinkingLevel:e.thinkingLevel}}function Ku(e){return{kind:`policy-blocked`,scope:e}}function qu(e,t,n){return{kind:e,message:t,scope:n}}function Ju(e,t,n){if(e===void 0||!Xu(e,t))return;let r=e.kind===`policy-blocked`?n:e.message;return r===void 0||r===``?void 0:r}function Yu(e,t,n){return Xu(e,t)?e.kind!==`policy-blocked`||n!==void 0&&n!==``:!1}function Xu(e,t){return t!==void 0&&e.scope.machineId===t.machineId&&e.scope.workspaceId===t.workspaceId}var Zu={economy:`Economy`,fast:`Fast`,standard:`Standard`,advanced:`Advanced`,capable:`Capable`,frontier:`Frontier`},Qu=Fn;function $u(e){return`${e.provider}/${e.id}`}function ed(e){let t=e.thinkingLevel.trim()===``?`no thinking level`:e.thinkingLevel;return`${$u(e.model)} · ${t}`}var td={off:`No reasoning`,minimal:`Very brief reasoning (~1k tokens)`,low:`Light reasoning (~2k tokens)`,medium:`Moderate reasoning (~8k tokens)`,high:`Deep reasoning (~16k tokens)`,xhigh:`Maximum reasoning (~32k tokens)`};function nd(e){let t=new Set(e.supported),n=new Set,r=[];for(let t of[...e.supported,...e.all])n.has(t)||(n.add(t),r.push(t));let i=e=>{let t=Qu.findIndex(t=>t===e);return t===-1?Qu.length:t};return r.map((e,t)=>({level:e,index:t})).sort((e,t)=>{let n=i(e.level)-i(t.level);return n===0?e.index-t.index:n}).map(({level:n})=>({level:n,supported:t.has(n),selected:n===e.selected,...td[n]===void 0?{}:{description:td[n]}}))}function rd(){return{sessions:[],projectSessions:[],clientQueuedSessionMessages:{},startingSessionCount:0,isLoadingSessions:!1,selectedNotificationInbox:void 0,treeDialog:void 0,fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,memory:{kind:`loading`},learnedSkills:{kind:`loading`},selectedTerminalId:void 0,error:``}}function id(){return{machines:[],selectedMachine:void 0,isLoadingMachines:!1,machineStatuses:{},machineRuntimes:{},projects:[],workspaces:[],sessions:[],projectSessions:[],messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,sendingPrompts:{},clientQueuedSessionMessages:{},startingSessionCount:0,isLoadingProjects:!1,isLoadingWorkspaces:!1,isLoadingSessions:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,status:void 0,activity:void 0,availableThinkingLevels:[],modelPolicy:void 0,isLoadingModelPolicy:!1,isSavingModelPolicy:!1,modelPolicyError:void 0,sessionStatuses:{},sessionActivities:{},workspaceActivities:{},machineActivities:{},selectedNotificationInbox:void 0,workspacesByProjectId:{},workspaceDeletionRuns:{},commandDialog:void 0,treeDialog:void 0,modelDialog:void 0,thinkingDialog:void 0,themeDialog:void 0,authDialog:void 0,actionPaletteOpen:!1,projectDialogOpen:!1,machineDialogOpen:!1,workspaceTool:`core:workspace.files`,mainView:`chat`,fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,workspaceUploadBatches:{},gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,memory:{kind:`loading`},learnedSkills:{kind:`loading`},activeTerminalCount:0,selectedTerminalId:void 0,piWebUiStatus:void 0,error:``}}function ad(e,t){return t?.phase===`active`||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}function od(e){return e!==void 0&&(e.hasSessionActivity||e.hasTerminalActivity)}function sd(e,t){return`${e}:${t}`}function cd(e,t){return`${e}:${t}`}function R(e){return e.selectedMachine?.id??`local`}var ld=class{constructor(){this.pendingByKey=new Map}request(e,t){let n=this.pendingByKey.get(e);if(n!==void 0)return n.latestRefresh=t,n.started&&(n.trailing=!0),n.promise;let r={promise:Promise.resolve(),latestRefresh:t,started:!1,trailing:!1};return r.promise=Promise.resolve().then(async()=>{let e,t;do{r.trailing=!1;let n=r.latestRefresh;r.started=!0,t=!1;try{await n()}catch(n){e=n,t=!0}}while(this.hasTrailingRequest(r));if(t)throw e}).finally(()=>{this.pendingByKey.get(e)===r&&this.pendingByKey.delete(e)}),this.pendingByKey.set(e,r),r.promise}hasTrailingRequest(e){return e.trailing}},ud=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.refreshes=new ld,this.api=n.api??_c,this.onActivityApplied=n.onActivityApplied}refresh(e=R(this.getState())){return this.refreshes.request(e,async()=>{this.applyMachineActivitySnapshot(e,dd(await this.api.workspaceActivity(e)))})}applyWorkspaceActivity(e,t=R(this.getState())){let n=this.getState(),r=R(n)===t,i=n.machineActivities[t]??(r?n.workspaceActivities:{});if(!pd(i,e))return;let a=fd(i,e);this.setState({machineActivities:{...n.machineActivities,[t]:a},...r?{workspaceActivities:a}:{}}),this.onActivityApplied?.(t)}applyMachineActivitySnapshot(e,t){let n=this.getState();this.setState({machineActivities:{...n.machineActivities,[e]:t},...R(n)===e?{workspaceActivities:t}:{}}),this.onActivityApplied?.(e)}};function dd(e){let t={};for(let n of e.workspaces)od(n)&&(t[n.cwd]=n);return t}function fd(e,t){let n={...e};return od(t)?(n[t.cwd]=t,n):Object.fromEntries(Object.entries(n).filter(([e])=>e!==t.cwd))}function pd(e,t){let n=e[t.cwd];return n===void 0?od(t):n.hasSessionActivity!==t.hasSessionActivity||n.hasTerminalActivity!==t.hasTerminalActivity}var md=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.applyStatus=n,this.oauthOperationGeneration=0,this.pollGeneration=0,this.api=r.api??kc,this.pollIntervalMs=r.pollIntervalMs??1e3}dispose(){this.oauthOperationGeneration+=1,this.stopPolling()}handleSlashCommand(e){let t=gd(e);return t===void 0?!1:(t.command===`login`?this.openLogin(t.providerId):this.openLogout(t.providerId),!0)}async openLogin(e){if(e!==void 0&&e!==``){await this.openLoginProvider(e);return}this.setState({authDialog:{step:`method`}})}async chooseLoginMethod(e){try{let{providers:t}=await this.api.authProviders({mode:`login`,authType:e,machineId:R(this.getState())});this.setState({authDialog:{step:`providers`,mode:`login`,authType:e,providers:t}})}catch(e){this.setState({error:String(e)})}}async selectLoginProvider(e,t){let n=this.getState().authDialog;if(n?.step!==`providers`)return;let r=n.providers.find(n=>n.id===e&&(t===void 0||n.authType===t));r!==void 0&&(r.authType===`oauth`||r.loginFlow===`interactive`?await this.startLoginFlow(r):this.setState({authDialog:{step:`apiKey`,provider:r,value:``}}))}updateApiKey(e){let t=this.getState().authDialog;if(t?.step!==`apiKey`)return;let n={...t};delete n.error,this.setState({authDialog:{...n,value:e}})}async saveApiKey(){let e=this.getState().authDialog;if(e?.step!==`apiKey`)return;let t=e.value.trim();if(t===``){this.setState({authDialog:{...e,error:`API key is required`}});return}let n={...e};delete n.error,this.setState({authDialog:{...n,saving:!0}});try{await this.api.saveApiKey(e.provider.id,t,R(this.getState())),this.closeDialog(),this.refreshStatus()}catch(t){this.setState({authDialog:{...e,saving:!1,error:String(t)}})}}async openLogout(e){try{let{providers:t}=await this.api.authProviders({mode:`logout`,machineId:R(this.getState())});if(e!==void 0&&e!==``){let n=t.find(t=>t.id===e);n!==void 0&&!this.rejectRemoteOAuth(`logout`,n)?await this.logoutProvider(n.id):n===void 0&&this.setState({error:`No stored credentials for ${e}`});return}this.setState({authDialog:{step:`logout`,providers:t}})}catch(e){this.setState({error:String(e)})}}async logoutProvider(e){let t=this.getState().authDialog,n=t?.step===`logout`?t.providers.find(t=>t.id===e):void 0;if(!(n!==void 0&&this.rejectRemoteOAuth(`logout`,n)))try{await this.api.logoutProvider(e,R(this.getState())),this.closeDialog(),this.refreshStatus()}catch(e){this.setState({error:String(e)})}}updateOAuthInput(e){let t=this.getState().authDialog;if(t?.step!==`oauth`)return;let n={...t};delete n.error,this.setState({authDialog:{...n,inputValue:e}})}async respondOAuth(e){let t=this.getState().authDialog;if(t?.step!==`oauth`)return;let n=t.flow.prompt??t.flow.select;if(n===void 0)return;let r=this.oauthOperationGeneration,i=t.flow.flowId,a=n.requestId,o=e??t.inputValue??``,s={...t};delete s.error,this.setState({authDialog:{...s,responding:!0}});try{let e=await this.api.respondOAuthFlow(i,a,o,t.machineId),n=this.currentOAuthDialog(r,i);if(e.flowId!==i||n===void 0||hd(n.flow)!==a)return;this.updateOAuthFlow(e,n.machineId)}catch(e){let t=this.currentOAuthDialog(r,i);if(t===void 0||hd(t.flow)!==a)return;this.setState({authDialog:{...t,responding:!1,error:String(e)}})}}async cancelOAuth(){let e=this.getState().authDialog;if(e?.step!==`oauth`){this.closeDialog();return}let t=e.flow.flowId,n=e.machineId;this.closeDialog();try{await this.api.cancelOAuthFlow(t,n)}catch{}}closeDialog(){this.oauthOperationGeneration+=1,this.stopPolling(),this.setState({authDialog:void 0})}async openLoginProvider(e){try{let{providers:t}=await this.api.authProviders({mode:`login`,machineId:R(this.getState())}),n=t.filter(t=>t.id===e);if(n.length===0){this.setState({error:`Auth provider not found: ${e}`});return}if(n.length>1){this.setState({authDialog:{step:`providers`,mode:`login`,providers:n}});return}let r=n[0];if(r===void 0)return;r.authType===`oauth`||r.loginFlow===`interactive`?await this.startLoginFlow(r):this.setState({authDialog:{step:`apiKey`,provider:r,value:``}})}catch(e){this.setState({error:String(e)})}}async startLoginFlow(e){if(this.rejectRemoteOAuth(`login`,e))return;let t=++this.oauthOperationGeneration;this.stopPolling();try{let n=R(this.getState()),r=e.authType===`oauth`?await this.api.startOAuthLogin(e.id,n):await this.api.startInteractiveApiKeyLogin(e.id,n);if(t!==this.oauthOperationGeneration){if(r.status===`running`)try{await this.api.cancelOAuthFlow(r.flowId,n)}catch{}return}this.updateOAuthFlow(r,n),r.status===`running`&&this.startPolling(r.flowId,n)}catch(e){t===this.oauthOperationGeneration&&this.setState({error:String(e)})}}rejectRemoteOAuth(e,t){let n=this.getState().selectedMachine;if(t.authType!==`oauth`||n?.kind!==`remote`)return!1;let r=n.baseUrl??`that remote PI WEBUI instance`;return this.setState({error:`OAuth ${e} for remote machines must be configured directly on ${r}.`}),!0}updateOAuthFlow(e,t){if(e.status===`complete`){this.stopPolling(),this.closeDialog(),this.refreshStatus(t);return}(e.status===`error`||e.status===`cancelled`)&&(this.oauthOperationGeneration+=1,this.stopPolling());let n=this.getState().authDialog,r=n?.step===`oauth`&&n.flow.flowId===e.flowId?n.inputValue??``:``,i=n?.step===`oauth`?hd(n.flow):void 0,a=hd(e),o=i!==void 0&&i===a,s=o?r:``,c=o&&n?.step===`oauth`?n.responding===!0:!1;this.setState({authDialog:{step:`oauth`,flow:e,machineId:t,inputValue:s,responding:c}})}startPolling(e,t){this.stopPolling();let n=this.oauthOperationGeneration,r=this.pollGeneration;this.pollTimer=window.setInterval(()=>{this.poll(e,t,n,r)},this.pollIntervalMs)}stopPolling(){this.pollGeneration+=1,this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(e,t,n,r){if(r!==this.pollGeneration)return;let i=this.currentOAuthDialog(n,e);if(i?.machineId!==t){this.stopPolling();return}let a=hd(i.flow);try{let i=await this.api.oauthFlow(e,t),o=this.currentOAuthDialog(n,e);if(i.flowId!==e||r!==this.pollGeneration||o?.machineId!==t||hd(o.flow)!==a)return;this.updateOAuthFlow(i,t)}catch(i){let o=this.currentOAuthDialog(n,e);if(r!==this.pollGeneration||o?.machineId!==t||hd(o.flow)!==a)return;this.stopPolling(),this.setState({authDialog:{...o,error:String(i)}})}}currentOAuthDialog(e,t){if(e!==this.oauthOperationGeneration)return;let n=this.getState().authDialog;return n?.step===`oauth`&&n.flow.flowId===t?n:void 0}async refreshStatus(e=R(this.getState())){let t=this.selectedSessionForMachine(e);if(t!==void 0)try{let n=await this.api.status(t,e),r=this.selectedSessionForMachine(e);if(r?.id!==t.id||r.cwd!==t.cwd)return;this.applyStatus(n)}catch{}}selectedSessionForMachine(e){let t=this.getState();if(R(t)!==e)return;let n=t.selectedSession;if(!(n===void 0||n.archived===!0))return n}};function hd(e){return e.prompt?.requestId??e.select?.requestId}function gd(e){let t=e.trim(),n=/^\/(login|logout)(?:\s+(\S+))?\s*$/u.exec(t);if(n===null)return;let r=n[1];if(r!==`login`&&r!==`logout`)return;let i=n[2];return i===void 0||i===``?{command:r}:{command:r,providerId:i}}function _d(e){return e.replaceAll(`:`,`.`)}function vd(e){let t=new URLSearchParams(window.location.search),n=`${e}--`,r={};for(let[e,i]of t.entries()){if(!e.startsWith(n))continue;let t=e.slice(n.length),a=r[t];a===void 0?r[t]=i:Array.isArray(a)?a.push(i):r[t]=[a,i]}return r}function yd(e,t){let n=vd(e)[t];return Array.isArray(n)?n[0]:n===``?void 0:n}function bd(e,t,n,r){let i=new URL(window.location.href),a=`${e}--${t}`;if(i.searchParams.delete(a),n!=null&&n!==``)if(Array.isArray(n))for(let e of n)i.searchParams.append(a,String(e));else i.searchParams.set(a,String(n));xd(i,r)}function xd(e,t){`${e.pathname}${e.search}${e.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t?.replace===!0?window.history.replaceState({},``,e):window.history.pushState({},``,e))}function Sd(e){let t=e.files.map((t,n)=>{let r=t.size;return{index:n,name:t.name,path:Jl(e.destinationFolder,t.name),size:t.size,loaded:0,total:r,percent:Od(0,r),lengthComputable:!0,status:n===0?`uploading`:`pending`}}),n=t.reduce((e,t)=>e+t.total,0);return{id:e.id,projectId:e.projectId,workspaceId:e.workspaceId,machineId:e.machineId,destinationFolder:e.destinationFolder,overwrite:e.overwrite,createDirs:e.createDirs,files:t,currentFileIndex:t.length===0?-1:0,loaded:0,total:n,percent:Od(0,n),status:`uploading`,startedAt:e.startedAt}}function Cd(e,t){let n=new Map(t.files.map(e=>[e.index,e])),r=e.files.map(e=>{let r=n.get(e.index);if(r===void 0)return e;let i={...e,path:r.path,loaded:r.loaded,total:r.total,percent:r.percent,lengthComputable:r.lengthComputable,status:r.error===void 0?r.done?`completed`:t.currentFileIndex===e.index?`uploading`:e.status:`error`};return r.error===void 0?delete i.error:i.error=r.error,i});return{...e,files:r,currentFileIndex:t.currentFileIndex,loaded:t.loaded,total:t.total,percent:t.percent}}function wd(e,t,n){let r=e.files.map((e,n)=>{let r=t[n];return{...e,...r===void 0?{}:{path:r.path,response:r},loaded:e.total,percent:1,lengthComputable:!0,status:`completed`}}),i=Dd(r);return{...e,files:r,currentFileIndex:r.length===0?-1:r.length-1,...i,status:`completed`,completedAt:n}}function Td(e,t,n){let r=e.files.map(n=>n.status===`completed`||n.status===`error`?n:n.status===`uploading`||n.index===e.currentFileIndex?{...n,status:`error`,error:t}:{...n,status:`cancelled`,error:`Not uploaded because an earlier file failed.`});return{...e,files:r,...Dd(r),status:`error`,error:t,completedAt:n}}function Ed(e,t){let n=`Upload cancelled`,r=e.files.map(e=>e.status===`completed`||e.status===`error`?e:{...e,status:`cancelled`,error:n});return{...e,files:r,...Dd(r),status:`cancelled`,error:n,completedAt:t}}function Dd(e){let t=e.reduce((e,t)=>e+t.total,0);return{loaded:t,total:t,percent:e.length===0?0:1}}function Od(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}var kd=_d(`core:workspace.files`),Ad=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.updateUrl=n,this.uploadTasks=new Map,this.uploadBatchSequence=0,this.api=r.api??kc,this.uploadWorkspaceFiles=r.uploadWorkspaceFiles??Xl,this.createUploadBatchId=r.createUploadBatchId??(()=>(this.uploadBatchSequence+=1,`workspace-upload-${String(this.uploadBatchSequence)}`)),this.now=r.now??(()=>new Date().toISOString())}async refreshFiles(){let e=this.getState().selectedProject,t=this.getState().selectedWorkspace;if(!(e===void 0||t===void 0))try{let n=R(this.getState()),r=await this.api.workspaceTree(e.id,t.id,``,n),i={...this.getState().expandedDirs};await Promise.all(Object.keys(i).map(async r=>{i[r]=(await this.api.workspaceTree(e.id,t.id,r,n)).entries})),this.setState({fileTree:r.entries,expandedDirs:i,fileTreeStale:!1,error:``})}catch(e){this.setState({error:String(e)})}}async expandDir(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0)){if(this.getState().expandedDirs[e]!==void 0){this.setState({expandedDirs:Pd(this.getState().expandedDirs,e)});return}try{let r=await this.api.workspaceTree(t.id,n.id,e,R(this.getState()));this.setState({expandedDirs:{...this.getState().expandedDirs,[e]:r.entries},error:``})}catch(e){this.setState({error:String(e)})}}}async selectFile(e){this.setState({selectedFilePath:e,selectedFileContent:void 0,workspaceTool:`core:workspace.files`,mainView:this.getState().mainView===`chat`?`chat`:`core:workspace.files`}),bd(kd,`file`,e),this.updateUrl({replace:!0}),await this.restoreFile(e)}async restoreFile(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0)){this.setState({selectedFilePath:e,selectedFileContent:void 0});try{let r=await this.api.workspaceFile(t.id,n.id,e,R(this.getState()));this.getState().selectedFilePath===e&&this.setState({selectedFileContent:r,error:``})}catch(t){if(this.getState().selectedFilePath!==e)return;if(jd(t)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:``}),bd(kd,`file`,void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(t)})}}}startWorkspaceUpload(e,t){let n=this.getState().selectedProject,r=this.getState().selectedWorkspace;if(n===void 0||r===void 0){this.setState({error:`Select a workspace before uploading files.`});return}if(e.length===0)return;let i=R(this.getState()),a=t.overwrite??!1,o=t.createDirs??!0,s;try{s=Sd({id:this.createUploadBatchId(),projectId:n.id,workspaceId:r.id,machineId:i,destinationFolder:t.destinationFolder,overwrite:a,createDirs:o,files:e,startedAt:this.now()})}catch(e){this.setState({error:String(e)});return}this.setUploadBatch(s);let c;try{c=this.uploadWorkspaceFiles(n.id,r.id,e,{destinationFolder:t.destinationFolder,machineId:i,overwrite:a,createDirs:o,onProgress:e=>{this.updateUploadProgress(s.id,e)}})}catch(e){return this.failUploadBatch(s.id,e),{batchId:s.id,done:Promise.resolve()}}this.uploadTasks.set(s.id,c);let l=c.promise.then(async e=>{await this.completeUploadBatch(s.id,e,t)}).catch(async e=>{await this.handleUploadFailure(s.id,e,t)}).finally(()=>{this.uploadTasks.delete(s.id)});return{batchId:s.id,done:l}}cancelWorkspaceUpload(e){let t=this.getUploadBatch(e);t?.status===`uploading`&&(this.setUploadBatch(Ed(t,this.now())),this.uploadTasks.get(e)?.cancel())}clearWorkspaceUpload(e){this.uploadTasks.get(e)?.cancel(),this.uploadTasks.delete(e),this.setState({workspaceUploadBatches:Pd(this.getState().workspaceUploadBatches,e)})}updateUploadProgress(e,t){let n=this.getUploadBatch(e);n?.status===`uploading`&&this.setUploadBatch(Cd(n,t))}async completeUploadBatch(e,t,n){let r=this.getUploadBatch(e);if(r?.status!==`uploading`||(this.setUploadBatch(wd(r,t,this.now()),{error:``}),!this.isCurrentWorkspaceBatch(r)))return;await this.refreshFiles();let i=t[0]?.path;n.selectUploadedFile!==!1&&i!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(i)}async handleUploadFailure(e,t,n){let r=this.failUploadBatch(e,t);if(!(t instanceof Gl)||t.responses.length===0||r===void 0||!this.isCurrentWorkspaceBatch(r))return;await this.refreshFiles();let i=t.responses[0]?.path;n.selectUploadedFile!==!1&&i!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(i)}failUploadBatch(e,t){let n=this.getUploadBatch(e);if(n?.status!==`uploading`)return;if(Md(t)){let e=Ed(n,this.now());return this.setUploadBatch(e),e}let r=Nd(t),i=Td(n,r,this.now());return this.setUploadBatch(i,{error:r}),i}getUploadBatch(e){return this.getState().workspaceUploadBatches[e]}setUploadBatch(e,t={}){this.setState({workspaceUploadBatches:{...this.getState().workspaceUploadBatches,[e.id]:e},...t})}isCurrentWorkspaceBatch(e){let t=this.getState();return t.selectedProject?.id===e.projectId&&t.selectedWorkspace?.id===e.workspaceId&&R(t)===e.machineId}};function jd(e){let t=String(e);return t.includes(`Path does not exist`)||t.includes(`ENOENT`)||t.includes(`no such file or directory`)}function Md(e){return e instanceof Wl}function Nd(e){return e instanceof Error?e.message:String(e)}function Pd(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}var Fd=_d(`core:workspace.git`),Id=class{constructor(e,t,n){this.getState=e,this.setState=t,this.updateUrl=n,this.statusRequest=0,this.diffRequest=0}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0,this.pollingScope=void 0,this.statusRequest+=1,this.diffRequest+=1}async refreshGit(e={}){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(t===void 0||n===void 0)return;let r=R(this.getState()),i=++this.statusRequest;this.diffRequest+=1;try{let a=await kc.gitStatus(t.id,n.id,r);if(i!==this.statusRequest||!this.isCurrentWorkspace(t,n,r))return;this.setState({gitStatus:a,gitStale:!1,...e.reportError===!1?{}:{error:``}});let o=this.getState().selectedDiffPath;o!==void 0&&(a.files.some(e=>e.path===o)?await this.refreshDiff(o,e):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),bd(Fd,`diff`,void 0,{replace:!0})))}catch(a){if(i!==this.statusRequest||!this.isCurrentWorkspace(t,n,r))return;e.reportError!==!1&&this.setState({error:String(a)})}}async selectDiff(e){this.setState({selectedDiffPath:e,selectedDiff:void 0,selectedStagedDiff:void 0,workspaceTool:`core:workspace.git`,mainView:this.getState().mainView===`chat`?`chat`:`core:workspace.git`}),bd(Fd,`diff`,e),this.updateUrl({replace:!0}),await this.refreshDiff(e)}async restoreDiff(e){this.setState({selectedDiffPath:e,selectedDiff:void 0,selectedStagedDiff:void 0}),await this.refreshDiff(e)}async refreshDiff(e,t={}){let n=this.getState().selectedProject,r=this.getState().selectedWorkspace;if(n===void 0||r===void 0)return;let i=R(this.getState()),a=++this.diffRequest;try{let[o,s]=await Promise.all([kc.gitDiff(n.id,r.id,{path:e},i),kc.gitDiff(n.id,r.id,{path:e,staged:!0},i)]);if(a!==this.diffRequest||!this.isCurrentWorkspace(n,r,i))return;this.setState({selectedDiff:o,selectedStagedDiff:s,...t.reportError===!1?{}:{error:``}})}catch(e){if(a!==this.diffRequest||!this.isCurrentWorkspace(n,r,i))return;t.reportError!==!1&&this.setState({error:String(e)})}}updatePolling(){let e=this.currentPollingScope();e===this.pollingScope&&this.pollTimer!==void 0||(this.dispose(),e!==void 0&&(this.pollingScope=e,this.refreshGit({reportError:!1}),this.pollTimer=window.setInterval(()=>{this.refreshGit({reportError:!1})},8e3)))}currentPollingScope(){let e=this.getState();if(!(e.selectedProject===void 0||e.selectedWorkspace?.isGitRepo!==!0))return JSON.stringify([R(e),e.selectedProject.id,e.selectedWorkspace.id])}isCurrentWorkspace(e,t,n){let r=this.getState();return R(r)===n&&r.selectedProject?.id===e.id&&r.selectedWorkspace?.id===t.id&&r.selectedWorkspace.projectId===t.projectId}},Ld=3e4,Rd={setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>{window.clearTimeout(e)}},zd=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.generation=0,this.nextRequestId=0,this.observing=!1,this.fetchSnapshot=n.snapshot??Zs.snapshot,this.timer=n.timer??Rd,this.pollIntervalMs=n.pollIntervalMs??Ld}updatePolling(e=!0){if(!e){this.stopObserving();return}this.observing=!0;let t=this.currentScope();if(t===void 0){this.invalidateScope();return}if(this.scope?.key!==t.key){this.startScope(t);return}this.inFlight?.generation===this.generation&&this.inFlight.scopeKey===t.key||this.pollTimer===void 0&&this.startRequest(t)}async refresh(){if(!this.observing)return;let e=this.currentScope();if(e===void 0){this.invalidateScope();return}if(this.scope?.key!==e.key){await this.startScope(e);return}this.clearPollTimer(),await this.startRequest(e)}dispose(){this.observing=!1,this.invalidateScope()}startScope(e){return this.invalidateScope(),this.scope=e,this.setState({learnedSkills:{kind:`loading`}}),this.startRequest(e)}startRequest(e){let t=this.inFlight;if(t?.generation===this.generation&&t.scopeKey===e.key)return t.promise;let n=this.generation,r=++this.nextRequestId,i={generation:n,requestId:r,scopeKey:e.key,promise:Promise.resolve()};this.inFlight=i;let a=this.load(e,n,r);return i.promise=a,a}async load(e,t,n){try{let n=await this.fetchSnapshot(e.workspacePath,e.machineId);if(!this.isCurrent(e,t))return;let r=Bd(n);this.setState({learnedSkills:r}),r.kind===`unavailable`&&this.stopObserving()}catch(n){if(!this.isCurrent(e,t))return;this.applyFailure(String(n))}finally{let r=this.inFlight?.requestId===n;r&&(this.inFlight=void 0),r&&this.isCurrent(e,t)&&this.scheduleNext(e,t)}}applyFailure(e){let t=this.getState().learnedSkills;if(t.kind===`data`){this.setState({learnedSkills:{...t,refreshError:e}});return}this.setState({learnedSkills:{kind:`error`,message:e}})}scheduleNext(e,t){this.clearPollTimer(),this.pollTimer=this.timer.setTimeout(()=>{this.pollTimer=void 0,!(!this.observing||!this.isCurrent(e,t))&&this.startRequest(e)},this.pollIntervalMs)}stopObserving(){this.observing&&(this.observing=!1,this.invalidateScope())}invalidateScope(){this.clearPollTimer(),this.scope=void 0,this.inFlight=void 0,this.generation+=1}clearPollTimer(){this.pollTimer!==void 0&&(this.timer.clearTimeout(this.pollTimer),this.pollTimer=void 0)}currentScope(){let e=this.getState(),t=e.selectedProject,n=e.selectedWorkspace;if(t===void 0||n===void 0)return;let r=R(e);return{key:JSON.stringify([r,t.id,n.id,n.path]),machineId:r,projectId:t.id,workspaceId:n.id,workspacePath:n.path}}isCurrent(e,t){if(!this.observing||t!==this.generation||this.scope?.key!==e.key)return!1;let n=this.currentScope();return n?.machineId===e.machineId&&n.projectId===e.projectId&&n.workspaceId===e.workspaceId&&n.workspacePath===e.workspacePath}};function Bd(e){return e.kind===`unavailable`?{kind:`unavailable`}:{kind:`data`,globalSkills:e.globalSkills,projectSkills:e.projectSkills,...e.projectUnavailableMessage===void 0?{}:{projectUnavailableMessage:e.projectUnavailableMessage}}}var Vd=3e4,Hd={setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>{window.clearTimeout(e)}},Ud=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.generation=0,this.nextRequestId=0,this.observing=!1,this.fetchSnapshot=n.snapshot??Ys.snapshot,this.timer=n.timer??Hd,this.pollIntervalMs=n.pollIntervalMs??Vd}updatePolling(e=!0){if(!e){this.stopObserving();return}this.observing=!0;let t=this.currentScope();if(t===void 0){this.invalidateScope();return}if(this.scope?.key!==t.key){this.startScope(t);return}this.inFlight?.generation===this.generation&&this.inFlight.scopeKey===t.key||this.pollTimer===void 0&&this.startRequest(t)}async refresh(){if(!this.observing)return;let e=this.currentScope();if(e===void 0){this.invalidateScope();return}if(this.scope?.key!==e.key){await this.startScope(e);return}this.clearPollTimer(),await this.startRequest(e)}dispose(){this.observing=!1,this.invalidateScope()}startScope(e){return this.invalidateScope(),this.scope=e,this.setState({memory:{kind:`loading`}}),this.startRequest(e)}startRequest(e){let t=this.inFlight;if(t?.generation===this.generation&&t.scopeKey===e.key)return t.promise;let n=this.generation,r=++this.nextRequestId,i={generation:n,requestId:r,scopeKey:e.key,promise:Promise.resolve()};this.inFlight=i;let a=this.load(e,n,r);return i.promise=a,a}async load(e,t,n){try{let n=await this.fetchSnapshot(e.workspacePath,e.machineId);if(!this.isCurrent(e,t))return;let r=Wd(n);this.setState({memory:r}),r.kind===`unavailable`&&this.stopObserving()}catch(n){if(!this.isCurrent(e,t))return;this.applyFailure(String(n))}finally{let r=this.inFlight?.requestId===n;r&&(this.inFlight=void 0),r&&this.isCurrent(e,t)&&this.scheduleNext(e,t)}}applyFailure(e){let t=this.getState().memory;if(t.kind===`data`){this.setState({memory:{...t,refreshError:e}});return}this.setState({memory:{kind:`error`,message:e}})}scheduleNext(e,t){this.clearPollTimer(),this.pollTimer=this.timer.setTimeout(()=>{this.pollTimer=void 0,!(!this.observing||!this.isCurrent(e,t))&&this.startRequest(e)},this.pollIntervalMs)}stopObserving(){this.observing&&(this.observing=!1,this.invalidateScope())}invalidateScope(){this.clearPollTimer(),this.scope=void 0,this.inFlight=void 0,this.generation+=1}clearPollTimer(){this.pollTimer!==void 0&&(this.timer.clearTimeout(this.pollTimer),this.pollTimer=void 0)}currentScope(){let e=this.getState(),t=e.selectedProject,n=e.selectedWorkspace;if(t===void 0||n===void 0)return;let r=R(e);return{key:JSON.stringify([r,t.id,n.id,n.path]),machineId:r,projectId:t.id,workspaceId:n.id,workspacePath:n.path}}isCurrent(e,t){if(!this.observing||t!==this.generation||this.scope?.key!==e.key)return!1;let n=this.currentScope();return n?.machineId===e.machineId&&n.projectId===e.projectId&&n.workspaceId===e.workspaceId&&n.workspacePath===e.workspacePath}};function Wd(e){return e.kind===`unavailable`?{kind:`unavailable`}:{kind:`data`,globalEntries:e.globalEntries,projectEntries:e.projectEntries,...e.projectUnavailableMessage===void 0?{}:{projectUnavailableMessage:e.projectUnavailableMessage}}}function Gd(e){let t=[],n=[];for(let r of e)Zd(r.index)&&t.push(Xd(r,`staged`,r.index)),Qd(r.workingTree)&&n.push(Xd(r,`unstaged`,r.workingTree));return{staged:t,unstaged:n}}function Kd(e){let t=Gd(e);return new Set([...t.staged,...t.unstaged].map(e=>e.path)).size}function qd(e){switch(e){case`modified`:return`M`;case`added`:return`A`;case`deleted`:return`D`;case`renamed`:return`R`;case`copied`:return`C`;case`untracked`:return`?`;case`conflicted`:return`U`;case`ignored`:return`!`;case`unmodified`:return``}}function Jd(e){switch(e){case`modified`:return`Modified`;case`added`:return`Added`;case`deleted`:return`Deleted`;case`renamed`:return`Renamed`;case`copied`:return`Copied`;case`untracked`:return`Untracked`;case`conflicted`:return`Conflicted`;case`ignored`:return`Ignored`;case`unmodified`:return`Unmodified`}}function Yd(e){return e.oldPath===void 0?e.path:`${e.oldPath} → ${e.path}`}function Xd(e,t,n){return{id:`${t}:${e.path}`,path:e.path,...e.oldPath===void 0?{}:{oldPath:e.oldPath},scope:t,state:n}}function Zd(e){return e!==`unmodified`&&e!==`untracked`&&e!==`ignored`&&e!==`conflicted`}function Qd(e){return e!==`unmodified`&&e!==`ignored`}var $d=class{constructor(e,t,n,r){this.getState=e,this.setState=t,this.updateUrl=n,this.projects=r,this.runtimeRefreshSeqByMachine=new Map}async loadMachines(e){this.setState({error:``,isLoadingMachines:!0});try{let t=await kc.machines(),n=await this.selectInitialMachine(t,e),r=new Set(t.map(e=>e.id));this.setState({machines:t,selectedMachine:n,machineActivities:tf(this.getState().machineActivities,r),machineRuntimes:tf(this.getState().machineRuntimes,r)}),this.refreshMachineHealthFor(t),this.refreshMachineRuntimeFor(t)}catch(e){this.setState({error:String(e)})}finally{this.setState({isLoadingMachines:!1})}}async selectMachine(e,t={}){this.getState().selectedMachine?.id!==e.id&&(this.setState({selectedMachine:e,projects:[],workspaces:[],isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,messages:[],messagePageStart:0,messagePageTotal:0,status:void 0,activity:void 0,sessionStatuses:{},sessionActivities:{},sendingPrompts:{},workspaceActivities:{},workspacesByProjectId:{},workspaceDeletionRuns:{},activeTerminalCount:0,...rd()}),t.updateUrl!==!1&&this.updateUrl(),await this.projects.loadProjects(),this.refreshMachineHealth(e.id),this.refreshMachineRuntime(e.id))}async addMachine(e){this.setState({error:``});try{let t=await kc.addMachine(e);return this.setState({machines:[...this.getState().machines.filter(e=>e.id!==t.id),t]}),await this.selectMachine(t),t}catch(e){this.setState({error:String(e)});return}}async deleteMachine(e=this.getState().selectedMachine,t={}){if(e!==void 0){if(e.kind===`local`){this.setState({error:`The local machine cannot be removed.`});return}try{let n=this.getState().selectedMachine?.id===e.id;await kc.deleteMachine(e.id);let r=this.getState().machines.filter(t=>t.id!==e.id),i=r.find(e=>e.id===`local`)??r[0];return this.setState({machines:r,machineStatuses:ef(this.getState().machineStatuses,e.id),machineRuntimes:ef(this.getState().machineRuntimes,e.id),machineActivities:ef(this.getState().machineActivities,e.id)}),n&&i!==void 0?(t.selectFallback===!1||await this.selectMachine(i),i):void 0}catch(e){this.setState({error:String(e)});return}}}async refreshMachineHealth(e=this.getState().selectedMachine?.id??`local`){try{let t=await kc.health(e);return this.setState({machineStatuses:{...this.getState().machineStatuses,[t.machineId]:t}}),t}catch(e){this.setState({error:String(e)});return}}async refreshMachineRuntime(e=this.getState().selectedMachine?.id??`local`){let t=(this.runtimeRefreshSeqByMachine.get(e)??0)+1;this.runtimeRefreshSeqByMachine.set(e,t);try{let n=await kc.runtime(e,!0);return this.runtimeRefreshSeqByMachine.get(e)===t?(this.setState({machineRuntimes:{...this.getState().machineRuntimes,[n.machineId]:n}}),n):void 0}catch(n){this.runtimeRefreshSeqByMachine.get(e)===t&&this.setState({error:String(n)});return}}async selectInitialMachine(e,t){let n=e.find(e=>e.id===(t??`local`));if(n===void 0)return this.localMachine(e);if(n.kind!==`remote`)return n;let r=await this.safeRemoteHealth(n);return this.setState({machineStatuses:{...this.getState().machineStatuses,[r.machineId]:r},...r.ok?{}:{error:`${n.name} is unavailable; reconnecting…`}}),n}async safeRemoteHealth(e){try{return await kc.health(e.id)}catch(t){return{machineId:e.id,ok:!1,checkedAt:new Date().toISOString(),status:`offline`,error:t instanceof Error?t.message:String(t)}}}localMachine(e){return e.find(e=>e.id===`local`)??e[0]}async refreshMachineHealthFor(e){let t=await Promise.allSettled(e.map(e=>kc.health(e.id))),n=Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[[e.value.machineId,e.value]]:[]));Object.keys(n).length>0&&this.setState({machineStatuses:{...this.getState().machineStatuses,...n}})}async refreshMachineRuntimeFor(e){let t=await Promise.allSettled(e.map(e=>kc.runtime(e.id))),n=Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[[e.value.machineId,e.value]]:[]));Object.keys(n).length>0&&this.setState({machineRuntimes:{...this.getState().machineRuntimes,...n}})}};function ef(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function tf(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)))}var nf=`~/workspace`,rf=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.workspaces=n,this.projectCatalogOperationSequence=0,this.pinMutationQueueByMachine=new Map,this.latestPinMutationOrderByMachine=new Map,this.api=r.api??kc,this.onProjectsApplied=r.onProjectsApplied}async loadProjects(){let e=R(this.getState()),t=++this.projectCatalogOperationSequence;this.setState({error:``,isLoadingProjects:!0});try{let n=await this.api.projects(e);if(!this.isCurrentProjectCatalogOperation(e,t))return!1;let r;if(n.length===0){if(r=await this.api.addProject(nf,void 0,!0,e),!this.isCurrentProjectCatalogOperation(e,t))return!1;n=[r]}let i=new Set(n.map(e=>e.id)),a=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([e])=>i.has(e))),o=this.getState().selectedProject,s=o!==void 0&&n.some(e=>e.id===o.id&&e.path!==o.path);return this.setState({projects:n,workspacesByProjectId:a}),s&&this.workspaces.clearSelection(),this.onProjectsApplied?.(e),r!==void 0&&await this.workspaces.selectProject(r),!0}catch(n){return this.isCurrentProjectCatalogOperation(e,t)&&this.setState({error:String(n)}),!1}finally{this.isCurrentProjectCatalogOperation(e,t)&&this.setState({isLoadingProjects:!1})}}async addProject(e,t){if(e.trim()===``)return;let n=R(this.getState()),r=++this.projectCatalogOperationSequence;this.setState({isLoadingProjects:!1});try{let i=await this.api.addProject(e.trim(),void 0,t,n);if(R(this.getState())!==n)return;if(!this.isCurrentProjectCatalogOperation(n,r)){this.setState({projectDialogOpen:!1}),await this.loadProjects();return}let a=this.getState().projects;this.setState({projects:[...a.filter(e=>e.id!==i.id),i],projectDialogOpen:!1}),this.onProjectsApplied?.(n),await this.workspaces.selectProject(i)}catch(e){this.isCurrentProjectCatalogOperation(n,r)&&this.setState({error:String(e)})}}async addRegisteredProject(e,t){if(e.trim()===``)throw Error(`Project path is required`);let n=R(this.getState()),r=++this.projectCatalogOperationSequence;this.setState({isLoadingProjects:!1});try{let i=await this.api.addProject(e,t,!1,n);if(R(this.getState())!==n)return i;if(!this.isCurrentProjectCatalogOperation(n,r))return await this.loadProjects(),i;let a=this.getState().projects;return this.setState({projects:[...a.filter(e=>e.id!==i.id),i]}),this.onProjectsApplied?.(n),await this.workspaces.selectProject(i),i}catch(e){throw e instanceof Error?e:Error(String(e))}}async closeProject(e){let t=R(this.getState());try{if(await this.api.closeProject(e,t),R(this.getState())!==t)return;this.workspaces.forgetProject(e);let n=this.getState();this.setState({projects:n.projects.filter(t=>t.id!==e)}),this.onProjectsApplied?.(t),n.selectedProject?.id===e&&this.workspaces.clearSelection()}catch(e){R(this.getState())===t&&this.setState({error:String(e)})}}async closeProjectTree(e){let t=R(this.getState()),n=++this.projectCatalogOperationSequence;this.setState({isLoadingProjects:!1});try{let{closedProjectIds:r}=await this.api.closeProjectTree(e,t);if(R(this.getState())!==t)return;for(let e of r)this.workspaces.forgetProject(e);let i=this.getState(),a=new Set(r);this.setState({projects:i.projects.filter(e=>!a.has(e.id))}),this.onProjectsApplied?.(t),i.selectedProject!==void 0&&a.has(i.selectedProject.id)&&this.workspaces.clearSelection(),this.isCurrentProjectCatalogOperation(t,n)||await this.loadProjects()}catch(e){this.isCurrentProjectCatalogOperation(t,n)&&this.setState({error:String(e)})}}async pinProject(e){await this.applyPinChange(e,t=>this.api.pinProject(e,t))}async unpinProject(e){await this.applyPinChange(e,t=>this.api.unpinProject(e,t))}async applyPinChange(e,t){let n=R(this.getState()),r=++this.projectCatalogOperationSequence;this.setState({isLoadingProjects:!1});let i=(this.latestPinMutationOrderByMachine.get(n)??0)+1;this.latestPinMutationOrderByMachine.set(n,i);let a=this.pinMutationQueueByMachine.get(n),o=a===void 0?this.runPinChange(n,r,i,t):a.catch(()=>void 0).then(async()=>{await this.runPinChange(n,r,i,t)});this.pinMutationQueueByMachine.set(n,o);try{await o}finally{this.cleanupPinMutationQueue(n,i,o)}}async runPinChange(e,t,n,r){try{let i=await r(e);if(!this.isLatestPinMutation(e,n))return;this.isCurrentProjectCatalogOperation(e,t)?this.setState({projects:i}):R(this.getState())===e&&await this.loadProjects()}catch(r){this.isCurrentPinMutation(e,t,n)&&this.setState({error:String(r)})}}isCurrentProjectCatalogOperation(e,t){return R(this.getState())===e&&this.projectCatalogOperationSequence===t}isLatestPinMutation(e,t){return this.latestPinMutationOrderByMachine.get(e)===t}isCurrentPinMutation(e,t,n){return this.isCurrentProjectCatalogOperation(e,t)&&this.isLatestPinMutation(e,n)}cleanupPinMutationQueue(e,t,n){this.pinMutationQueueByMachine.get(e)===n&&(this.pinMutationQueueByMachine.delete(e),this.latestPinMutationOrderByMachine.get(e)===t&&this.latestPinMutationOrderByMachine.delete(e))}},af=5e3,of=`reconcile selected project catalog`,sf={setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>{window.clearTimeout(e)}},cf=class{constructor(e,t){this.getState=e,this.generation=0,this.nextRequestId=0,this.observing=!1,this.listWorkspaces=t.workspaces??bc.workspaces,this.applySnapshot=t.applySnapshot,this.timer=t.timer??sf,this.pollIntervalMs=t.pollIntervalMs??af,this.onBackgroundError=t.onBackgroundError,this.captureTopologyRequest=t.captureTopologyRequest}updatePolling(e=!0){if(!e){this.stopObserving();return}this.observing=!0;let t=this.currentScope();if(t===void 0){this.invalidateScope();return}let n=this.retargetScope(t);this.inFlight===void 0&&(!n&&this.pollTimer!==void 0||this.scheduleNext(t,this.generation))}refresh(){if(!this.observing)return Promise.resolve();let e=this.currentScope();if(e===void 0)return this.invalidateScope(),Promise.resolve();this.retargetScope(e),this.clearPollTimer();let t=this.generation,n=this.inFlight;return n===void 0?this.startRequest(e,t):n.generation===t&&n.scopeKey===e.key?n.promise:this.queueImmediateRefresh(e,t)}dispose(){this.observing=!1,this.invalidateScope()}retargetScope(e){return this.scope?.key===e.key?(this.scope=e,!1):(this.clearPollTimer(),this.clearQueuedImmediateRefresh(),this.scope=e,this.generation+=1,!0)}startRequest(e,t){let n=this.inFlight;if(n!==void 0)return n.generation===t&&n.scopeKey===e.key?n.promise:this.queueImmediateRefresh(e,t);let r=++this.nextRequestId,i,a=new Promise(e=>{i=e});if(i===void 0)throw Error(`Project catalog request promise was not initialized`);return this.inFlight={generation:t,requestId:r,scopeKey:e.key,promise:a},this.load(e,t,r).then(i,i),a}async load(e,t,n){try{let n=this.captureTopologyRequest?.({machineId:e.machineId,projectId:e.project.id,projectPath:e.project.path}),r=await this.listWorkspaces(e.project.id,e.machineId);if(!this.isCurrent(e,t))return;await this.applySnapshot({machineId:e.machineId,project:e.project,workspaces:r,...n===void 0?{}:{topologyRequest:n}})}catch(n){this.isCurrent(e,t)&&this.reportBackgroundError(n)}finally{this.finishRequest(n)}}finishRequest(e){if(this.inFlight?.requestId!==e)return;this.inFlight=void 0;let t=this.queuedImmediateRefresh;if(t!==void 0){if(this.queuedImmediateRefresh=void 0,this.isCurrent(t.scope,t.generation)){this.startRequest(t.scope,t.generation).then(()=>{t.resolve()},()=>{t.resolve()});return}t.resolve()}let n=this.scope;n!==void 0&&this.isCurrent(n,this.generation)&&this.scheduleNext(n,this.generation)}queueImmediateRefresh(e,t){let n=this.queuedImmediateRefresh;if(n?.generation===t&&n.scope.key===e.key)return n.promise;this.clearQueuedImmediateRefresh();let r,i=new Promise(e=>{r=e});if(r===void 0)throw Error(`Queued project catalog refresh promise was not initialized`);return this.queuedImmediateRefresh={generation:t,scope:e,promise:i,resolve:r},i}scheduleNext(e,t){this.isCurrent(e,t)&&(this.clearPollTimer(),this.pollTimer=this.timer.setTimeout(()=>{this.pollTimer=void 0,!(!this.isCurrent(e,t)||this.inFlight!==void 0)&&this.startRequest(e,t)},this.pollIntervalMs))}stopObserving(){this.observing=!1,this.invalidateScope()}invalidateScope(){this.clearPollTimer(),this.clearQueuedImmediateRefresh(),this.scope=void 0,this.generation+=1}clearPollTimer(){this.pollTimer!==void 0&&(this.timer.clearTimeout(this.pollTimer),this.pollTimer=void 0)}clearQueuedImmediateRefresh(){let e=this.queuedImmediateRefresh;this.queuedImmediateRefresh=void 0,e?.resolve()}currentScope(){let e=this.getState(),t=e.selectedProject;if(t===void 0||e.isLoadingWorkspaces)return;let n=R(e);return{key:JSON.stringify([n,t.id,t.path]),machineId:n,project:t}}isCurrent(e,t){return!this.observing||t!==this.generation||this.scope?.key!==e.key?!1:this.currentScope()?.key===e.key}reportBackgroundError(e){if(this.onBackgroundError!==void 0)try{this.onBackgroundError(of,e)}catch{}}},lf=`record recent project`,uf=class{constructor(e){this.deps=e,this.current={kind:`loading`},this.queuesByMachine=new Map,this.authoritativeProjectIdByMachine=new Map,this.latestIntentByMachine=new Map,this.generation=0,this.api=e.api??yc}get state(){return this.current}async load(){let e=this.deps.machineId(),t=++this.generation;this.latestIntentByMachine.delete(e),this.authoritativeProjectIdByMachine.delete(e),this.publish({kind:`loading`}),await this.enqueue(e,async()=>{this.authoritativeProjectIdByMachine.delete(e);try{let n=await this.api.recentProjects(e);if(this.isStale(t,e))return;this.publish({kind:`ready`,entries:n})}catch(n){if(this.isStale(t,e))return;this.publish({kind:`failed`,message:df(n)})}})}retry(){return this.load()}recordWork(e,t=this.deps.machineId()){if(this.latestIntentByMachine.get(t)?.projectId===e)return;let n={projectId:e};this.latestIntentByMachine.set(t,n);let r=this.generation;this.enqueue(t,async()=>{if(this.authoritativeProjectIdByMachine.get(t)!==e)try{let n=await this.api.recordRecentProject(e,t);if(this.authoritativeProjectIdByMachine.set(t,e),this.isStale(r,t))return;this.publish({kind:`ready`,entries:n})}catch(e){this.latestIntentByMachine.get(t)===n&&this.latestIntentByMachine.delete(t),this.deps.onBackgroundError?.(lf,e)}})}async removeEntry(e){let t=this.deps.machineId();this.latestIntentByMachine.delete(t),this.authoritativeProjectIdByMachine.delete(t);let n=this.generation,r;if(await this.enqueue(t,async()=>{try{let r=await this.api.removeRecentProject(e,t);this.authoritativeProjectIdByMachine.delete(t),this.isStale(n,t)||this.publish({kind:`ready`,entries:r})}catch(e){r=e instanceof Error?e:Error(String(e))}}),r!==void 0)throw r;return{kind:`removed`}}enqueue(e,t){let n=(this.queuesByMachine.get(e)??Promise.resolve()).then(t,t),r=n.catch(()=>void 0);return this.queuesByMachine.set(e,r),r.then(()=>{this.queuesByMachine.get(e)===r&&this.queuesByMachine.delete(e)}),n}isStale(e,t){return e!==this.generation||t!==this.deps.machineId()}publish(e){this.current=e,this.deps.onChange(e)}};function df(e){return e instanceof Error?e.message:String(e)}function ff(e,t){return t[e.path]}function pf(e){if(e?.hasSessionActivity===!0)return`session`;if(e?.hasTerminalActivity===!0)return`terminal`}function mf(e,t,n){return _f(vf(e,t,n))}function hf(e,t,n){return t.some(t=>t.projectId===e.id&&t.path===n)||n===e.path||n.startsWith(`${e.path}/`)}function gf(e){return _f(Object.values(e??{}))}function _f(e){if(e.some(e=>e.hasSessionActivity))return`session`;if(e.some(e=>e.hasTerminalActivity))return`terminal`}function vf(e,t,n){return Object.values(n).filter(n=>hf(e,t,n.cwd))}var yf=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.machineGeneration=0,this.activityMachineGeneration=-1,this.projectTopologyGeneration=0,this.nextCwdActivation=0,this.observedActiveCwds=new Set,this.cwdActivations=new Map,this.attemptedCwdActivations=new Map,this.api=n.api??bc,this.onProjectTopology=n.onProjectTopology,this.captureTopologyRequest=n.captureTopologyRequest,this.onError=n.onError}handleActivityApplied(e){return R(this.getState())===e?(this.activityMachineGeneration=this.machineGeneration,this.reconcile(e)):Promise.resolve()}handleProjectsApplied(e){return R(this.getState())!==e||(this.projectTopologyGeneration+=1,this.attemptedCwdActivations.clear(),this.activePass=void 0,this.activityMachineGeneration!==this.machineGeneration)?Promise.resolve():this.reconcile(e)}handleSelectedMachineChanged(){this.machineGeneration+=1,this.projectTopologyGeneration+=1,this.observedActiveCwds.clear(),this.cwdActivations.clear(),this.attemptedCwdActivations.clear(),this.activePass=void 0}reconcile(e){let t=this.getState();if(R(t)!==e)return Promise.resolve();let n=this.syncActiveCwds(t),r=new Map([...n].filter(([e,n])=>!bf(t.projects,t.workspacesByProjectId,e)&&this.attemptedCwdActivations.get(e)!==n)),i=this.activePass;if(i!==void 0)return(i.machineGeneration!==this.machineGeneration||i.projectTopologyGeneration!==this.projectTopologyGeneration||[...r].some(([e,t])=>i.cwdActivations.get(e)!==t))&&(i.trailingRequested=!0),i.promise;if(r.size===0||t.projects.length===0)return Promise.resolve();let a={machineGeneration:this.machineGeneration,projectTopologyGeneration:this.projectTopologyGeneration,machineId:e,projects:t.projects.map(e=>({id:e.id,path:e.path,startingWorkspaces:t.workspacesByProjectId[e.id]})),cwdActivations:r,trailingRequested:!1,promise:Promise.resolve()};return this.activePass=a,a.promise=this.runPass(a),a.promise}async runPass(e){if(await Promise.all(e.projects.map(async t=>{try{let n=this.captureTopologyRequest?.({machineId:e.machineId,projectId:t.id,projectPath:t.path}),r=await this.api.workspaces(t.id,e.machineId);await this.applyProjectWorkspaces(e,t,r,n)}catch(n){this.isPassScopeCurrent(e)&&this.reportError({machineId:e.machineId,projectId:t.id,error:n})}})),this.activePass!==e)return;let t=this.getState(),n=this.syncActiveCwds(t);for(let[r,i]of e.cwdActivations)n.get(r)===i&&!bf(t.projects,t.workspacesByProjectId,r)&&this.attemptedCwdActivations.set(r,i);let r=e.trailingRequested;this.activePass=void 0,r&&await this.reconcile(R(this.getState()))}async applyProjectWorkspaces(e,t,n,r){if(this.activePass!==e||!this.isPassScopeCurrent(e))return;let i=this.getState();if(i.projects.find(e=>e.id===t.id)?.path===t.path&&!(r===void 0&&i.workspacesByProjectId[t.id]!==t.startingWorkspaces)){if(this.onProjectTopology!==void 0){await this.onProjectTopology({machineId:e.machineId,projectId:t.id,projectPath:t.path,workspaces:n,...r===void 0?{}:{topologyRequest:r}});return}this.setState({workspacesByProjectId:{...this.getState().workspacesByProjectId,[t.id]:n}})}}isPassScopeCurrent(e){return e.machineGeneration===this.machineGeneration&&e.projectTopologyGeneration===this.projectTopologyGeneration&&R(this.getState())===e.machineId}syncActiveCwds(e){let t=new Set(Object.values(e.workspaceActivities).filter(od).map(e=>e.cwd));for(let e of this.observedActiveCwds)t.has(e)||(this.cwdActivations.delete(e),this.attemptedCwdActivations.delete(e));for(let e of t)this.observedActiveCwds.has(e)||(this.nextCwdActivation+=1,this.cwdActivations.set(e,this.nextCwdActivation),this.attemptedCwdActivations.delete(e));return this.observedActiveCwds=t,new Map([...t].map(e=>[e,this.cwdActivations.get(e)??0]))}reportError(e){if(this.onError!==void 0)try{this.onError(e)}catch{}}};function bf(e,t,n){return e.some(e=>hf(e,t[e.id]??[],n))}var xf=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.requestSequence=0,this.api=n.api??Us,this.onRefreshError=n.onRefreshError??(()=>void 0)}async refresh(){let e=R(this.getState());if(this.pendingUpdateCheck?.machineId===e)return;let t=++this.requestSequence;try{let n=await this.api.piWebUiStatus(e);this.isCurrent(e,t)&&this.setState({piWebUiStatus:n})}catch(n){if(!this.isCurrent(e,t))return;this.setState({piWebUiStatus:void 0}),this.onRefreshError(e,n)}}checkForUpdates(){let e=R(this.getState()),t=this.pendingUpdateCheck;if(t?.machineId===e)return t.promise;let n=++this.requestSequence,r=this.api.checkForUpdates(e).then(t=>{this.isCurrent(e,n)&&(this.setState({piWebUiStatus:t}),Sf(t))}).catch(t=>{if(this.isCurrent(e,n))throw t}).finally(()=>{this.pendingUpdateCheck?.requestSequence===n&&(this.pendingUpdateCheck=void 0)});return this.pendingUpdateCheck={machineId:e,requestSequence:n,promise:r},r}isCurrent(e,t){return R(this.getState())===e&&t===this.requestSequence}};function Sf(e){if(e.release.error!==void 0)throw Error(`PI WEBUI update check failed: ${e.release.error}`);if(e.release.skipped===!0)throw Error(`PI WEBUI update check was skipped because remote version checks are disabled by offline/version-check settings`)}var Cf=`pi-webui:cached-new-sessions:v1`,wf=`browserCachedNew`,Tf=`local`;function Ef(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function Df(e,t=Tf,n=Ef()){if(e.messageCount!==0||e.archived===!0)return;let r=Nf(n).filter(n=>n.id!==e.id||n.machineId!==t);Pf([Of(e,t),...r],n)}function Of(e,t=Tf){return{...e,browserCachedNew:!0,machineId:t}}function kf(e,t=Tf,n=Ef()){Pf(Nf(n).filter(n=>n.id!==e||n.machineId!==t),n)}function Af(e,t,n=Tf,r=Ef()){let i=new Set(t.map(e=>e.id)),a=Nf(r),o=a.filter(e=>e.machineId!==n||!i.has(e.id));return o.length!==a.length&&Pf(o,r),[...o.filter(t=>t.machineId===n&&t.cwd===e),...t]}function jf(e){return e!==void 0&&If(e)&&e.browserCachedNew===!0}function Mf(e){return{id:e.id,path:e.path,cwd:e.cwd,...e.persisted===void 0?{}:{persisted:e.persisted},...e.name===void 0?{}:{name:e.name},created:e.created,modified:e.modified,messageCount:e.messageCount,firstMessage:e.firstMessage,...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath},...`machineId`in e&&typeof e.machineId==`string`?{machineId:e.machineId}:{machineId:Tf},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt},...e.creationSource===void 0?{}:{creationSource:e.creationSource}}}function Nf(e=Ef()){try{let t=e?.getItem(Cf);if(t==null||t===``)return[];let n=JSON.parse(t);return Array.isArray(n)?n.flatMap(e=>Ff(e)):[]}catch{return[]}}function Pf(e,t=Ef()){try{e.length===0?t?.removeItem(Cf):t?.setItem(Cf,JSON.stringify(e))}catch{}}function Ff(e){if(!Lf(e))return[];let t=Rf(e,`id`),n=Rf(e,`path`),r=Rf(e,`cwd`),i=Rf(e,`created`),a=Rf(e,`modified`),o=Rf(e,`firstMessage`),s=Bf(e,`messageCount`);if(t===void 0||n===void 0||r===void 0||i===void 0||a===void 0||o===void 0||s!==0)return[];let c=zf(e,`name`),l=zf(e,`parentSessionPath`),u=zf(e,`machineId`)??Tf,d=e.creationSource===`session-list-plus`?e.creationSource:void 0;return[{id:t,path:n,cwd:r,...c===void 0?{}:{name:c},created:i,modified:a,messageCount:s,firstMessage:o,...l===void 0?{}:{parentSessionPath:l},...d===void 0?{}:{creationSource:d},machineId:u,browserCachedNew:!0}]}function If(e){return wf in e}function Lf(e){return typeof e==`object`&&!!e}function Rf(e,t){let n=e[t];return typeof n==`string`?n:void 0}function zf(e,t){let n=e[t];return n===void 0||typeof n!=`string`?void 0:n}function Bf(e,t){let n=e[t];return typeof n==`number`?n:void 0}function Vf(e){return op(e.flatMap(Kf)).filter(e=>e.parts.length>0)}function Hf(e,t){return{role:e,parts:[{type:`text`,text:t}]}}function Uf(e,t){let n=Qf(t),r=z(t,`entryId`),i=z(t,`previousAssistantEntryId`),a=hp(t,`canFork`);return{...e,...n===void 0?{}:{meta:n},...r===void 0?{}:{entryId:r},...i===void 0?{}:{previousAssistantEntryId:i},...a===void 0?{}:{canFork:a}}}function Wf(e,t,n){if(n===``)return e;let r=e.at(-1),i=r?.parts.at(-1);return r?.role===t&&i?.type===`text`?[...e.slice(0,-1),{...r,parts:[...r.parts.slice(0,-1),{...i,text:i.text+n}]}]:r?.role===t?[...e.slice(0,-1),{...r,parts:[...r.parts,{type:`text`,text:n}]}]:[...e,Hf(t,n)]}function Gf(e,t){if(t===``)return e;let n=e.at(-1),r=n?.parts.at(-1);return n?.role===`assistant`&&r?.type===`thinking`?[...e.slice(0,-1),{...n,parts:[...n.parts.slice(0,-1),{...r,text:r.text+t}]}]:n?.role===`assistant`?[...e.slice(0,-1),{...n,parts:[...n.parts,{type:`thinking`,text:t}]}]:[...e,{role:`assistant`,parts:[{type:`thinking`,text:t}]}]}function Kf(e){if(Jf(e))return[e];if(z(e,`role`)===`bashExecution`)return[Uf(tp(e),e)];let t=np(z(e,`role`)),n=rp(mp(e,`content`),e),r=t===`user`?Yf(n):void 0;if(r!==void 0)return r.map(t=>Uf(t,e));let i=Zf(e);if(t===`tool`)return[Uf({role:t,parts:n,...i===void 0?{}:{source:i}},e)];let a=n.filter(e=>e.type!==`empty`),o=t===`assistant`&&a.length>0&&a.every(e=>e.type===`skillRead`)?`skill`:t,s=a.length>0?[Uf({role:o,parts:a,...i===void 0?{}:{source:i}},e)]:[],c=qf(e);return c===void 0?s:[...s,Uf(c,e)]}function qf(e){if(z(e,`role`)!==`assistant`||z(e,`stopReason`)!==`error`)return;let t=z(e,`errorMessage`)?.trim();return Hf(`system`,`Model response failed: ${t===void 0||t===``?`The model returned an error.`:t}`)}function Jf(e){let t=z(e,`role`);return(t===`user`||t===`assistant`||t===`tool`||t===`system`||t===`bash`||t===`skill`)&&Array.isArray(mp(e,`parts`))}function Yf(e){if(e.length!==1||e[0]?.type!==`text`)return;let t=Xf(e[0].text);if(t!==void 0)return[{role:`user`,parts:[{type:`skillInvocation`,name:t.name,location:t.location,content:t.content}]},...t.userMessage===void 0?[]:[{role:`user`,parts:[{type:`text`,text:t.userMessage}]}]]}function Xf(e){let t=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(e);if(t===null)return;let n=t[4]?.trim();return{name:t[1]??`skill`,location:t[2]??``,content:t[3]??``,...n===void 0||n===``?{}:{userMessage:n}}}function Zf(e){let t=z(e,`source`);if(t===`compaction`||t===`branch_summary`)return t}function Qf(e){let t=$f(mp(e,`timestamp`)),n=ep(e);if(!(t===void 0&&n===void 0))return{...t===void 0?{}:{timestamp:t},...n===void 0?{}:{model:n}}}function $f(e){if(typeof e==`number`&&Number.isFinite(e))return new Date(e).toISOString();if(typeof e!=`string`||e===``)return;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function ep(e){if(z(e,`role`)!==`assistant`)return;let t=z(e,`provider`),n=z(e,`model`),r=z(e,`responseModel`);if(!((t===void 0||t===``)&&(n===void 0||n===``)&&(r===void 0||r===``)))return{...t===void 0||t===``?{}:{provider:t},...n===void 0||n===``?{}:{id:n},...r===void 0||r===``?{}:{responseId:r}}}function tp(e){let t=z(e,`command`)??``,n=hp(e,`excludeFromContext`)===!0?[`excluded from context`,``,`$ ${t}`]:[`$ ${t}`],r=mp(e,`output`);r!=null&&n.push(``,_p(r));let i=mp(e,`exitCode`);i!=null&&n.push(``,`exit ${_p(i)}`),hp(e,`cancelled`)===!0&&n.push(``,`cancelled`),hp(e,`truncated`)===!0&&n.push(``,`output truncated`);let a=z(e,`fullOutputPath`);return a!==void 0&&a!==``&&n.push(``,`full output: ${a}`),{role:`bash`,parts:[{type:`text`,text:n.join(`
@@ -673,6 +673,10 @@ This will delete every archived session on this machine regardless of age or cle
673
673
  .msg.event-group.live { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
674
674
  .msg.event-group > summary { position: sticky; top: -26px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); color: var(--pi-muted); }
675
675
  .msg.event-group.live > summary { border-bottom-color: var(--pi-success-border); background: var(--pi-success-bg); color: var(--pi-success); }
676
+ /* A collapsed group has no body, so the summary separator has nothing to
677
+ separate. Dropping it also stops its straight 1px line from overhanging the
678
+ rounded container border at the bottom corners. */
679
+ .msg.event-group:not([open]) > summary { border-bottom: 0; border-radius: 9px; }
676
680
  .msg.event-group > summary .label { margin: 0; }
677
681
  .group-body { padding: 0 12px 12px; }
678
682
  .event-group-window-control { display: flex; justify-content: flex-start; padding: 10px 12px 0; }
@@ -1211,7 +1215,7 @@ This will delete every archived session on this machine regardless of age or cle
1211
1215
  .review-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1212
1216
  .dialog-error { border: 1px solid var(--pi-danger); border-radius: 8px; background: color-mix(in srgb, var(--pi-danger) 10%, transparent); color: var(--pi-danger); padding: 9px; line-height: 1.35; overflow-wrap: anywhere; }
1213
1217
  footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
1214
- `]}};H([x({attribute:!1})],lS.prototype,`context`,void 0),H([C(`#workspace-upload-input`)],lS.prototype,`uploadInput`,void 0),H([S()],lS.prototype,`pendingUpload`,void 0),H([S()],lS.prototype,`destinationFolder`,void 0),H([S()],lS.prototype,`overwrite`,void 0),H([S()],lS.prototype,`createDirs`,void 0),H([S()],lS.prototype,`formError`,void 0),H([S()],lS.prototype,`dragActive`,void 0),lS=H([b(`workspace-files-panel`)],lS);function uS(e,t){return Object.values(e).filter(e=>e.projectId===t.projectId&&e.workspaceId===t.workspaceId&&e.machineId===t.machineId).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))}function dS(e,t){if(e.length===0)return`Choose at least one file to upload.`;for(let n of e)try{Jl(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function fS(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function pS(e){let t=e.selectedFileContent;if(e.selectedFilePath===void 0||e.selectedFilePath===``)return`Select a file.`;if(t===void 0)return`Loading ${e.selectedFilePath}…`;if(t.mediaType!==`image`&&t.binary)return`Binary file: ${t.path} · ${ES(t.size)}`}function mS(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function hS(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function gS(e){return e==null?[]:Array.from(e)}function _S(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function vS(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function yS(e){let t=e.files.length,n=t===1?`file`:`files`;switch(e.status){case`completed`:return`Uploaded ${String(t)} ${n}`;case`error`:return`Upload failed for ${String(t)} ${n}`;case`cancelled`:return`Upload cancelled for ${String(t)} ${n}`;case`uploading`:return`Uploading ${String(t)} ${n}`}}function bS(e){switch(e.status){case`completed`:return`Done`;case`error`:return`Failed`;case`cancelled`:return`Cancelled`;case`uploading`:return wS(e.percent)}}function xS(e){return e.status===`uploading`?e.percent:1}function SS(e){switch(e.status){case`pending`:return`Pending`;case`uploading`:return wS(e.percent);case`completed`:return`Done`;case`error`:return`Error`;case`cancelled`:return`Cancelled`}}function CS(e){return e.error===void 0?e.response===void 0?`${e.path} · ${ES(e.loaded)} / ${ES(e.total)}`:`Wrote ${e.response.path}`:e.error}function wS(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function TS(){cS(()=>import(`./CodeViewer-3Y40kwMd.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)}function ES(e){if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${String(e)} B`;let t=e/1024;if(t<1024)return`${DS(t)} KB`;let n=t/1024;return n<1024?`${DS(n)} MB`:`${DS(n/1024)} GB`}function DS(e){return e>=10?String(Math.round(e)):e.toFixed(1)}var OS=2e3,kS=class extends y{constructor(...e){super(...e),this.loading=!1,this.error=``,this.dynamicMetricsRequest=0,this.dynamicMetricsRefreshInFlight=!1}willUpdate(e){if(!e.has(`context`))return;let t=this.context?.machine.id;if(t===void 0){this.stopDynamicMetricsPolling(),this.machineId=void 0;return}t!==this.machineId&&(this.stopDynamicMetricsPolling(),this.machineId=t,this.loadSystemInfo(t))}async loadSystemInfo(e=this.machineId){if(e!==void 0){this.loading=!0,this.error=``;try{let t=await Us.systemInfo(e);this.isCurrentMachine(e)&&(this.systemInfo=t,this.isConnected&&this.startDynamicMetricsPolling())}catch(t){this.isCurrentMachine(e)&&(this.error=t instanceof Error?t.message:String(t))}finally{this.isCurrentMachine(e)&&(this.loading=!1)}}}connectedCallback(){super.connectedCallback(),this.startDynamicMetricsPolling()}disconnectedCallback(){this.stopDynamicMetricsPolling(),super.disconnectedCallback()}startDynamicMetricsPolling(){let e=this.machineId;e===void 0||this.systemInfo===void 0||this.dynamicMetricsTimer!==void 0||(this.dynamicMetricsPollingMachineId=e,this.dynamicMetricsTimer=window.setInterval(()=>{this.refreshDynamicMetrics(e)},OS))}stopDynamicMetricsPolling(){this.dynamicMetricsTimer!==void 0&&window.clearInterval(this.dynamicMetricsTimer),this.dynamicMetricsTimer=void 0,this.dynamicMetricsPollingMachineId=void 0,this.dynamicMetricsRequest+=1,this.dynamicMetricsRefreshInFlight=!1}async refreshDynamicMetrics(e){if(this.loading||this.error!==``||this.dynamicMetricsRefreshInFlight||this.dynamicMetricsPollingMachineId!==e)return;this.dynamicMetricsRefreshInFlight=!0;let t=++this.dynamicMetricsRequest;try{let n=await Us.systemMetrics(e);if(!this.isCurrentDynamicMetricsRequest(e,t))return;this.applyDynamicMetrics(n)}catch{}finally{t===this.dynamicMetricsRequest&&(this.dynamicMetricsRefreshInFlight=!1)}}isCurrentDynamicMetricsRequest(e,t){return t===this.dynamicMetricsRequest&&this.dynamicMetricsPollingMachineId===e&&this.isCurrentMachine(e)}applyDynamicMetrics(e){let t=this.systemInfo;t!==void 0&&(this.systemInfo={...t,memory:e.memory,network:{...t.network,...e.network}})}isCurrentMachine(e){return this.machineId===e&&this.context?.machine.id===e}render(){if(this.loading)return g`<section class="info-panel"><p class="muted">Loading system information…</p></section>`;if(this.error!==``)return g`<section class="info-panel">
1218
+ `]}};H([x({attribute:!1})],lS.prototype,`context`,void 0),H([C(`#workspace-upload-input`)],lS.prototype,`uploadInput`,void 0),H([S()],lS.prototype,`pendingUpload`,void 0),H([S()],lS.prototype,`destinationFolder`,void 0),H([S()],lS.prototype,`overwrite`,void 0),H([S()],lS.prototype,`createDirs`,void 0),H([S()],lS.prototype,`formError`,void 0),H([S()],lS.prototype,`dragActive`,void 0),lS=H([b(`workspace-files-panel`)],lS);function uS(e,t){return Object.values(e).filter(e=>e.projectId===t.projectId&&e.workspaceId===t.workspaceId&&e.machineId===t.machineId).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))}function dS(e,t){if(e.length===0)return`Choose at least one file to upload.`;for(let n of e)try{Jl(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function fS(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function pS(e){let t=e.selectedFileContent;if(e.selectedFilePath===void 0||e.selectedFilePath===``)return`Select a file.`;if(t===void 0)return`Loading ${e.selectedFilePath}…`;if(t.mediaType!==`image`&&t.binary)return`Binary file: ${t.path} · ${ES(t.size)}`}function mS(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function hS(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function gS(e){return e==null?[]:Array.from(e)}function _S(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function vS(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function yS(e){let t=e.files.length,n=t===1?`file`:`files`;switch(e.status){case`completed`:return`Uploaded ${String(t)} ${n}`;case`error`:return`Upload failed for ${String(t)} ${n}`;case`cancelled`:return`Upload cancelled for ${String(t)} ${n}`;case`uploading`:return`Uploading ${String(t)} ${n}`}}function bS(e){switch(e.status){case`completed`:return`Done`;case`error`:return`Failed`;case`cancelled`:return`Cancelled`;case`uploading`:return wS(e.percent)}}function xS(e){return e.status===`uploading`?e.percent:1}function SS(e){switch(e.status){case`pending`:return`Pending`;case`uploading`:return wS(e.percent);case`completed`:return`Done`;case`error`:return`Error`;case`cancelled`:return`Cancelled`}}function CS(e){return e.error===void 0?e.response===void 0?`${e.path} · ${ES(e.loaded)} / ${ES(e.total)}`:`Wrote ${e.response.path}`:e.error}function wS(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function TS(){cS(()=>import(`./CodeViewer-SGnd_OTg.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)}function ES(e){if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${String(e)} B`;let t=e/1024;if(t<1024)return`${DS(t)} KB`;let n=t/1024;return n<1024?`${DS(n)} MB`:`${DS(n/1024)} GB`}function DS(e){return e>=10?String(Math.round(e)):e.toFixed(1)}var OS=2e3,kS=class extends y{constructor(...e){super(...e),this.loading=!1,this.error=``,this.dynamicMetricsRequest=0,this.dynamicMetricsRefreshInFlight=!1}willUpdate(e){if(!e.has(`context`))return;let t=this.context?.machine.id;if(t===void 0){this.stopDynamicMetricsPolling(),this.machineId=void 0;return}t!==this.machineId&&(this.stopDynamicMetricsPolling(),this.machineId=t,this.loadSystemInfo(t))}async loadSystemInfo(e=this.machineId){if(e!==void 0){this.loading=!0,this.error=``;try{let t=await Us.systemInfo(e);this.isCurrentMachine(e)&&(this.systemInfo=t,this.isConnected&&this.startDynamicMetricsPolling())}catch(t){this.isCurrentMachine(e)&&(this.error=t instanceof Error?t.message:String(t))}finally{this.isCurrentMachine(e)&&(this.loading=!1)}}}connectedCallback(){super.connectedCallback(),this.startDynamicMetricsPolling()}disconnectedCallback(){this.stopDynamicMetricsPolling(),super.disconnectedCallback()}startDynamicMetricsPolling(){let e=this.machineId;e===void 0||this.systemInfo===void 0||this.dynamicMetricsTimer!==void 0||(this.dynamicMetricsPollingMachineId=e,this.dynamicMetricsTimer=window.setInterval(()=>{this.refreshDynamicMetrics(e)},OS))}stopDynamicMetricsPolling(){this.dynamicMetricsTimer!==void 0&&window.clearInterval(this.dynamicMetricsTimer),this.dynamicMetricsTimer=void 0,this.dynamicMetricsPollingMachineId=void 0,this.dynamicMetricsRequest+=1,this.dynamicMetricsRefreshInFlight=!1}async refreshDynamicMetrics(e){if(this.loading||this.error!==``||this.dynamicMetricsRefreshInFlight||this.dynamicMetricsPollingMachineId!==e)return;this.dynamicMetricsRefreshInFlight=!0;let t=++this.dynamicMetricsRequest;try{let n=await Us.systemMetrics(e);if(!this.isCurrentDynamicMetricsRequest(e,t))return;this.applyDynamicMetrics(n)}catch{}finally{t===this.dynamicMetricsRequest&&(this.dynamicMetricsRefreshInFlight=!1)}}isCurrentDynamicMetricsRequest(e,t){return t===this.dynamicMetricsRequest&&this.dynamicMetricsPollingMachineId===e&&this.isCurrentMachine(e)}applyDynamicMetrics(e){let t=this.systemInfo;t!==void 0&&(this.systemInfo={...t,memory:e.memory,network:{...t.network,...e.network}})}isCurrentMachine(e){return this.machineId===e&&this.context?.machine.id===e}render(){if(this.loading)return g`<section class="info-panel"><p class="muted">Loading system information…</p></section>`;if(this.error!==``)return g`<section class="info-panel">
1215
1219
  <p class="error-text">Failed to load system information: ${this.error}</p>
1216
1220
  <button @click=${()=>{this.loadSystemInfo()}}>Retry</button>
1217
1221
  </section>`;let e=this.systemInfo;return e===void 0?g`<section class="info-panel"><p class="muted">System information unavailable.</p></section>`:g`<section class="info-panel">
@@ -1465,7 +1469,7 @@ This will delete every archived session on this machine regardless of age or cle
1465
1469
  <div class="viewer-header"><strong>${e.path??`diff`}</strong><small>${e.staged?`staged`:`unstaged`}${e.truncated?` · truncated`:``}</small></div>
1466
1470
  <unified-diff-viewer .diff=${e.diff}></unified-diff-viewer>
1467
1471
  </section>
1468
- `}function HS(){cS(()=>import(`./UnifiedDiffViewer-xek-ZrBA.js`),[],import.meta.url)}function US(){cS(()=>Promise.resolve().then(()=>lB),void 0,import.meta.url)}function WS(e){return g`<workspace-info-panel .context=${e}></workspace-info-panel>`}function GS(e){let t=KS(e);return g`
1472
+ `}function HS(){cS(()=>import(`./UnifiedDiffViewer-zvBeY6cg.js`),[],import.meta.url)}function US(){cS(()=>Promise.resolve().then(()=>lB),void 0,import.meta.url)}function WS(e){return g`<workspace-info-panel .context=${e}></workspace-info-panel>`}function GS(e){let t=KS(e);return g`
1469
1473
  <p class="summary">
1470
1474
  <span class="summary-branch">${t.branch}</span>
1471
1475
  ${t.latestTag===void 0?null:g`<span class="summary-tag" aria-label=${`Latest tag ${t.latestTag}`}>${t.latestTag}</span>`}
@@ -2859,7 +2863,7 @@ This will delete every archived session on this machine regardless of age or cle
2859
2863
  `,n),i=e.slice(n,r<0?e.length:r),a=/^ {0,3}(`{3,}|~{3,})/u.exec(i)?.[1];if(t!==void 0){a?.startsWith(t.character)===!0&&a.length>=t.length&&(t=void 0);continue}let o=a?.startsWith("`")===!0?"`":a?.startsWith(`~`)===!0?`~`:void 0;if(o!==void 0&&a!==void 0){t={character:o,length:a.length};continue}if(Ok(e.slice(n))!==void 0)return n}}function Dk(e,t){let n=Ok(e);if(n!==void 0)return{type:`latex-display`,raw:n.raw,tex:n.tex,displayMode:!0}}function Ok(e){let t=e.indexOf(`
2860
2864
  `),n=t<0?e:e.slice(0,t),r=kk(n);if(r===void 0)return;let i=n.slice(r.delimiterEnd).replace(/^[ \t]+/u,``);if(i!==``){let a=jk(i,r.delimiter);if(a<0)return;let o=i.slice(0,a);if(o.length===0||o.length>dk)return;let s=o.replace(/[ \t]+$/u,``);if(s.trim()===``||/^[ \t]*$/u.exec(i.slice(a+r.delimiter.length))===null)return;let c=t<0?n.length:t+1;return{raw:e.slice(0,c),tex:s}}if(t<0)return;let a=[],o=t+1,s=0;for(;o<=e.length;){let t=e.indexOf(`
2861
2865
  `,o),n=t<0?e.length:t,i=e.slice(o,n);if(Ak(i,r.delimiter)){if(a.length===0||a.every(e=>e.trim()===``))return;let r=t<0?n:t+1;return{raw:e.slice(0,r),tex:a.join(`
2862
- `)}}if(Mk(i)||(a.push(i),s+=i.length+ +(a.length>1),s>dk)||t<0)return;o=t+1}}function kk(e){let t=/^( {0,3})(\$\$|\\\[)([ \t]*)$/u.exec(e);if(t!==null){let e=t[2];return e!==`$$`&&e!==`\\[`?void 0:{delimiter:e,delimiterEnd:t[0].length}}let n=/^( {0,3})(\$\$|\\\[)/u.exec(e);if(n===null)return;let r=n[2];if(!(r!==`$$`&&r!==`\\[`))return{delimiter:r,delimiterEnd:n[0].length}}function Ak(e,t){return RegExp(`^ {0,3}${t===`$$`?`\\$\\$`:`\\\\\\]`}[ \\t]*$`,`u`).test(e)}function jk(e,t){let n=t===`$$`?`$$`:`\\]`,r=e.slice(0,dk+n.length),i=0;for(;i<r.length;){let t=r.indexOf(n,i);if(t<0||t>dk)return-1;if(/^[ \t]*$/u.test(e.slice(t+n.length)))return t;i=t+n.length}return-1}function Mk(e){return/^ {0,3}(?:```|~~~)/u.test(e)}function Nk(e){return Pk(e),e}function Pk(e){for(let t of e)Fk(t)}function Fk(e){if(Rk(e,`paragraph`)||Rk(e,`heading`)){e.tokens=Lk(e.tokens);return}if(Rk(e,`blockquote`)){Pk(e.tokens);return}if(Rk(e,`list`)){for(let t of e.items)Pk(t.tokens);return}if(Rk(e,`list_item`)){Ik(e.tokens);return}if(Rk(e,`text`)&&e.tokens!==void 0){e.tokens=Lk(e.tokens);return}if(Rk(e,`table`)){for(let t of e.header)t.tokens=Lk(t.tokens);for(let t of e.rows)for(let e of t)e.tokens=Lk(e.tokens)}}function Ik(e){for(let t of e)Rk(t,`text`)&&t.tokens!==void 0?t.tokens=Lk(t.tokens):Fk(t)}function Lk(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===void 0)break;if(zk(r)){let r=[];for(;n<e.length;){let t=e[n];if(t===void 0||!zk(t))break;r.push(t),n+=1}t.push(...Bk(r));continue}(Rk(r,`em`)||Rk(r,`strong`)||Rk(r,`del`)||Rk(r,`text`)&&r.tokens!==void 0)&&(r.tokens=Lk(r.tokens)),t.push(r),n+=1}return t}function Rk(e,t){return e.type===t}function zk(e){return Rk(e,`escape`)||Rk(e,`text`)&&e.tokens===void 0}function Bk(e){let t=e.map(e=>e.raw).join(``);if(!Sk(t))return e;let n=Uk(t);if(n.length===0)return e;let r=Vk(e),i={index:0},a=[],o=0;for(let e of n){Hk(a,r,i,o,e.start);let n=t.slice(e.start,e.end);e.kind===`math`?a.push({type:e.displayMode===!0?`latex-display`:`latex-inline`,raw:n,tex:e.tex??``,displayMode:e.displayMode===!0}):a.push({type:`latex-inline-literal`,raw:n}),o=e.end}return Hk(a,r,i,o,t.length),a}function Vk(e){let t=[],n=0;for(let r of e){let e=n+r.raw.length;t.push({token:r,start:n,end:e}),n=e}return t}function Hk(e,t,n,r,i){if(!(r>=i)){for(;n.index<t.length;){let e=t[n.index];if(e===void 0||e.end>r)break;n.index+=1}for(;n.index<t.length;n.index+=1){let a=t[n.index];if(a===void 0||a.start>=i)break;let o=Math.max(r,a.start)-a.start,s=Math.min(i,a.end)-a.start;if(o===0&&s===a.token.raw.length)e.push(a.token);else{let t=a.token.raw.slice(o,s),n=a.token.text.slice(o,s);e.push({type:`text`,raw:t,text:n.length===t.length?n:t,escaped:a.token.type===`text`&&a.token.escaped})}if(a.end>i)break}}}function Uk(e){let t={head:void 0,tail:void 0},n=0,r,i,a,o,s=!1,c=!1;for(let l=0;l<e.length;l+=1){r=qk(r),i=qk(i),a=qk(a),o=qk(o),r!==void 0&&l-r.start-1>dk&&(Gk(t,r.placeholder),r=void 0,s=!0),i!==void 0&&l-i.start-2>dk&&(Gk(t,i.placeholder),i=void 0,c=!0),a!==void 0&&l-a.start-2>dk&&(a=void 0),o!==void 0&&l-o.start-2>dk&&(o=void 0);let u=e[l];if(u===`\\`){if(n+=1,n%2==1){let n=e[l+1];if(n===`(`||n===`)`||n===`[`||n===`]`){let r=Wk(t,l,l+2,`literal`);if(n===`(`)a??={start:l,placeholder:r};else if(n===`)`&&a!==void 0){let n=e.slice(a.start+2,l);n.length<=dk&&n.length>0&&n.trim()!==``&&!/\s/u.test(n[0]??``)&&!/\s/u.test(n.at(-1)??``)&&Zk(e,a.start)&&Qk(e,l+2)&&Kk(t,a.placeholder,l+2,`math`,n,!1),a=void 0}else if(n===`[`)o??={start:l,placeholder:r};else if(n===`]`&&o!==void 0){let n=e.slice(o.start+2,l);n.length<=dk&&n.length>0&&n.trim()!==``&&Kk(t,o.placeholder,l+2,`literal`),o=void 0}}}continue}if(u===`$`){let a=n%2==1;if(e[l+1]===`$`){if(!a){if(i===void 0&&!c)i={start:l,placeholder:Wk(t,l,l+2,`literal`)};else if(i!==void 0){let n=e.slice(i.start+2,l);n.length<=dk&&n.trim()!==``?Kk(t,i.placeholder,l+2,`literal`):(Gk(t,i.placeholder),n.length>dk&&(c=!0)),i=void 0}}l+=1,n=0;continue}if(!a&&!s)if(r===void 0)Yk(e,l)&&(r={start:l,placeholder:Wk(t,l,l+1,`literal`)});else{let n=e.slice(r.start+1,l);Xk(e,r.start,l,n)?(Kk(t,r.placeholder,l+1,`math`,n,!1),r=void 0):(Gk(t,r.placeholder),r=void 0,Yk(e,l)&&(r={start:l,placeholder:Wk(t,l,l+1,`literal`)}))}n=0;continue}n=0}return r!==void 0&&Gk(t,r.placeholder),i!==void 0&&Gk(t,i.placeholder),tA(Jk(t))}function Wk(e,t,n,r){let i={start:t,end:n,kind:r,linked:!0,previous:e.tail,next:void 0};return e.tail===void 0?e.head=i:e.tail.next=i,e.tail=i,i}function Gk(e,t){t.linked&&=(t.previous===void 0?e.head=t.next:t.previous.next=t.next,t.next===void 0?e.tail=t.previous:t.next.previous=t.previous,t.previous=void 0,t.next=void 0,!1)}function Kk(e,t,n,r,i,a){let o=t.next;for(;o!==void 0&&o.start<n;){let t=o.next;Gk(e,o),o=t}t.end=n,t.kind=r,i===void 0?delete t.tex:t.tex=i,a===void 0?delete t.displayMode:t.displayMode=a}function qk(e){return e?.placeholder.linked===!0?e:void 0}function Jk(e){let t=[];for(let n=e.head;n!==void 0;n=n.next){let e={start:n.start,end:n.end,kind:n.kind};n.tex!==void 0&&(e.tex=n.tex),n.displayMode!==void 0&&(e.displayMode=n.displayMode),t.push(e)}return t}function Yk(e,t){let n=e[t+1];return Zk(e,t)&&n!==void 0&&!/\s/u.test(n)}function Xk(e,t,n,r){return n>t+1&&r.length>0&&!/\s/u.test(r.at(-1)??``)&&Qk(e,n+1)}function Zk(e,t){if(t<=0)return!0;let n=t-1,r=eA(e.charCodeAt(n))?n-1:n;return $k(e.codePointAt(r))}function Qk(e,t){return $k(e.codePointAt(t))}function $k(e){return e===void 0||/[\s\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function eA(e){return e>=56320&&e<=57343}function tA(e){let t=[];for(let n of e){let e=t.at(-1);e?.kind===`literal`&&n.kind===`literal`&&e.end===n.start?e.end=n.end:t.push({...n})}return t}function nA(e,t,n){if(e.type===`latex-inline-literal`)return yk(e.raw);if(e.type===`latex-block-literal`)return`<p>${yk(e.raw)}</p>`;let r=rA(e);if(r===void 0)return``;if(!iA(r.tex,t))return gA(r);let i;try{i=n(r.tex,{displayMode:r.displayMode})}catch{return gA(r)}if(!aA(i,t))return gA(r);let a=`aria-label="${bk(r.tex)}"`;return r.displayMode?`<div class="math-display" role="img" ${a}>${i}</div>`:`<span class="math-inline" role="img" ${a}>${i}</span>`}function rA(e){if(e.type!==`latex-inline`&&e.type!==`latex-display`)return;let t=e,n=t.tex,r=t.displayMode;if(!(typeof n!=`string`||typeof r!=`boolean`))return{type:e.type,raw:e.raw,tex:n,displayMode:r}}function iA(e,t){return t.outputAdmissionClosed||e.length>fk||t.mathSourceUnits+e.length>pk||!oA(e)?!1:(t.mathSourceUnits+=e.length,!0)}function aA(e,t){return e.length>vk||t.mathOutputUnits+e.length>_k?(t.outputAdmissionClosed=!0,!1):(t.mathOutputUnits+=e.length,!0)}function oA(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`\\`){let t=i;for(;t<e.length&&e[t]===`\\`;)t+=1;let a=t-i;if(a>=2&&(r+=Math.floor(a/2)),r>gk)return!1;if(a%2==1){let r=e[t];if(/[A-Za-z@]/u.test(r??``)){n+=1;let r=sA(e,t),a=e.slice(t-1,r);if(cA(a)||!fA(e,a,r))return!1;i=r-1}else i=t}else i=t-1;continue}if(a===`{`){if(t+=1,t>mk)return!1}else if(a===`}`)t=Math.max(0,t-1);else if(a===`&`&&(r+=1,r>gk))return!1}return n<=hk}function sA(e,t){let n=t;for(;n<e.length&&/[A-Za-z@]/u.test(e[n]??``);)n+=1;return n}function cA(e){return[`\\def`,`\\gdef`,`\\edef`,`\\xdef`,`\\let`,`\\newcommand`,`\\renewcommand`,`\\href`,`\\url`,`\\style`,`\\class`,`\\cssId`,`\\bbox`,`\\unicode`,`\\definecolor`].includes(e)}var lA={"\\color":{modelBracket:!0,colorArgs:1},"\\textcolor":{modelBracket:!0,colorArgs:1},"\\colorbox":{modelBracket:!1,colorArgs:1},"\\fcolorbox":{modelBracket:!1,colorArgs:2},"\\rowcolor":{modelBracket:!0,colorArgs:1},"\\cellcolor":{modelBracket:!0,colorArgs:1},"\\columncolor":{modelBracket:!0,colorArgs:1}},uA=/^(?:rgb|RGB|gray)$/u,dA=/^[A-Za-z0-9#%(),.!\s-]+$/u;function fA(e,t,n){let r=lA[t];if(r===void 0)return!0;let i=n,a=!1;if(i=mA(e,i),e[i]===`[`){if(!r.modelBracket)return!1;let t=e.indexOf(`]`,i+1);if(t===-1)return!1;let n=e.slice(i+1,t).trim();a=uA.test(n),i=t+1}for(let t=0;t<r.colorArgs;t+=1){if(i=mA(e,i),e[i]!==`{`)return!1;let t=hA(e,i+1);if(t===-1)return!1;let n=e.slice(i+1,t);if(!a&&!pA(n))return!1;i=t+1}return!0}function pA(e){return e.trim()!==``&&dA.test(e)}function mA(e,t){let n=t;for(;n<e.length&&/\s/u.test(e[n]??``);)n+=1;return n}function hA(e,t){let n=0;for(let r=t;r<e.length;r+=1)if(e[r]===`{`)n+=1;else if(e[r]===`}`){if(n===0)return r;--n}return-1}function gA(e){return e.displayMode?`<p>${yk(e.raw)}</p>`:yk(e.raw)}var _A=class extends Error{constructor(){super(`MathJax has not finished loading yet`),this.name=`MathJaxNotReadyError`}},vA,yA,bA,xA;function SA(){return vA??=cS(()=>import(`./mathjaxEngine-BUb2J-FW.js`).then(e=>{bA=e.mathJaxStyles(),xA=CA(bA);let t=document.createElement(`style`);return t.setAttribute(`data-mathjax-chtml`,``),t.textContent=bA,document.head.append(t),yA=e,e}),[],import.meta.url).catch(e=>{throw console.error(`MathJax failed to load; math will render as literal source.`,e),e}),vA}function CA(e){if(!(typeof CSSStyleSheet!=`function`||typeof CSSStyleSheet.prototype.replaceSync!=`function`))try{let t=new CSSStyleSheet;return t.replaceSync(e),t}catch{return}}function wA(e){if(bA===void 0)return;if(xA!==void 0&&`adoptedStyleSheets`in e){e.adoptedStyleSheets.includes(xA)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,xA]);return}if(e.querySelector(`style[data-mathjax-chtml]`)!==null)return;let t=document.createElement(`style`);t.setAttribute(`data-mathjax-chtml`,``),t.textContent=bA,e.append(t)}function TA(){return yA!==void 0}function EA(){return SA().then(()=>void 0)}function DA(e,t){if(yA===void 0)throw new _A;return yA.convertLatex(e,t.displayMode)}var OA=new V.Renderer;OA.html=({text:e})=>yk(e);var kA=1600,AA=6e6,jA=8,MA=new Map,NA=0,PA=DA;function FA(e,t={}){let n=Sk(e),r=t.cache!==!1&&t.renderMath===void 0&&(!n||TA());if(r){let t=MA.get(e);if(t!==void 0)return MA.delete(e),MA.set(e,t),t.html}let i=RA(t.renderMath!==void 0||Sk(e)?Ck(e,t.renderMath??PA):V.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:OA}));return r&&IA(e,i),i}function IA(e,t){let n=e.length+t.length;if(n>AA/jA)return;let r=MA.get(e);r!==void 0&&(MA.delete(e),NA-=r.chars),MA.set(e,{html:t,chars:n}),NA+=n,LA()}function LA(){for(;MA.size>1&&(MA.size>kA||NA>AA);){let e=MA.entries().next();if(e.done===!0)break;let[t,n]=e.value;MA.delete(t),NA-=n.chars}}function RA(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, iframe, object, embed`).forEach(e=>{e.remove()}),t.content.querySelectorAll(`*`).forEach(e=>{for(let t of[...e.attributes]){let n=t.name.toLowerCase();n.startsWith(`on`)&&e.removeAttribute(t.name),(n===`href`||n===`src`)&&!zA(t.value)&&e.removeAttribute(t.name)}if(e instanceof HTMLElement){let t=e.style.position.trim().toLowerCase();(t===`fixed`||t===`absolute`||t===`sticky`)&&e.removeAttribute(`style`)}e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noreferrer noopener`))}),t.innerHTML}function zA(e){if(e.startsWith(`#`)||e.startsWith(`/`))return!0;try{return[`http:`,`https:`,`mailto:`].includes(new URL(e).protocol)}catch{return!1}}function BA({text:e,live:t}){return t&&(e.length>=24e3||xk(e))}var VA=class extends y{constructor(...e){super(...e),this.text=``,this.live=!1,this.retryMathRender=!1,this.mathRetryScheduled=!1,this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`.code-copy-button`);if(!(t instanceof HTMLButtonElement))return;let n=t.closest(`.code-block-wrapper`);if(!(n instanceof HTMLElement))return;let r=n.querySelector(`pre code`);r instanceof HTMLElement&&this.copyCode(r.textContent,t)}}render(){return BA(this)?g`<div class="formatted plain" dir="auto">${this.text}</div>`:g`<div class="formatted" dir="auto" @click=${this.onFormattedClick}>${uk(this.renderMarkdown())}</div>`}renderMarkdown(){return this.retryMathRender?(this.retryMathRender=!1,FA(this.text,{cache:!1,renderMath:DA})):FA(this.text,{cache:!this.live})}scheduleMathRetry(){this.mathRetryScheduled||TA()||this.live||!xk(this.text)||(this.mathRetryScheduled=!0,EA().then(()=>{this.retryMathRender=!0,this.requestUpdate()}).catch(()=>{}))}updated(){this.enhanceCodeBlocks(),xk(this.text)&&this.renderRoot instanceof ShadowRoot&&wA(this.renderRoot),this.scheduleMathRetry()}enhanceCodeBlocks(){this.renderRoot.querySelectorAll(`pre`).forEach(e=>{if(!(e instanceof HTMLPreElement)||e.parentElement?.classList.contains(`code-block-wrapper`)===!0||!(e.querySelector(`code`)instanceof HTMLElement))return;let t=document.createElement(`div`);t.className=`code-block-wrapper`;let n=document.createElement(`button`);n.type=`button`,n.className=`code-copy-button`,n.title=`Copy code block`,n.setAttribute(`aria-label`,`Copy code block`);let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),r.textContent=`⧉`,n.append(r),e.before(t),t.append(e,n)})}async copyCode(e,t){let n=await mO(e);this.setCopyButtonState(t,n?`copied`:`failed`),window.setTimeout(()=>{this.setCopyButtonState(t,`idle`)},1200)}setCopyButtonState(e,t){let n=e.querySelector(`span`);n!==null&&(n.textContent=t===`copied`?`✓`:`⧉`);let r=t===`copied`?`Copied code block`:t===`failed`?`Failed to copy code block`:`Copy code block`;e.title=r,e.setAttribute(`aria-label`,r)}static{this.styles=[eS,h`
2866
+ `)}}if(Mk(i)||(a.push(i),s+=i.length+ +(a.length>1),s>dk)||t<0)return;o=t+1}}function kk(e){let t=/^( {0,3})(\$\$|\\\[)([ \t]*)$/u.exec(e);if(t!==null){let e=t[2];return e!==`$$`&&e!==`\\[`?void 0:{delimiter:e,delimiterEnd:t[0].length}}let n=/^( {0,3})(\$\$|\\\[)/u.exec(e);if(n===null)return;let r=n[2];if(!(r!==`$$`&&r!==`\\[`))return{delimiter:r,delimiterEnd:n[0].length}}function Ak(e,t){return RegExp(`^ {0,3}${t===`$$`?`\\$\\$`:`\\\\\\]`}[ \\t]*$`,`u`).test(e)}function jk(e,t){let n=t===`$$`?`$$`:`\\]`,r=e.slice(0,dk+n.length),i=0;for(;i<r.length;){let t=r.indexOf(n,i);if(t<0||t>dk)return-1;if(/^[ \t]*$/u.test(e.slice(t+n.length)))return t;i=t+n.length}return-1}function Mk(e){return/^ {0,3}(?:```|~~~)/u.test(e)}function Nk(e){return Pk(e),e}function Pk(e){for(let t of e)Fk(t)}function Fk(e){if(Rk(e,`paragraph`)||Rk(e,`heading`)){e.tokens=Lk(e.tokens);return}if(Rk(e,`blockquote`)){Pk(e.tokens);return}if(Rk(e,`list`)){for(let t of e.items)Pk(t.tokens);return}if(Rk(e,`list_item`)){Ik(e.tokens);return}if(Rk(e,`text`)&&e.tokens!==void 0){e.tokens=Lk(e.tokens);return}if(Rk(e,`table`)){for(let t of e.header)t.tokens=Lk(t.tokens);for(let t of e.rows)for(let e of t)e.tokens=Lk(e.tokens)}}function Ik(e){for(let t of e)Rk(t,`text`)&&t.tokens!==void 0?t.tokens=Lk(t.tokens):Fk(t)}function Lk(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===void 0)break;if(zk(r)){let r=[];for(;n<e.length;){let t=e[n];if(t===void 0||!zk(t))break;r.push(t),n+=1}t.push(...Bk(r));continue}(Rk(r,`em`)||Rk(r,`strong`)||Rk(r,`del`)||Rk(r,`text`)&&r.tokens!==void 0)&&(r.tokens=Lk(r.tokens)),t.push(r),n+=1}return t}function Rk(e,t){return e.type===t}function zk(e){return Rk(e,`escape`)||Rk(e,`text`)&&e.tokens===void 0}function Bk(e){let t=e.map(e=>e.raw).join(``);if(!Sk(t))return e;let n=Uk(t);if(n.length===0)return e;let r=Vk(e),i={index:0},a=[],o=0;for(let e of n){Hk(a,r,i,o,e.start);let n=t.slice(e.start,e.end);e.kind===`math`?a.push({type:e.displayMode===!0?`latex-display`:`latex-inline`,raw:n,tex:e.tex??``,displayMode:e.displayMode===!0}):a.push({type:`latex-inline-literal`,raw:n}),o=e.end}return Hk(a,r,i,o,t.length),a}function Vk(e){let t=[],n=0;for(let r of e){let e=n+r.raw.length;t.push({token:r,start:n,end:e}),n=e}return t}function Hk(e,t,n,r,i){if(!(r>=i)){for(;n.index<t.length;){let e=t[n.index];if(e===void 0||e.end>r)break;n.index+=1}for(;n.index<t.length;n.index+=1){let a=t[n.index];if(a===void 0||a.start>=i)break;let o=Math.max(r,a.start)-a.start,s=Math.min(i,a.end)-a.start;if(o===0&&s===a.token.raw.length)e.push(a.token);else{let t=a.token.raw.slice(o,s),n=a.token.text.slice(o,s);e.push({type:`text`,raw:t,text:n.length===t.length?n:t,escaped:a.token.type===`text`&&a.token.escaped})}if(a.end>i)break}}}function Uk(e){let t={head:void 0,tail:void 0},n=0,r,i,a,o,s=!1,c=!1;for(let l=0;l<e.length;l+=1){r=qk(r),i=qk(i),a=qk(a),o=qk(o),r!==void 0&&l-r.start-1>dk&&(Gk(t,r.placeholder),r=void 0,s=!0),i!==void 0&&l-i.start-2>dk&&(Gk(t,i.placeholder),i=void 0,c=!0),a!==void 0&&l-a.start-2>dk&&(a=void 0),o!==void 0&&l-o.start-2>dk&&(o=void 0);let u=e[l];if(u===`\\`){if(n+=1,n%2==1){let n=e[l+1];if(n===`(`||n===`)`||n===`[`||n===`]`){let r=Wk(t,l,l+2,`literal`);if(n===`(`)a??={start:l,placeholder:r};else if(n===`)`&&a!==void 0){let n=e.slice(a.start+2,l);n.length<=dk&&n.length>0&&n.trim()!==``&&!/\s/u.test(n[0]??``)&&!/\s/u.test(n.at(-1)??``)&&Zk(e,a.start)&&Qk(e,l+2)&&Kk(t,a.placeholder,l+2,`math`,n,!1),a=void 0}else if(n===`[`)o??={start:l,placeholder:r};else if(n===`]`&&o!==void 0){let n=e.slice(o.start+2,l);n.length<=dk&&n.length>0&&n.trim()!==``&&Kk(t,o.placeholder,l+2,`literal`),o=void 0}}}continue}if(u===`$`){let a=n%2==1;if(e[l+1]===`$`){if(!a){if(i===void 0&&!c)i={start:l,placeholder:Wk(t,l,l+2,`literal`)};else if(i!==void 0){let n=e.slice(i.start+2,l);n.length<=dk&&n.trim()!==``?Kk(t,i.placeholder,l+2,`literal`):(Gk(t,i.placeholder),n.length>dk&&(c=!0)),i=void 0}}l+=1,n=0;continue}if(!a&&!s)if(r===void 0)Yk(e,l)&&(r={start:l,placeholder:Wk(t,l,l+1,`literal`)});else{let n=e.slice(r.start+1,l);Xk(e,r.start,l,n)?(Kk(t,r.placeholder,l+1,`math`,n,!1),r=void 0):(Gk(t,r.placeholder),r=void 0,Yk(e,l)&&(r={start:l,placeholder:Wk(t,l,l+1,`literal`)}))}n=0;continue}n=0}return r!==void 0&&Gk(t,r.placeholder),i!==void 0&&Gk(t,i.placeholder),tA(Jk(t))}function Wk(e,t,n,r){let i={start:t,end:n,kind:r,linked:!0,previous:e.tail,next:void 0};return e.tail===void 0?e.head=i:e.tail.next=i,e.tail=i,i}function Gk(e,t){t.linked&&=(t.previous===void 0?e.head=t.next:t.previous.next=t.next,t.next===void 0?e.tail=t.previous:t.next.previous=t.previous,t.previous=void 0,t.next=void 0,!1)}function Kk(e,t,n,r,i,a){let o=t.next;for(;o!==void 0&&o.start<n;){let t=o.next;Gk(e,o),o=t}t.end=n,t.kind=r,i===void 0?delete t.tex:t.tex=i,a===void 0?delete t.displayMode:t.displayMode=a}function qk(e){return e?.placeholder.linked===!0?e:void 0}function Jk(e){let t=[];for(let n=e.head;n!==void 0;n=n.next){let e={start:n.start,end:n.end,kind:n.kind};n.tex!==void 0&&(e.tex=n.tex),n.displayMode!==void 0&&(e.displayMode=n.displayMode),t.push(e)}return t}function Yk(e,t){let n=e[t+1];return Zk(e,t)&&n!==void 0&&!/\s/u.test(n)}function Xk(e,t,n,r){return n>t+1&&r.length>0&&!/\s/u.test(r.at(-1)??``)&&Qk(e,n+1)}function Zk(e,t){if(t<=0)return!0;let n=t-1,r=eA(e.charCodeAt(n))?n-1:n;return $k(e.codePointAt(r))}function Qk(e,t){return $k(e.codePointAt(t))}function $k(e){return e===void 0||/[\s\p{P}\p{S}]/u.test(String.fromCodePoint(e))}function eA(e){return e>=56320&&e<=57343}function tA(e){let t=[];for(let n of e){let e=t.at(-1);e?.kind===`literal`&&n.kind===`literal`&&e.end===n.start?e.end=n.end:t.push({...n})}return t}function nA(e,t,n){if(e.type===`latex-inline-literal`)return yk(e.raw);if(e.type===`latex-block-literal`)return`<p>${yk(e.raw)}</p>`;let r=rA(e);if(r===void 0)return``;if(!iA(r.tex,t))return gA(r);let i;try{i=n(r.tex,{displayMode:r.displayMode})}catch{return gA(r)}if(!aA(i,t))return gA(r);let a=`aria-label="${bk(r.tex)}"`;return r.displayMode?`<div class="math-display" role="img" ${a}>${i}</div>`:`<span class="math-inline" role="img" ${a}>${i}</span>`}function rA(e){if(e.type!==`latex-inline`&&e.type!==`latex-display`)return;let t=e,n=t.tex,r=t.displayMode;if(!(typeof n!=`string`||typeof r!=`boolean`))return{type:e.type,raw:e.raw,tex:n,displayMode:r}}function iA(e,t){return t.outputAdmissionClosed||e.length>fk||t.mathSourceUnits+e.length>pk||!oA(e)?!1:(t.mathSourceUnits+=e.length,!0)}function aA(e,t){return e.length>vk||t.mathOutputUnits+e.length>_k?(t.outputAdmissionClosed=!0,!1):(t.mathOutputUnits+=e.length,!0)}function oA(e){let t=0,n=0,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`\\`){let t=i;for(;t<e.length&&e[t]===`\\`;)t+=1;let a=t-i;if(a>=2&&(r+=Math.floor(a/2)),r>gk)return!1;if(a%2==1){let r=e[t];if(/[A-Za-z@]/u.test(r??``)){n+=1;let r=sA(e,t),a=e.slice(t-1,r);if(cA(a)||!fA(e,a,r))return!1;i=r-1}else i=t}else i=t-1;continue}if(a===`{`){if(t+=1,t>mk)return!1}else if(a===`}`)t=Math.max(0,t-1);else if(a===`&`&&(r+=1,r>gk))return!1}return n<=hk}function sA(e,t){let n=t;for(;n<e.length&&/[A-Za-z@]/u.test(e[n]??``);)n+=1;return n}function cA(e){return[`\\def`,`\\gdef`,`\\edef`,`\\xdef`,`\\let`,`\\newcommand`,`\\renewcommand`,`\\href`,`\\url`,`\\style`,`\\class`,`\\cssId`,`\\bbox`,`\\unicode`,`\\definecolor`].includes(e)}var lA={"\\color":{modelBracket:!0,colorArgs:1},"\\textcolor":{modelBracket:!0,colorArgs:1},"\\colorbox":{modelBracket:!1,colorArgs:1},"\\fcolorbox":{modelBracket:!1,colorArgs:2},"\\rowcolor":{modelBracket:!0,colorArgs:1},"\\cellcolor":{modelBracket:!0,colorArgs:1},"\\columncolor":{modelBracket:!0,colorArgs:1}},uA=/^(?:rgb|RGB|gray)$/u,dA=/^[A-Za-z0-9#%(),.!\s-]+$/u;function fA(e,t,n){let r=lA[t];if(r===void 0)return!0;let i=n,a=!1;if(i=mA(e,i),e[i]===`[`){if(!r.modelBracket)return!1;let t=e.indexOf(`]`,i+1);if(t===-1)return!1;let n=e.slice(i+1,t).trim();a=uA.test(n),i=t+1}for(let t=0;t<r.colorArgs;t+=1){if(i=mA(e,i),e[i]!==`{`)return!1;let t=hA(e,i+1);if(t===-1)return!1;let n=e.slice(i+1,t);if(!a&&!pA(n))return!1;i=t+1}return!0}function pA(e){return e.trim()!==``&&dA.test(e)}function mA(e,t){let n=t;for(;n<e.length&&/\s/u.test(e[n]??``);)n+=1;return n}function hA(e,t){let n=0;for(let r=t;r<e.length;r+=1)if(e[r]===`{`)n+=1;else if(e[r]===`}`){if(n===0)return r;--n}return-1}function gA(e){return e.displayMode?`<p>${yk(e.raw)}</p>`:yk(e.raw)}var _A=class extends Error{constructor(){super(`MathJax has not finished loading yet`),this.name=`MathJaxNotReadyError`}},vA,yA,bA,xA;function SA(){return vA??=cS(()=>import(`./mathjaxEngine-GogjYyEz.js`).then(e=>{bA=e.mathJaxStyles(),xA=CA(bA);let t=document.createElement(`style`);return t.setAttribute(`data-mathjax-chtml`,``),t.textContent=bA,document.head.append(t),yA=e,e}),[],import.meta.url).catch(e=>{throw console.error(`MathJax failed to load; math will render as literal source.`,e),e}),vA}function CA(e){if(!(typeof CSSStyleSheet!=`function`||typeof CSSStyleSheet.prototype.replaceSync!=`function`))try{let t=new CSSStyleSheet;return t.replaceSync(e),t}catch{return}}function wA(e){if(bA===void 0)return;if(xA!==void 0&&`adoptedStyleSheets`in e){e.adoptedStyleSheets.includes(xA)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,xA]);return}if(e.querySelector(`style[data-mathjax-chtml]`)!==null)return;let t=document.createElement(`style`);t.setAttribute(`data-mathjax-chtml`,``),t.textContent=bA,e.append(t)}function TA(){return yA!==void 0}function EA(){return SA().then(()=>void 0)}function DA(e,t){if(yA===void 0)throw new _A;return yA.convertLatex(e,t.displayMode)}var OA=new V.Renderer;OA.html=({text:e})=>yk(e);var kA=1600,AA=6e6,jA=8,MA=new Map,NA=0,PA=DA;function FA(e,t={}){let n=Sk(e),r=t.cache!==!1&&t.renderMath===void 0&&(!n||TA());if(r){let t=MA.get(e);if(t!==void 0)return MA.delete(e),MA.set(e,t),t.html}let i=RA(t.renderMath!==void 0||Sk(e)?Ck(e,t.renderMath??PA):V.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:OA}));return r&&IA(e,i),i}function IA(e,t){let n=e.length+t.length;if(n>AA/jA)return;let r=MA.get(e);r!==void 0&&(MA.delete(e),NA-=r.chars),MA.set(e,{html:t,chars:n}),NA+=n,LA()}function LA(){for(;MA.size>1&&(MA.size>kA||NA>AA);){let e=MA.entries().next();if(e.done===!0)break;let[t,n]=e.value;MA.delete(t),NA-=n.chars}}function RA(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, iframe, object, embed`).forEach(e=>{e.remove()}),t.content.querySelectorAll(`*`).forEach(e=>{for(let t of[...e.attributes]){let n=t.name.toLowerCase();n.startsWith(`on`)&&e.removeAttribute(t.name),(n===`href`||n===`src`)&&!zA(t.value)&&e.removeAttribute(t.name)}if(e instanceof HTMLElement){let t=e.style.position.trim().toLowerCase();(t===`fixed`||t===`absolute`||t===`sticky`)&&e.removeAttribute(`style`)}e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noreferrer noopener`))}),t.innerHTML}function zA(e){if(e.startsWith(`#`)||e.startsWith(`/`))return!0;try{return[`http:`,`https:`,`mailto:`].includes(new URL(e).protocol)}catch{return!1}}function BA({text:e,live:t}){return t&&(e.length>=24e3||xk(e))}var VA=class extends y{constructor(...e){super(...e),this.text=``,this.live=!1,this.retryMathRender=!1,this.mathRetryScheduled=!1,this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`.code-copy-button`);if(!(t instanceof HTMLButtonElement))return;let n=t.closest(`.code-block-wrapper`);if(!(n instanceof HTMLElement))return;let r=n.querySelector(`pre code`);r instanceof HTMLElement&&this.copyCode(r.textContent,t)}}render(){return BA(this)?g`<div class="formatted plain" dir="auto">${this.text}</div>`:g`<div class="formatted" dir="auto" @click=${this.onFormattedClick}>${uk(this.renderMarkdown())}</div>`}renderMarkdown(){return this.retryMathRender?(this.retryMathRender=!1,FA(this.text,{cache:!1,renderMath:DA})):FA(this.text,{cache:!this.live})}scheduleMathRetry(){this.mathRetryScheduled||TA()||this.live||!xk(this.text)||(this.mathRetryScheduled=!0,EA().then(()=>{this.retryMathRender=!0,this.requestUpdate()}).catch(()=>{}))}updated(){this.enhanceCodeBlocks(),xk(this.text)&&this.renderRoot instanceof ShadowRoot&&wA(this.renderRoot),this.scheduleMathRetry()}enhanceCodeBlocks(){this.renderRoot.querySelectorAll(`pre`).forEach(e=>{if(!(e instanceof HTMLPreElement)||e.parentElement?.classList.contains(`code-block-wrapper`)===!0||!(e.querySelector(`code`)instanceof HTMLElement))return;let t=document.createElement(`div`);t.className=`code-block-wrapper`;let n=document.createElement(`button`);n.type=`button`,n.className=`code-copy-button`,n.title=`Copy code block`,n.setAttribute(`aria-label`,`Copy code block`);let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),r.textContent=`⧉`,n.append(r),e.before(t),t.append(e,n)})}async copyCode(e,t){let n=await mO(e);this.setCopyButtonState(t,n?`copied`:`failed`),window.setTimeout(()=>{this.setCopyButtonState(t,`idle`)},1200)}setCopyButtonState(e,t){let n=e.querySelector(`span`);n!==null&&(n.textContent=t===`copied`?`✓`:`⧉`);let r=t===`copied`?`Copied code block`:t===`failed`?`Failed to copy code block`:`Copy code block`;e.title=r,e.setAttribute(`aria-label`,r)}static{this.styles=[eS,h`
2863
2867
  .formatted.plain { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
2864
2868
  .math-inline { display: inline-block; max-width: 100%; overflow-x: auto; vertical-align: -0.25em; }
2865
2869
  .math-display { display: block; max-width: 100%; overflow-x: auto; margin: 10px 0; }
@@ -7417,7 +7421,7 @@ This will delete every archived session on this machine regardless of age or cle
7417
7421
  .git-update-manager-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(190px, 40%) minmax(0, 1fr); }
7418
7422
  .git-update-manager-entries { border-right: 0; border-bottom: 1px solid var(--pi-border); }
7419
7423
  }
7420
- `}};H([x({attribute:!1})],DV.prototype,`onClose`,void 0),H([x({attribute:!1})],DV.prototype,`onStatusChange`,void 0),H([x({attribute:!1})],DV.prototype,`workspace`,void 0),H([x()],DV.prototype,`machineId`,void 0),H([x({attribute:!1})],DV.prototype,`api`,void 0),H([S()],DV.prototype,`status`,void 0),H([S()],DV.prototype,`selectedChange`,void 0),H([S()],DV.prototype,`selectedDiff`,void 0),H([S()],DV.prototype,`loadingStatus`,void 0),H([S()],DV.prototype,`loadingDiff`,void 0),H([S()],DV.prototype,`error`,void 0),H([S()],DV.prototype,`bounds`,void 0),DV=H([b(`git-update-manager-panel`)],DV);function OV(){cS(()=>import(`./UnifiedDiffViewer-xek-ZrBA.js`),[],import.meta.url)}function kV(e,t){let n=Gd(e.files);return[...n.staged,...n.unstaged].find(e=>e.id===t)}function AV(e){return e===`staged`?`Staged`:`Unstaged`}function jV(e,t){return e===void 0?void 0:JSON.stringify([t,e.projectId,e.id])}function MV(e){return e instanceof Error?e.message:String(e)}var NV=900*1e3,PV=750,FV=[1e3,3e3,8e3,15e3,3e4],IV={capture:!0},LV=`auto:on`,RV=`auto:off`,zV=`theme:`,BV=_d(`core:workspace.files`),VV=_d(`core:workspace.git`),HV=_d(`core:workspace.terminal`),UV=`workspace-memory`,WV=`workspace.memory`,GV=`workspace-memory:workspace.memory`,KV=`workspace-learned-skills`,qV=`workspace.learned-skills`,JV=`workspace-learned-skills:workspace.learned-skills`,YV=`workspace-tasks`,XV=`workspace.tasks`,ZV=320,QV=2,$V=`(min-width: 1181px)`,eH=75,tH=`Could not remember this model policy; this session still uses it.`,$=class extends y{constructor(e={}){super(),this.state=id(),this.sessionUnread=new Yb({onChange:e=>{R(this.state)===e&&(this.syncUnreadSessionIds(),this.syncSelectedSessionReadState())},onBackgroundError:(e,t,n)=>{console.warn(`Failed to ${e} session unread state for ${t}`,n)}}),this.unreadSessionIds=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions),this.unreadConnected=!1,this.notifications=new Lg(()=>this.state,e=>{this.setState(e)},{onBackgroundError:(e,t)=>{console.warn(e,t)}}),this.hostSpeech=new Ug({onStateChange:()=>{this.hostSpeechSurfaceVisible()&&this.requestUpdate()}}),this.sessions=new Rh(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new bh,{refreshProjectSessionCatalog:()=>this.projectCatalog.refresh(),notifications:this.notifications,onSelectedSessionReady:({machineId:e,session:t})=>{this.commitReadyChatAfterRender(e,t)},replacePromptEditorText:async({machineId:e,sessionId:t,text:n})=>{await this.updateComplete,!(R(this.state)!==e||this.state.selectedSession?.id!==t)&&this.promptEditor?.replaceText(n)},onStarterModelPolicyConfirmed:e=>{this.handleStarterModelPolicyConfirmed(e)}}),this.workspaces=new Uv(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new Vv,{onBackgroundError:(e,t)=>{console.warn(`Failed to ${e}`,t)}}),this.projectCatalog=new cf(()=>this.state,{workspaces:bc.workspaces,applySnapshot:async e=>{await this.workspaces.reconcileProjectCatalog(e)},captureTopologyRequest:e=>this.workspaces.captureProjectCatalogTopologyRequest(e),onBackgroundError:(e,t)=>{console.warn(`Failed to ${e}`,t)}}),this.projectActivityOwnership=new yf(()=>this.state,e=>{this.setState(e)},{api:bc,captureTopologyRequest:e=>this.workspaces.captureProjectCatalogTopologyRequest(e),onProjectTopology:async e=>{let t=this.state.projects.find(t=>t.id===e.projectId&&t.path===e.projectPath);t!==void 0&&await this.workspaces.reconcileProjectCatalog({machineId:e.machineId,project:t,workspaces:e.workspaces,...e.topologyRequest===void 0?{}:{topologyRequest:e.topologyRequest}})},onError:({machineId:e,projectId:t,error:n})=>{console.warn(`Failed to discover project activity ownership for ${t} on ${e}`,n)}}),this.activity=new ud(()=>this.state,e=>{this.setState(e)},{onActivityApplied:e=>{this.projectActivityOwnership.handleActivityApplied(e)}}),this.auth=new md(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.projects=new rf(()=>this.state,e=>{this.setState(e)},this.workspaces,{onProjectsApplied:e=>{this.projectActivityOwnership.handleProjectsApplied(e),this.recentProjects.load()}}),this.machines=new $d(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.piWebUiStatusController=new xf(()=>this.state,e=>{this.setState(e)},{onRefreshError:(e,t)=>{console.warn(`Failed to refresh PI WEBUI status for ${e}`,t)}}),this.files=new Ad(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new Id(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.memory=new Ud(()=>this.state,e=>{this.setState(e)}),this.learnedSkills=new zd(()=>this.state,e=>{this.setState(e)}),this.recentProjects=new uf({machineId:()=>R(this.state),onChange:()=>{this.requestUpdate()},onBackgroundError:(e,t)=>{console.warn(`Failed to ${e}`,t)}}),this.keyboard=new Zy,this.realtime=new Rm,this.machineRealtimeSockets=new Map,this.unreadRuntimeRefreshes=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new Ny,this.terminalSelection=new Ky,this.appShell=new RC(this),this.browserResume=new VC({onResumeSignal:()=>{this.handleBrowserResumeSignal()},refreshAfterResume:()=>this.refreshAfterBrowserResume(),onRefreshError:e=>{console.warn(`Failed to refresh after browser resume`,e)}}),this.speechInputSettingsConnected=!1,this.speechInputSettingsRequestSeq=0,this.isSpeechInputSettingsRequestCurrent=e=>this.speechInputSettingsConnected&&e===this.speechInputSettingsRequestSeq,this.speechInputSettingsChannelDispatchQueued=!1,this.speechInputSettingsChannelRefreshInFlight=!1,this.panelCollapse=new lw(this),this.panelResize=new pw(this),this.navigationSections=new ow(this,()=>this.state,()=>this.appShell.isMobileNavigationLayout),this.systemLightThemeMedia=typeof window<`u`&&`matchMedia`in window?window.matchMedia(`(prefers-color-scheme: light)`):void 0,this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.machineNavigationRestoreSeq=0,this.navigationSelectionSeq=0,this.routeRestoreSeq=0,this.routeRestoreDepth=0,this.remoteRouteRestoreAttempt=0,this.remoteRouteRestoreInProgress=!1,this.plugins=nH(),this.reportActivityRailError=(e,t,n)=>{console.warn(`Plugin activity rail contribution failed`,e,t,n)},this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=_x()??px,this.activeThemeId=fx,this.isRefreshingApp=!1,this.recentProjectDialogInitialView=`closed-actions`,this.recentProjectDialogGeneration=0,this.starterSessionDefaultsSeq=0,this.starterModelPolicyPreferenceReadError=``,this.starterModelPolicyPreferenceWriter=new Cb({save:async(e,t)=>{let n=await xc.updateSessionDefaults(e.cwd,{starterModelPolicyPreference:t},e.machineId),r=this.starterModelPolicyPreferenceScope();return r?.machineId===e.machineId&&r.cwd===e.cwd&&(this.starterModelPolicyPreferenceReadError=``),n},onStateChange:()=>{this.requestUpdate()}}),this.confirmedStarterModelPolicyPreferenceWriter=new Ob({remember:(e,t)=>xc.rememberCurrentModelPolicy(t,e.machineId),onStateChange:(e,t)=>{this.starterModelPolicyPreferenceScopeMatchesCurrentSelection(e)&&this.confirmedStarterModelPolicyUiGeneration===this.starterModelPolicySelectionGeneration&&(!t.saving&&t.error===void 0&&(this.starterModelPolicyPreferenceReadError=``),this.requestUpdate())}}),this.starterModelPolicySelectionGeneration=0,this.modelTierCatalogLoading=!1,this.modelTierCatalogError=``,this.activeModelPolicyApplyGeneration=0,this.modelTierCatalogSeq=0,this.modelsConfigDialogOpen=!1,this.projectBrowserOpen=!1,this.statisticsLoading=!1,this.statisticsRequestGeneration=0,this.sessionBrowserOpen=!1,this.skillsConfigDialogOpen=!1,this.pluginsConfigDialogOpen=!1,this.systemPromptDialogOpen=!1,this.gitUpdateManagerPanelOpen=!1,this.terminalModalOpen=!1,this.terminalModalMaximized=!1,this.initialTerminalModalPreferences=iT(),this.terminalModalFontSize=this.initialTerminalModalPreferences.fontSize,this.terminalModalOpacity=this.initialTerminalModalPreferences.opacity,this.initialWorkspaceTabVisibility=fT(),this.terminalTabHidden=this.initialWorkspaceTabVisibility.terminalHidden,this.infoTabHidden=this.initialWorkspaceTabVisibility.infoHidden,this.railOrder=yV()??[...pV],this.compactRailOpen=!1,this.activeActivityRailGeneration=0,this.settingsSection=Pw(),this.shortcutConfig={},this.workspaceUploadDefaultFolder=Kl(void 0),this.sessionWarningVisibility=rx(),this.onPopState=()=>void this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)}),this.onPageShow=()=>{this.renegotiateUnreadMachines(),this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onTerminalModalViewportResize=()=>{this.terminalModalBounds!==void 0&&(this.terminalModalBounds=Zw(this.terminalModalBounds,this.terminalModalViewport()))},this.onKeyDown=e=>{if(e.key===`Escape`&&this.promptEditor?.cancelSpeechInput()===!0){e.preventDefault(),e.stopPropagation();return}this.compactRailOpen||this.activeActivityRailId!==void 0||this.settingsSection!==void 0||this.state.treeDialog!==void 0||this.state.actionPaletteOpen||this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())},this.closeCompactActivityRail=()=>{if(!this.compactRailOpen)return;this.compactRailOpen=!1;let e=this.compactActivityRailLauncher;this.updateComplete.then(()=>{!this.compactRailOpen&&this.activeActivityRailId===void 0&&(e===void 0?this.currentCompactActivityRailLauncher()?.focus():this.restoreActivityRailFocus(e))})},this.toggleCompactActivityRail=e=>{this.appShell.isDesktopActivityRailLayout||(!this.compactRailOpen&&e!==void 0&&(this.compactActivityRailLauncher=e),this.compactRailOpen=!this.compactRailOpen)},this.handleSendPrompt=(e,t,n,r)=>{this.sendPrompt(e,t,n,r)},this.handleStartSessionPrompt=(e,t,n,r)=>{if(!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e))return;if(this.starterModelPolicyBlocksStart()){let e=this.starterNoticeScope();e!==void 0&&this.publishStarterNotice(Ku(e));return}this.starterNotice=void 0;let i=this.state.selectedWorkspace?.id,a=R(this.state),o=this.selectedProjectWorkTarget(a),s=this.starterModelPolicy,c=this.starterPlusModelPolicyInitializer();this.starterModelPolicySelectionSupported(a)&&c===void 0||((c===void 0?this.sessions.startSessionWithPrompt(e,t,n,r,this.starterModelPolicyStartSnapshot(),e=>{this.clearStarterModelPolicyAfterSuccessfulStart(e,i,s)}):this.sessions.startPlusSessionWithPrompt(e,t,n,r??`inline`,c,()=>void 0)).then(e=>{e&&this.recordProjectWork(o)}).catch(e=>{i!==void 0&&this.publishStarterNotice(qu(`start-failed`,`Could not start the session. ${NH(e)}`,{machineId:a,workspaceId:i}))}),this.focusChatComposer())},this.handleSelectStarterModel=()=>{this.openStarterModelDialog()},this.handleSelectStarterThinking=()=>{this.openStarterThinkingDialog()},this.handleSelectStarterPolicyMode=async e=>{let t=this.starterModelPolicy;if(t===void 0||t.mode===e)return;if(this.starterModelPolicySelectionSupported()){let n=e===`exact`?xu(t):t.tier===void 0?{...t,mode:`tiered`}:bu(t,t.tier);this.setStarterModelPolicyDraft(n),this.ensureModelTierCatalog(R(this.state));return}if(e===`exact`){let e=xu(t);this.setStarterModelPolicyDraft(e);let n=this.starterSessionDefaults,r=n===void 0?void 0:hu(n);r!==void 0&&yu(e.exact,r)&&this.persistStarterModelPolicyPreference(e);return}let n=t.tier===void 0?{...t,mode:`tiered`}:bu(t,t.tier),r=this.setStarterModelPolicyDraft(n);if(n.tier===void 0){this.ensureModelTierCatalog(R(this.state));return}let i=await this.ensureStarterModelPolicyCatalog();this.starterModelPolicy!==r||i===void 0||wu(r,i)!==void 0&&this.persistStarterModelPolicyPreference(r)},this.handleSelectStarterPolicyTier=async e=>{let t=this.starterModelPolicy,n=await this.ensureStarterModelPolicyCatalog();if(t===void 0||t!==this.starterModelPolicy||n===void 0)return;let r=bu(t,e);if(this.starterModelPolicySelectionSupported()){this.setStarterModelPolicyDraft(r);return}wu(r,n)!==void 0&&(this.setStarterModelPolicyDraft(r),this.persistStarterModelPolicyPreference(r))},this.handleSelectStarterPolicyThinking=async e=>{await this.pickStarterThinking(e)},this.handleSelectActivePolicyMode=async e=>{let t=await this.prepareActiveModelPolicyDraft();if(!(t===void 0||t!==this.activeModelPolicyDraftForState(this.state)||t.mode===e)){if(this.cancelActiveModelPolicyApply(),e===`exact`){this.setActiveModelPolicyDraft(xu(t)),this.scheduleActiveExactModelPolicyApply();return}if(t.tier===void 0){this.setActiveModelPolicyDraft({...t,mode:`tiered`});return}this.setActiveModelPolicyDraft(bu(t,t.tier)),await this.applyActiveModelPolicyDraft()}},this.handleSelectActivePolicyTier=async e=>{let t=await this.prepareActiveModelPolicyDraft();if(t===void 0||t!==this.activeModelPolicyDraftForState(this.state))return;this.cancelActiveModelPolicyApply();let n=bu(t,e);this.setActiveModelPolicyDraft(n),await this.applyActiveModelPolicyDraft()},this.handleSelectActivePolicyThinking=async e=>{await this.pickThinking(e)},this.handleOpenTerminalFromRail=()=>{this.closeCompactActivityRail(),this.state.selectedWorkspace!==void 0&&(this.terminalModalOpen=!0)},this.handleOpenGitUpdateManagerFromRail=()=>{this.closeCompactActivityRail(),this.state.selectedWorkspace!==void 0&&(this.gitUpdateManagerPanelOpen=!0)},this.handleCloseGitUpdateManagerPanel=()=>{this.gitUpdateManagerPanelOpen=!1},this.handleOpenThemeFromRail=()=>{this.closeCompactActivityRail(),this.openThemeDialog()},this.handleRailOrderChange=e=>{this.railOrder=e,bV(e)},this.handleCloseTerminalModal=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalOpen=!1},this.toggleTerminalModalMaximized=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalMaximized=!this.terminalModalMaximized},this.handleTerminalModalMovePointerDown=e=>{this.startTerminalModalPointerInteraction(`move`,e)},this.handleTerminalModalResizePointerDown=e=>{this.startTerminalModalPointerInteraction(`resize`,e)},this.handleTerminalModalPointerMove=e=>{let t=this.terminalModalPointerInteraction;if(t?.pointerId!==e.pointerId)return;e.preventDefault();let n={x:e.clientX-t.startClientX,y:e.clientY-t.startClientY},r=this.terminalModalViewport();this.terminalModalBounds=t.operation===`move`?Yw(t.bounds,n,r):Xw(t.bounds,n,r)},this.handleTerminalModalPointerUp=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&(e.preventDefault(),this.finishTerminalModalPointerInteraction())},this.handleTerminalModalPointerCancel=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&this.finishTerminalModalPointerInteraction()},this.adjustTerminalFontSize=e=>{let t=nT(this.terminalModalFontSize+e);t!==this.terminalModalFontSize&&(this.terminalModalFontSize=t,this.persistTerminalModalPreferences())},this.adjustTerminalOpacity=e=>{let t=rT(this.terminalModalOpacity+e);t!==this.terminalModalOpacity&&(this.terminalModalOpacity=t,this.persistTerminalModalPreferences())},this.handleStopActiveWork=()=>{this.sessions.stopActiveWork()},this.handleCompact=()=>{this.sessions.runCommand(`/compact`)},this.handleToggleHostSpeech=e=>{let t=this.state.selectedSession;if(t===void 0||R(this.state)!==`local`)return;let n=this.hostSpeech.snapshot.active;if(n?.sessionId===t.id&&n.messageKey===e.messageKey){this.hostSpeech.stop();return}this.hostSpeech.startManual({machineId:`local`,sessionId:t.id,messageKey:e.messageKey,text:e.text})},this.handleClearServerQueue=()=>{this.sessions.clearServerQueue()},this.handleEditFromHere=async(e,t)=>{let n=R(this.state),r=this.state.selectedSession?.id;try{!(await this.sessions.editFromHere(e,t)).cancelled&&r!==void 0&&R(this.state)===n&&this.state.selectedSession?.id===r&&await this.focusChatComposer()}catch{}},this.handleForkFromHere=async e=>{await this.sessions.forkFromHere(e)},this.handleDismissWarning=e=>{this.sessions.dismissWarning(e)},this.handleDismissNotification=e=>{this.notifications.dismissNotification(e)},this.handleDismissAllNotifications=()=>{this.notifications.dismissAll()},this.handleToggleWarnings=()=>{let e=cx(this.sessionWarningVisibility);e!==this.sessionWarningVisibility&&(this.sessionWarningVisibility=e,this.requestUpdate())},this.handleSelectModel=()=>{this.openModelDialog()},this.handleSelectThinking=()=>{this.openThinkingDialog()},this.speechInputSettingsApi=e.speechInputApi??Gs,this.createSpeechInputSettingsChannel=e.createSpeechInputSettingsChannel??(e=>new qC(e)),this.workspaceTasks=(e.createWorkspaceTasksController??(e=>new iy(e)))({selectedScope:()=>bH(this.state),onChange:()=>{this.requestUpdate()}})}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute(`pwa-display-mode`,this.appShell.isPwaDisplayMode),this.syncSessionWarningVisibility(),this.syncStarterNotice()}updated(){this.committedChatIdentity=aH(this.state),this.syncSelectedSessionReadState(),this.compactRailOpen&&this.appShell.isDesktopActivityRailLayout&&this.closeCompactActivityRail();let e=this.activeActivityRailId;e!==void 0&&this.activeActivityRailItem()===void 0&&this.closeActivityRailItem(e,this.activeActivityRailGeneration)}syncSessionWarningVisibility(){let e=this.state.selectedSession;this.sessionWarningVisibility=ax(this.sessionWarningVisibility,e===void 0?void 0:cd(R(this.state),e.id),this.state.status===void 0?void 0:this.state.status.warnings??[])}syncSelectedSessionReadState(){let e=this.state.selectedSession;if(e===void 0)return;let t=R(this.state);this.isSessionSeen(t,e)&&this.sessionUnread.acknowledge(t,e)}async commitReadyChatAfterRender(e,t){let n=iH(e,t);await this.updateComplete,!(!this.unreadConnected||aH(this.state)!==n)&&(this.readyChatIdentity=n,this.syncSelectedSessionReadState())}syncUnreadSessionIds(){let e=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions);DH(e,this.unreadSessionIds)||(this.unreadSessionIds=e)}syncWindowTitle(){this.disconnectWindowTitle();let e=vT(this.state.selectedProject?.name);this.windowTitleCleanup=yT(e)}disconnectWindowTitle(){this.windowTitleCleanup?.(),this.windowTitleCleanup=void 0}isSessionSeen(e,t){if(!this.unreadConnected)return!1;let n=iH(e,t);return aH(this.state)!==n||this.committedChatIdentity!==n||this.readyChatIdentity!==n||typeof document<`u`&&(document.visibilityState!==`visible`||typeof document.hasFocus==`function`&&!document.hasFocus())||this.isChatObscured()?!1:this.state.mainView===`chat`?!0:this.state.mainView===`navigation`?!this.appShell.isMobileNavigationLayout:this.isDesktopSideBySideLayout()}isChatObscured(){return this.compactRailOpen||this.activeActivityRailId!==void 0||this.settingsSection!==void 0||this.sessionCleanupDialog!==void 0||this.historyWindow!==void 0||this.modelsConfigDialogOpen||this.skillsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.pluginsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.systemPromptDialogOpen&&this.state.selectedSession!==void 0||this.state.actionPaletteOpen||this.projectBrowserOpen||this.statisticsProject!==void 0||this.sessionBrowserOpen||this.state.projectDialogOpen||this.state.machineDialogOpen||this.state.commandDialog!==void 0||this.state.treeDialog!==void 0||this.state.modelDialog!==void 0||this.state.thinkingDialog!==void 0||this.state.themeDialog!==void 0||this.state.authDialog!==void 0||this.gitUpdateManagerPanelOpen||this.terminalModalOpen||this.recentProjectDialogEntry!==void 0}hostSpeechSurfaceVisible(){return R(this.state)===`local`?this.settingsSection===`general`||this.state.selectedSession!==void 0&&!this.isChatObscured():!1}abandonHostSpeechIfSourceInvalid(e){let t=this.hostSpeech.snapshot.active;if(t===void 0)return;let n=e.selectedSession;if(n?.id!==t.sessionId)return;if(n.archived===!0){this.hostSpeech.stop();return}let r=Rv({messages:e.messages,messagePageStart:e.messagePageStart},t.messageKey);(r===``||!this.hostSpeech.matchesActiveSource({sessionId:t.sessionId,messageKey:t.messageKey,text:r}))&&this.hostSpeech.stop()}connectedCallback(){super.connectedCallback(),this.connectSpeechInputSettings(),this.hostSpeech.select(oH(this.state)),this.hostSpeech.refreshStatus(),this.synchronizeProjectCatalogPolling(),this.unreadConnected=!0,window.addEventListener(`popstate`,this.onPopState),window.addEventListener(`pageshow`,this.onPageShow),window.addEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.connect(),window.addEventListener(`keydown`,this.onKeyDown,IV),this.systemLightThemeMedia?.addEventListener(`change`,this.onSystemLightThemeChange),this.applyPreferredTheme(!1),this.connectRealtime(),this.renegotiateUnreadMachines(),this.piWebUiStatusTimer=window.setInterval(()=>{this.schedulePiWebUiStatusRefresh()},NV),this.refreshWorkspaceActivity(),this.recentProjects.load(),this.loadClientConfig(),this.ensureGatewayPluginsLoaded(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebUiStatusRefresh()}),this.syncWindowTitle()}disconnectedCallback(){this.disconnectSpeechInputSettings(),this.finishTerminalModalPointerInteraction(),this.hostSpeech.dispose(),this.unreadConnected=!1,this.committedChatIdentity=void 0,this.readyChatIdentity=void 0,this.unreadRuntimeRefreshes.clear(),this.sessionUnread.retainMachines(new Set),window.removeEventListener(`popstate`,this.onPopState),window.removeEventListener(`pageshow`,this.onPageShow),window.removeEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.disconnect(),window.removeEventListener(`keydown`,this.onKeyDown,IV),this.systemLightThemeMedia?.removeEventListener(`change`,this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.resetActiveModelPolicyDraft(),this.sessions.dispose(),this.projectCatalog.dispose(),this.notifications.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.git.dispose(),this.memory.dispose(),this.learnedSkills.dispose(),this.piWebUiStatusTimer!==void 0&&window.clearInterval(this.piWebUiStatusTimer),this.piWebUiStatusTimer=void 0,this.clearScheduledPiWebUiStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.clearPendingRemoteRouteRestore(),this.disconnectWindowTitle(),this.workspaceTasks.observe(!1),this.workspaceTasks.dispose(),super.disconnectedCallback()}setState(e){if(!EH(this.state,e))return;let t=this.state,n={...t,...e},r=oH(t),i=oH(n);sH(r,i)?t.status?.isCompacting!==!0&&n.status?.isCompacting===!0?this.hostSpeech.stop():this.abandonHostSpeechIfSourceInvalid(n):this.hostSpeech.select(i);let a=cH(t),o=uH(t),s=lH(t);this.state=n,s!==lH(this.state)&&(this.starterModelPolicySelectionGeneration+=1),a!==cH(this.state)&&this.resetActiveModelPolicyDraft(),aH(t)!==aH(this.state)&&(this.committedChatIdentity=void 0,this.readyChatIdentity=void 0),SH(t,this.state)&&this.syncSessionUnreadMachines(),this.syncUnreadSessionIds(),this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),!this.shouldShowSessionStartScreen(t)&&this.shouldShowSessionStartScreen(this.state)&&this.state.selectedWorkspace!==void 0&&this.loadStarterSessionDefaults(this.state.selectedWorkspace),this.handleMachineChange(t,this.state),this.handleStarterModelPolicyCapabilityChange(t,this.state),CH(t,this.state)&&this.syncMachineActivitySubscriptions(),this.notifications.syncEnvironment(t,this.state),t.selectedProject?.name!==this.state.selectedProject?.name&&this.syncWindowTitle(),this.synchronizeProjectCatalogPolling();let c=uH(this.state);c!==void 0&&c!==o&&this.preloadActiveModelPolicyInputs()}synchronizeProjectCatalogPolling(){this.projectCatalog.updatePolling(!!this.isConnected)}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();let e=kw();await this.machines.loadMachines(e.machineId);let t=this.routeForSelectedMachine(e),n=this.state.machineStatuses[t.machineId??`local`];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,n)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}connectSpeechInputSettings(){if(!this.speechInputSettingsConnected){this.speechInputSettingsConnected=!0;try{this.speechInputSettingsChannel=this.createSpeechInputSettingsChannel(e=>{this.handleSpeechInputSettingsChannelRevision(e)})}catch{this.speechInputSettingsChannel=void 0}this.refreshSpeechInputSettings()}}disconnectSpeechInputSettings(){!this.speechInputSettingsConnected&&this.speechInputSettingsChannel===void 0||(this.speechInputSettingsConnected=!1,this.speechInputSettingsRequestSeq+=1,this.speechInputSettingsChannelDispatchQueued=!1,this.speechInputSettingsChannelRefreshInFlight=!1,this.pendingSpeechInputSettingsChannelRevision=void 0,this.speechInputSettingsChannel?.close(),this.speechInputSettingsChannel=void 0)}async refreshSpeechInputSettings(){if(!this.speechInputSettingsConnected)return;let e=++this.speechInputSettingsRequestSeq;try{let t=await this.speechInputSettingsApi.settings();if(e!==this.speechInputSettingsRequestSeq)return;this.speechInputSettings=t}catch{}}handleSpeechInputSettingsLoaded(e){this.adoptSpeechInputSettings(e,!1)}handleSpeechInputSettingsSaved(e){this.adoptSpeechInputSettings(e,!0)}adoptSpeechInputSettings(e,t){this.speechInputSettingsConnected&&(this.speechInputSettingsRequestSeq+=1,this.speechInputSettings=e,this.pendingSpeechInputSettingsChannelRevision===e.revision&&(this.pendingSpeechInputSettingsChannelRevision=void 0),t&&this.speechInputSettingsChannel?.publish(e.revision))}handleSpeechInputSettingsChannelRevision(e){!this.speechInputSettingsConnected||e===this.speechInputSettings?.revision||(this.pendingSpeechInputSettingsChannelRevision=e,!(this.speechInputSettingsChannelRefreshInFlight||this.speechInputSettingsChannelDispatchQueued)&&(this.speechInputSettingsChannelDispatchQueued=!0,queueMicrotask(()=>{this.speechInputSettingsChannelDispatchQueued=!1,!(!this.speechInputSettingsConnected||this.speechInputSettingsChannelRefreshInFlight)&&this.refreshSpeechInputSettingsFromChannel()})))}async refreshSpeechInputSettingsFromChannel(){if(!(!this.speechInputSettingsConnected||this.speechInputSettingsChannelRefreshInFlight)&&this.pendingSpeechInputSettingsChannelRevision!==void 0){this.pendingSpeechInputSettingsChannelRevision=void 0,this.speechInputSettingsChannelRefreshInFlight=!0;try{await this.refreshSpeechInputSettings()}finally{this.speechInputSettingsChannelRefreshInFlight=!1,this.shouldRunSpeechInputSettingsChannelTrailingRefresh()&&this.refreshSpeechInputSettingsFromChannel()}}}shouldRunSpeechInputSettingsChannelTrailingRefresh(){return this.speechInputSettingsConnected&&this.pendingSpeechInputSettingsChannelRevision!==void 0}handleBrowserResumeSignal(){this.appShell.repairViewportPosition(),this.schedulePiWebUiStatusRefresh(),this.retryPendingRemoteRouteRestoreSoon()}async refreshAfterBrowserResume(){this.projectCatalog.refresh(),await this.renegotiateUnreadMachines(),await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.refreshWorkspaceDeletionRuns(),this.refreshSpeechInputSettings()])}schedulePiWebUiStatusRefresh(e=PV){this.clearScheduledPiWebUiStatusRefresh(),this.piWebUiStatusDeferredTimer=window.setTimeout(()=>{this.piWebUiStatusDeferredTimer=void 0,this.piWebUiStatusController.refresh()},e)}clearScheduledPiWebUiStatusRefresh(){this.piWebUiStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebUiStatusDeferredTimer),this.piWebUiStatusDeferredTimer=void 0)}async refreshWorkspaceActivity(e=R(this.state)){try{await this.activity.refresh(e)}catch(t){console.warn(`Failed to refresh workspace activity for ${e}`,t)}}async refreshMachineActivities(){let e=this.state.machines.length===0?[R(this.state)]:this.state.machines.filter(e=>TH(e,this.state.machineStatuses[e.id])).map(e=>e.id);await Promise.all(e.map(e=>this.refreshWorkspaceActivity(e)))}async loadClientConfig(){try{this.applyClientConfig((await ec.config()).effectiveConfig)}catch(e){console.warn(`Failed to load PI WEBUI config`,e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=Kl(e),this.hostSpeech.configure(e.tts)}async refreshAppData(){if(!this.isRefreshingApp){this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.loadClientConfig(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface()]),this.schedulePiWebUiStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){let e=this.state.selectedWorkspace,t=this.state.mainView!==`chat`&&this.state.mainView!==`navigation`?this.state.mainView:this.state.workspaceTool;t===`core:workspace.files`?await this.files.refreshFiles():t===`core:workspace.git`?await this.git.refreshGit():t===`core:workspace.terminal`&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(kw(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,n=this.readWorkspaceRouteSurface(e),r){let i=R(this.state),a=e.projectId===void 0||e.projectId===``?AH():n,o=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=a.selectedTerminalId;try{await this.restoreRouteMachine(e,!1);let n=this.loadPluginsForSelectedMachine();if(e.tool?.startsWith(`machine.`)===!0&&await n,!this.isCurrentRouteRestore(o))return;if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:r??e.view??this.defaultRouteView(),selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),e.projectId===void 0||e.projectId===``){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(e)){a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl();return}let i=this.state.projects.find(t=>t.id===e.projectId);if(!i){this.setState({selectedFilePath:void 0,selectedDiffPath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(i,{workspaceId:e.workspaceId,sessionId:e.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(o))return;this.setState({selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),R(this.state)!==i&&this.schedulePiWebUiStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===``?AH():{selectedFilePath:yd(BV,`file`),selectedDiffPath:yd(VV,`diff`),selectedTerminalId:yd(HV,`terminal`)}}routeForSelectedMachine(e){let t=this.state.selectedMachine?.id??`local`;return(e.machineId??`local`)===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){Aw(e,{replace:!0}),bd(BV,`file`,void 0,{replace:!0}),bd(VV,`diff`,void 0,{replace:!0}),bd(HV,`terminal`,void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??`local`]){let n=e.machineId??`local`,r=this.state.selectedMachine;return n===`local`||r?.id!==n||r.kind!==`remote`||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===``?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=MH(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;let e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{let t=e.machineId??`local`,n=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(n?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==``){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=FV.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){let n=e.machineId??`local`,r=this.state.machines.find(e=>e.id===n)?.name??this.state.selectedMachine?.name??`Remote machine`,i=this.state.machineStatuses[n]?.error??(this.state.error===``?void 0:this.state.error),a=t.exhausted===!0?`${r} is still unavailable.`:`${r} is unavailable; reconnecting…`;this.setState({error:`${a}${i===void 0?``:` ${i}`}`})}pendingRemoteRouteRestoreStillCurrent(e){let t=e.machineId??`local`;return t!==`local`&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(e=>e.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){let n=e.machineId??`local`;if(this.state.selectedMachine?.id===n)return;let r=this.state.machines.find(e=>e.id===n);r!==void 0&&await this.machines.selectMachine(r,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??`local`)===(this.state.selectedMachine?.id??`local`)&&e.workspaceId!==void 0&&e.workspaceId!==``&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e===`core:workspace.files`&&await this.files.refreshFiles(),e===`core:workspace.files`&&t!==void 0&&await this.files.restoreFile(t),e===`core:workspace.git`&&await this.git.refreshGit()}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await IH(),t()&&(this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()))))}shouldAutoFocusPrompt(){return this.appShell.shouldAutoFocusPrompt()}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(){return this.appShell.defaultRouteView()}updateUrl(e){this.rememberCurrentMachineNavigation(),Aw({machineId:this.state.selectedMachine?.id,projectId:this.state.selectedProject?.id,workspaceId:this.state.selectedWorkspace?.id,sessionId:this.state.selectedSession?.id,tool:this.state.workspaceTool,view:this.state.mainView===`navigation`?void 0:this.state.mainView},e),this.syncWorkspaceRouteSurfaceToUrl()}rememberCurrentMachineNavigation(){this.machineNavigation.remember(Fy(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(Fy(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){Aw(Iy(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){bd(BV,`file`,e.selectedFilePath,{replace:!0}),bd(VV,`diff`,e.selectedDiffPath,{replace:!0}),bd(HV,`terminal`,e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();let n=++this.machineNavigationRestoreSeq,r=this.machineNavigation.latest(e.id)??Py(e.id);if(await this.restoreRouteFor(Iy(r),!1,r.surface,r.view),!(n!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(r)){this.machineNavigation.remember(r),this.writeMachineNavigationSnapshotToUrl(r);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==``}openWorkspaceTool(e){e===`core:workspace.terminal`&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e),this.git.updatePolling()}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool(`core:workspace.terminal`)}terminalCommandRunsForOrigin(e,t=R(this.state)){let n=jH(t,e),r=this.terminalCommandRunRuntimes.get(n);if(r!==void 0)return r;let i=Vw(e,{api:{runTerminalCommand:(e,n)=>Sc.runTerminalCommand(e,n,t),listCommandRuns:e=>Sc.listCommandRuns(e,t),getCommandRun:e=>Sc.getCommandRun(e,t)},openTerminal:(e,n)=>{this.openRuntimeTerminal(t,e,n)}}),a={...i,runCommand:async e=>{let n=await i.runCommand(e);return this.recordProjectWork({machineId:t,projectId:e.workspace.projectId}),n}};return this.terminalCommandRunRuntimes.set(n,a),a}async openRuntimeTerminal(e,t,n){return(R(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:`core:workspace.terminal`,view:`core:workspace.terminal`},!1,{selectedTerminalId:n?.terminalId},`core:workspace.terminal`),R(this.state)!==e)?(this.setState({error:`Machine not found for terminal command run`}),!1):(this.openTerminal(n),!0)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){let t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){bd(HV,`terminal`,e,t)}terminalWorkspaceKey(e){return`${R(this.state)}:${e.path}`}selectMainView(e){if(e!==`navigation`&&e!==`chat`){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}openSettings(e=`general`){this.settingsSection=e,Fw(e)}closeSettings(){this.settingsSection=void 0,Fw(void 0)}navigateSettings(e){this.settingsSection=e,Fw(e)}restoreSettingsRoute(){this.settingsSection=Pw()}handleWorkspaceChange(e,t){let n=xH(e,t);if(e.selectedWorkspace?.id===t.selectedWorkspace?.id){n&&(this.synchronizeMemoryPollingForSelectedWorkspace(),this.synchronizeLearnedSkillsPollingForSelectedWorkspace(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace());return}this.starterSessionDefaults=void 0,this.resetStarterModelPolicyForScopeChange(),this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();let r=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));if(this.setState({activeTerminalCount:0,selectedTerminalId:r}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(r,{replace:!0})),t.selectedWorkspace===void 0){this.synchronizeMemoryPollingForSelectedWorkspace(),this.synchronizeLearnedSkillsPollingForSelectedWorkspace(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace();return}this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling(),this.synchronizeMemoryPollingForSelectedWorkspace(),this.synchronizeLearnedSkillsPollingForSelectedWorkspace(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace()}async loadStarterSessionDefaults(e,t={}){let n=R(this.state),r=++this.starterSessionDefaultsSeq,i=this.starterModelPolicySelectionSupported(n),a=()=>r===this.starterSessionDefaultsSeq&&R(this.state)===n&&this.state.selectedWorkspace?.id===e.id&&this.state.selectedWorkspace.path===e.path&&(t.expectedSelectionGeneration===void 0||this.starterModelPolicySelectionGeneration===t.expectedSelectionGeneration);try{let r=i?await xc.sessionDefaultsV2(e.path,n):await xc.sessionDefaults(e.path,n);if(!a())return;let o=this.starterSessionDefaults;this.starterSessionDefaults=r,this.starterNotice=void 0,this.starterModelPolicyPreferenceReadError=r.starterModelPolicyPreferenceError??``;let s=this.starterModelPolicy;s===void 0||i&&!mH(o)?this.starterModelPolicy=gu(r):i?this.starterModelPolicy=s:this.starterModelPolicy=_u(s,r),this.completeStarterModelPolicyFromActiveTier();let c=this.starterModelPolicy;if(this.selectedMachineModelTierCatalog()===void 0&&(i||c.mode===`tiered`&&!this.modelTierCatalogLoading)){let e=this.ensureModelTierCatalog(n);t.awaitModelTierCatalog===!0&&await e}}catch(t){a()&&(console.warn(`Failed to load Pi session defaults`,t),this.publishStarterNotice(qu(`defaults-failed`,`Could not load this workspace's model defaults. ${NH(t)}`,{machineId:n,workspaceId:e.id})))}}syncSessionUnreadMachines(){if(!this.unreadConnected){this.sessionUnread.retainMachines(new Set);return}let e=new Set(this.state.machines.map(e=>e.id));this.sessionUnread.retainMachines(e);for(let t of e){let e=this.state.machineRuntimes[t];if(e===void 0)continue;let n=this.unreadRuntimeRefreshes.has(t)||!e.ok?`unknown`:E(e,w.sessionsUnread)?`supported`:`unsupported`;this.sessionUnread.setCapability(t,n)&&this.sessionUnread.refresh(t)}}async renegotiateUnreadMachines(){if(!this.unreadConnected)return;let e=new Set(this.state.machines.map(e=>e.id));e.add(R(this.state)),await Promise.all([...e].map(async e=>{await this.renegotiateUnreadMachine(e)}))}renegotiateUnreadMachine(e){let t=this.unreadRuntimeRefreshes.get(e);if(t!==void 0)return t;this.sessionUnread.setCapability(e,`unknown`);let n=!1,r=Promise.resolve().then(async()=>{n=await this.machines.refreshMachineRuntime(e)!==void 0});this.unreadRuntimeRefreshes.set(e,r);let i=()=>{this.unreadRuntimeRefreshes.get(e)===r&&(this.unreadRuntimeRefreshes.delete(e),this.unreadConnected&&(n?this.syncSessionUnreadMachines():this.sessionUnread.setCapability(e,`unknown`)))};return r.then(i,i),r}connectRealtime(){let e=R(this.state);this.realtime.connect(t=>{this.handleRealtimeEvent(e,t)},()=>{this.renegotiateUnreadMachine(e);let t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t),this.refreshWorkspaceActivity(e),this.projectCatalog.refresh()},e)}syncMachineActivitySubscriptions(){let e=this.machineActivitySubscriptionIds();for(let[t,n]of this.machineRealtimeSockets.entries())e.has(t)||(n.close(),this.machineRealtimeSockets.delete(t));for(let t of e){if(this.machineRealtimeSockets.has(t))continue;let e=new Rm;e.connect(e=>{this.handleMachineActivityEvent(t,e)},()=>{this.renegotiateUnreadMachine(t),this.refreshWorkspaceActivity(t)},t),this.machineRealtimeSockets.set(t,e)}}closeMachineActivitySockets(){for(let e of this.machineRealtimeSockets.values())e.close();this.machineRealtimeSockets.clear()}machineActivitySubscriptionIds(){let e=R(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(e=>wH(e,this.state.machineStatuses[e.id])).map(e=>e.id))}handleMachineActivityEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`&&this.activity.applyWorkspaceActivity(t.activity,e)}handleRealtimeEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`?this.activity.applyWorkspaceActivity(t.activity):kH(t)?(this.applyTerminalEvent(t),t.type===`terminal.exited`&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(e){let t=this.state.selectedWorkspace;t!==void 0&&(e.type===`terminal.closed`?e.cwd:e.terminal.cwd)===t.path&&(e.type===`terminal.created`&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type===`terminal.closed`?e.terminalId:e.terminal.id),e.type===`terminal.closed`&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){let t=R(this.state);try{let n=await Sc.terminals(e.projectId,e.id,t);if(R(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(let e of n)e.exited||this.activeTerminalIds.add(e.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(e,t){let n=OH(e),r=OH(t);n&&!r&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){if((e.selectedMachine?.id??`local`)===(t.selectedMachine?.id??`local`))return;this.closeRecentProjectDialogForMachineChange(),this.closeProjectStatistics(),this.projectActivityOwnership.handleSelectedMachineChanged(),(this.pendingRemoteRouteRestore?.machineId??`local`)!==(t.selectedMachine?.id??`local`)&&this.clearPendingRemoteRouteRestore(),this.sessions.clearActiveSession(),this.starterSessionDefaults=void 0,this.resetStarterModelPolicyForScopeChange(),this.resetModelTierCatalogForMachineChange(),this.realtime.close(),this.connectRealtime(),this.activeTerminalIds.clear(),this.sessionCleanupDialog=void 0,this.setState({piWebUiStatus:void 0}),this.git.updatePolling(),this.recentProjects.load(),this.loadPluginsForSelectedMachine();let n=t.selectedWorkspace;n!==void 0&&this.shouldShowSessionStartScreen(t)&&this.loadStarterSessionDefaults(n)}refreshSelectedWorkspaceTool(e){e===`core:workspace.files`&&this.files.refreshFiles(),e===`core:workspace.git`&&this.git.refreshGit()}renderWorkspacePanel(){return g`
7424
+ `}};H([x({attribute:!1})],DV.prototype,`onClose`,void 0),H([x({attribute:!1})],DV.prototype,`onStatusChange`,void 0),H([x({attribute:!1})],DV.prototype,`workspace`,void 0),H([x()],DV.prototype,`machineId`,void 0),H([x({attribute:!1})],DV.prototype,`api`,void 0),H([S()],DV.prototype,`status`,void 0),H([S()],DV.prototype,`selectedChange`,void 0),H([S()],DV.prototype,`selectedDiff`,void 0),H([S()],DV.prototype,`loadingStatus`,void 0),H([S()],DV.prototype,`loadingDiff`,void 0),H([S()],DV.prototype,`error`,void 0),H([S()],DV.prototype,`bounds`,void 0),DV=H([b(`git-update-manager-panel`)],DV);function OV(){cS(()=>import(`./UnifiedDiffViewer-zvBeY6cg.js`),[],import.meta.url)}function kV(e,t){let n=Gd(e.files);return[...n.staged,...n.unstaged].find(e=>e.id===t)}function AV(e){return e===`staged`?`Staged`:`Unstaged`}function jV(e,t){return e===void 0?void 0:JSON.stringify([t,e.projectId,e.id])}function MV(e){return e instanceof Error?e.message:String(e)}var NV=900*1e3,PV=750,FV=[1e3,3e3,8e3,15e3,3e4],IV={capture:!0},LV=`auto:on`,RV=`auto:off`,zV=`theme:`,BV=_d(`core:workspace.files`),VV=_d(`core:workspace.git`),HV=_d(`core:workspace.terminal`),UV=`workspace-memory`,WV=`workspace.memory`,GV=`workspace-memory:workspace.memory`,KV=`workspace-learned-skills`,qV=`workspace.learned-skills`,JV=`workspace-learned-skills:workspace.learned-skills`,YV=`workspace-tasks`,XV=`workspace.tasks`,ZV=320,QV=2,$V=`(min-width: 1181px)`,eH=75,tH=`Could not remember this model policy; this session still uses it.`,$=class extends y{constructor(e={}){super(),this.state=id(),this.sessionUnread=new Yb({onChange:e=>{R(this.state)===e&&(this.syncUnreadSessionIds(),this.syncSelectedSessionReadState())},onBackgroundError:(e,t,n)=>{console.warn(`Failed to ${e} session unread state for ${t}`,n)}}),this.unreadSessionIds=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions),this.unreadConnected=!1,this.notifications=new Lg(()=>this.state,e=>{this.setState(e)},{onBackgroundError:(e,t)=>{console.warn(e,t)}}),this.hostSpeech=new Ug({onStateChange:()=>{this.hostSpeechSurfaceVisible()&&this.requestUpdate()}}),this.sessions=new Rh(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new bh,{refreshProjectSessionCatalog:()=>this.projectCatalog.refresh(),notifications:this.notifications,onSelectedSessionReady:({machineId:e,session:t})=>{this.commitReadyChatAfterRender(e,t)},replacePromptEditorText:async({machineId:e,sessionId:t,text:n})=>{await this.updateComplete,!(R(this.state)!==e||this.state.selectedSession?.id!==t)&&this.promptEditor?.replaceText(n)},onStarterModelPolicyConfirmed:e=>{this.handleStarterModelPolicyConfirmed(e)}}),this.workspaces=new Uv(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new Vv,{onBackgroundError:(e,t)=>{console.warn(`Failed to ${e}`,t)}}),this.projectCatalog=new cf(()=>this.state,{workspaces:bc.workspaces,applySnapshot:async e=>{await this.workspaces.reconcileProjectCatalog(e)},captureTopologyRequest:e=>this.workspaces.captureProjectCatalogTopologyRequest(e),onBackgroundError:(e,t)=>{console.warn(`Failed to ${e}`,t)}}),this.projectActivityOwnership=new yf(()=>this.state,e=>{this.setState(e)},{api:bc,captureTopologyRequest:e=>this.workspaces.captureProjectCatalogTopologyRequest(e),onProjectTopology:async e=>{let t=this.state.projects.find(t=>t.id===e.projectId&&t.path===e.projectPath);t!==void 0&&await this.workspaces.reconcileProjectCatalog({machineId:e.machineId,project:t,workspaces:e.workspaces,...e.topologyRequest===void 0?{}:{topologyRequest:e.topologyRequest}})},onError:({machineId:e,projectId:t,error:n})=>{console.warn(`Failed to discover project activity ownership for ${t} on ${e}`,n)}}),this.activity=new ud(()=>this.state,e=>{this.setState(e)},{onActivityApplied:e=>{this.projectActivityOwnership.handleActivityApplied(e)}}),this.auth=new md(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.projects=new rf(()=>this.state,e=>{this.setState(e)},this.workspaces,{onProjectsApplied:e=>{this.projectActivityOwnership.handleProjectsApplied(e),this.recentProjects.load()}}),this.machines=new $d(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.piWebUiStatusController=new xf(()=>this.state,e=>{this.setState(e)},{onRefreshError:(e,t)=>{console.warn(`Failed to refresh PI WEBUI status for ${e}`,t)}}),this.files=new Ad(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new Id(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.memory=new Ud(()=>this.state,e=>{this.setState(e)}),this.learnedSkills=new zd(()=>this.state,e=>{this.setState(e)}),this.recentProjects=new uf({machineId:()=>R(this.state),onChange:()=>{this.requestUpdate()},onBackgroundError:(e,t)=>{console.warn(`Failed to ${e}`,t)}}),this.keyboard=new Zy,this.realtime=new Rm,this.machineRealtimeSockets=new Map,this.unreadRuntimeRefreshes=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new Ny,this.terminalSelection=new Ky,this.appShell=new RC(this),this.browserResume=new VC({onResumeSignal:()=>{this.handleBrowserResumeSignal()},refreshAfterResume:()=>this.refreshAfterBrowserResume(),onRefreshError:e=>{console.warn(`Failed to refresh after browser resume`,e)}}),this.speechInputSettingsConnected=!1,this.speechInputSettingsRequestSeq=0,this.isSpeechInputSettingsRequestCurrent=e=>this.speechInputSettingsConnected&&e===this.speechInputSettingsRequestSeq,this.speechInputSettingsChannelDispatchQueued=!1,this.speechInputSettingsChannelRefreshInFlight=!1,this.panelCollapse=new lw(this),this.panelResize=new pw(this),this.navigationSections=new ow(this,()=>this.state,()=>this.appShell.isMobileNavigationLayout),this.systemLightThemeMedia=typeof window<`u`&&`matchMedia`in window?window.matchMedia(`(prefers-color-scheme: light)`):void 0,this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.machineNavigationRestoreSeq=0,this.navigationSelectionSeq=0,this.routeRestoreSeq=0,this.routeRestoreDepth=0,this.remoteRouteRestoreAttempt=0,this.remoteRouteRestoreInProgress=!1,this.plugins=nH(),this.reportActivityRailError=(e,t,n)=>{console.warn(`Plugin activity rail contribution failed`,e,t,n)},this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=_x()??px,this.activeThemeId=fx,this.isRefreshingApp=!1,this.recentProjectDialogInitialView=`closed-actions`,this.recentProjectDialogGeneration=0,this.starterSessionDefaultsSeq=0,this.starterModelPolicyPreferenceReadError=``,this.starterModelPolicyPreferenceWriter=new Cb({save:async(e,t)=>{let n=await xc.updateSessionDefaults(e.cwd,{starterModelPolicyPreference:t},e.machineId),r=this.starterModelPolicyPreferenceScope();return r?.machineId===e.machineId&&r.cwd===e.cwd&&(this.starterModelPolicyPreferenceReadError=``),n},onStateChange:()=>{this.requestUpdate()}}),this.confirmedStarterModelPolicyPreferenceWriter=new Ob({remember:(e,t)=>xc.rememberCurrentModelPolicy(t,e.machineId),onStateChange:(e,t)=>{this.starterModelPolicyPreferenceScopeMatchesCurrentSelection(e)&&this.confirmedStarterModelPolicyUiGeneration===this.starterModelPolicySelectionGeneration&&(!t.saving&&t.error===void 0&&(this.starterModelPolicyPreferenceReadError=``),this.requestUpdate())}}),this.starterModelPolicySelectionGeneration=0,this.modelTierCatalogLoading=!1,this.modelTierCatalogError=``,this.activeModelPolicyApplyGeneration=0,this.modelTierCatalogSeq=0,this.modelsConfigDialogOpen=!1,this.projectBrowserOpen=!1,this.statisticsLoading=!1,this.statisticsRequestGeneration=0,this.sessionBrowserOpen=!1,this.skillsConfigDialogOpen=!1,this.pluginsConfigDialogOpen=!1,this.systemPromptDialogOpen=!1,this.gitUpdateManagerPanelOpen=!1,this.terminalModalOpen=!1,this.terminalModalMaximized=!1,this.initialTerminalModalPreferences=iT(),this.terminalModalFontSize=this.initialTerminalModalPreferences.fontSize,this.terminalModalOpacity=this.initialTerminalModalPreferences.opacity,this.initialWorkspaceTabVisibility=fT(),this.terminalTabHidden=this.initialWorkspaceTabVisibility.terminalHidden,this.infoTabHidden=this.initialWorkspaceTabVisibility.infoHidden,this.railOrder=yV()??[...pV],this.compactRailOpen=!1,this.activeActivityRailGeneration=0,this.settingsSection=Pw(),this.shortcutConfig={},this.workspaceUploadDefaultFolder=Kl(void 0),this.sessionWarningVisibility=rx(),this.onPopState=()=>void this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)}),this.onPageShow=()=>{this.renegotiateUnreadMachines(),this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onTerminalModalViewportResize=()=>{this.terminalModalBounds!==void 0&&(this.terminalModalBounds=Zw(this.terminalModalBounds,this.terminalModalViewport()))},this.onKeyDown=e=>{if(e.key===`Escape`&&this.promptEditor?.cancelSpeechInput()===!0){e.preventDefault(),e.stopPropagation();return}this.compactRailOpen||this.activeActivityRailId!==void 0||this.settingsSection!==void 0||this.state.treeDialog!==void 0||this.state.actionPaletteOpen||this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())},this.closeCompactActivityRail=()=>{if(!this.compactRailOpen)return;this.compactRailOpen=!1;let e=this.compactActivityRailLauncher;this.updateComplete.then(()=>{!this.compactRailOpen&&this.activeActivityRailId===void 0&&(e===void 0?this.currentCompactActivityRailLauncher()?.focus():this.restoreActivityRailFocus(e))})},this.toggleCompactActivityRail=e=>{this.appShell.isDesktopActivityRailLayout||(!this.compactRailOpen&&e!==void 0&&(this.compactActivityRailLauncher=e),this.compactRailOpen=!this.compactRailOpen)},this.handleSendPrompt=(e,t,n,r)=>{this.sendPrompt(e,t,n,r)},this.handleStartSessionPrompt=(e,t,n,r)=>{if(!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e))return;if(this.starterModelPolicyBlocksStart()){let e=this.starterNoticeScope();e!==void 0&&this.publishStarterNotice(Ku(e));return}this.starterNotice=void 0;let i=this.state.selectedWorkspace?.id,a=R(this.state),o=this.selectedProjectWorkTarget(a),s=this.starterModelPolicy,c=this.starterPlusModelPolicyInitializer();this.starterModelPolicySelectionSupported(a)&&c===void 0||((c===void 0?this.sessions.startSessionWithPrompt(e,t,n,r,this.starterModelPolicyStartSnapshot(),e=>{this.clearStarterModelPolicyAfterSuccessfulStart(e,i,s)}):this.sessions.startPlusSessionWithPrompt(e,t,n,r??`inline`,c,()=>void 0)).then(e=>{e&&this.recordProjectWork(o)}).catch(e=>{i!==void 0&&this.publishStarterNotice(qu(`start-failed`,`Could not start the session. ${NH(e)}`,{machineId:a,workspaceId:i}))}),this.focusChatComposer())},this.handleSelectStarterModel=()=>{this.openStarterModelDialog()},this.handleSelectStarterThinking=()=>{this.openStarterThinkingDialog()},this.handleSelectStarterPolicyMode=async e=>{let t=this.starterModelPolicy;if(t===void 0||t.mode===e)return;if(this.starterModelPolicySelectionSupported()){let n=e===`exact`?xu(t):t.tier===void 0?{...t,mode:`tiered`}:bu(t,t.tier);this.setStarterModelPolicyDraft(n),this.ensureModelTierCatalog(R(this.state));return}if(e===`exact`){let e=xu(t);this.setStarterModelPolicyDraft(e);let n=this.starterSessionDefaults,r=n===void 0?void 0:hu(n);r!==void 0&&yu(e.exact,r)&&this.persistStarterModelPolicyPreference(e);return}let n=t.tier===void 0?{...t,mode:`tiered`}:bu(t,t.tier),r=this.setStarterModelPolicyDraft(n);if(n.tier===void 0){this.ensureModelTierCatalog(R(this.state));return}let i=await this.ensureStarterModelPolicyCatalog();this.starterModelPolicy!==r||i===void 0||wu(r,i)!==void 0&&this.persistStarterModelPolicyPreference(r)},this.handleSelectStarterPolicyTier=async e=>{let t=this.starterModelPolicy,n=await this.ensureStarterModelPolicyCatalog();if(t===void 0||t!==this.starterModelPolicy||n===void 0)return;let r=bu(t,e);if(this.starterModelPolicySelectionSupported()){this.setStarterModelPolicyDraft(r);return}wu(r,n)!==void 0&&(this.setStarterModelPolicyDraft(r),this.persistStarterModelPolicyPreference(r))},this.handleSelectStarterPolicyThinking=async e=>{await this.pickStarterThinking(e)},this.handleSelectActivePolicyMode=async e=>{let t=await this.prepareActiveModelPolicyDraft();if(!(t===void 0||t!==this.activeModelPolicyDraftForState(this.state)||t.mode===e)){if(this.cancelActiveModelPolicyApply(),e===`exact`){this.setActiveModelPolicyDraft(xu(t)),this.scheduleActiveExactModelPolicyApply();return}if(t.tier===void 0){this.setActiveModelPolicyDraft({...t,mode:`tiered`});return}this.setActiveModelPolicyDraft(bu(t,t.tier)),await this.applyActiveModelPolicyDraft()}},this.handleSelectActivePolicyTier=async e=>{let t=await this.prepareActiveModelPolicyDraft();if(t===void 0||t!==this.activeModelPolicyDraftForState(this.state))return;this.cancelActiveModelPolicyApply();let n=bu(t,e);this.setActiveModelPolicyDraft(n),await this.applyActiveModelPolicyDraft()},this.handleSelectActivePolicyThinking=async e=>{await this.pickThinking(e)},this.handleOpenTerminalFromRail=()=>{this.closeCompactActivityRail(),this.state.selectedWorkspace!==void 0&&(this.terminalModalOpen=!0)},this.handleOpenGitUpdateManagerFromRail=()=>{this.closeCompactActivityRail(),this.state.selectedWorkspace!==void 0&&(this.gitUpdateManagerPanelOpen=!0)},this.handleCloseGitUpdateManagerPanel=()=>{this.gitUpdateManagerPanelOpen=!1},this.handleOpenThemeFromRail=()=>{this.closeCompactActivityRail(),this.openThemeDialog()},this.handleRailOrderChange=e=>{this.railOrder=e,bV(e)},this.handleCloseTerminalModal=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalOpen=!1},this.toggleTerminalModalMaximized=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalMaximized=!this.terminalModalMaximized},this.handleTerminalModalMovePointerDown=e=>{this.startTerminalModalPointerInteraction(`move`,e)},this.handleTerminalModalResizePointerDown=e=>{this.startTerminalModalPointerInteraction(`resize`,e)},this.handleTerminalModalPointerMove=e=>{let t=this.terminalModalPointerInteraction;if(t?.pointerId!==e.pointerId)return;e.preventDefault();let n={x:e.clientX-t.startClientX,y:e.clientY-t.startClientY},r=this.terminalModalViewport();this.terminalModalBounds=t.operation===`move`?Yw(t.bounds,n,r):Xw(t.bounds,n,r)},this.handleTerminalModalPointerUp=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&(e.preventDefault(),this.finishTerminalModalPointerInteraction())},this.handleTerminalModalPointerCancel=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&this.finishTerminalModalPointerInteraction()},this.adjustTerminalFontSize=e=>{let t=nT(this.terminalModalFontSize+e);t!==this.terminalModalFontSize&&(this.terminalModalFontSize=t,this.persistTerminalModalPreferences())},this.adjustTerminalOpacity=e=>{let t=rT(this.terminalModalOpacity+e);t!==this.terminalModalOpacity&&(this.terminalModalOpacity=t,this.persistTerminalModalPreferences())},this.handleStopActiveWork=()=>{this.sessions.stopActiveWork()},this.handleCompact=()=>{this.sessions.runCommand(`/compact`)},this.handleToggleHostSpeech=e=>{let t=this.state.selectedSession;if(t===void 0||R(this.state)!==`local`)return;let n=this.hostSpeech.snapshot.active;if(n?.sessionId===t.id&&n.messageKey===e.messageKey){this.hostSpeech.stop();return}this.hostSpeech.startManual({machineId:`local`,sessionId:t.id,messageKey:e.messageKey,text:e.text})},this.handleClearServerQueue=()=>{this.sessions.clearServerQueue()},this.handleEditFromHere=async(e,t)=>{let n=R(this.state),r=this.state.selectedSession?.id;try{!(await this.sessions.editFromHere(e,t)).cancelled&&r!==void 0&&R(this.state)===n&&this.state.selectedSession?.id===r&&await this.focusChatComposer()}catch{}},this.handleForkFromHere=async e=>{await this.sessions.forkFromHere(e)},this.handleDismissWarning=e=>{this.sessions.dismissWarning(e)},this.handleDismissNotification=e=>{this.notifications.dismissNotification(e)},this.handleDismissAllNotifications=()=>{this.notifications.dismissAll()},this.handleToggleWarnings=()=>{let e=cx(this.sessionWarningVisibility);e!==this.sessionWarningVisibility&&(this.sessionWarningVisibility=e,this.requestUpdate())},this.handleSelectModel=()=>{this.openModelDialog()},this.handleSelectThinking=()=>{this.openThinkingDialog()},this.speechInputSettingsApi=e.speechInputApi??Gs,this.createSpeechInputSettingsChannel=e.createSpeechInputSettingsChannel??(e=>new qC(e)),this.workspaceTasks=(e.createWorkspaceTasksController??(e=>new iy(e)))({selectedScope:()=>bH(this.state),onChange:()=>{this.requestUpdate()}})}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute(`pwa-display-mode`,this.appShell.isPwaDisplayMode),this.syncSessionWarningVisibility(),this.syncStarterNotice()}updated(){this.committedChatIdentity=aH(this.state),this.syncSelectedSessionReadState(),this.compactRailOpen&&this.appShell.isDesktopActivityRailLayout&&this.closeCompactActivityRail();let e=this.activeActivityRailId;e!==void 0&&this.activeActivityRailItem()===void 0&&this.closeActivityRailItem(e,this.activeActivityRailGeneration)}syncSessionWarningVisibility(){let e=this.state.selectedSession;this.sessionWarningVisibility=ax(this.sessionWarningVisibility,e===void 0?void 0:cd(R(this.state),e.id),this.state.status===void 0?void 0:this.state.status.warnings??[])}syncSelectedSessionReadState(){let e=this.state.selectedSession;if(e===void 0)return;let t=R(this.state);this.isSessionSeen(t,e)&&this.sessionUnread.acknowledge(t,e)}async commitReadyChatAfterRender(e,t){let n=iH(e,t);await this.updateComplete,!(!this.unreadConnected||aH(this.state)!==n)&&(this.readyChatIdentity=n,this.syncSelectedSessionReadState())}syncUnreadSessionIds(){let e=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions);DH(e,this.unreadSessionIds)||(this.unreadSessionIds=e)}syncWindowTitle(){this.disconnectWindowTitle();let e=vT(this.state.selectedProject?.name);this.windowTitleCleanup=yT(e)}disconnectWindowTitle(){this.windowTitleCleanup?.(),this.windowTitleCleanup=void 0}isSessionSeen(e,t){if(!this.unreadConnected)return!1;let n=iH(e,t);return aH(this.state)!==n||this.committedChatIdentity!==n||this.readyChatIdentity!==n||typeof document<`u`&&(document.visibilityState!==`visible`||typeof document.hasFocus==`function`&&!document.hasFocus())||this.isChatObscured()?!1:this.state.mainView===`chat`?!0:this.state.mainView===`navigation`?!this.appShell.isMobileNavigationLayout:this.isDesktopSideBySideLayout()}isChatObscured(){return this.compactRailOpen||this.activeActivityRailId!==void 0||this.settingsSection!==void 0||this.sessionCleanupDialog!==void 0||this.historyWindow!==void 0||this.modelsConfigDialogOpen||this.skillsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.pluginsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.systemPromptDialogOpen&&this.state.selectedSession!==void 0||this.state.actionPaletteOpen||this.projectBrowserOpen||this.statisticsProject!==void 0||this.sessionBrowserOpen||this.state.projectDialogOpen||this.state.machineDialogOpen||this.state.commandDialog!==void 0||this.state.treeDialog!==void 0||this.state.modelDialog!==void 0||this.state.thinkingDialog!==void 0||this.state.themeDialog!==void 0||this.state.authDialog!==void 0||this.gitUpdateManagerPanelOpen||this.terminalModalOpen||this.recentProjectDialogEntry!==void 0}hostSpeechSurfaceVisible(){return R(this.state)===`local`?this.settingsSection===`general`||this.state.selectedSession!==void 0&&!this.isChatObscured():!1}abandonHostSpeechIfSourceInvalid(e){let t=this.hostSpeech.snapshot.active;if(t===void 0)return;let n=e.selectedSession;if(n?.id!==t.sessionId)return;if(n.archived===!0){this.hostSpeech.stop();return}let r=Rv({messages:e.messages,messagePageStart:e.messagePageStart},t.messageKey);(r===``||!this.hostSpeech.matchesActiveSource({sessionId:t.sessionId,messageKey:t.messageKey,text:r}))&&this.hostSpeech.stop()}connectedCallback(){super.connectedCallback(),this.connectSpeechInputSettings(),this.hostSpeech.select(oH(this.state)),this.hostSpeech.refreshStatus(),this.synchronizeProjectCatalogPolling(),this.unreadConnected=!0,window.addEventListener(`popstate`,this.onPopState),window.addEventListener(`pageshow`,this.onPageShow),window.addEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.connect(),window.addEventListener(`keydown`,this.onKeyDown,IV),this.systemLightThemeMedia?.addEventListener(`change`,this.onSystemLightThemeChange),this.applyPreferredTheme(!1),this.connectRealtime(),this.renegotiateUnreadMachines(),this.piWebUiStatusTimer=window.setInterval(()=>{this.schedulePiWebUiStatusRefresh()},NV),this.refreshWorkspaceActivity(),this.recentProjects.load(),this.loadClientConfig(),this.ensureGatewayPluginsLoaded(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebUiStatusRefresh()}),this.syncWindowTitle()}disconnectedCallback(){this.disconnectSpeechInputSettings(),this.finishTerminalModalPointerInteraction(),this.hostSpeech.dispose(),this.unreadConnected=!1,this.committedChatIdentity=void 0,this.readyChatIdentity=void 0,this.unreadRuntimeRefreshes.clear(),this.sessionUnread.retainMachines(new Set),window.removeEventListener(`popstate`,this.onPopState),window.removeEventListener(`pageshow`,this.onPageShow),window.removeEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.disconnect(),window.removeEventListener(`keydown`,this.onKeyDown,IV),this.systemLightThemeMedia?.removeEventListener(`change`,this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.resetActiveModelPolicyDraft(),this.sessions.dispose(),this.projectCatalog.dispose(),this.notifications.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.git.dispose(),this.memory.dispose(),this.learnedSkills.dispose(),this.piWebUiStatusTimer!==void 0&&window.clearInterval(this.piWebUiStatusTimer),this.piWebUiStatusTimer=void 0,this.clearScheduledPiWebUiStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.clearPendingRemoteRouteRestore(),this.disconnectWindowTitle(),this.workspaceTasks.observe(!1),this.workspaceTasks.dispose(),super.disconnectedCallback()}setState(e){if(!EH(this.state,e))return;let t=this.state,n={...t,...e},r=oH(t),i=oH(n);sH(r,i)?t.status?.isCompacting!==!0&&n.status?.isCompacting===!0?this.hostSpeech.stop():this.abandonHostSpeechIfSourceInvalid(n):this.hostSpeech.select(i);let a=cH(t),o=uH(t),s=lH(t);this.state=n,s!==lH(this.state)&&(this.starterModelPolicySelectionGeneration+=1),a!==cH(this.state)&&this.resetActiveModelPolicyDraft(),aH(t)!==aH(this.state)&&(this.committedChatIdentity=void 0,this.readyChatIdentity=void 0),SH(t,this.state)&&this.syncSessionUnreadMachines(),this.syncUnreadSessionIds(),this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),!this.shouldShowSessionStartScreen(t)&&this.shouldShowSessionStartScreen(this.state)&&this.state.selectedWorkspace!==void 0&&this.loadStarterSessionDefaults(this.state.selectedWorkspace),this.handleMachineChange(t,this.state),this.handleStarterModelPolicyCapabilityChange(t,this.state),CH(t,this.state)&&this.syncMachineActivitySubscriptions(),this.notifications.syncEnvironment(t,this.state),t.selectedProject?.name!==this.state.selectedProject?.name&&this.syncWindowTitle(),this.synchronizeProjectCatalogPolling();let c=uH(this.state);c!==void 0&&c!==o&&this.preloadActiveModelPolicyInputs()}synchronizeProjectCatalogPolling(){this.projectCatalog.updatePolling(!!this.isConnected)}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();let e=kw();await this.machines.loadMachines(e.machineId);let t=this.routeForSelectedMachine(e),n=this.state.machineStatuses[t.machineId??`local`];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,n)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}connectSpeechInputSettings(){if(!this.speechInputSettingsConnected){this.speechInputSettingsConnected=!0;try{this.speechInputSettingsChannel=this.createSpeechInputSettingsChannel(e=>{this.handleSpeechInputSettingsChannelRevision(e)})}catch{this.speechInputSettingsChannel=void 0}this.refreshSpeechInputSettings()}}disconnectSpeechInputSettings(){!this.speechInputSettingsConnected&&this.speechInputSettingsChannel===void 0||(this.speechInputSettingsConnected=!1,this.speechInputSettingsRequestSeq+=1,this.speechInputSettingsChannelDispatchQueued=!1,this.speechInputSettingsChannelRefreshInFlight=!1,this.pendingSpeechInputSettingsChannelRevision=void 0,this.speechInputSettingsChannel?.close(),this.speechInputSettingsChannel=void 0)}async refreshSpeechInputSettings(){if(!this.speechInputSettingsConnected)return;let e=++this.speechInputSettingsRequestSeq;try{let t=await this.speechInputSettingsApi.settings();if(e!==this.speechInputSettingsRequestSeq)return;this.speechInputSettings=t}catch{}}handleSpeechInputSettingsLoaded(e){this.adoptSpeechInputSettings(e,!1)}handleSpeechInputSettingsSaved(e){this.adoptSpeechInputSettings(e,!0)}adoptSpeechInputSettings(e,t){this.speechInputSettingsConnected&&(this.speechInputSettingsRequestSeq+=1,this.speechInputSettings=e,this.pendingSpeechInputSettingsChannelRevision===e.revision&&(this.pendingSpeechInputSettingsChannelRevision=void 0),t&&this.speechInputSettingsChannel?.publish(e.revision))}handleSpeechInputSettingsChannelRevision(e){!this.speechInputSettingsConnected||e===this.speechInputSettings?.revision||(this.pendingSpeechInputSettingsChannelRevision=e,!(this.speechInputSettingsChannelRefreshInFlight||this.speechInputSettingsChannelDispatchQueued)&&(this.speechInputSettingsChannelDispatchQueued=!0,queueMicrotask(()=>{this.speechInputSettingsChannelDispatchQueued=!1,!(!this.speechInputSettingsConnected||this.speechInputSettingsChannelRefreshInFlight)&&this.refreshSpeechInputSettingsFromChannel()})))}async refreshSpeechInputSettingsFromChannel(){if(!(!this.speechInputSettingsConnected||this.speechInputSettingsChannelRefreshInFlight)&&this.pendingSpeechInputSettingsChannelRevision!==void 0){this.pendingSpeechInputSettingsChannelRevision=void 0,this.speechInputSettingsChannelRefreshInFlight=!0;try{await this.refreshSpeechInputSettings()}finally{this.speechInputSettingsChannelRefreshInFlight=!1,this.shouldRunSpeechInputSettingsChannelTrailingRefresh()&&this.refreshSpeechInputSettingsFromChannel()}}}shouldRunSpeechInputSettingsChannelTrailingRefresh(){return this.speechInputSettingsConnected&&this.pendingSpeechInputSettingsChannelRevision!==void 0}handleBrowserResumeSignal(){this.appShell.repairViewportPosition(),this.schedulePiWebUiStatusRefresh(),this.retryPendingRemoteRouteRestoreSoon()}async refreshAfterBrowserResume(){this.projectCatalog.refresh(),await this.renegotiateUnreadMachines(),await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.refreshWorkspaceDeletionRuns(),this.refreshSpeechInputSettings()])}schedulePiWebUiStatusRefresh(e=PV){this.clearScheduledPiWebUiStatusRefresh(),this.piWebUiStatusDeferredTimer=window.setTimeout(()=>{this.piWebUiStatusDeferredTimer=void 0,this.piWebUiStatusController.refresh()},e)}clearScheduledPiWebUiStatusRefresh(){this.piWebUiStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebUiStatusDeferredTimer),this.piWebUiStatusDeferredTimer=void 0)}async refreshWorkspaceActivity(e=R(this.state)){try{await this.activity.refresh(e)}catch(t){console.warn(`Failed to refresh workspace activity for ${e}`,t)}}async refreshMachineActivities(){let e=this.state.machines.length===0?[R(this.state)]:this.state.machines.filter(e=>TH(e,this.state.machineStatuses[e.id])).map(e=>e.id);await Promise.all(e.map(e=>this.refreshWorkspaceActivity(e)))}async loadClientConfig(){try{this.applyClientConfig((await ec.config()).effectiveConfig)}catch(e){console.warn(`Failed to load PI WEBUI config`,e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=Kl(e),this.hostSpeech.configure(e.tts)}async refreshAppData(){if(!this.isRefreshingApp){this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.loadClientConfig(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface()]),this.schedulePiWebUiStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){let e=this.state.selectedWorkspace,t=this.state.mainView!==`chat`&&this.state.mainView!==`navigation`?this.state.mainView:this.state.workspaceTool;t===`core:workspace.files`?await this.files.refreshFiles():t===`core:workspace.git`?await this.git.refreshGit():t===`core:workspace.terminal`&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(kw(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,n=this.readWorkspaceRouteSurface(e),r){let i=R(this.state),a=e.projectId===void 0||e.projectId===``?AH():n,o=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=a.selectedTerminalId;try{await this.restoreRouteMachine(e,!1);let n=this.loadPluginsForSelectedMachine();if(e.tool?.startsWith(`machine.`)===!0&&await n,!this.isCurrentRouteRestore(o))return;if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:r??e.view??this.defaultRouteView(),selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),e.projectId===void 0||e.projectId===``){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(e)){a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl();return}let i=this.state.projects.find(t=>t.id===e.projectId);if(!i){this.setState({selectedFilePath:void 0,selectedDiffPath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(i,{workspaceId:e.workspaceId,sessionId:e.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(o))return;this.setState({selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),R(this.state)!==i&&this.schedulePiWebUiStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===``?AH():{selectedFilePath:yd(BV,`file`),selectedDiffPath:yd(VV,`diff`),selectedTerminalId:yd(HV,`terminal`)}}routeForSelectedMachine(e){let t=this.state.selectedMachine?.id??`local`;return(e.machineId??`local`)===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){Aw(e,{replace:!0}),bd(BV,`file`,void 0,{replace:!0}),bd(VV,`diff`,void 0,{replace:!0}),bd(HV,`terminal`,void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??`local`]){let n=e.machineId??`local`,r=this.state.selectedMachine;return n===`local`||r?.id!==n||r.kind!==`remote`||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===``?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=MH(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;let e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{let t=e.machineId??`local`,n=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(n?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==``){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=FV.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){let n=e.machineId??`local`,r=this.state.machines.find(e=>e.id===n)?.name??this.state.selectedMachine?.name??`Remote machine`,i=this.state.machineStatuses[n]?.error??(this.state.error===``?void 0:this.state.error),a=t.exhausted===!0?`${r} is still unavailable.`:`${r} is unavailable; reconnecting…`;this.setState({error:`${a}${i===void 0?``:` ${i}`}`})}pendingRemoteRouteRestoreStillCurrent(e){let t=e.machineId??`local`;return t!==`local`&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(e=>e.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){let n=e.machineId??`local`;if(this.state.selectedMachine?.id===n)return;let r=this.state.machines.find(e=>e.id===n);r!==void 0&&await this.machines.selectMachine(r,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??`local`)===(this.state.selectedMachine?.id??`local`)&&e.workspaceId!==void 0&&e.workspaceId!==``&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e===`core:workspace.files`&&await this.files.refreshFiles(),e===`core:workspace.files`&&t!==void 0&&await this.files.restoreFile(t),e===`core:workspace.git`&&await this.git.refreshGit()}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await IH(),t()&&(this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()))))}shouldAutoFocusPrompt(){return this.appShell.shouldAutoFocusPrompt()}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(){return this.appShell.defaultRouteView()}updateUrl(e){this.rememberCurrentMachineNavigation(),Aw({machineId:this.state.selectedMachine?.id,projectId:this.state.selectedProject?.id,workspaceId:this.state.selectedWorkspace?.id,sessionId:this.state.selectedSession?.id,tool:this.state.workspaceTool,view:this.state.mainView===`navigation`?void 0:this.state.mainView},e),this.syncWorkspaceRouteSurfaceToUrl()}rememberCurrentMachineNavigation(){this.machineNavigation.remember(Fy(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(Fy(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){Aw(Iy(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){bd(BV,`file`,e.selectedFilePath,{replace:!0}),bd(VV,`diff`,e.selectedDiffPath,{replace:!0}),bd(HV,`terminal`,e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();let n=++this.machineNavigationRestoreSeq,r=this.machineNavigation.latest(e.id)??Py(e.id);if(await this.restoreRouteFor(Iy(r),!1,r.surface,r.view),!(n!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(r)){this.machineNavigation.remember(r),this.writeMachineNavigationSnapshotToUrl(r);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==``}openWorkspaceTool(e){e===`core:workspace.terminal`&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e),this.git.updatePolling()}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool(`core:workspace.terminal`)}terminalCommandRunsForOrigin(e,t=R(this.state)){let n=jH(t,e),r=this.terminalCommandRunRuntimes.get(n);if(r!==void 0)return r;let i=Vw(e,{api:{runTerminalCommand:(e,n)=>Sc.runTerminalCommand(e,n,t),listCommandRuns:e=>Sc.listCommandRuns(e,t),getCommandRun:e=>Sc.getCommandRun(e,t)},openTerminal:(e,n)=>{this.openRuntimeTerminal(t,e,n)}}),a={...i,runCommand:async e=>{let n=await i.runCommand(e);return this.recordProjectWork({machineId:t,projectId:e.workspace.projectId}),n}};return this.terminalCommandRunRuntimes.set(n,a),a}async openRuntimeTerminal(e,t,n){return(R(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:`core:workspace.terminal`,view:`core:workspace.terminal`},!1,{selectedTerminalId:n?.terminalId},`core:workspace.terminal`),R(this.state)!==e)?(this.setState({error:`Machine not found for terminal command run`}),!1):(this.openTerminal(n),!0)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){let t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){bd(HV,`terminal`,e,t)}terminalWorkspaceKey(e){return`${R(this.state)}:${e.path}`}selectMainView(e){if(e!==`navigation`&&e!==`chat`){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}openSettings(e=`general`){this.settingsSection=e,Fw(e)}closeSettings(){this.settingsSection=void 0,Fw(void 0)}navigateSettings(e){this.settingsSection=e,Fw(e)}restoreSettingsRoute(){this.settingsSection=Pw()}handleWorkspaceChange(e,t){let n=xH(e,t);if(e.selectedWorkspace?.id===t.selectedWorkspace?.id){n&&(this.synchronizeMemoryPollingForSelectedWorkspace(),this.synchronizeLearnedSkillsPollingForSelectedWorkspace(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace());return}this.starterSessionDefaults=void 0,this.resetStarterModelPolicyForScopeChange(),this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();let r=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));if(this.setState({activeTerminalCount:0,selectedTerminalId:r}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(r,{replace:!0})),t.selectedWorkspace===void 0){this.synchronizeMemoryPollingForSelectedWorkspace(),this.synchronizeLearnedSkillsPollingForSelectedWorkspace(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace();return}this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling(),this.synchronizeMemoryPollingForSelectedWorkspace(),this.synchronizeLearnedSkillsPollingForSelectedWorkspace(),this.synchronizeWorkspaceTasksObservationForSelectedWorkspace()}async loadStarterSessionDefaults(e,t={}){let n=R(this.state),r=++this.starterSessionDefaultsSeq,i=this.starterModelPolicySelectionSupported(n),a=()=>r===this.starterSessionDefaultsSeq&&R(this.state)===n&&this.state.selectedWorkspace?.id===e.id&&this.state.selectedWorkspace.path===e.path&&(t.expectedSelectionGeneration===void 0||this.starterModelPolicySelectionGeneration===t.expectedSelectionGeneration);try{let r=i?await xc.sessionDefaultsV2(e.path,n):await xc.sessionDefaults(e.path,n);if(!a())return;let o=this.starterSessionDefaults;this.starterSessionDefaults=r,this.starterNotice=void 0,this.starterModelPolicyPreferenceReadError=r.starterModelPolicyPreferenceError??``;let s=this.starterModelPolicy;s===void 0||i&&!mH(o)?this.starterModelPolicy=gu(r):i?this.starterModelPolicy=s:this.starterModelPolicy=_u(s,r),this.completeStarterModelPolicyFromActiveTier();let c=this.starterModelPolicy;if(this.selectedMachineModelTierCatalog()===void 0&&(i||c.mode===`tiered`&&!this.modelTierCatalogLoading)){let e=this.ensureModelTierCatalog(n);t.awaitModelTierCatalog===!0&&await e}}catch(t){a()&&(console.warn(`Failed to load Pi session defaults`,t),this.publishStarterNotice(qu(`defaults-failed`,`Could not load this workspace's model defaults. ${NH(t)}`,{machineId:n,workspaceId:e.id})))}}syncSessionUnreadMachines(){if(!this.unreadConnected){this.sessionUnread.retainMachines(new Set);return}let e=new Set(this.state.machines.map(e=>e.id));this.sessionUnread.retainMachines(e);for(let t of e){let e=this.state.machineRuntimes[t];if(e===void 0)continue;let n=this.unreadRuntimeRefreshes.has(t)||!e.ok?`unknown`:E(e,w.sessionsUnread)?`supported`:`unsupported`;this.sessionUnread.setCapability(t,n)&&this.sessionUnread.refresh(t)}}async renegotiateUnreadMachines(){if(!this.unreadConnected)return;let e=new Set(this.state.machines.map(e=>e.id));e.add(R(this.state)),await Promise.all([...e].map(async e=>{await this.renegotiateUnreadMachine(e)}))}renegotiateUnreadMachine(e){let t=this.unreadRuntimeRefreshes.get(e);if(t!==void 0)return t;this.sessionUnread.setCapability(e,`unknown`);let n=!1,r=Promise.resolve().then(async()=>{n=await this.machines.refreshMachineRuntime(e)!==void 0});this.unreadRuntimeRefreshes.set(e,r);let i=()=>{this.unreadRuntimeRefreshes.get(e)===r&&(this.unreadRuntimeRefreshes.delete(e),this.unreadConnected&&(n?this.syncSessionUnreadMachines():this.sessionUnread.setCapability(e,`unknown`)))};return r.then(i,i),r}connectRealtime(){let e=R(this.state);this.realtime.connect(t=>{this.handleRealtimeEvent(e,t)},()=>{this.renegotiateUnreadMachine(e);let t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t),this.refreshWorkspaceActivity(e),this.projectCatalog.refresh()},e)}syncMachineActivitySubscriptions(){let e=this.machineActivitySubscriptionIds();for(let[t,n]of this.machineRealtimeSockets.entries())e.has(t)||(n.close(),this.machineRealtimeSockets.delete(t));for(let t of e){if(this.machineRealtimeSockets.has(t))continue;let e=new Rm;e.connect(e=>{this.handleMachineActivityEvent(t,e)},()=>{this.renegotiateUnreadMachine(t),this.refreshWorkspaceActivity(t)},t),this.machineRealtimeSockets.set(t,e)}}closeMachineActivitySockets(){for(let e of this.machineRealtimeSockets.values())e.close();this.machineRealtimeSockets.clear()}machineActivitySubscriptionIds(){let e=R(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(e=>wH(e,this.state.machineStatuses[e.id])).map(e=>e.id))}handleMachineActivityEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`&&this.activity.applyWorkspaceActivity(t.activity,e)}handleRealtimeEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`?this.activity.applyWorkspaceActivity(t.activity):kH(t)?(this.applyTerminalEvent(t),t.type===`terminal.exited`&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(e){let t=this.state.selectedWorkspace;t!==void 0&&(e.type===`terminal.closed`?e.cwd:e.terminal.cwd)===t.path&&(e.type===`terminal.created`&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type===`terminal.closed`?e.terminalId:e.terminal.id),e.type===`terminal.closed`&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){let t=R(this.state);try{let n=await Sc.terminals(e.projectId,e.id,t);if(R(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(let e of n)e.exited||this.activeTerminalIds.add(e.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(e,t){let n=OH(e),r=OH(t);n&&!r&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){if((e.selectedMachine?.id??`local`)===(t.selectedMachine?.id??`local`))return;this.closeRecentProjectDialogForMachineChange(),this.closeProjectStatistics(),this.projectActivityOwnership.handleSelectedMachineChanged(),(this.pendingRemoteRouteRestore?.machineId??`local`)!==(t.selectedMachine?.id??`local`)&&this.clearPendingRemoteRouteRestore(),this.sessions.clearActiveSession(),this.starterSessionDefaults=void 0,this.resetStarterModelPolicyForScopeChange(),this.resetModelTierCatalogForMachineChange(),this.realtime.close(),this.connectRealtime(),this.activeTerminalIds.clear(),this.sessionCleanupDialog=void 0,this.setState({piWebUiStatus:void 0}),this.git.updatePolling(),this.recentProjects.load(),this.loadPluginsForSelectedMachine();let n=t.selectedWorkspace;n!==void 0&&this.shouldShowSessionStartScreen(t)&&this.loadStarterSessionDefaults(n)}refreshSelectedWorkspaceTool(e){e===`core:workspace.files`&&this.files.refreshFiles(),e===`core:workspace.git`&&this.git.refreshGit()}renderWorkspacePanel(){return g`
7421
7425
  <workspace-panel
7422
7426
  id="workspace-panel"
7423
7427
  .emptyState=${this.state.selectedWorkspace===void 0?this.workspacePanelEmptyState():void 0}
@@ -1,4 +1,4 @@
1
- import{l as e,n as t}from"./index-C8fQLkMH.js";var n=e((e=>{var t=e&&e.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)},n=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},r=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},i=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.LiteElement=void 0,e.LiteElement=function(){function e(e,a,o){var s,c;a===void 0&&(a={}),o===void 0&&(o=[]),this.kind=e,this.attributes=t({},a),this.children=r([],n(o),!1);try{for(var l=i(this.children),u=l.next();!u.done;u=l.next()){var d=u.value;d.parent=this}}catch(e){s={error:e}}finally{try{u&&!u.done&&(c=l.return)&&c.call(l)}finally{if(s)throw s.error}}this.styles=null}return e}()})),r=e((e=>{var t=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractDOMAdaptor=void 0,e.AbstractDOMAdaptor=function(){function e(e){e===void 0&&(e=null),this.document=e}return e.prototype.node=function(e,n,r,i){var a,o;n===void 0&&(n={}),r===void 0&&(r=[]);var s=this.create(e,i);this.setAttributes(s,n);try{for(var c=t(r),l=c.next();!l.done;l=c.next()){var u=l.value;this.append(s,u)}}catch(e){a={error:e}}finally{try{l&&!l.done&&(o=c.return)&&o.call(c)}finally{if(a)throw a.error}}return s},e.prototype.setAttributes=function(e,n){var r,i,a,o,s,c;if(n.style&&typeof n.style!=`string`)try{for(var l=t(Object.keys(n.style)),u=l.next();!u.done;u=l.next()){var d=u.value;this.setStyle(e,d.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()}),n.style[d])}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}if(n.properties)try{for(var f=t(Object.keys(n.properties)),p=f.next();!p.done;p=f.next()){var d=p.value;e[d]=n.properties[d]}}catch(e){a={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(a)throw a.error}}try{for(var m=t(Object.keys(n)),h=m.next();!h.done;h=m.next()){var d=h.value;(d!==`style`||typeof n.style==`string`)&&d!==`properties`&&this.setAttribute(e,d,n[d])}}catch(e){s={error:e}}finally{try{h&&!h.done&&(c=m.return)&&c.call(m)}finally{if(s)throw s.error}}},e.prototype.replace=function(e,t){return this.insert(e,t),this.remove(t),t},e.prototype.childNode=function(e,t){return this.childNodes(e)[t]},e.prototype.allClasses=function(e){var t=this.getAttribute(e,`class`);return t?t.replace(/ +/g,` `).replace(/^ /,``).replace(/ $/,``).split(/ /):[]},e}()})),i=e((e=>{var t=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},n=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},r=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.lookup=e.separateOptions=e.selectOptionsFromKeys=e.selectOptions=e.userOptions=e.defaultOptions=e.insert=e.copy=e.keys=e.makeArray=e.expandable=e.Expandable=e.OPTIONS=e.REMOVE=e.APPEND=e.isObject=void 0;var i={}.constructor;function a(e){return typeof e==`object`&&!!e&&(e.constructor===i||e.constructor===o)}e.isObject=a,e.APPEND=`[+]`,e.REMOVE=`[-]`,e.OPTIONS={invalidOption:`warn`,optionError:function(t,n){if(e.OPTIONS.invalidOption===`fatal`)throw Error(t);console.warn(`MathJax: `+t)}};var o=function(){function e(){}return e}();e.Expandable=o;function s(e){return Object.assign(Object.create(o.prototype),e)}e.expandable=s;function c(e){return Array.isArray(e)?e:[e]}e.makeArray=c;function l(e){return e?Object.keys(e).concat(Object.getOwnPropertySymbols(e)):[]}e.keys=l;function u(e){var n,r,i={};try{for(var c=t(l(e)),f=c.next();!f.done;f=c.next()){var p=f.value,m=Object.getOwnPropertyDescriptor(e,p),h=m.value;Array.isArray(h)?m.value=d([],h,!1):a(h)&&(m.value=u(h)),m.enumerable&&(i[p]=m)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return Object.defineProperties(e.constructor===o?s({}):{},i)}e.copy=u;function d(i,s,c){var f,p;c===void 0&&(c=!0);var m=function(t){if(c&&i[t]===void 0&&i.constructor!==o)return typeof t==`symbol`&&(t=t.toString()),e.OPTIONS.optionError(`Invalid option "${t}" (no default value).`,t),`continue`;var f=s[t],p=i[t];if(a(f)&&p!==null&&(typeof p==`object`||typeof p==`function`)){var m=l(f);Array.isArray(p)&&(m.length===1&&(m[0]===e.APPEND||m[0]===e.REMOVE)&&Array.isArray(f[m[0]])||m.length===2&&m.sort().join(`,`)===e.APPEND+`,`+e.REMOVE&&Array.isArray(f[e.APPEND])&&Array.isArray(f[e.REMOVE]))?(f[e.REMOVE]&&(p=i[t]=p.filter(function(t){return f[e.REMOVE].indexOf(t)<0})),f[e.APPEND]&&(i[t]=r(r([],n(p),!1),n(f[e.APPEND]),!1))):d(p,f,c)}else Array.isArray(f)?(i[t]=[],d(i[t],f,!1)):a(f)?i[t]=u(f):i[t]=f};try{for(var h=t(l(s)),g=h.next();!g.done;g=h.next()){var _=g.value;m(_)}}catch(e){f={error:e}}finally{try{g&&!g.done&&(p=h.return)&&p.call(h)}finally{if(f)throw f.error}}return i}e.insert=d;function f(e){return[...arguments].slice(1).forEach(function(t){return d(e,t,!1)}),e}e.defaultOptions=f;function p(e){return[...arguments].slice(1).forEach(function(t){return d(e,t,!0)}),e}e.userOptions=p;function m(e){for(var n,r,i=[],a=1;a<arguments.length;a++)i[a-1]=arguments[a];var o={};try{for(var s=t(i),c=s.next();!c.done;c=s.next()){var l=c.value;e.hasOwnProperty(l)&&(o[l]=e[l])}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}e.selectOptions=m;function h(e,t){return m.apply(void 0,r([e],n(Object.keys(t)),!1))}e.selectOptionsFromKeys=h;function g(e){for(var n,r,i,a,o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];var c=[];try{for(var l=t(o),u=l.next();!u.done;u=l.next()){var d=u.value,f={},p={};try{for(var m=(i=void 0,t(Object.keys(e||{}))),h=m.next();!h.done;h=m.next()){var g=h.value;(d[g]===void 0?p:f)[g]=e[g]}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}c.push(f),e=p}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return c.unshift(e),c}e.separateOptions=g;function _(e,t,n){return n===void 0&&(n=null),t.hasOwnProperty(e)?t[e]:n}e.lookup=_})),a=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),n=e&&e.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.NodeMixin=e.NodeMixinOptions=void 0;var r=i();e.NodeMixinOptions={badCSS:!0,badSizes:!0};function a(i,a){var o;return a===void 0&&(a={}),a=(0,r.userOptions)((0,r.defaultOptions)({},e.NodeMixinOptions),a),o=function(e){t(n,e);function n(){var t=[...arguments],n=e.call(this,t[0])||this,i=n.constructor;return n.options=(0,r.userOptions)((0,r.defaultOptions)({},i.OPTIONS),t[1]),n}return n.prototype.fontSize=function(t){return a.badCSS?this.options.fontSize:e.prototype.fontSize.call(this,t)},n.prototype.fontFamily=function(t){return a.badCSS?this.options.fontFamily:e.prototype.fontFamily.call(this,t)},n.prototype.nodeSize=function(t,r,i){if(r===void 0&&(r=1),i===void 0&&(i=null),!a.badSizes)return e.prototype.nodeSize.call(this,t,r,i);var o=this.textContent(t),s=Array.from(o.replace(n.cjkPattern,``)).length;return[(Array.from(o).length-s)*this.options.cjkCharWidth+s*this.options.unknownCharWidth,this.options.unknownCharHeight]},n.prototype.nodeBBox=function(t){return a.badSizes?{left:0,right:0,top:0,bottom:0}:e.prototype.nodeBBox.call(this,t)},n}(i),o.OPTIONS=n(n({},a.badCSS?{fontSize:16,fontFamily:`Times`}:{}),a.badSizes?{cjkCharWidth:1,unknownCharWidth:.6,unknownCharHeight:.8}:{}),o.cjkPattern=new RegExp([`[`,`ᄀ-ᅟ`,`〈〉`,`⺀-〾`,`぀-㉇`,`㉐-䶿`,`一-꓆`,`ꥠ-ꥼ`,`가-힣`,`豈-﫿`,`︐-︙`,`︰-﹫`,`!-⦆¢-₩`,`𛀀-𛀁`,`🈀-🉑`,`𠀀-𿿽`,`]`].join(``),`gu`),o}e.NodeMixin=a})),o=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LiteDocument=void 0;var t=n();e.LiteDocument=function(){function e(){this.root=new t.LiteElement(`html`,{},[this.head=new t.LiteElement(`head`),this.body=new t.LiteElement(`body`)]),this.type=``}return Object.defineProperty(e.prototype,"kind",{get:function(){return`#document`},enumerable:!1,configurable:!0}),e}()})),s=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,"__esModule",{value:!0}),e.LiteComment=e.LiteText=void 0;var n=function(){function e(e){e===void 0&&(e=``),this.value=e}return Object.defineProperty(e.prototype,"kind",{get:function(){return`#text`},enumerable:!1,configurable:!0}),e}();e.LiteText=n,e.LiteComment=function(e){t(n,e);function n(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(n.prototype,"kind",{get:function(){return`#comment`},enumerable:!1,configurable:!0}),n}(n)})),c=e((e=>{var t=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},n=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.LiteList=void 0,e.LiteList=function(){function e(e){this.nodes=[],this.nodes=n([],t(e),!1)}return e.prototype.append=function(e){this.nodes.push(e)},e.prototype[Symbol.iterator]=function(){var e=0;return{next:function(){return e===this.nodes.length?{value:null,done:!0}:{value:this.nodes[e++],done:!1}}}},e}()})),l=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.retryAfter=e.handleRetriesFor=void 0;function t(e){return new Promise(function t(n,r){try{n(e())}catch(e){e.retry&&e.retry instanceof Promise?e.retry.then(function(){return t(n,r)}).catch(function(e){return r(e)}):e.restart&&e.restart.isCallback?MathJax.Callback.After(function(){return t(n,r)},e.restart):r(e)}})}e.handleRetriesFor=t;function n(e){var t=Error(`MathJax retry`);throw t.retry=e,t}e.retryAfter=n})),u=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION=`3.2.2`})),d=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PrioritizedList=void 0,e.PrioritizedList=function(){function e(){this.items=[],this.items=[]}return e.prototype[Symbol.iterator]=function(){var e=0,t=this.items;return{next:function(){return{value:t[e++],done:e>t.length}}}},e.prototype.add=function(t,n){n===void 0&&(n=e.DEFAULTPRIORITY);var r=this.items.length;do r--;while(r>=0&&n<this.items[r].priority);return this.items.splice(r+1,0,{item:t,priority:n}),t},e.prototype.remove=function(e){var t=this.items.length;do t--;while(t>=0&&this.items[t].item!==e);t>=0&&this.items.splice(t,1)},e.DEFAULTPRIORITY=5,e}()})),f=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),n=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.HandlerList=void 0,e.HandlerList=function(e){t(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.register=function(e){return this.add(e,e.priority)},r.prototype.unregister=function(e){this.remove(e)},r.prototype.handlesDocument=function(e){var t,r;try{for(var i=n(this),a=i.next();!a.done;a=i.next()){var o=a.value.item;if(o.handlesDocument(e))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}throw Error(`Can't find handler for document`)},r.prototype.document=function(e,t){return t===void 0&&(t=null),this.handlesDocument(e).create(e,t)},r}(d().PrioritizedList)})),p=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mathjax=void 0;var t=u(),n=f(),r=l();e.mathjax={version:t.VERSION,handlers:new n.HandlerList,document:function(t,n){return e.mathjax.handlers.document(t,n)},handleRetriesFor:r.handleRetriesFor,retryAfter:r.retryAfter,asyncLoad:null}})),m=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.asyncLoad=void 0;var t=p();function n(e){return t.mathjax.asyncLoad?new Promise(function(n,r){var i=t.mathjax.asyncLoad(e);i instanceof Promise?i.then(function(e){return n(e)}).catch(function(e){return r(e)}):n(i)}):Promise.reject(`Can't load '${e}': No asyncLoad method specified`)}e.asyncLoad=n})),h=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.numeric=e.translate=e.remove=e.add=e.entities=e.options=void 0;var t=l(),n=m();e.options={loadMissingEntities:!0},e.entities={ApplyFunction:`⁡`,Backslash:`∖`,Because:`∵`,Breve:`˘`,Cap:`⋒`,CenterDot:`·`,CircleDot:`⊙`,CircleMinus:`⊖`,CirclePlus:`⊕`,CircleTimes:`⊗`,Congruent:`≡`,ContourIntegral:`∮`,Coproduct:`∐`,Cross:`⨯`,Cup:`⋓`,CupCap:`≍`,Dagger:`‡`,Del:`∇`,Delta:`Δ`,Diamond:`⋄`,DifferentialD:`ⅆ`,DotEqual:`≐`,DoubleDot:`¨`,DoubleRightTee:`⊨`,DoubleVerticalBar:`∥`,DownArrow:`↓`,DownLeftVector:`↽`,DownRightVector:`⇁`,DownTee:`⊤`,Downarrow:`⇓`,Element:`∈`,EqualTilde:`≂`,Equilibrium:`⇌`,Exists:`∃`,ExponentialE:`ⅇ`,FilledVerySmallSquare:`▪`,ForAll:`∀`,Gamma:`Γ`,Gg:`⋙`,GreaterEqual:`≥`,GreaterEqualLess:`⋛`,GreaterFullEqual:`≧`,GreaterLess:`≷`,GreaterSlantEqual:`⩾`,GreaterTilde:`≳`,Hacek:`ˇ`,Hat:`^`,HumpDownHump:`≎`,HumpEqual:`≏`,Im:`ℑ`,ImaginaryI:`ⅈ`,Integral:`∫`,Intersection:`⋂`,InvisibleComma:`⁣`,InvisibleTimes:`⁢`,Lambda:`Λ`,Larr:`↞`,LeftAngleBracket:`⟨`,LeftArrow:`←`,LeftArrowRightArrow:`⇆`,LeftCeiling:`⌈`,LeftDownVector:`⇃`,LeftFloor:`⌊`,LeftRightArrow:`↔`,LeftTee:`⊣`,LeftTriangle:`⊲`,LeftTriangleEqual:`⊴`,LeftUpVector:`↿`,LeftVector:`↼`,Leftarrow:`⇐`,Leftrightarrow:`⇔`,LessEqualGreater:`⋚`,LessFullEqual:`≦`,LessGreater:`≶`,LessSlantEqual:`⩽`,LessTilde:`≲`,Ll:`⋘`,Lleftarrow:`⇚`,LongLeftArrow:`⟵`,LongLeftRightArrow:`⟷`,LongRightArrow:`⟶`,Longleftarrow:`⟸`,Longleftrightarrow:`⟺`,Longrightarrow:`⟹`,Lsh:`↰`,MinusPlus:`∓`,NestedGreaterGreater:`≫`,NestedLessLess:`≪`,NotDoubleVerticalBar:`∦`,NotElement:`∉`,NotEqual:`≠`,NotExists:`∄`,NotGreater:`≯`,NotGreaterEqual:`≱`,NotLeftTriangle:`⋪`,NotLeftTriangleEqual:`⋬`,NotLess:`≮`,NotLessEqual:`≰`,NotPrecedes:`⊀`,NotPrecedesSlantEqual:`⋠`,NotRightTriangle:`⋫`,NotRightTriangleEqual:`⋭`,NotSubsetEqual:`⊈`,NotSucceeds:`⊁`,NotSucceedsSlantEqual:`⋡`,NotSupersetEqual:`⊉`,NotTilde:`≁`,NotVerticalBar:`∤`,Omega:`Ω`,OverBar:`‾`,OverBrace:`⏞`,PartialD:`∂`,Phi:`Φ`,Pi:`Π`,PlusMinus:`±`,Precedes:`≺`,PrecedesEqual:`⪯`,PrecedesSlantEqual:`≼`,PrecedesTilde:`≾`,Product:`∏`,Proportional:`∝`,Psi:`Ψ`,Rarr:`↠`,Re:`ℜ`,ReverseEquilibrium:`⇋`,RightAngleBracket:`⟩`,RightArrow:`→`,RightArrowLeftArrow:`⇄`,RightCeiling:`⌉`,RightDownVector:`⇂`,RightFloor:`⌋`,RightTee:`⊢`,RightTeeArrow:`↦`,RightTriangle:`⊳`,RightTriangleEqual:`⊵`,RightUpVector:`↾`,RightVector:`⇀`,Rightarrow:`⇒`,Rrightarrow:`⇛`,Rsh:`↱`,Sigma:`Σ`,SmallCircle:`∘`,Sqrt:`√`,Square:`□`,SquareIntersection:`⊓`,SquareSubset:`⊏`,SquareSubsetEqual:`⊑`,SquareSuperset:`⊐`,SquareSupersetEqual:`⊒`,SquareUnion:`⊔`,Star:`⋆`,Subset:`⋐`,SubsetEqual:`⊆`,Succeeds:`≻`,SucceedsEqual:`⪰`,SucceedsSlantEqual:`≽`,SucceedsTilde:`≿`,SuchThat:`∋`,Sum:`∑`,Superset:`⊃`,SupersetEqual:`⊇`,Supset:`⋑`,Therefore:`∴`,Theta:`Θ`,Tilde:`∼`,TildeEqual:`≃`,TildeFullEqual:`≅`,TildeTilde:`≈`,UnderBar:`_`,UnderBrace:`⏟`,Union:`⋃`,UnionPlus:`⊎`,UpArrow:`↑`,UpDownArrow:`↕`,UpTee:`⊥`,Uparrow:`⇑`,Updownarrow:`⇕`,Upsilon:`Υ`,Vdash:`⊩`,Vee:`⋁`,VerticalBar:`∣`,VerticalTilde:`≀`,Vvdash:`⊪`,Wedge:`⋀`,Xi:`Ξ`,amp:`&`,acute:`´`,aleph:`ℵ`,alpha:`α`,amalg:`⨿`,and:`∧`,ang:`∠`,angmsd:`∡`,angsph:`∢`,ape:`≊`,backprime:`‵`,backsim:`∽`,backsimeq:`⋍`,beta:`β`,beth:`ℶ`,between:`≬`,bigcirc:`◯`,bigodot:`⨀`,bigoplus:`⨁`,bigotimes:`⨂`,bigsqcup:`⨆`,bigstar:`★`,bigtriangledown:`▽`,bigtriangleup:`△`,biguplus:`⨄`,blacklozenge:`⧫`,blacktriangle:`▴`,blacktriangledown:`▾`,blacktriangleleft:`◂`,bowtie:`⋈`,boxdl:`┐`,boxdr:`┌`,boxminus:`⊟`,boxplus:`⊞`,boxtimes:`⊠`,boxul:`┘`,boxur:`└`,bsol:`\\`,bull:`•`,cap:`∩`,check:`✓`,chi:`χ`,circ:`ˆ`,circeq:`≗`,circlearrowleft:`↺`,circlearrowright:`↻`,circledR:`®`,circledS:`Ⓢ`,circledast:`⊛`,circledcirc:`⊚`,circleddash:`⊝`,clubs:`♣`,colon:`:`,comp:`∁`,ctdot:`⋯`,cuepr:`⋞`,cuesc:`⋟`,cularr:`↶`,cup:`∪`,curarr:`↷`,curlyvee:`⋎`,curlywedge:`⋏`,dagger:`†`,daleth:`ℸ`,ddarr:`⇊`,deg:`°`,delta:`δ`,digamma:`ϝ`,div:`÷`,divideontimes:`⋇`,dot:`˙`,doteqdot:`≑`,dotplus:`∔`,dotsquare:`⊡`,dtdot:`⋱`,ecir:`≖`,efDot:`≒`,egs:`⪖`,ell:`ℓ`,els:`⪕`,empty:`∅`,epsi:`ε`,epsiv:`ϵ`,erDot:`≓`,eta:`η`,eth:`ð`,flat:`♭`,fork:`⋔`,frown:`⌢`,gEl:`⪌`,gamma:`γ`,gap:`⪆`,gimel:`ℷ`,gnE:`≩`,gnap:`⪊`,gne:`⪈`,gnsim:`⋧`,gt:`>`,gtdot:`⋗`,harrw:`↭`,hbar:`ℏ`,hellip:`…`,hookleftarrow:`↩`,hookrightarrow:`↪`,imath:`ı`,infin:`∞`,intcal:`⊺`,iota:`ι`,jmath:`ȷ`,kappa:`κ`,kappav:`ϰ`,lEg:`⪋`,lambda:`λ`,lap:`⪅`,larrlp:`↫`,larrtl:`↢`,lbrace:`{`,lbrack:`[`,le:`≤`,leftleftarrows:`⇇`,leftthreetimes:`⋋`,lessdot:`⋖`,lmoust:`⎰`,lnE:`≨`,lnap:`⪉`,lne:`⪇`,lnsim:`⋦`,longmapsto:`⟼`,looparrowright:`↬`,lowast:`∗`,loz:`◊`,lt:`<`,ltimes:`⋉`,ltri:`◃`,macr:`¯`,malt:`✠`,mho:`℧`,mu:`μ`,multimap:`⊸`,nLeftarrow:`⇍`,nLeftrightarrow:`⇎`,nRightarrow:`⇏`,nVDash:`⊯`,nVdash:`⊮`,natur:`♮`,nearr:`↗`,nharr:`↮`,nlarr:`↚`,not:`¬`,nrarr:`↛`,nu:`ν`,nvDash:`⊭`,nvdash:`⊬`,nwarr:`↖`,omega:`ω`,omicron:`ο`,or:`∨`,osol:`⊘`,period:`.`,phi:`φ`,phiv:`ϕ`,pi:`π`,piv:`ϖ`,prap:`⪷`,precnapprox:`⪹`,precneqq:`⪵`,precnsim:`⋨`,prime:`′`,psi:`ψ`,quot:`"`,rarrtl:`↣`,rbrace:`}`,rbrack:`]`,rho:`ρ`,rhov:`ϱ`,rightrightarrows:`⇉`,rightthreetimes:`⋌`,ring:`˚`,rmoust:`⎱`,rtimes:`⋊`,rtri:`▹`,scap:`⪸`,scnE:`⪶`,scnap:`⪺`,scnsim:`⋩`,sdot:`⋅`,searr:`↘`,sect:`§`,sharp:`♯`,sigma:`σ`,sigmav:`ς`,simne:`≆`,smile:`⌣`,spades:`♠`,sub:`⊂`,subE:`⫅`,subnE:`⫋`,subne:`⊊`,supE:`⫆`,supnE:`⫌`,supne:`⊋`,swarr:`↙`,tau:`τ`,theta:`θ`,thetav:`ϑ`,tilde:`˜`,times:`×`,triangle:`▵`,triangleq:`≜`,upsi:`υ`,upuparrows:`⇈`,veebar:`⊻`,vellip:`⋮`,weierp:`℘`,xi:`ξ`,yen:`¥`,zeta:`ζ`,zigrarr:`⇝`,nbsp:`\xA0`,rsquo:`’`,lsquo:`‘`};var r={};function i(t,n){Object.assign(e.entities,t),r[n]=!0}e.add=i;function a(t){delete e.entities[t]}e.remove=a;function o(e){return e.replace(/&([a-z][a-z0-9]*|#(?:[0-9]+|x[0-9a-f]+));/gi,s)}e.translate=o;function s(i,a){if(a.charAt(0)===`#`)return c(a.slice(1));if(e.entities[a])return e.entities[a];if(e.options.loadMissingEntities){var o=a.match(/^[a-zA-Z](fr|scr|opf)$/)?RegExp.$1:a.charAt(0).toLowerCase();r[o]||(r[o]=!0,(0,t.retryAfter)((0,n.asyncLoad)(`./util/entities/`+o+`.js`)))}return i}function c(e){var t=e.charAt(0)===`x`?parseInt(e.slice(1),16):parseInt(e);return String.fromCodePoint(t)}e.numeric=c})),g=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(n,e,i);return r(n,e),n},a=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},o=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.LiteParser=e.PATTERNS=void 0;var c=i(h()),l=n(),u=s(),d;(function(e){e.TAGNAME=`[a-z][^\\s\\n>]*`,e.ATTNAME=`[a-z][^\\s\\n>=]*`,e.VALUE=`(?:'[^']*'|"[^"]*"|[^\\s\\n]+)`,e.VALUESPLIT=`(?:'([^']*)'|"([^"]*)"|([^\\s\\n]+))`,e.SPACE=`(?:\\s|\\n)+`,e.OPTIONALSPACE=`(?:\\s|\\n)*`,e.ATTRIBUTE=e.ATTNAME+`(?:`+e.OPTIONALSPACE+`=`+e.OPTIONALSPACE+e.VALUE+`)?`,e.ATTRIBUTESPLIT=`(`+e.ATTNAME+`)(?:`+e.OPTIONALSPACE+`=`+e.OPTIONALSPACE+e.VALUESPLIT+`)?`,e.TAG=`(<(?:`+e.TAGNAME+`(?:`+e.SPACE+e.ATTRIBUTE+`)*`+e.OPTIONALSPACE+`/?|/`+e.TAGNAME+`|!--[^]*?--|![^]*?)(?:>|$))`,e.tag=new RegExp(e.TAG,`i`),e.attr=new RegExp(e.ATTRIBUTE,`i`),e.attrsplit=new RegExp(e.ATTRIBUTESPLIT,`i`)})(d=e.PATTERNS||={}),e.LiteParser=function(){function e(){}return e.prototype.parseFromString=function(e,t,n){t===void 0&&(t=`text/html`),n===void 0&&(n=null);for(var r=n.createDocument(),i=n.body(r),a=e.replace(/<\?.*?\?>/g,``).split(d.tag);a.length;){var o=a.shift(),s=a.shift();o&&this.addText(n,i,o),s&&s.charAt(s.length-1)===`>`&&(s.charAt(1)===`!`?this.addComment(n,i,s):i=s.charAt(1)===`/`?this.closeTag(n,i,s):this.openTag(n,i,s,a))}return this.checkDocument(n,r),r},e.prototype.addText=function(e,t,n){return n=c.translate(n),e.append(t,e.text(n))},e.prototype.addComment=function(e,t,n){return e.append(t,new u.LiteComment(n))},e.prototype.closeTag=function(e,t,n){for(var r=n.slice(2,n.length-1).toLowerCase();e.parent(t)&&e.kind(t)!==r;)t=e.parent(t);return e.parent(t)},e.prototype.openTag=function(e,t,n,r){var i=this.constructor.PCDATA,a=this.constructor.SELF_CLOSING,o=n.match(/<(.*?)[\s\n>\/]/)[1].toLowerCase(),s=e.node(o),c=n.replace(/^<.*?[\s\n>]/,``).split(d.attrsplit);return(c.pop().match(/>$/)||c.length<5)&&(this.addAttributes(e,s,c),e.append(t,s),!a[o]&&!n.match(/\/>$/)&&(i[o]?this.handlePCDATA(e,s,o,r):t=s)),t},e.prototype.addAttributes=function(e,t,n){for(var r=this.constructor.CDATA_ATTR;n.length;){var i=a(n.splice(0,5),5),o=i[1],s=i[2],l=i[3],u=i[4],d=s||l||u||``;r[o]||(d=c.translate(d)),e.setAttribute(t,o,d)}},e.prototype.handlePCDATA=function(e,t,n,r){for(var i=[],a=`</`+n+`>`,o=``;r.length&&o!==a;)i.push(o),i.push(r.shift()),o=r.shift();e.append(t,e.text(i.join(``)))},e.prototype.checkDocument=function(e,t){var n,r,i,a,s=this.getOnlyChild(e,e.body(t));if(s){try{for(var c=o(e.childNodes(e.body(t))),l=c.next();!l.done;l=c.next()){var d=l.value;if(d===s)break;d instanceof u.LiteComment&&d.value.match(/^<!DOCTYPE/)&&(t.type=d.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}switch(e.kind(s)){case`html`:try{for(var f=o(s.children),p=f.next();!p.done;p=f.next()){var d=p.value;switch(e.kind(d)){case`head`:t.head=d;break;case`body`:t.body=d;break}}}catch(e){i={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}t.root=s,e.remove(s),e.parent(t.body)!==s&&e.append(s,t.body),e.parent(t.head)!==s&&e.insert(t.head,t.body);break;case`head`:t.head=e.replace(s,t.head);break;case`body`:t.body=e.replace(s,t.body);break}}},e.prototype.getOnlyChild=function(e,t){var n,r,i=null;try{for(var a=o(e.childNodes(t)),s=a.next();!s.done;s=a.next()){var c=s.value;if(c instanceof l.LiteElement){if(i)return null;i=c}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i},e.prototype.serialize=function(e,t,n){var r=this;n===void 0&&(n=!1);var i=this.constructor.SELF_CLOSING,a=this.constructor.CDATA_ATTR,o=e.kind(t),s=e.allAttributes(t).map(function(e){return e.name+`="`+(a[e.name]?e.value:r.protectAttribute(e.value))+`"`}).join(` `),c=this.serializeInner(e,t,n);return`<`+o+(s?` `+s:``)+((!n||c)&&!i[o]?`>${c}</${o}>`:n?`/>`:`>`)},e.prototype.serializeInner=function(e,t,n){var r=this;return n===void 0&&(n=!1),this.constructor.PCDATA.hasOwnProperty(t.kind)?e.childNodes(t).map(function(t){return e.value(t)}).join(``):e.childNodes(t).map(function(t){var i=e.kind(t);return i===`#text`?r.protectHTML(e.value(t)):i===`#comment`?t.value:r.serialize(e,t,n)}).join(``)},e.prototype.protectAttribute=function(e){return typeof e!=`string`&&(e=String(e)),e.replace(/"/g,`&quot;`)},e.prototype.protectHTML=function(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)},e.SELF_CLOSING={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},e.PCDATA={option:!0,textarea:!0,fieldset:!0,title:!0,style:!0,script:!0},e.CDATA_ATTR={style:!0,datafld:!0,datasrc:!0,href:!0,src:!0,longdesc:!0,usemap:!0,cite:!0,datetime:!0,action:!0,axis:!0,profile:!0,content:!0,scheme:!0},e}()})),_=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LiteWindow=void 0;var t=n(),r=o(),i=c(),a=g();e.LiteWindow=function(){function e(){this.DOMParser=a.LiteParser,this.NodeList=i.LiteList,this.HTMLCollection=i.LiteList,this.HTMLElement=t.LiteElement,this.DocumentFragment=i.LiteList,this.Document=r.LiteDocument,this.document=new r.LiteDocument}return e}()})),v=e((e=>{var t=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},n=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},r=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.Styles=void 0;var i=[`top`,`right`,`bottom`,`left`],a=[`width`,`style`,`color`];function o(e){for(var t=e.split(/((?:'[^']*'|"[^"]*"|,[\s\n]|[^\s\n])*)/g),n=[];t.length>1;)t.shift(),n.push(t.shift());return n}function s(e){var n,r,i=o(this.styles[e]);i.length===0&&i.push(``),i.length===1&&i.push(i[0]),i.length===2&&i.push(i[0]),i.length===3&&i.push(i[1]);try{for(var a=t(v.connect[e].children),s=a.next();!s.done;s=a.next()){var c=s.value;this.setStyle(this.childName(e,c),i.shift())}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}function c(e){var n,r,i=v.connect[e].children,a=[];try{for(var o=t(i),s=o.next();!s.done;s=o.next()){var c=s.value,l=this.styles[e+`-`+c];if(!l){delete this.styles[e];return}a.push(l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a[3]===a[1]&&(a.pop(),a[2]===a[0]&&(a.pop(),a[1]===a[0]&&a.pop())),this.styles[e]=a.join(` `)}function l(e){var n,r;try{for(var i=t(v.connect[e].children),a=i.next();!a.done;a=i.next()){var o=a.value;this.setStyle(this.childName(e,o),this.styles[e])}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}function u(e){var i,a,o=r([],n(v.connect[e].children),!1),s=this.styles[this.childName(e,o.shift())];try{for(var c=t(o),l=c.next();!l.done;l=c.next()){var u=l.value;if(this.styles[this.childName(e,u)]!==s){delete this.styles[e];return}}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=c.return)&&a.call(c)}finally{if(i)throw i.error}}this.styles[e]=s}var d={width:/^(?:[\d.]+(?:[a-z]+)|thin|medium|thick|inherit|initial|unset)$/,style:/^(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|inherit|initial|unset)$/};function f(e){var n,r,i,a,s={width:``,style:``,color:``};try{for(var c=t(o(this.styles[e])),l=c.next();!l.done;l=c.next()){var u=l.value;u.match(d.width)&&s.width===``?s.width=u:u.match(d.style)&&s.style===``?s.style=u:s.color=u}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}try{for(var f=t(v.connect[e].children),p=f.next();!p.done;p=f.next()){var m=p.value;this.setStyle(this.childName(e,m),s[m])}}catch(e){i={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}}function p(e){var n,r,i=[];try{for(var a=t(v.connect[e].children),o=a.next();!o.done;o=a.next()){var s=o.value,c=this.styles[this.childName(e,s)];c&&i.push(c)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}i.length?this.styles[e]=i.join(` `):delete this.styles[e]}var m={style:/^(?:normal|italic|oblique|inherit|initial|unset)$/,variant:RegExp(`^(?:`+[`normal|none`,`inherit|initial|unset`,`common-ligatures|no-common-ligatures`,`discretionary-ligatures|no-discretionary-ligatures`,`historical-ligatures|no-historical-ligatures`,`contextual|no-contextual`,`(?:stylistic|character-variant|swash|ornaments|annotation)\\([^)]*\\)`,`small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps`,`lining-nums|oldstyle-nums|proportional-nums|tabular-nums`,`diagonal-fractions|stacked-fractions`,`ordinal|slashed-zero`,`jis78|jis83|jis90|jis04|simplified|traditional`,`full-width|proportional-width`,`ruby`].join(`|`)+`)$`),weight:/^(?:normal|bold|bolder|lighter|[1-9]00|inherit|initial|unset)$/,stretch:RegExp(`^(?:`+[`normal`,`(?:(?:ultra|extra|semi)-)?condensed`,`(?:(?:semi|extra|ulta)-)?expanded`,`inherit|initial|unset`].join(`|`)+`)$`),size:RegExp(`^(?:`+[`xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller`,`[d.]+%|[d.]+[a-z]+`,`inherit|initial|unset`].join(`|`)+`)(?:/(?:normal|[d.+](?:%|[a-z]+)?))?$`)};function h(e){var r,i,a,s,c=o(this.styles[e]),l={style:``,variant:[],weight:``,stretch:``,size:``,family:``,"line-height":``};try{for(var u=t(c),d=u.next();!d.done;d=u.next()){var f=d.value;l.family=f;try{for(var p=(a=void 0,t(Object.keys(m))),h=p.next();!h.done;h=p.next()){var _=h.value;if((Array.isArray(l[_])||l[_]===``)&&f.match(m[_]))if(_===`size`){var v=n(f.split(/\//),2),y=v[0],b=v[1];l[_]=y,b&&(l[`line-height`]=b)}else l.size===``&&(Array.isArray(l[_])?l[_].push(f):l[_]=f)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(s=p.return)&&s.call(p)}finally{if(a)throw a.error}}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}g(e,l),delete this.styles[e]}function g(e,n){var r,i;try{for(var a=t(v.connect[e].children),o=a.next();!o.done;o=a.next()){var s=o.value,c=this.childName(e,s);if(Array.isArray(n[s])){var l=n[s];l.length&&(this.styles[c]=l.join(` `))}else n[s]!==``&&(this.styles[c]=n[s])}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}function _(e){}var v=function(){function e(e){e===void 0&&(e=``),this.parse(e)}return Object.defineProperty(e.prototype,"cssText",{get:function(){var e,n,r=[];try{for(var i=t(Object.keys(this.styles)),a=i.next();!a.done;a=i.next()){var o=a.value,s=this.parentName(o);this.styles[s]||r.push(o+`: `+this.styles[o]+`;`)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r.join(` `)},enumerable:!1,configurable:!0}),e.prototype.set=function(t,n){for(t=this.normalizeName(t),this.setStyle(t,n),e.connect[t]&&!e.connect[t].combine&&(this.combineChildren(t),delete this.styles[t]);t.match(/-/)&&(t=this.parentName(t),e.connect[t]);)e.connect[t].combine.call(this,t)},e.prototype.get=function(e){return e=this.normalizeName(e),this.styles.hasOwnProperty(e)?this.styles[e]:``},e.prototype.setStyle=function(t,n){this.styles[t]=n,e.connect[t]&&e.connect[t].children&&e.connect[t].split.call(this,t),n===``&&delete this.styles[t]},e.prototype.combineChildren=function(n){var r,i,a=this.parentName(n);try{for(var o=t(e.connect[n].children),s=o.next();!s.done;s=o.next()){var c=s.value,l=this.childName(a,c);e.connect[l].combine.call(this,l)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},e.prototype.parentName=function(e){var t=e.replace(/-[^-]*$/,``);return e===t?``:t},e.prototype.childName=function(t,n){return n.match(/-/)?n:(e.connect[t]&&!e.connect[t].combine&&(n+=t.replace(/.*-/,`-`),t=this.parentName(t)),t+`-`+n)},e.prototype.normalizeName=function(e){return e.replace(/[A-Z]/g,function(e){return`-`+e.toLowerCase()})},e.prototype.parse=function(e){e===void 0&&(e=``);var t=this.constructor.pattern;this.styles={};for(var r=e.replace(t.comment,``).split(t.style);r.length>1;){var i=n(r.splice(0,3),3),a=i[0],o=i[1],s=i[2];if(a.match(/[^\s\n]/))return;this.set(o,s)}},e.pattern={style:/([-a-z]+)[\s\n]*:[\s\n]*((?:'[^']*'|"[^"]*"|\n|.)*?)[\s\n]*(?:;|$)/g,comment:/\/\*[^]*?\*\//g},e.connect={padding:{children:i,split:s,combine:c},border:{children:i,split:l,combine:u},"border-top":{children:a,split:f,combine:p},"border-right":{children:a,split:f,combine:p},"border-bottom":{children:a,split:f,combine:p},"border-left":{children:a,split:f,combine:p},"border-width":{children:i,split:s,combine:null},"border-style":{children:i,split:s,combine:null},"border-color":{children:i,split:s,combine:null},font:{children:[`style`,`variant`,`weight`,`stretch`,`line-height`,`size`,`family`],split:h,combine:_}},e}();e.Styles=v})),y=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),i=e&&e.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)},c=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},l=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},u=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.liteAdaptor=e.LiteAdaptor=e.LiteBase=void 0;var d=r(),f=a(),p=o(),m=n(),h=s(),y=_(),b=g(),x=v(),S=function(e){t(n,e);function n(){var t=e.call(this)||this;return t.parser=new b.LiteParser,t.window=new y.LiteWindow,t}return n.prototype.parse=function(e,t){return this.parser.parseFromString(e,t,this)},n.prototype.create=function(e,t){return t===void 0&&(t=null),new m.LiteElement(e)},n.prototype.text=function(e){return new h.LiteText(e)},n.prototype.comment=function(e){return new h.LiteComment(e)},n.prototype.createDocument=function(){return new p.LiteDocument},n.prototype.head=function(e){return e.head},n.prototype.body=function(e){return e.body},n.prototype.root=function(e){return e.root},n.prototype.doctype=function(e){return e.type},n.prototype.tags=function(e,t,n){n===void 0&&(n=null);var r=[],i=[];if(n)return i;for(var a=e;a;){var o=a.kind;o!==`#text`&&o!==`#comment`&&(a=a,o===t&&i.push(a),a.children.length&&(r=a.children.concat(r))),a=r.shift()}return i},n.prototype.elementById=function(e,t){for(var n=[],r=e;r;){if(r.kind!==`#text`&&r.kind!==`#comment`){if(r=r,r.attributes.id===t)return r;r.children.length&&(n=r.children.concat(n))}r=n.shift()}return null},n.prototype.elementsByClass=function(e,t){for(var n=[],r=[],i=e;i;)i.kind!==`#text`&&i.kind!==`#comment`&&(i=i,(i.attributes.class||``).trim().split(/ +/).includes(t)&&r.push(i),i.children.length&&(n=i.children.concat(n))),i=n.shift();return r},n.prototype.getElements=function(e,t){var n,r,i=[],a=this.body(t);try{for(var o=c(e),s=o.next();!s.done;s=o.next()){var l=s.value;if(typeof l==`string`)if(l.charAt(0)===`#`){var u=this.elementById(a,l.slice(1));u&&i.push(u)}else l.charAt(0)===`.`?i=i.concat(this.elementsByClass(a,l.slice(1))):l.match(/^[-a-z][-a-z0-9]*$/i)&&(i=i.concat(this.tags(a,l)));else Array.isArray(l)?i=i.concat(l):l instanceof this.window.NodeList||l instanceof this.window.HTMLCollection?i=i.concat(l.nodes):i.push(l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},n.prototype.contains=function(e,t){for(;t&&t!==e;)t=this.parent(t);return!!t},n.prototype.parent=function(e){return e.parent},n.prototype.childIndex=function(e){return e.parent?e.parent.children.findIndex(function(t){return t===e}):-1},n.prototype.append=function(e,t){return t.parent&&this.remove(t),e.children.push(t),t.parent=e,t},n.prototype.insert=function(e,t){if(e.parent&&this.remove(e),t&&t.parent){var n=this.childIndex(t);t.parent.children.splice(n,0,e),e.parent=t.parent}},n.prototype.remove=function(e){var t=this.childIndex(e);return t>=0&&e.parent.children.splice(t,1),e.parent=null,e},n.prototype.replace=function(e,t){var n=this.childIndex(t);return n>=0&&(t.parent.children[n]=e,e.parent=t.parent,t.parent=null),t},n.prototype.clone=function(e){var t=this,n=new m.LiteElement(e.kind);return n.attributes=i({},e.attributes),n.children=e.children.map(function(e){if(e.kind===`#text`)return new h.LiteText(e.value);if(e.kind===`#comment`)return new h.LiteComment(e.value);var r=t.clone(e);return r.parent=n,r}),n},n.prototype.split=function(e,t){var n=new h.LiteText(e.value.slice(t));return e.value=e.value.slice(0,t),e.parent.children.splice(this.childIndex(e)+1,0,n),n.parent=e.parent,n},n.prototype.next=function(e){var t=e.parent;if(!t)return null;var n=this.childIndex(e)+1;return n>=0&&n<t.children.length?t.children[n]:null},n.prototype.previous=function(e){var t=e.parent;if(!t)return null;var n=this.childIndex(e)-1;return n>=0?t.children[n]:null},n.prototype.firstChild=function(e){return e.children[0]},n.prototype.lastChild=function(e){return e.children[e.children.length-1]},n.prototype.childNodes=function(e){return u([],l(e.children),!1)},n.prototype.childNode=function(e,t){return e.children[t]},n.prototype.kind=function(e){return e.kind},n.prototype.value=function(e){return e.kind===`#text`?e.value:e.kind===`#comment`?e.value.replace(/^<!(--)?((?:.|\n)*)\1>$/,`$2`):``},n.prototype.textContent=function(e){var t=this;return e.children.reduce(function(e,n){return e+(n.kind===`#text`?n.value:n.kind===`#comment`?``:t.textContent(n))},``)},n.prototype.innerHTML=function(e){return this.parser.serializeInner(this,e)},n.prototype.outerHTML=function(e){return this.parser.serialize(this,e)},n.prototype.serializeXML=function(e){return this.parser.serialize(this,e,!0)},n.prototype.setAttribute=function(e,t,n,r){r===void 0&&(r=null),typeof n!=`string`&&(n=String(n)),r&&(t=r.replace(/.*\//,``)+`:`+t.replace(/^.*:/,``)),e.attributes[t]=n,t===`style`&&(e.styles=null)},n.prototype.getAttribute=function(e,t){return e.attributes[t]},n.prototype.removeAttribute=function(e,t){delete e.attributes[t]},n.prototype.hasAttribute=function(e,t){return e.attributes.hasOwnProperty(t)},n.prototype.allAttributes=function(e){var t,n,r=e.attributes,i=[];try{for(var a=c(Object.keys(r)),o=a.next();!o.done;o=a.next()){var s=o.value;i.push({name:s,value:r[s]})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},n.prototype.addClass=function(e,t){var n=(e.attributes.class||``).split(/ /);n.find(function(e){return e===t})||(n.push(t),e.attributes.class=n.join(` `))},n.prototype.removeClass=function(e,t){var n=(e.attributes.class||``).split(/ /),r=n.findIndex(function(e){return e===t});r>=0&&(n.splice(r,1),e.attributes.class=n.join(` `))},n.prototype.hasClass=function(e,t){return!!(e.attributes.class||``).split(/ /).find(function(e){return e===t})},n.prototype.setStyle=function(e,t,n){e.styles||=new x.Styles(this.getAttribute(e,`style`)),e.styles.set(t,n),e.attributes.style=e.styles.cssText},n.prototype.getStyle=function(e,t){if(!e.styles){var n=this.getAttribute(e,`style`);if(!n)return``;e.styles=new x.Styles(n)}return e.styles.get(t)},n.prototype.allStyles=function(e){return this.getAttribute(e,`style`)},n.prototype.insertRules=function(e,t){e.children=[this.text(t.join(`
1
+ import{l as e,n as t}from"./index-BsI-Foow.js";var n=e((e=>{var t=e&&e.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)},n=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},r=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},i=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.LiteElement=void 0,e.LiteElement=function(){function e(e,a,o){var s,c;a===void 0&&(a={}),o===void 0&&(o=[]),this.kind=e,this.attributes=t({},a),this.children=r([],n(o),!1);try{for(var l=i(this.children),u=l.next();!u.done;u=l.next()){var d=u.value;d.parent=this}}catch(e){s={error:e}}finally{try{u&&!u.done&&(c=l.return)&&c.call(l)}finally{if(s)throw s.error}}this.styles=null}return e}()})),r=e((e=>{var t=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractDOMAdaptor=void 0,e.AbstractDOMAdaptor=function(){function e(e){e===void 0&&(e=null),this.document=e}return e.prototype.node=function(e,n,r,i){var a,o;n===void 0&&(n={}),r===void 0&&(r=[]);var s=this.create(e,i);this.setAttributes(s,n);try{for(var c=t(r),l=c.next();!l.done;l=c.next()){var u=l.value;this.append(s,u)}}catch(e){a={error:e}}finally{try{l&&!l.done&&(o=c.return)&&o.call(c)}finally{if(a)throw a.error}}return s},e.prototype.setAttributes=function(e,n){var r,i,a,o,s,c;if(n.style&&typeof n.style!=`string`)try{for(var l=t(Object.keys(n.style)),u=l.next();!u.done;u=l.next()){var d=u.value;this.setStyle(e,d.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()}),n.style[d])}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}if(n.properties)try{for(var f=t(Object.keys(n.properties)),p=f.next();!p.done;p=f.next()){var d=p.value;e[d]=n.properties[d]}}catch(e){a={error:e}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(a)throw a.error}}try{for(var m=t(Object.keys(n)),h=m.next();!h.done;h=m.next()){var d=h.value;(d!==`style`||typeof n.style==`string`)&&d!==`properties`&&this.setAttribute(e,d,n[d])}}catch(e){s={error:e}}finally{try{h&&!h.done&&(c=m.return)&&c.call(m)}finally{if(s)throw s.error}}},e.prototype.replace=function(e,t){return this.insert(e,t),this.remove(t),t},e.prototype.childNode=function(e,t){return this.childNodes(e)[t]},e.prototype.allClasses=function(e){var t=this.getAttribute(e,`class`);return t?t.replace(/ +/g,` `).replace(/^ /,``).replace(/ $/,``).split(/ /):[]},e}()})),i=e((e=>{var t=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},n=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},r=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.lookup=e.separateOptions=e.selectOptionsFromKeys=e.selectOptions=e.userOptions=e.defaultOptions=e.insert=e.copy=e.keys=e.makeArray=e.expandable=e.Expandable=e.OPTIONS=e.REMOVE=e.APPEND=e.isObject=void 0;var i={}.constructor;function a(e){return typeof e==`object`&&!!e&&(e.constructor===i||e.constructor===o)}e.isObject=a,e.APPEND=`[+]`,e.REMOVE=`[-]`,e.OPTIONS={invalidOption:`warn`,optionError:function(t,n){if(e.OPTIONS.invalidOption===`fatal`)throw Error(t);console.warn(`MathJax: `+t)}};var o=function(){function e(){}return e}();e.Expandable=o;function s(e){return Object.assign(Object.create(o.prototype),e)}e.expandable=s;function c(e){return Array.isArray(e)?e:[e]}e.makeArray=c;function l(e){return e?Object.keys(e).concat(Object.getOwnPropertySymbols(e)):[]}e.keys=l;function u(e){var n,r,i={};try{for(var c=t(l(e)),f=c.next();!f.done;f=c.next()){var p=f.value,m=Object.getOwnPropertyDescriptor(e,p),h=m.value;Array.isArray(h)?m.value=d([],h,!1):a(h)&&(m.value=u(h)),m.enumerable&&(i[p]=m)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return Object.defineProperties(e.constructor===o?s({}):{},i)}e.copy=u;function d(i,s,c){var f,p;c===void 0&&(c=!0);var m=function(t){if(c&&i[t]===void 0&&i.constructor!==o)return typeof t==`symbol`&&(t=t.toString()),e.OPTIONS.optionError(`Invalid option "${t}" (no default value).`,t),`continue`;var f=s[t],p=i[t];if(a(f)&&p!==null&&(typeof p==`object`||typeof p==`function`)){var m=l(f);Array.isArray(p)&&(m.length===1&&(m[0]===e.APPEND||m[0]===e.REMOVE)&&Array.isArray(f[m[0]])||m.length===2&&m.sort().join(`,`)===e.APPEND+`,`+e.REMOVE&&Array.isArray(f[e.APPEND])&&Array.isArray(f[e.REMOVE]))?(f[e.REMOVE]&&(p=i[t]=p.filter(function(t){return f[e.REMOVE].indexOf(t)<0})),f[e.APPEND]&&(i[t]=r(r([],n(p),!1),n(f[e.APPEND]),!1))):d(p,f,c)}else Array.isArray(f)?(i[t]=[],d(i[t],f,!1)):a(f)?i[t]=u(f):i[t]=f};try{for(var h=t(l(s)),g=h.next();!g.done;g=h.next()){var _=g.value;m(_)}}catch(e){f={error:e}}finally{try{g&&!g.done&&(p=h.return)&&p.call(h)}finally{if(f)throw f.error}}return i}e.insert=d;function f(e){return[...arguments].slice(1).forEach(function(t){return d(e,t,!1)}),e}e.defaultOptions=f;function p(e){return[...arguments].slice(1).forEach(function(t){return d(e,t,!0)}),e}e.userOptions=p;function m(e){for(var n,r,i=[],a=1;a<arguments.length;a++)i[a-1]=arguments[a];var o={};try{for(var s=t(i),c=s.next();!c.done;c=s.next()){var l=c.value;e.hasOwnProperty(l)&&(o[l]=e[l])}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}e.selectOptions=m;function h(e,t){return m.apply(void 0,r([e],n(Object.keys(t)),!1))}e.selectOptionsFromKeys=h;function g(e){for(var n,r,i,a,o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];var c=[];try{for(var l=t(o),u=l.next();!u.done;u=l.next()){var d=u.value,f={},p={};try{for(var m=(i=void 0,t(Object.keys(e||{}))),h=m.next();!h.done;h=m.next()){var g=h.value;(d[g]===void 0?p:f)[g]=e[g]}}catch(e){i={error:e}}finally{try{h&&!h.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}c.push(f),e=p}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return c.unshift(e),c}e.separateOptions=g;function _(e,t,n){return n===void 0&&(n=null),t.hasOwnProperty(e)?t[e]:n}e.lookup=_})),a=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),n=e&&e.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.NodeMixin=e.NodeMixinOptions=void 0;var r=i();e.NodeMixinOptions={badCSS:!0,badSizes:!0};function a(i,a){var o;return a===void 0&&(a={}),a=(0,r.userOptions)((0,r.defaultOptions)({},e.NodeMixinOptions),a),o=function(e){t(n,e);function n(){var t=[...arguments],n=e.call(this,t[0])||this,i=n.constructor;return n.options=(0,r.userOptions)((0,r.defaultOptions)({},i.OPTIONS),t[1]),n}return n.prototype.fontSize=function(t){return a.badCSS?this.options.fontSize:e.prototype.fontSize.call(this,t)},n.prototype.fontFamily=function(t){return a.badCSS?this.options.fontFamily:e.prototype.fontFamily.call(this,t)},n.prototype.nodeSize=function(t,r,i){if(r===void 0&&(r=1),i===void 0&&(i=null),!a.badSizes)return e.prototype.nodeSize.call(this,t,r,i);var o=this.textContent(t),s=Array.from(o.replace(n.cjkPattern,``)).length;return[(Array.from(o).length-s)*this.options.cjkCharWidth+s*this.options.unknownCharWidth,this.options.unknownCharHeight]},n.prototype.nodeBBox=function(t){return a.badSizes?{left:0,right:0,top:0,bottom:0}:e.prototype.nodeBBox.call(this,t)},n}(i),o.OPTIONS=n(n({},a.badCSS?{fontSize:16,fontFamily:`Times`}:{}),a.badSizes?{cjkCharWidth:1,unknownCharWidth:.6,unknownCharHeight:.8}:{}),o.cjkPattern=new RegExp([`[`,`ᄀ-ᅟ`,`〈〉`,`⺀-〾`,`぀-㉇`,`㉐-䶿`,`一-꓆`,`ꥠ-ꥼ`,`가-힣`,`豈-﫿`,`︐-︙`,`︰-﹫`,`!-⦆¢-₩`,`𛀀-𛀁`,`🈀-🉑`,`𠀀-𿿽`,`]`].join(``),`gu`),o}e.NodeMixin=a})),o=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LiteDocument=void 0;var t=n();e.LiteDocument=function(){function e(){this.root=new t.LiteElement(`html`,{},[this.head=new t.LiteElement(`head`),this.body=new t.LiteElement(`body`)]),this.type=``}return Object.defineProperty(e.prototype,"kind",{get:function(){return`#document`},enumerable:!1,configurable:!0}),e}()})),s=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,"__esModule",{value:!0}),e.LiteComment=e.LiteText=void 0;var n=function(){function e(e){e===void 0&&(e=``),this.value=e}return Object.defineProperty(e.prototype,"kind",{get:function(){return`#text`},enumerable:!1,configurable:!0}),e}();e.LiteText=n,e.LiteComment=function(e){t(n,e);function n(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(n.prototype,"kind",{get:function(){return`#comment`},enumerable:!1,configurable:!0}),n}(n)})),c=e((e=>{var t=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},n=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.LiteList=void 0,e.LiteList=function(){function e(e){this.nodes=[],this.nodes=n([],t(e),!1)}return e.prototype.append=function(e){this.nodes.push(e)},e.prototype[Symbol.iterator]=function(){var e=0;return{next:function(){return e===this.nodes.length?{value:null,done:!0}:{value:this.nodes[e++],done:!1}}}},e}()})),l=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.retryAfter=e.handleRetriesFor=void 0;function t(e){return new Promise(function t(n,r){try{n(e())}catch(e){e.retry&&e.retry instanceof Promise?e.retry.then(function(){return t(n,r)}).catch(function(e){return r(e)}):e.restart&&e.restart.isCallback?MathJax.Callback.After(function(){return t(n,r)},e.restart):r(e)}})}e.handleRetriesFor=t;function n(e){var t=Error(`MathJax retry`);throw t.retry=e,t}e.retryAfter=n})),u=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION=`3.2.2`})),d=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PrioritizedList=void 0,e.PrioritizedList=function(){function e(){this.items=[],this.items=[]}return e.prototype[Symbol.iterator]=function(){var e=0,t=this.items;return{next:function(){return{value:t[e++],done:e>t.length}}}},e.prototype.add=function(t,n){n===void 0&&(n=e.DEFAULTPRIORITY);var r=this.items.length;do r--;while(r>=0&&n<this.items[r].priority);return this.items.splice(r+1,0,{item:t,priority:n}),t},e.prototype.remove=function(e){var t=this.items.length;do t--;while(t>=0&&this.items[t].item!==e);t>=0&&this.items.splice(t,1)},e.DEFAULTPRIORITY=5,e}()})),f=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),n=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.HandlerList=void 0,e.HandlerList=function(e){t(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.register=function(e){return this.add(e,e.priority)},r.prototype.unregister=function(e){this.remove(e)},r.prototype.handlesDocument=function(e){var t,r;try{for(var i=n(this),a=i.next();!a.done;a=i.next()){var o=a.value.item;if(o.handlesDocument(e))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}throw Error(`Can't find handler for document`)},r.prototype.document=function(e,t){return t===void 0&&(t=null),this.handlesDocument(e).create(e,t)},r}(d().PrioritizedList)})),p=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mathjax=void 0;var t=u(),n=f(),r=l();e.mathjax={version:t.VERSION,handlers:new n.HandlerList,document:function(t,n){return e.mathjax.handlers.document(t,n)},handleRetriesFor:r.handleRetriesFor,retryAfter:r.retryAfter,asyncLoad:null}})),m=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.asyncLoad=void 0;var t=p();function n(e){return t.mathjax.asyncLoad?new Promise(function(n,r){var i=t.mathjax.asyncLoad(e);i instanceof Promise?i.then(function(e){return n(e)}).catch(function(e){return r(e)}):n(i)}):Promise.reject(`Can't load '${e}': No asyncLoad method specified`)}e.asyncLoad=n})),h=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.numeric=e.translate=e.remove=e.add=e.entities=e.options=void 0;var t=l(),n=m();e.options={loadMissingEntities:!0},e.entities={ApplyFunction:`⁡`,Backslash:`∖`,Because:`∵`,Breve:`˘`,Cap:`⋒`,CenterDot:`·`,CircleDot:`⊙`,CircleMinus:`⊖`,CirclePlus:`⊕`,CircleTimes:`⊗`,Congruent:`≡`,ContourIntegral:`∮`,Coproduct:`∐`,Cross:`⨯`,Cup:`⋓`,CupCap:`≍`,Dagger:`‡`,Del:`∇`,Delta:`Δ`,Diamond:`⋄`,DifferentialD:`ⅆ`,DotEqual:`≐`,DoubleDot:`¨`,DoubleRightTee:`⊨`,DoubleVerticalBar:`∥`,DownArrow:`↓`,DownLeftVector:`↽`,DownRightVector:`⇁`,DownTee:`⊤`,Downarrow:`⇓`,Element:`∈`,EqualTilde:`≂`,Equilibrium:`⇌`,Exists:`∃`,ExponentialE:`ⅇ`,FilledVerySmallSquare:`▪`,ForAll:`∀`,Gamma:`Γ`,Gg:`⋙`,GreaterEqual:`≥`,GreaterEqualLess:`⋛`,GreaterFullEqual:`≧`,GreaterLess:`≷`,GreaterSlantEqual:`⩾`,GreaterTilde:`≳`,Hacek:`ˇ`,Hat:`^`,HumpDownHump:`≎`,HumpEqual:`≏`,Im:`ℑ`,ImaginaryI:`ⅈ`,Integral:`∫`,Intersection:`⋂`,InvisibleComma:`⁣`,InvisibleTimes:`⁢`,Lambda:`Λ`,Larr:`↞`,LeftAngleBracket:`⟨`,LeftArrow:`←`,LeftArrowRightArrow:`⇆`,LeftCeiling:`⌈`,LeftDownVector:`⇃`,LeftFloor:`⌊`,LeftRightArrow:`↔`,LeftTee:`⊣`,LeftTriangle:`⊲`,LeftTriangleEqual:`⊴`,LeftUpVector:`↿`,LeftVector:`↼`,Leftarrow:`⇐`,Leftrightarrow:`⇔`,LessEqualGreater:`⋚`,LessFullEqual:`≦`,LessGreater:`≶`,LessSlantEqual:`⩽`,LessTilde:`≲`,Ll:`⋘`,Lleftarrow:`⇚`,LongLeftArrow:`⟵`,LongLeftRightArrow:`⟷`,LongRightArrow:`⟶`,Longleftarrow:`⟸`,Longleftrightarrow:`⟺`,Longrightarrow:`⟹`,Lsh:`↰`,MinusPlus:`∓`,NestedGreaterGreater:`≫`,NestedLessLess:`≪`,NotDoubleVerticalBar:`∦`,NotElement:`∉`,NotEqual:`≠`,NotExists:`∄`,NotGreater:`≯`,NotGreaterEqual:`≱`,NotLeftTriangle:`⋪`,NotLeftTriangleEqual:`⋬`,NotLess:`≮`,NotLessEqual:`≰`,NotPrecedes:`⊀`,NotPrecedesSlantEqual:`⋠`,NotRightTriangle:`⋫`,NotRightTriangleEqual:`⋭`,NotSubsetEqual:`⊈`,NotSucceeds:`⊁`,NotSucceedsSlantEqual:`⋡`,NotSupersetEqual:`⊉`,NotTilde:`≁`,NotVerticalBar:`∤`,Omega:`Ω`,OverBar:`‾`,OverBrace:`⏞`,PartialD:`∂`,Phi:`Φ`,Pi:`Π`,PlusMinus:`±`,Precedes:`≺`,PrecedesEqual:`⪯`,PrecedesSlantEqual:`≼`,PrecedesTilde:`≾`,Product:`∏`,Proportional:`∝`,Psi:`Ψ`,Rarr:`↠`,Re:`ℜ`,ReverseEquilibrium:`⇋`,RightAngleBracket:`⟩`,RightArrow:`→`,RightArrowLeftArrow:`⇄`,RightCeiling:`⌉`,RightDownVector:`⇂`,RightFloor:`⌋`,RightTee:`⊢`,RightTeeArrow:`↦`,RightTriangle:`⊳`,RightTriangleEqual:`⊵`,RightUpVector:`↾`,RightVector:`⇀`,Rightarrow:`⇒`,Rrightarrow:`⇛`,Rsh:`↱`,Sigma:`Σ`,SmallCircle:`∘`,Sqrt:`√`,Square:`□`,SquareIntersection:`⊓`,SquareSubset:`⊏`,SquareSubsetEqual:`⊑`,SquareSuperset:`⊐`,SquareSupersetEqual:`⊒`,SquareUnion:`⊔`,Star:`⋆`,Subset:`⋐`,SubsetEqual:`⊆`,Succeeds:`≻`,SucceedsEqual:`⪰`,SucceedsSlantEqual:`≽`,SucceedsTilde:`≿`,SuchThat:`∋`,Sum:`∑`,Superset:`⊃`,SupersetEqual:`⊇`,Supset:`⋑`,Therefore:`∴`,Theta:`Θ`,Tilde:`∼`,TildeEqual:`≃`,TildeFullEqual:`≅`,TildeTilde:`≈`,UnderBar:`_`,UnderBrace:`⏟`,Union:`⋃`,UnionPlus:`⊎`,UpArrow:`↑`,UpDownArrow:`↕`,UpTee:`⊥`,Uparrow:`⇑`,Updownarrow:`⇕`,Upsilon:`Υ`,Vdash:`⊩`,Vee:`⋁`,VerticalBar:`∣`,VerticalTilde:`≀`,Vvdash:`⊪`,Wedge:`⋀`,Xi:`Ξ`,amp:`&`,acute:`´`,aleph:`ℵ`,alpha:`α`,amalg:`⨿`,and:`∧`,ang:`∠`,angmsd:`∡`,angsph:`∢`,ape:`≊`,backprime:`‵`,backsim:`∽`,backsimeq:`⋍`,beta:`β`,beth:`ℶ`,between:`≬`,bigcirc:`◯`,bigodot:`⨀`,bigoplus:`⨁`,bigotimes:`⨂`,bigsqcup:`⨆`,bigstar:`★`,bigtriangledown:`▽`,bigtriangleup:`△`,biguplus:`⨄`,blacklozenge:`⧫`,blacktriangle:`▴`,blacktriangledown:`▾`,blacktriangleleft:`◂`,bowtie:`⋈`,boxdl:`┐`,boxdr:`┌`,boxminus:`⊟`,boxplus:`⊞`,boxtimes:`⊠`,boxul:`┘`,boxur:`└`,bsol:`\\`,bull:`•`,cap:`∩`,check:`✓`,chi:`χ`,circ:`ˆ`,circeq:`≗`,circlearrowleft:`↺`,circlearrowright:`↻`,circledR:`®`,circledS:`Ⓢ`,circledast:`⊛`,circledcirc:`⊚`,circleddash:`⊝`,clubs:`♣`,colon:`:`,comp:`∁`,ctdot:`⋯`,cuepr:`⋞`,cuesc:`⋟`,cularr:`↶`,cup:`∪`,curarr:`↷`,curlyvee:`⋎`,curlywedge:`⋏`,dagger:`†`,daleth:`ℸ`,ddarr:`⇊`,deg:`°`,delta:`δ`,digamma:`ϝ`,div:`÷`,divideontimes:`⋇`,dot:`˙`,doteqdot:`≑`,dotplus:`∔`,dotsquare:`⊡`,dtdot:`⋱`,ecir:`≖`,efDot:`≒`,egs:`⪖`,ell:`ℓ`,els:`⪕`,empty:`∅`,epsi:`ε`,epsiv:`ϵ`,erDot:`≓`,eta:`η`,eth:`ð`,flat:`♭`,fork:`⋔`,frown:`⌢`,gEl:`⪌`,gamma:`γ`,gap:`⪆`,gimel:`ℷ`,gnE:`≩`,gnap:`⪊`,gne:`⪈`,gnsim:`⋧`,gt:`>`,gtdot:`⋗`,harrw:`↭`,hbar:`ℏ`,hellip:`…`,hookleftarrow:`↩`,hookrightarrow:`↪`,imath:`ı`,infin:`∞`,intcal:`⊺`,iota:`ι`,jmath:`ȷ`,kappa:`κ`,kappav:`ϰ`,lEg:`⪋`,lambda:`λ`,lap:`⪅`,larrlp:`↫`,larrtl:`↢`,lbrace:`{`,lbrack:`[`,le:`≤`,leftleftarrows:`⇇`,leftthreetimes:`⋋`,lessdot:`⋖`,lmoust:`⎰`,lnE:`≨`,lnap:`⪉`,lne:`⪇`,lnsim:`⋦`,longmapsto:`⟼`,looparrowright:`↬`,lowast:`∗`,loz:`◊`,lt:`<`,ltimes:`⋉`,ltri:`◃`,macr:`¯`,malt:`✠`,mho:`℧`,mu:`μ`,multimap:`⊸`,nLeftarrow:`⇍`,nLeftrightarrow:`⇎`,nRightarrow:`⇏`,nVDash:`⊯`,nVdash:`⊮`,natur:`♮`,nearr:`↗`,nharr:`↮`,nlarr:`↚`,not:`¬`,nrarr:`↛`,nu:`ν`,nvDash:`⊭`,nvdash:`⊬`,nwarr:`↖`,omega:`ω`,omicron:`ο`,or:`∨`,osol:`⊘`,period:`.`,phi:`φ`,phiv:`ϕ`,pi:`π`,piv:`ϖ`,prap:`⪷`,precnapprox:`⪹`,precneqq:`⪵`,precnsim:`⋨`,prime:`′`,psi:`ψ`,quot:`"`,rarrtl:`↣`,rbrace:`}`,rbrack:`]`,rho:`ρ`,rhov:`ϱ`,rightrightarrows:`⇉`,rightthreetimes:`⋌`,ring:`˚`,rmoust:`⎱`,rtimes:`⋊`,rtri:`▹`,scap:`⪸`,scnE:`⪶`,scnap:`⪺`,scnsim:`⋩`,sdot:`⋅`,searr:`↘`,sect:`§`,sharp:`♯`,sigma:`σ`,sigmav:`ς`,simne:`≆`,smile:`⌣`,spades:`♠`,sub:`⊂`,subE:`⫅`,subnE:`⫋`,subne:`⊊`,supE:`⫆`,supnE:`⫌`,supne:`⊋`,swarr:`↙`,tau:`τ`,theta:`θ`,thetav:`ϑ`,tilde:`˜`,times:`×`,triangle:`▵`,triangleq:`≜`,upsi:`υ`,upuparrows:`⇈`,veebar:`⊻`,vellip:`⋮`,weierp:`℘`,xi:`ξ`,yen:`¥`,zeta:`ζ`,zigrarr:`⇝`,nbsp:`\xA0`,rsquo:`’`,lsquo:`‘`};var r={};function i(t,n){Object.assign(e.entities,t),r[n]=!0}e.add=i;function a(t){delete e.entities[t]}e.remove=a;function o(e){return e.replace(/&([a-z][a-z0-9]*|#(?:[0-9]+|x[0-9a-f]+));/gi,s)}e.translate=o;function s(i,a){if(a.charAt(0)===`#`)return c(a.slice(1));if(e.entities[a])return e.entities[a];if(e.options.loadMissingEntities){var o=a.match(/^[a-zA-Z](fr|scr|opf)$/)?RegExp.$1:a.charAt(0).toLowerCase();r[o]||(r[o]=!0,(0,t.retryAfter)((0,n.asyncLoad)(`./util/entities/`+o+`.js`)))}return i}function c(e){var t=e.charAt(0)===`x`?parseInt(e.slice(1),16):parseInt(e);return String.fromCodePoint(t)}e.numeric=c})),g=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(n,e,i);return r(n,e),n},a=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},o=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)};Object.defineProperty(e,"__esModule",{value:!0}),e.LiteParser=e.PATTERNS=void 0;var c=i(h()),l=n(),u=s(),d;(function(e){e.TAGNAME=`[a-z][^\\s\\n>]*`,e.ATTNAME=`[a-z][^\\s\\n>=]*`,e.VALUE=`(?:'[^']*'|"[^"]*"|[^\\s\\n]+)`,e.VALUESPLIT=`(?:'([^']*)'|"([^"]*)"|([^\\s\\n]+))`,e.SPACE=`(?:\\s|\\n)+`,e.OPTIONALSPACE=`(?:\\s|\\n)*`,e.ATTRIBUTE=e.ATTNAME+`(?:`+e.OPTIONALSPACE+`=`+e.OPTIONALSPACE+e.VALUE+`)?`,e.ATTRIBUTESPLIT=`(`+e.ATTNAME+`)(?:`+e.OPTIONALSPACE+`=`+e.OPTIONALSPACE+e.VALUESPLIT+`)?`,e.TAG=`(<(?:`+e.TAGNAME+`(?:`+e.SPACE+e.ATTRIBUTE+`)*`+e.OPTIONALSPACE+`/?|/`+e.TAGNAME+`|!--[^]*?--|![^]*?)(?:>|$))`,e.tag=new RegExp(e.TAG,`i`),e.attr=new RegExp(e.ATTRIBUTE,`i`),e.attrsplit=new RegExp(e.ATTRIBUTESPLIT,`i`)})(d=e.PATTERNS||={}),e.LiteParser=function(){function e(){}return e.prototype.parseFromString=function(e,t,n){t===void 0&&(t=`text/html`),n===void 0&&(n=null);for(var r=n.createDocument(),i=n.body(r),a=e.replace(/<\?.*?\?>/g,``).split(d.tag);a.length;){var o=a.shift(),s=a.shift();o&&this.addText(n,i,o),s&&s.charAt(s.length-1)===`>`&&(s.charAt(1)===`!`?this.addComment(n,i,s):i=s.charAt(1)===`/`?this.closeTag(n,i,s):this.openTag(n,i,s,a))}return this.checkDocument(n,r),r},e.prototype.addText=function(e,t,n){return n=c.translate(n),e.append(t,e.text(n))},e.prototype.addComment=function(e,t,n){return e.append(t,new u.LiteComment(n))},e.prototype.closeTag=function(e,t,n){for(var r=n.slice(2,n.length-1).toLowerCase();e.parent(t)&&e.kind(t)!==r;)t=e.parent(t);return e.parent(t)},e.prototype.openTag=function(e,t,n,r){var i=this.constructor.PCDATA,a=this.constructor.SELF_CLOSING,o=n.match(/<(.*?)[\s\n>\/]/)[1].toLowerCase(),s=e.node(o),c=n.replace(/^<.*?[\s\n>]/,``).split(d.attrsplit);return(c.pop().match(/>$/)||c.length<5)&&(this.addAttributes(e,s,c),e.append(t,s),!a[o]&&!n.match(/\/>$/)&&(i[o]?this.handlePCDATA(e,s,o,r):t=s)),t},e.prototype.addAttributes=function(e,t,n){for(var r=this.constructor.CDATA_ATTR;n.length;){var i=a(n.splice(0,5),5),o=i[1],s=i[2],l=i[3],u=i[4],d=s||l||u||``;r[o]||(d=c.translate(d)),e.setAttribute(t,o,d)}},e.prototype.handlePCDATA=function(e,t,n,r){for(var i=[],a=`</`+n+`>`,o=``;r.length&&o!==a;)i.push(o),i.push(r.shift()),o=r.shift();e.append(t,e.text(i.join(``)))},e.prototype.checkDocument=function(e,t){var n,r,i,a,s=this.getOnlyChild(e,e.body(t));if(s){try{for(var c=o(e.childNodes(e.body(t))),l=c.next();!l.done;l=c.next()){var d=l.value;if(d===s)break;d instanceof u.LiteComment&&d.value.match(/^<!DOCTYPE/)&&(t.type=d.value)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}switch(e.kind(s)){case`html`:try{for(var f=o(s.children),p=f.next();!p.done;p=f.next()){var d=p.value;switch(e.kind(d)){case`head`:t.head=d;break;case`body`:t.body=d;break}}}catch(e){i={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}t.root=s,e.remove(s),e.parent(t.body)!==s&&e.append(s,t.body),e.parent(t.head)!==s&&e.insert(t.head,t.body);break;case`head`:t.head=e.replace(s,t.head);break;case`body`:t.body=e.replace(s,t.body);break}}},e.prototype.getOnlyChild=function(e,t){var n,r,i=null;try{for(var a=o(e.childNodes(t)),s=a.next();!s.done;s=a.next()){var c=s.value;if(c instanceof l.LiteElement){if(i)return null;i=c}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i},e.prototype.serialize=function(e,t,n){var r=this;n===void 0&&(n=!1);var i=this.constructor.SELF_CLOSING,a=this.constructor.CDATA_ATTR,o=e.kind(t),s=e.allAttributes(t).map(function(e){return e.name+`="`+(a[e.name]?e.value:r.protectAttribute(e.value))+`"`}).join(` `),c=this.serializeInner(e,t,n);return`<`+o+(s?` `+s:``)+((!n||c)&&!i[o]?`>${c}</${o}>`:n?`/>`:`>`)},e.prototype.serializeInner=function(e,t,n){var r=this;return n===void 0&&(n=!1),this.constructor.PCDATA.hasOwnProperty(t.kind)?e.childNodes(t).map(function(t){return e.value(t)}).join(``):e.childNodes(t).map(function(t){var i=e.kind(t);return i===`#text`?r.protectHTML(e.value(t)):i===`#comment`?t.value:r.serialize(e,t,n)}).join(``)},e.prototype.protectAttribute=function(e){return typeof e!=`string`&&(e=String(e)),e.replace(/"/g,`&quot;`)},e.prototype.protectHTML=function(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)},e.SELF_CLOSING={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},e.PCDATA={option:!0,textarea:!0,fieldset:!0,title:!0,style:!0,script:!0},e.CDATA_ATTR={style:!0,datafld:!0,datasrc:!0,href:!0,src:!0,longdesc:!0,usemap:!0,cite:!0,datetime:!0,action:!0,axis:!0,profile:!0,content:!0,scheme:!0},e}()})),_=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LiteWindow=void 0;var t=n(),r=o(),i=c(),a=g();e.LiteWindow=function(){function e(){this.DOMParser=a.LiteParser,this.NodeList=i.LiteList,this.HTMLCollection=i.LiteList,this.HTMLElement=t.LiteElement,this.DocumentFragment=i.LiteList,this.Document=r.LiteDocument,this.document=new r.LiteDocument}return e}()})),v=e((e=>{var t=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},n=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},r=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.Styles=void 0;var i=[`top`,`right`,`bottom`,`left`],a=[`width`,`style`,`color`];function o(e){for(var t=e.split(/((?:'[^']*'|"[^"]*"|,[\s\n]|[^\s\n])*)/g),n=[];t.length>1;)t.shift(),n.push(t.shift());return n}function s(e){var n,r,i=o(this.styles[e]);i.length===0&&i.push(``),i.length===1&&i.push(i[0]),i.length===2&&i.push(i[0]),i.length===3&&i.push(i[1]);try{for(var a=t(v.connect[e].children),s=a.next();!s.done;s=a.next()){var c=s.value;this.setStyle(this.childName(e,c),i.shift())}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}function c(e){var n,r,i=v.connect[e].children,a=[];try{for(var o=t(i),s=o.next();!s.done;s=o.next()){var c=s.value,l=this.styles[e+`-`+c];if(!l){delete this.styles[e];return}a.push(l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a[3]===a[1]&&(a.pop(),a[2]===a[0]&&(a.pop(),a[1]===a[0]&&a.pop())),this.styles[e]=a.join(` `)}function l(e){var n,r;try{for(var i=t(v.connect[e].children),a=i.next();!a.done;a=i.next()){var o=a.value;this.setStyle(this.childName(e,o),this.styles[e])}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}function u(e){var i,a,o=r([],n(v.connect[e].children),!1),s=this.styles[this.childName(e,o.shift())];try{for(var c=t(o),l=c.next();!l.done;l=c.next()){var u=l.value;if(this.styles[this.childName(e,u)]!==s){delete this.styles[e];return}}}catch(e){i={error:e}}finally{try{l&&!l.done&&(a=c.return)&&a.call(c)}finally{if(i)throw i.error}}this.styles[e]=s}var d={width:/^(?:[\d.]+(?:[a-z]+)|thin|medium|thick|inherit|initial|unset)$/,style:/^(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|inherit|initial|unset)$/};function f(e){var n,r,i,a,s={width:``,style:``,color:``};try{for(var c=t(o(this.styles[e])),l=c.next();!l.done;l=c.next()){var u=l.value;u.match(d.width)&&s.width===``?s.width=u:u.match(d.style)&&s.style===``?s.style=u:s.color=u}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}try{for(var f=t(v.connect[e].children),p=f.next();!p.done;p=f.next()){var m=p.value;this.setStyle(this.childName(e,m),s[m])}}catch(e){i={error:e}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}}function p(e){var n,r,i=[];try{for(var a=t(v.connect[e].children),o=a.next();!o.done;o=a.next()){var s=o.value,c=this.styles[this.childName(e,s)];c&&i.push(c)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}i.length?this.styles[e]=i.join(` `):delete this.styles[e]}var m={style:/^(?:normal|italic|oblique|inherit|initial|unset)$/,variant:RegExp(`^(?:`+[`normal|none`,`inherit|initial|unset`,`common-ligatures|no-common-ligatures`,`discretionary-ligatures|no-discretionary-ligatures`,`historical-ligatures|no-historical-ligatures`,`contextual|no-contextual`,`(?:stylistic|character-variant|swash|ornaments|annotation)\\([^)]*\\)`,`small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps`,`lining-nums|oldstyle-nums|proportional-nums|tabular-nums`,`diagonal-fractions|stacked-fractions`,`ordinal|slashed-zero`,`jis78|jis83|jis90|jis04|simplified|traditional`,`full-width|proportional-width`,`ruby`].join(`|`)+`)$`),weight:/^(?:normal|bold|bolder|lighter|[1-9]00|inherit|initial|unset)$/,stretch:RegExp(`^(?:`+[`normal`,`(?:(?:ultra|extra|semi)-)?condensed`,`(?:(?:semi|extra|ulta)-)?expanded`,`inherit|initial|unset`].join(`|`)+`)$`),size:RegExp(`^(?:`+[`xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller`,`[d.]+%|[d.]+[a-z]+`,`inherit|initial|unset`].join(`|`)+`)(?:/(?:normal|[d.+](?:%|[a-z]+)?))?$`)};function h(e){var r,i,a,s,c=o(this.styles[e]),l={style:``,variant:[],weight:``,stretch:``,size:``,family:``,"line-height":``};try{for(var u=t(c),d=u.next();!d.done;d=u.next()){var f=d.value;l.family=f;try{for(var p=(a=void 0,t(Object.keys(m))),h=p.next();!h.done;h=p.next()){var _=h.value;if((Array.isArray(l[_])||l[_]===``)&&f.match(m[_]))if(_===`size`){var v=n(f.split(/\//),2),y=v[0],b=v[1];l[_]=y,b&&(l[`line-height`]=b)}else l.size===``&&(Array.isArray(l[_])?l[_].push(f):l[_]=f)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(s=p.return)&&s.call(p)}finally{if(a)throw a.error}}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}g(e,l),delete this.styles[e]}function g(e,n){var r,i;try{for(var a=t(v.connect[e].children),o=a.next();!o.done;o=a.next()){var s=o.value,c=this.childName(e,s);if(Array.isArray(n[s])){var l=n[s];l.length&&(this.styles[c]=l.join(` `))}else n[s]!==``&&(this.styles[c]=n[s])}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}function _(e){}var v=function(){function e(e){e===void 0&&(e=``),this.parse(e)}return Object.defineProperty(e.prototype,"cssText",{get:function(){var e,n,r=[];try{for(var i=t(Object.keys(this.styles)),a=i.next();!a.done;a=i.next()){var o=a.value,s=this.parentName(o);this.styles[s]||r.push(o+`: `+this.styles[o]+`;`)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r.join(` `)},enumerable:!1,configurable:!0}),e.prototype.set=function(t,n){for(t=this.normalizeName(t),this.setStyle(t,n),e.connect[t]&&!e.connect[t].combine&&(this.combineChildren(t),delete this.styles[t]);t.match(/-/)&&(t=this.parentName(t),e.connect[t]);)e.connect[t].combine.call(this,t)},e.prototype.get=function(e){return e=this.normalizeName(e),this.styles.hasOwnProperty(e)?this.styles[e]:``},e.prototype.setStyle=function(t,n){this.styles[t]=n,e.connect[t]&&e.connect[t].children&&e.connect[t].split.call(this,t),n===``&&delete this.styles[t]},e.prototype.combineChildren=function(n){var r,i,a=this.parentName(n);try{for(var o=t(e.connect[n].children),s=o.next();!s.done;s=o.next()){var c=s.value,l=this.childName(a,c);e.connect[l].combine.call(this,l)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},e.prototype.parentName=function(e){var t=e.replace(/-[^-]*$/,``);return e===t?``:t},e.prototype.childName=function(t,n){return n.match(/-/)?n:(e.connect[t]&&!e.connect[t].combine&&(n+=t.replace(/.*-/,`-`),t=this.parentName(t)),t+`-`+n)},e.prototype.normalizeName=function(e){return e.replace(/[A-Z]/g,function(e){return`-`+e.toLowerCase()})},e.prototype.parse=function(e){e===void 0&&(e=``);var t=this.constructor.pattern;this.styles={};for(var r=e.replace(t.comment,``).split(t.style);r.length>1;){var i=n(r.splice(0,3),3),a=i[0],o=i[1],s=i[2];if(a.match(/[^\s\n]/))return;this.set(o,s)}},e.pattern={style:/([-a-z]+)[\s\n]*:[\s\n]*((?:'[^']*'|"[^"]*"|\n|.)*?)[\s\n]*(?:;|$)/g,comment:/\/\*[^]*?\*\//g},e.connect={padding:{children:i,split:s,combine:c},border:{children:i,split:l,combine:u},"border-top":{children:a,split:f,combine:p},"border-right":{children:a,split:f,combine:p},"border-bottom":{children:a,split:f,combine:p},"border-left":{children:a,split:f,combine:p},"border-width":{children:i,split:s,combine:null},"border-style":{children:i,split:s,combine:null},"border-color":{children:i,split:s,combine:null},font:{children:[`style`,`variant`,`weight`,`stretch`,`line-height`,`size`,`family`],split:h,combine:_}},e}();e.Styles=v})),y=e((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),i=e&&e.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)},c=e&&e.__values||function(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)},l=e&&e.__read||function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},u=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,"__esModule",{value:!0}),e.liteAdaptor=e.LiteAdaptor=e.LiteBase=void 0;var d=r(),f=a(),p=o(),m=n(),h=s(),y=_(),b=g(),x=v(),S=function(e){t(n,e);function n(){var t=e.call(this)||this;return t.parser=new b.LiteParser,t.window=new y.LiteWindow,t}return n.prototype.parse=function(e,t){return this.parser.parseFromString(e,t,this)},n.prototype.create=function(e,t){return t===void 0&&(t=null),new m.LiteElement(e)},n.prototype.text=function(e){return new h.LiteText(e)},n.prototype.comment=function(e){return new h.LiteComment(e)},n.prototype.createDocument=function(){return new p.LiteDocument},n.prototype.head=function(e){return e.head},n.prototype.body=function(e){return e.body},n.prototype.root=function(e){return e.root},n.prototype.doctype=function(e){return e.type},n.prototype.tags=function(e,t,n){n===void 0&&(n=null);var r=[],i=[];if(n)return i;for(var a=e;a;){var o=a.kind;o!==`#text`&&o!==`#comment`&&(a=a,o===t&&i.push(a),a.children.length&&(r=a.children.concat(r))),a=r.shift()}return i},n.prototype.elementById=function(e,t){for(var n=[],r=e;r;){if(r.kind!==`#text`&&r.kind!==`#comment`){if(r=r,r.attributes.id===t)return r;r.children.length&&(n=r.children.concat(n))}r=n.shift()}return null},n.prototype.elementsByClass=function(e,t){for(var n=[],r=[],i=e;i;)i.kind!==`#text`&&i.kind!==`#comment`&&(i=i,(i.attributes.class||``).trim().split(/ +/).includes(t)&&r.push(i),i.children.length&&(n=i.children.concat(n))),i=n.shift();return r},n.prototype.getElements=function(e,t){var n,r,i=[],a=this.body(t);try{for(var o=c(e),s=o.next();!s.done;s=o.next()){var l=s.value;if(typeof l==`string`)if(l.charAt(0)===`#`){var u=this.elementById(a,l.slice(1));u&&i.push(u)}else l.charAt(0)===`.`?i=i.concat(this.elementsByClass(a,l.slice(1))):l.match(/^[-a-z][-a-z0-9]*$/i)&&(i=i.concat(this.tags(a,l)));else Array.isArray(l)?i=i.concat(l):l instanceof this.window.NodeList||l instanceof this.window.HTMLCollection?i=i.concat(l.nodes):i.push(l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},n.prototype.contains=function(e,t){for(;t&&t!==e;)t=this.parent(t);return!!t},n.prototype.parent=function(e){return e.parent},n.prototype.childIndex=function(e){return e.parent?e.parent.children.findIndex(function(t){return t===e}):-1},n.prototype.append=function(e,t){return t.parent&&this.remove(t),e.children.push(t),t.parent=e,t},n.prototype.insert=function(e,t){if(e.parent&&this.remove(e),t&&t.parent){var n=this.childIndex(t);t.parent.children.splice(n,0,e),e.parent=t.parent}},n.prototype.remove=function(e){var t=this.childIndex(e);return t>=0&&e.parent.children.splice(t,1),e.parent=null,e},n.prototype.replace=function(e,t){var n=this.childIndex(t);return n>=0&&(t.parent.children[n]=e,e.parent=t.parent,t.parent=null),t},n.prototype.clone=function(e){var t=this,n=new m.LiteElement(e.kind);return n.attributes=i({},e.attributes),n.children=e.children.map(function(e){if(e.kind===`#text`)return new h.LiteText(e.value);if(e.kind===`#comment`)return new h.LiteComment(e.value);var r=t.clone(e);return r.parent=n,r}),n},n.prototype.split=function(e,t){var n=new h.LiteText(e.value.slice(t));return e.value=e.value.slice(0,t),e.parent.children.splice(this.childIndex(e)+1,0,n),n.parent=e.parent,n},n.prototype.next=function(e){var t=e.parent;if(!t)return null;var n=this.childIndex(e)+1;return n>=0&&n<t.children.length?t.children[n]:null},n.prototype.previous=function(e){var t=e.parent;if(!t)return null;var n=this.childIndex(e)-1;return n>=0?t.children[n]:null},n.prototype.firstChild=function(e){return e.children[0]},n.prototype.lastChild=function(e){return e.children[e.children.length-1]},n.prototype.childNodes=function(e){return u([],l(e.children),!1)},n.prototype.childNode=function(e,t){return e.children[t]},n.prototype.kind=function(e){return e.kind},n.prototype.value=function(e){return e.kind===`#text`?e.value:e.kind===`#comment`?e.value.replace(/^<!(--)?((?:.|\n)*)\1>$/,`$2`):``},n.prototype.textContent=function(e){var t=this;return e.children.reduce(function(e,n){return e+(n.kind===`#text`?n.value:n.kind===`#comment`?``:t.textContent(n))},``)},n.prototype.innerHTML=function(e){return this.parser.serializeInner(this,e)},n.prototype.outerHTML=function(e){return this.parser.serialize(this,e)},n.prototype.serializeXML=function(e){return this.parser.serialize(this,e,!0)},n.prototype.setAttribute=function(e,t,n,r){r===void 0&&(r=null),typeof n!=`string`&&(n=String(n)),r&&(t=r.replace(/.*\//,``)+`:`+t.replace(/^.*:/,``)),e.attributes[t]=n,t===`style`&&(e.styles=null)},n.prototype.getAttribute=function(e,t){return e.attributes[t]},n.prototype.removeAttribute=function(e,t){delete e.attributes[t]},n.prototype.hasAttribute=function(e,t){return e.attributes.hasOwnProperty(t)},n.prototype.allAttributes=function(e){var t,n,r=e.attributes,i=[];try{for(var a=c(Object.keys(r)),o=a.next();!o.done;o=a.next()){var s=o.value;i.push({name:s,value:r[s]})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},n.prototype.addClass=function(e,t){var n=(e.attributes.class||``).split(/ /);n.find(function(e){return e===t})||(n.push(t),e.attributes.class=n.join(` `))},n.prototype.removeClass=function(e,t){var n=(e.attributes.class||``).split(/ /),r=n.findIndex(function(e){return e===t});r>=0&&(n.splice(r,1),e.attributes.class=n.join(` `))},n.prototype.hasClass=function(e,t){return!!(e.attributes.class||``).split(/ /).find(function(e){return e===t})},n.prototype.setStyle=function(e,t,n){e.styles||=new x.Styles(this.getAttribute(e,`style`)),e.styles.set(t,n),e.attributes.style=e.styles.cssText},n.prototype.getStyle=function(e,t){if(!e.styles){var n=this.getAttribute(e,`style`);if(!n)return``;e.styles=new x.Styles(n)}return e.styles.get(t)},n.prototype.allStyles=function(e){return this.getAttribute(e,`style`)},n.prototype.insertRules=function(e,t){e.children=[this.text(t.join(`
2
2
 
3
3
  `)+`
4
4
 
@@ -54,7 +54,7 @@
54
54
  html, body { margin: 0; height: 100%; overflow: hidden; background: var(--pi-bg); color: var(--pi-text); }
55
55
  body { min-height: 100dvh; }
56
56
  </style>
57
- <script type="module" crossorigin src="./assets/index-C8fQLkMH.js"></script>
57
+ <script type="module" crossorigin src="./assets/index-BsI-Foow.js"></script>
58
58
  <link rel="modulepreload" crossorigin href="./assets/vendor-editor-core-vyMPzMNA.js">
59
59
  <link rel="modulepreload" crossorigin href="./assets/vendor-editor-languages-DlEQaRIv.js">
60
60
  <link rel="modulepreload" crossorigin href="./assets/vendor-terminal-D8k4UKM2.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperdreamer/pi-webui",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "description": "Web UI for persistent Pi Coding Agent sessions in real workspaces.",
5
5
  "license": "MIT",
6
6
  "author": "Federico Jaramillo Martinez and HyperDreamer",