@chainingintention/pi-web-cn 1.202607.9 → 1.202607.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{CodeViewer-C3BRqouf.js → CodeViewer-5vQNxhKQ.js} +1 -1
- package/dist/client/assets/{TerminalPanel-DZ2ed4NZ.js → TerminalPanel-Ctz1zP84.js} +6 -3
- package/dist/client/assets/{UnifiedDiffViewer-zWHee3_J.js → UnifiedDiffViewer-DXLMHyO2.js} +1 -1
- package/dist/client/assets/{index-DS5Xapk8.js → index-Jmsbve6u.js} +3 -3
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,J as t,P as n,S as r,Y as i,l as a,q as o,y as s}from"./vendor-editor-core-vUi74DnD.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-DoaXUodB.js";import{_ as g,a as _,f as v,g as y,m as b,p as x,u as S}from"./index-
|
|
1
|
+
import{$ as e,J as t,P as n,S as r,Y as i,l as a,q as o,y as s}from"./vendor-editor-core-vUi74DnD.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-DoaXUodB.js";import{_ as g,a as _,f as v,g as y,m as b,p as x,u as S}from"./index-Jmsbve6u.js";import{t as C}from"./vendor-editor-legacy-CYBnW6ZU.js";var w=class extends b{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 y`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new o({parent:this.editorHost,state:e.create({doc:this.content,extensions:[i(),t.of(a),n(r,{fallback:!0}),e.readOnly.of(!0),o.editable.of(!1),o.lineWrapping,T,...D(this.language),...O(this.language)]})}))}static{this.styles=g`
|
|
2
2
|
:host { display: block; min-height: 0; height: 100%; }
|
|
3
3
|
.host { height: 100%; min-height: 0; overflow: auto; }
|
|
4
4
|
`}};_([v()],w.prototype,`content`,void 0),_([v()],w.prototype,`language`,void 0),_([S(`.host`)],w.prototype,`editorHost`,void 0),w=_([x(`code-viewer`)],w);var T=o.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=o.theme({".cm-content":{textAlign:`start`},".cm-line":{unicodeBidi:`plaintext`}});function D(e){return e===`markdown`?[o.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{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as ee,t as te,u as m}from"./index-
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as ee,t as te,u as m}from"./index-Jmsbve6u.js";import{n as h,t as g}from"./vendor-terminal-D8k4UKM2.js";var ne=`important`,re=` !important`,_=u(class extends p{constructor(e){if(super(e),e.type!==s.ATTRIBUTE||e.name!==`style`||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`},``)}update(e,[t]){let{style:n}=e.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let e of this.ft)t[e]??(this.ft.delete(e),e.includes(`-`)?n.removeProperty(e):n[e]=null);for(let e in t){let r=t[e];if(r!=null){this.ft.add(e);let t=typeof r==`string`&&r.endsWith(re);e.includes(`-`)||t?n.setProperty(e,t?r.slice(0,-11):r,t?ne:``):n[e]=r}}return o}}),ie=`#ffffff`,ae=`#000000`,v=[`#2e3436`,`#cc0000`,`#4e9a06`,`#c4a000`,`#3465a4`,`#75507b`,`#06989a`,`#d3d7cf`,`#555753`,`#ef2929`,`#8ae234`,`#fce94f`,`#729fcf`,`#ad7fa8`,`#34e2e2`,`#eeeeec`],y=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],b={black:v[0],red:v[1],green:v[2],yellow:v[3],blue:v[4],magenta:v[5],cyan:v[6],white:v[7],brightBlack:v[8],brightRed:v[9],brightGreen:v[10],brightYellow:v[11],brightBlue:v[12],brightMagenta:v[13],brightCyan:v[14],brightWhite:v[15]};function x(e,t,n={}){let r=Math.max(0,Math.floor(t));if(e.length<=0||r===0)return{text:``,lines:[],physicalLineCount:0,viewportLine:0};let i=ce(n.theme),a=n.theme?.foreground??ie,o=n.theme?.background??ae,s=[],c=e.getNullCell(),l=-1;for(let t=0;t<e.length;t+=1){let u=e.getLine(t);if(u===void 0){s.push({text:``,runs:[],wrapped:!1});continue}let d=S(u,r,c,{palette:i,foreground:a,background:o,drawBoldTextInBrightColors:n.drawBoldTextInBrightColors!==!1});s.push(d),(d.text!==``||d.runs.some(e=>e.style.background!==o))&&(l=t)}let u=Math.min(e.length-1,Math.max(0,e.baseY+e.cursorY)),d=Math.max(l,u),f=s.slice(0,d+1),p=[];for(let e of f){let t=p.at(-1);if(e.wrapped&&t!==void 0){t.text+=e.text,oe(t.runs,e.runs);continue}p.push({text:e.text,runs:e.runs.map(e=>({text:e.text,style:e.style}))})}return{text:p.map(e=>e.text).join(`
|
|
2
2
|
`),lines:p,physicalLineCount:f.length,viewportLine:Math.min(d,Math.max(0,e.viewportY))}}function S(e,t,n,r){let i=[],a=Math.min(t,e.length);for(let t=0;t<a;t+=1){let a=e.getCell(t,n);if(a===void 0){i.push({text:` `,meaningful:!1,style:T(r)});continue}let o=a.getWidth();if(o===0)continue;let s=a.getChars();i.push({text:s===``?` `.repeat(Math.max(1,o)):s,meaningful:s!==``||!a.isAttributeDefault(),style:C(a,r)})}let o=i.length-1;for(;o>=0&&i[o]?.meaningful!==!0;)--o;let s=[],c=``;for(let e=0;e<=o;e+=1){let t=i[e];t!==void 0&&(c+=t.text,E(s,{text:t.text,style:t.style}))}return{text:c,runs:s,wrapped:e.isWrapped}}function C(e,t){let n=e.isInverse()!==0,r=w(e,`foreground`,t),i=w(e,`background`,t);if(n&&([r,i]=[i,r]),e.isBold()!==0&&t.drawBoldTextInBrightColors){let i=n?e.isBgPalette()?e.getBgColor():void 0:e.isFgPalette()?e.getFgColor():void 0;i!==void 0&&i>=0&&i<8&&(r=t.palette[i+8]??r)}return{foreground:r,background:i,bold:e.isBold()!==0,italic:e.isItalic()!==0,dim:e.isDim()!==0,underline:e.isUnderline()!==0,invisible:e.isInvisible()!==0,strikethrough:e.isStrikethrough()!==0,overline:e.isOverline()!==0}}function w(e,t,n){let r=t===`foreground`?e.isFgRGB():e.isBgRGB(),i=t===`foreground`?e.isFgPalette():e.isBgPalette(),a=t===`foreground`?e.getFgColor():e.getBgColor();return r?le(a):i?n.palette[a]??(t===`foreground`?n.foreground:n.background):t===`foreground`?n.foreground:n.background}function T(e){return{foreground:e.foreground,background:e.background,bold:!1,italic:!1,dim:!1,underline:!1,invisible:!1,strikethrough:!1,overline:!1}}function oe(e,t){for(let n of t)E(e,n)}function E(e,t){if(t.text===``)return;let n=e.at(-1);if(n!==void 0&&se(n.style,t.style)){n.text+=t.text;return}e.push({text:t.text,style:t.style})}function se(e,t){return e.foreground===t.foreground&&e.background===t.background&&e.bold===t.bold&&e.italic===t.italic&&e.dim===t.dim&&e.underline===t.underline&&e.invisible===t.invisible&&e.strikethrough===t.strikethrough&&e.overline===t.overline}function ce(e){let t=[...v];for(let n=0;n<y.length;n+=1){let r=y[n];if(r===void 0)continue;let i=e?.[r];typeof i==`string`&&(t[n]=i)}let n=[0,95,135,175,215,255];for(let e=0;e<216;e+=1){let r=n[Math.floor(e/36)%6]??0,i=n[Math.floor(e/6)%6]??0,a=n[e%6]??0;t.push(D(r,i,a))}for(let e=0;e<24;e+=1){let n=8+e*10;t.push(D(n,n,n))}for(let n=0;n<Math.min(e?.extendedAnsi?.length??0,240);n+=1){let r=e?.extendedAnsi?.[n];r!==void 0&&(t[n+16]=r)}return t}function le(e){return`#${(e&16777215).toString(16).padStart(6,`0`)}`}function D(e,t,n){return`#${e.toString(16).padStart(2,`0`)}${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}`}var O=`pi-web.terminal.softKeys`,ue=`(pointer: coarse), (max-width: 760px)`;function de(e,t){return e??t}function fe(e){if(e===`true`)return!0;if(e===`false`)return!1}function k(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(ue):void 0}function A(e){return e?.matches===!0}function j(e=k()){return de(N(),A(e))}function M(){return N()!==void 0}function N(e=F()){if(e!==void 0)try{return fe(e.getItem(O))}catch{return}}function P(e,t=F()){if(t!==void 0)try{t.setItem(O,String(e))}catch{}}function F(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}var I=[{id:`escape`,label:`Esc`,ariaLabel:`Escape`,title:`发送 Escape`},{id:`tab`,label:`Tab`,ariaLabel:`Tab`,title:`发送 Tab`},{id:`ctrl-c`,label:`Ctrl+C`,ariaLabel:`Control C`,title:`中断前台进程`},{id:`ctrl-d`,label:`Ctrl+D`,ariaLabel:`Control D`,title:`发送 EOF / 关闭输入`},{id:`ctrl-z`,label:`Ctrl+Z`,ariaLabel:`Control Z`,title:`挂起前台进程`},{id:`ctrl-l`,label:`Ctrl+L`,ariaLabel:`Control L`,title:`清屏 / 重绘终端`},{id:`ctrl-r`,label:`Ctrl+R`,ariaLabel:`Control R`,title:`反向搜索历史`},{id:`ctrl-u`,label:`Ctrl+U`,ariaLabel:`Control U`,title:`删除到行首`},{id:`ctrl-w`,label:`Ctrl+W`,ariaLabel:`Control W`,title:`删除上一个单词`},{id:`arrow-left`,label:`←`,ariaLabel:`左箭头`,title:`向左移动`},{id:`arrow-up`,label:`↑`,ariaLabel:`上箭头`,title:`向上移动 / 上一条命令`},{id:`arrow-down`,label:`↓`,ariaLabel:`下箭头`,title:`向下移动 / 下一条命令`},{id:`arrow-right`,label:`→`,ariaLabel:`右箭头`,title:`向右移动`},{id:`home`,label:`Home`,ariaLabel:`Home`,title:`移动到开头`},{id:`end`,label:`End`,ariaLabel:`End`,title:`移动到末尾`},{id:`page-up`,label:`PgUp`,ariaLabel:`向上翻页`,title:`向上翻页`},{id:`page-down`,label:`PgDn`,ariaLabel:`向下翻页`,title:`向下翻页`},{id:`delete`,label:`Del`,ariaLabel:`Delete`,title:`向前删除`},{id:`backspace`,label:`⌫`,ariaLabel:`Backspace`,title:`退格`},{id:`meta-backward-word`,label:`M-B`,ariaLabel:`Meta B`,title:`向后移动一个单词`},{id:`meta-forward-word`,label:`M-F`,ariaLabel:`Meta F`,title:`向前移动一个单词`}],L=`\x1B`,R=``;function z(e,t){switch(e){case`escape`:return L;case`tab`:return` `;case`ctrl-c`:return B(`c`);case`ctrl-d`:return B(`d`);case`ctrl-z`:return B(`z`);case`ctrl-l`:return B(`l`);case`ctrl-r`:return B(`r`);case`ctrl-u`:return B(`u`);case`ctrl-w`:return B(`w`);case`arrow-left`:return V(`D`,t);case`arrow-up`:return V(`A`,t);case`arrow-down`:return V(`B`,t);case`arrow-right`:return V(`C`,t);case`home`:return H(`H`,t);case`end`:return H(`F`,t);case`page-up`:return`${L}[5~`;case`page-down`:return`${L}[6~`;case`delete`:return`${L}[3~`;case`backspace`:return R;case`meta-backward-word`:return`${L}b`;case`meta-forward-word`:return`${L}f`}}function B(e){return String.fromCharCode(e.toUpperCase().charCodeAt(0)-64)}function V(e,t){return t?.applicationCursorKeysMode===!0?`${L}O${e}`:`${L}[${e}`}function H(e,t){return t?.applicationCursorKeysMode===!0?`${L}O${e}`:`${L}[${e}`}var pe=8,me=500,U=class extends l{constructor(...e){super(...e),this.refocusOnClick=!0,this.onInput=()=>void 0,this.lastPointerFinishedAt=0}sendSoftKey(e,t){this.onInput(z(e.id,this.modes),t)}onSoftKeyPointerDown(e,t){e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),this.pointerStart={pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY})}onSoftKeyPointerMove(e){let t=this.pointerStart;t?.pointerId===e.pointerId&&W(t,e)&&this.finishSoftKeyPointer()}onSoftKeyPointerUp(e,t){let n=this.pointerStart;n?.pointerId===e.pointerId&&(e.preventDefault(),this.finishSoftKeyPointer(),!(n.key.id!==t.id||W(n,e))&&this.sendSoftKey(t,{refocus:e.pointerType===`mouse`}))}onSoftKeyPointerCancel(e){this.pointerStart?.pointerId===e.pointerId&&this.finishSoftKeyPointer()}finishSoftKeyPointer(){this.pointerStart=void 0,this.lastPointerFinishedAt=Date.now()}onSoftKeyClick(e,t){if(Date.now()-this.lastPointerFinishedAt<me){e.preventDefault();return}this.sendSoftKey(t,{refocus:this.refocusOnClick})}render(){return a`
|
|
3
3
|
<div class="terminal-soft-keys" role="toolbar" aria-label="终端快捷键">
|
|
4
4
|
${I.map(e=>a`
|
|
@@ -113,9 +113,12 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n a
|
|
|
113
113
|
</div>
|
|
114
114
|
${this.error===void 0?null:a`<p class="error">${this.error}</p>`}
|
|
115
115
|
${this.renderCommandRunNotice()}
|
|
116
|
-
${this.
|
|
116
|
+
${this.renderTerminalAccessoryBar()}
|
|
117
117
|
${this.loading?a`<p class="muted">正在加载终端…</p>`:null}
|
|
118
|
-
<div class="terminal-
|
|
118
|
+
<div class="terminal-stage">
|
|
119
|
+
<div class=${this.copySnapshot===void 0?`terminal-host`:`terminal-host copying`} ?inert=${this.copySnapshot!==void 0}></div>
|
|
120
|
+
${this.renderCopyMode()}
|
|
121
|
+
</div>
|
|
119
122
|
</section>
|
|
120
123
|
`}static{this.styles=e`
|
|
121
124
|
:host { flex: 1 1 auto; min-height: 0; display: flex; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as e,a as t,f as n,g as r,m as i,p as a}from"./index-
|
|
1
|
+
import{_ as e,a as t,f as n,g as r,m as i,p as a}from"./index-Jmsbve6u.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-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-5vQNxhKQ.js","./vendor-editor-core-vUi74DnD.js","./vendor-editor-languages-DoaXUodB.js","./vendor-editor-legacy-CYBnW6ZU.js","./TerminalPanel-Ctz1zP84.js","./vendor-terminal-D8k4UKM2.js","./vendor-terminal-BrP-ENHg.css"])))=>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,Z as s,d as c,f as l,j as u,l as d,p as f,q as p,u as m}from"./vendor-editor-core-vUi74DnD.js";import{a as ee,o as te,s as ne}from"./vendor-editor-languages-DoaXUodB.js";(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 re=globalThis,ie=re.ShadowRoot&&(re.ShadyCSS===void 0||re.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,ae=Symbol(),oe=new WeakMap,se=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==ae)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(ie&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=oe.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&oe.set(t,e))}return e}toString(){return this.cssText}},ce=e=>new se(typeof e==`string`?e:e+``,void 0,ae),h=(e,...t)=>new se(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,ae),le=(e,t)=>{if(ie)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=re.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},ue=ie?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return ce(t)})(e):e,{is:de,defineProperty:fe,getOwnPropertyDescriptor:pe,getOwnPropertyNames:me,getOwnPropertySymbols:he,getPrototypeOf:ge}=Object,_e=globalThis,ve=_e.trustedTypes,ye=ve?ve.emptyScript:``,be=_e.reactiveElementPolyfillSupport,xe=(e,t)=>e,Se={toAttribute(e,t){switch(t){case Boolean:e=e?ye: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}},Ce=(e,t)=>!de(e,t),we={attribute:!0,type:String,converter:Se,reflect:!1,useDefault:!1,hasChanged:Ce};Symbol.metadata??=Symbol(`metadata`),_e.litPropertyMetadata??=new WeakMap;var Te=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=we){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&&fe(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=pe(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)??we}static _$Ei(){if(this.hasOwnProperty(xe(`elementProperties`)))return;let e=ge(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(xe(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xe(`properties`))){let e=this.properties,t=[...me(e),...he(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(ue(e))}else e!==void 0&&t.push(ue(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 le(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?Se: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?Se: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??Ce)(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){}};Te.elementStyles=[],Te.shadowRootOptions={mode:`open`},Te[xe(`elementProperties`)]=new Map,Te[xe(`finalized`)]=new Map,be?.({ReactiveElement:Te}),(_e.reactiveElementVersions??=[]).push(`2.1.2`);var Ee=globalThis,De=e=>e,Oe=Ee.trustedTypes,ke=Oe?Oe.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Ae=`$lit$`,je=`lit$${Math.random().toFixed(9).slice(2)}$`,Me=`?`+je,Ne=`<${Me}>`,Pe=document,Fe=()=>Pe.createComment(``),Ie=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Le=Array.isArray,Re=e=>Le(e)||typeof e?.[Symbol.iterator]==`function`,ze=`[
|
|
3
3
|
\f\r]`,Be=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ve=/-->/g,He=/>/g,Ue=RegExp(`>|${ze}(?:([^\\s"'>=/]+)(${ze}*=${ze}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),We=/'/g,Ge=/"/g,Ke=/^(?:script|style|textarea|title)$/i,qe=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),g=qe(1),Je=qe(2),Ye=Symbol.for(`lit-noChange`),_=Symbol.for(`lit-nothing`),Xe=new WeakMap,Ze=Pe.createTreeWalker(Pe,129);function Qe(e,t){if(!Le(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return ke===void 0?t:ke.createHTML(t)}var $e=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=Be;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===Be?c[1]===`!--`?o=Ve:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=Ue):(Ke.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=Ue):o=He:o===Ue?c[0]===`>`?(o=i??Be,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?Ue:c[3]===`"`?Ge:We):o===Ge||o===We?o=Ue:o===Ve||o===He?o=Be:(o=Ue,i=void 0);let d=o===Ue&&e[t+1].startsWith(`/>`)?` `:``;a+=o===Be?n+Ne:l>=0?(r.push(s),n.slice(0,l)+Ae+n.slice(l)+je+d):n+je+(l===-2?t:d)}return[Qe(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},et=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]=$e(t,n);if(this.el=e.createElement(l,r),Ze.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=Ze.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(Ae)){let t=u[o++],n=i.getAttribute(e).split(je),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?at:r[1]===`?`?ot:r[1]===`@`?st:it}),i.removeAttribute(e)}else e.startsWith(je)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(Ke.test(i.tagName)){let e=i.textContent.split(je),t=e.length-1;if(t>0){i.textContent=Oe?Oe.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],Fe()),Ze.nextNode(),c.push({type:2,index:++a});i.append(e[t],Fe())}}}else if(i.nodeType===8)if(i.data===Me)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(je,e+1))!==-1;)c.push({type:7,index:a}),e+=je.length-1}a++}}static createElement(e,t){let n=Pe.createElement(`template`);return n.innerHTML=e,n}};function tt(e,t,n=e,r){if(t===Ye)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=Ie(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=tt(e,i._$AS(e,t.values),i,r)),t}var nt=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??Pe).importNode(t,!0);Ze.currentNode=r;let i=Ze.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new rt(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new ct(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=Ze.nextNode(),a++)}return Ze.currentNode=Pe,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++}},rt=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=_,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=tt(this,e,t),Ie(e)?e===_||e==null||e===``?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==Ye&&this._(e):e._$litType$===void 0?e.nodeType===void 0?Re(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!==_&&Ie(this._$AH)?this._$AA.nextSibling.data=e:this.T(Pe.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=et.createElement(Qe(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new nt(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=Xe.get(e.strings);return t===void 0&&Xe.set(e.strings,t=new et(e)),t}k(t){Le(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(Fe()),this.O(Fe()),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=De(e).nextSibling;De(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},it=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=_,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=_}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=tt(this,e,t,0),a=!Ie(e)||e!==this._$AH&&e!==Ye,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=tt(this,r[n+o],t,o),s===Ye&&(s=this._$AH[o]),a||=!Ie(s)||s!==this._$AH[o],s===_?e=_:e!==_&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===_?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},at=class extends it{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_?void 0:e}},ot=class extends it{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_)}},st=class extends it{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=tt(this,e,t,0)??_)===Ye)return;let n=this._$AH,r=e===_&&n!==_||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==_&&(n===_||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)}},ct=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){tt(this,e)}},lt={M:Ae,P:je,A:Me,C:1,L:$e,R:nt,D:Re,V:tt,I:rt,H:it,N:ot,U:st,B:at,F:ct},ut=Ee.litHtmlPolyfillSupport;ut?.(et,rt),(Ee.litHtmlVersions??=[]).push(`3.3.3`);var dt=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new rt(t.insertBefore(Fe(),e),e,void 0,n??{})}return i._$AI(e),i},ft=globalThis,v=class extends Te{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=dt(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Ye}};v._$litElement$=!0,v.finalized=!0,ft.litElementHydrateSupport?.({LitElement:v});var pt=ft.litElementPolyfillSupport;pt?.({LitElement:v}),(ft.litElementVersions??=[]).push(`4.2.2`);var y=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},mt={attribute:!0,type:String,converter:Se,reflect:!1,hasChanged:Ce},ht=(e=mt,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 b(e){return(t,n)=>typeof n==`object`?ht(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 x(e){return b({...e,state:!0,attribute:!1})}var gt=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function S(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 gt(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 gt(n,r,{get(){return a(this)}})}}var _t=`management`;function vt(e=Tt()){return wt(e)===_t}function yt(e=Et()){return vt(e?.search)?`management`:`normal`}function bt(e,t=Et(),n=`management`){return St(e,t,n,!0)}function xt(e,t=Et(),n=`management`){return St(e,t,n,!1)}function St(e,t,n,r){if(n===`normal`||t===void 0)return e;let i=Ct(t);if(i===void 0)return e;let a=new URL(e,t.origin);return a.searchParams.set(`embed`,i.embed),i.token!==void 0&&a.searchParams.set(`token`,i.token),`${a.pathname}${a.search}${r?a.hash:``}`}function Ct(e){if(e===void 0)return;let t=wt(e.search),n=e.searchParams.get(`token`)?.trim();if(t===_t)return{embed:t,...n===void 0||n===``?{}:{token:n}}}function wt(e){if(e===void 0||e===``)return;let t=new URLSearchParams(e).get(`embed`)?.trim();return t===``?void 0:t}function Tt(){return typeof window>`u`?void 0:window.location.search}function Et(){if(globalThis.location===void 0)return;let e=globalThis.location;if(typeof e.href==`string`&&e.href!==``)return new URL(e.href);let t=typeof e.protocol==`string`&&e.protocol!==``?e.protocol:`http:`,n=typeof e.host==`string`&&e.host!==``?e.host:`localhost`,r=typeof e.search==`string`?e.search:``;return new URL(`${t}//${n}/${r}`)}function Dt(e,t=kt()){let n=new URL(t.viteBaseUrl,t.documentBaseUrl);return new URL(At(e),n).toString()}function Ot(e,t=kt()){let n=new URL(Dt(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 kt(){return{viteBaseUrl:`./`,documentBaseUrl:typeof document>`u`?`http://localhost/`:document.baseURI}}function At(e){return e.startsWith(`/`)?`.${e}`:e}var jt=yt();function Mt(e){jt=e}function Nt(e){return Dt(bt(e,void 0,jt))}async function C(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(Nt(e),{...n,headers:r});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(Ft(e)??i.statusText)}return t(await i.json())}async function Pt(e,t){let n=await fetch(Nt(e));if(!(n.status===204||n.status===404)){if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(Ft(e)??n.statusText)}return t(await n.json())}}function Ft(e){if(It(e))return typeof e.error==`string`?e.error:void 0}function It(e){return typeof e==`object`&&!!e}function w(e){return typeof e==`object`&&!!e}function T(e){if(!w(e))throw Error(`Expected object response`);return e}function E(e,t){let n=e[t];if(typeof n!=`string`)throw Error(`Expected string field: ${t}`);return n}function D(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw Error(`Expected optional string field: ${t}`);return n}}function O(e,t){let n=e[t];if(typeof n!=`number`)throw Error(`Expected number field: ${t}`);return n}function Lt(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`number`)throw Error(`Expected optional number field: ${t}`);return n}}function k(e,t){let n=e[t];if(typeof n!=`boolean`)throw Error(`Expected boolean field: ${t}`);return n}function A(e){return t=>{if(!Array.isArray(t))throw Error(`Expected array response`);return t.map(e)}}function Rt(e,t){if(T(e)[t]!==!0)throw Error(`Expected ${t} response`);return!0}function j(e,t){return t===void 0?{}:{[e]:t}}function zt(e){return(e.split(/[\\/]/u).at(-1)?.toLowerCase()??e.toLowerCase()).replace(/(?:\.[cm]?js|\.exe|\.cmd)$/iu,``)===`pi`}function Bt(e){return!e.includes(`/`)&&!e.includes(`\\`)&&zt(e)}var Vt=new Set([`schemaVersion`,`revision`,`command`,`dir`,`sessionDirEnvKeys`]),Ht=/^sha256:[0-9a-f]{64}$/u,Ut=/^[A-Za-z0-9_][A-Za-z0-9._+-]*$/u,Wt=new Set([`PI_WEB_AGENT_SESSION_DIR`,`PI_CODING_AGENT_SESSION_DIR`]);function Gt(e){if(!Xt(e)||Object.keys(e).some(e=>!Vt.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`||!Ht.test(n))&&!(typeof r!=`string`||!Kt(r))&&!(typeof i!=`string`||!qt(i))&&Yt(a)&&new Set(a).size===a.length&&!(a[0]!==`PI_WEB_AGENT_SESSION_DIR`||a.some(e=>!Wt.has(e))))return Object.freeze({schemaVersion:t,revision:n,command:r,dir:i,sessionDirEnvKeys:Object.freeze([...a])})}function Kt(e){return e!==e.trim()||/[\s;&|`$<>]/u.test(e)?!1:qt(e)?!e.endsWith(`/`)&&!e.endsWith(`\\`):Ut.test(e)}function qt(e){if(e===``||e!==e.trim()||Jt(e))return!1;let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function Jt(e){for(let t of e){let e=t.charCodeAt(0);if(e<32||e===127)return!0}return!1}function Yt(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function Xt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var M={sessionsDeleteArchived:`sessions.deleteArchived`,sessionsBulkMutations:`sessions.bulkMutations`,sessionsCleanup:`sessions.cleanup`,sessionsReload:`sessions.reload`,sessionsClearQueue:`sessions.clearQueue`,sessionsPersistedState:`sessions.persistedState`,promptAttachments:`prompt.attachments`,workspaceFileSuggestions:`workspace.fileSuggestions`,piPackagesManage:`piPackages.manage`,selectedMachineSettings:`settings.selectedMachine`,agentProfileConfig:`settings.agentProfile`},Zt=Object.values(M),Qt=new Set(Zt);M.sessionsDeleteArchived,M.sessionsBulkMutations,M.sessionsCleanup,M.sessionsReload,M.sessionsClearQueue,M.sessionsPersistedState,M.promptAttachments,M.workspaceFileSuggestions,M.piPackagesManage,M.selectedMachineSettings,M.agentProfileConfig,M.sessionsDeleteArchived,M.sessionsBulkMutations,M.sessionsCleanup,M.sessionsReload,M.sessionsClearQueue,M.sessionsPersistedState,M.promptAttachments,M.sessionsDeleteArchived,M.sessionsBulkMutations,M.sessionsCleanup,M.sessionsReload,M.sessionsClearQueue,M.sessionsPersistedState,M.promptAttachments,M.workspaceFileSuggestions,M.piPackagesManage,M.selectedMachineSettings,M.agentProfileConfig;function $t(e){return typeof e==`string`&&Qt.has(e)}function en(e,t){return e?.capabilities?.includes(t)===!0}function tn(e){if(!(!Array.isArray(e)||!e.every(e=>typeof e==`string`)))return e.filter($t)}function nn(e){let t=T(e);return{path:E(t,`path`),exists:k(t,`exists`),config:rn(t.config),effectiveConfig:rn(t.effectiveConfig),envOverrides:pn(t.envOverrides)}}function rn(e){let t=T(e);return{...j(`host`,D(t,`host`)),...j(`port`,Lt(t,`port`)),...j(`allowedHosts`,sn(t.allowedHosts)),...j(`shortcuts`,dn(t.shortcuts)),...j(`plugins`,fn(t.plugins)),...j(`normalAuth`,on(t.normalAuth)),...j(`managementEmbed`,mn(t.managementEmbed)),...j(`pathAccess`,cn(t.pathAccess)),...j(`uploads`,un(t.uploads)),...j(`maxUploadBytes`,Lt(t,`maxUploadBytes`)),...j(`spawnSessions`,Bn(t,`spawnSessions`)),...j(`subsessions`,Bn(t,`subsessions`)),...j(`agent`,an(t.agent))}}function an(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB agent field`);return{...j(`command`,D(e,`command`)),...j(`dir`,D(e,`dir`))}}}function on(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB normalAuth field`);return{...j(`passwordHash`,D(e,`passwordHash`))}}}function sn(e){if(e!==void 0){if(e===!0)return!0;if(Array.isArray(e)&&e.every(e=>typeof e==`string`))return e;throw Error(`Invalid PI WEB allowedHosts field`)}}function cn(e){if(e===void 0)return;if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB pathAccess field`);let t=e.allowedPaths;return{...j(`allowedPaths`,ln(t,`pathAccess.allowedPaths`))}}function ln(e,t){if(e!==void 0){if(Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``))return e;throw Error(`Invalid PI WEB ${t} field`)}}function un(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB uploads field`);return{...j(`defaultFolder`,D(e,`defaultFolder`))}}}function dn(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB shortcuts field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t!==null&&(typeof t!=`string`||t===``))throw Error(`Invalid PI WEB shortcut field`);return[e,t]}))}}function fn(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB plugins field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(!w(t)||Array.isArray(t))throw Error(`Invalid PI WEB plugin config field`);let n=t.enabled;if(n!==void 0&&typeof n!=`boolean`)throw Error(`Invalid PI WEB plugin enabled field`);let r=t.settings;if(r!==void 0&&(!w(r)||Array.isArray(r)))throw Error(`Invalid PI WEB plugin settings field`);return[e,t]}))}}function pn(e){let t=T(e);return{host:k(t,`host`),port:k(t,`port`),allowedHosts:k(t,`allowedHosts`),spawnSessions:k(t,`spawnSessions`),subsessions:k(t,`subsessions`),agentCommand:Bn(t,`agentCommand`)??!1,agentDir:Bn(t,`agentDir`)??!1,...Sn(t),agentSessionDir:Bn(t,`agentSessionDir`)??!1}}function mn(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB managementEmbed field`);return{...j(`enabled`,Bn(e,`enabled`)),...j(`projectRoot`,D(e,`projectRoot`)),...j(`auth`,hn(e.auth,[`sharedSecretEnv`,`issuer`,`audience`],`managementEmbed.auth`)),...j(`sandbox`,gn(e.sandbox)),...j(`tools`,_n(e.tools))}}}function hn(e,t,n){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB ${n} field`);return Object.fromEntries(t.flatMap(t=>{let n=D(e,t);return n===void 0?[]:[[t,n]]}))}}function gn(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB managementEmbed.sandbox field`);return{...j(`pythonExecutable`,D(e,`pythonExecutable`)),...j(`env`,vn(e.env,`managementEmbed.sandbox.env`))}}}function _n(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid PI WEB managementEmbed.tools field`);return{...j(`allow`,ln(e.allow,`managementEmbed.tools.allow`)),...j(`deny`,ln(e.deny,`managementEmbed.tools.deny`)),...j(`permissions`,yn(e.permissions,`managementEmbed.tools.permissions`))}}}function vn(e,t){if(e!==void 0){if(!w(e)||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`string`))throw Error(`Invalid PI WEB ${t} field`);return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,bn(n,t)]))}}function yn(e,t){if(e!==void 0){if(!w(e)||Array.isArray(e)||Object.values(e).some(e=>typeof e!=`boolean`))throw Error(`Invalid PI WEB ${t} field`);return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,xn(n,t)]))}}function bn(e,t){if(typeof e!=`string`)throw Error(`Invalid PI WEB ${t} field`);return e}function xn(e,t){if(typeof e!=`boolean`)throw Error(`Invalid PI WEB ${t} field`);return e}function Sn(e){let t=e.agentDirSource;if(t===void 0)return{};if(t!==`pi-web`&&t!==`pi-compatibility`)throw Error(`Invalid PI WEB agentDirSource field`);return{agentDirSource:t}}function Cn(e){let t=T(e);return{plugins:A(wn)(t.plugins)}}function wn(e){let t=T(e);return{id:E(t,`id`),module:E(t,`module`),source:E(t,`source`),scope:Tn(t.scope),machineSpecific:zn(t.machineSpecific,`machineSpecific`)??!1,enabled:k(t,`enabled`)}}function Tn(e){if(e!==`bundled`&&e!==`local`&&e!==`user`&&e!==`project`)throw Error(`Invalid PI WEB plugin scope`);return e}function En(e){let t=T(e);return{packageName:E(t,`packageName`),generatedAt:E(t,`generatedAt`),components:On(t.components),release:Nn(t.release),commands:Pn(t.commands),messages:A(Fn)(t.messages)}}function Dn(e){let t=T(e);return{packageName:E(t,`packageName`),generatedAt:E(t,`generatedAt`),components:kn(t.components),capabilities:Ln(t.capabilities)}}function On(e){let t=T(e);return{web:jn(t.web),sessiond:jn(t.sessiond)}}function kn(e){let t=T(e);return{web:An(t.web),sessiond:An(t.sessiond)}}function An(e){let t=T(e),n=In(t.component),r=t.activeAgentProfile,i=r===void 0?void 0:Gt(r);if(r!==void 0&&(n!==`sessiond`||i===void 0))throw Error(`Invalid active agent profile descriptor`);return{component:n,label:E(t,`label`),...j(`runtimeVersion`,D(t,`runtimeVersion`)),available:k(t,`available`),capabilities:Ln(t.capabilities),...j(`activeAgentProfile`,i),...j(`error`,D(t,`error`))}}function jn(e){let t=T(e);return{component:In(t.component),label:E(t,`label`),...j(`runtimeVersion`,D(t,`runtimeVersion`)),...j(`installedVersion`,D(t,`installedVersion`)),stale:k(t,`stale`),available:k(t,`available`),...j(`installation`,Mn(t.installation)),...j(`error`,D(t,`error`))}}function Mn(e){if(e===void 0)return;let t=T(e),n=E(t,`kind`);if(n!==`pi-package`&&n!==`npm-global`&&n!==`local`&&n!==`docker`&&n!==`unknown`)throw Error(`Invalid PI WEB installation kind`);let r=t.scope;if(r!==void 0&&r!==`user`&&r!==`project`)throw Error(`Invalid PI WEB installation scope`);let i=t.dockerMode;if(i!==void 0&&i!==`runtime`&&i!==`dev`)throw Error(`Invalid PI WEB Docker mode`);return{kind:n,...j(`path`,D(t,`path`)),...j(`source`,D(t,`source`)),...r===void 0?{}:{scope:r},...j(`npmRoot`,D(t,`npmRoot`)),...i===void 0?{}:{dockerMode:i}}}function Nn(e){let t=T(e);return{packageName:E(t,`packageName`),...j(`latestVersion`,D(t,`latestVersion`)),updateAvailable:k(t,`updateAvailable`),...j(`checkedAt`,D(t,`checkedAt`)),...t.skipped===!0?{skipped:!0}:{},...j(`error`,D(t,`error`))}}function Pn(e){let t=T(e);return{...j(`update`,D(t,`update`)),...j(`restart`,D(t,`restart`)),...j(`restartWeb`,D(t,`restartWeb`)),...j(`restartSessiond`,D(t,`restartSessiond`)),...j(`status`,D(t,`status`))}}function Fn(e){let t=T(e);return{id:E(t,`id`),severity:Rn(t.severity),title:E(t,`title`),body:E(t,`body`),...j(`command`,D(t,`command`))}}function In(e){if(e!==`web`&&e!==`sessiond`)throw Error(`Invalid PI WEB service component`);return e}function Ln(e){let t=tn(e);if(t===void 0)throw Error(`Invalid PI WEB capabilities`);return t}function Rn(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid PI WEB status severity`);return e}function zn(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`Expected optional boolean field: ${t}`);return e}}function Bn(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw Error(`Invalid PI WEB ${t} field`);return n}}function Vn(e){let t=T(e);return A(Hn)(t.machines)}function Hn(e){let t=T(e),n=Gn(t,`kind`),r=D(t,`baseUrl`),i=Kn(t,`status`),a=D(t,`statusMessage`);return{id:E(t,`id`),name:E(t,`name`),kind:n,...r===void 0?{}:{baseUrl:r},createdAt:E(t,`createdAt`),updatedAt:E(t,`updatedAt`),...i===void 0?{}:{status:i},...a===void 0?{}:{statusMessage:a}}}function Un(e){let t=T(e),n=Kn(t,`status`),r=D(t,`error`);return{machineId:E(t,`machineId`),ok:k(t,`ok`),checkedAt:E(t,`checkedAt`),...n===void 0?{}:{status:n},...t.web===void 0?{}:{web:jn(t.web)},...t.sessiond===void 0?{}:{sessiond:jn(t.sessiond)},...r===void 0?{}:{error:r}}}function Wn(e){let t=T(e),n=D(t,`error`);return{machineId:E(t,`machineId`),ok:k(t,`ok`),checkedAt:E(t,`checkedAt`),...j(`packageName`,D(t,`packageName`)),...j(`generatedAt`,D(t,`generatedAt`)),...t.components===void 0?{}:{components:kn(t.components)},...t.capabilities===void 0?{}:{capabilities:Ln(t.capabilities)},...n===void 0?{}:{error:n}}}function Gn(e,t){let n=E(e,t);if(n!==`local`&&n!==`remote`)throw Error(`Expected machine kind field: ${t}`);return n}function Kn(e,t){let n=D(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 qn(e){let t=T(e);return{configured:k(t,`configured`),authenticated:k(t,`authenticated`)}}function Jn(e){if(!Array.isArray(e))throw Error(`Expected array response`);return e}function Yn(e,t){if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`Expected string array field: ${t}`);return e}function Xn(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`Expected optional boolean field: ${t}`);return e}}function Zn(e){if(Array.isArray(e))return{messages:e,start:0,total:e.length};let t=T(e);return{messages:Jn(t.messages),start:O(t,`start`),total:O(t,`total`)}}function Qn(e){let t=T(e);return{id:E(t,`id`),name:E(t,`name`),path:E(t,`path`),createdAt:E(t,`createdAt`)}}function $n(e){let t=T(e),n=D(t,`branch`);return{id:E(t,`id`),projectId:E(t,`projectId`),path:E(t,`path`),label:E(t,`label`),...n===void 0?{}:{branch:n},isMain:k(t,`isMain`),isGitRepo:k(t,`isGitRepo`),isGitWorktree:k(t,`isGitWorktree`),...j(`effectiveConfig`,er(t.effectiveConfig))}}function er(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid workspace effectiveConfig field`);return{...j(`uploads`,Qr(e.uploads))}}}function tr(e){return{path:E(T(e),`path`)}}function nr(e){let t=T(e);if(t.deleted!==!0)throw Error(`Expected deleted response`);return{deleted:!0,path:E(t,`path`)}}function rr(e){let t=T(e),n=D(t,`name`),r=Xn(t.persisted,`persisted`),i=D(t,`parentSessionPath`),a=D(t,`archivedAt`);return{id:E(t,`id`),path:E(t,`path`),cwd:E(t,`cwd`),...r===void 0?{}:{persisted:r},...n===void 0?{}:{name:n},created:E(t,`created`),modified:E(t,`modified`),messageCount:O(t,`messageCount`),firstMessage:E(t,`firstMessage`),...i===void 0?{}:{parentSessionPath:i},...t.archived===!0?{archived:!0}:{},...a===void 0?{}:{archivedAt:a}}}function ir(e){return{sessionIds:Yn(T(e).sessionIds,`sessionIds`)}}function ar(e){return{pinned:k(T(e),`pinned`)}}function or(e){let t=T(e);return{sessionId:E(t,`sessionId`),...j(`persisted`,Xn(t.persisted,`persisted`)),isStreaming:k(t,`isStreaming`),isCompacting:k(t,`isCompacting`),isBashRunning:k(t,`isBashRunning`),pendingMessageCount:O(t,`pendingMessageCount`),queuedMessages:t.queuedMessages===void 0?[]:A(hr)(t.queuedMessages),...j(`messageCount`,Lt(t,`messageCount`)),tokens:gr(t.tokens),cost:O(t,`cost`),...vr(t.model),...Mr(t.contextUsage),...j(`thinkingLevel`,D(t,`thinkingLevel`))}}function sr(e){let t=T(e),n=t.skippedBusySessionIds===void 0?void 0:Yn(t.skippedBusySessionIds,`skippedBusySessionIds`);return{generatedAt:E(t,`generatedAt`),thresholds:fr(t.thresholds),projects:A(pr)(t.projects),totals:mr(t.totals),...n===void 0?{}:{skippedBusySessionIds:n}}}function cr(e){let t=T(e);return{...sr(t),archivedSessionIds:Yn(t.archivedSessionIds,`archivedSessionIds`),deletedSessionIds:Yn(t.deletedSessionIds,`deletedSessionIds`)}}function lr(e){let t=T(e);if(t.archived!==!0)throw Error(`Expected bulk archived response`);return{archived:!0,archivedSessionIds:Yn(t.archivedSessionIds,`archivedSessionIds`),failures:A(dr)(t.failures),generatedAt:E(t,`generatedAt`)}}function ur(e){let t=T(e);if(t.deleted!==!0)throw Error(`Expected bulk deleted response`);return{deleted:!0,deletedSessionIds:Yn(t.deletedSessionIds,`deletedSessionIds`),failures:A(dr)(t.failures),generatedAt:E(t,`generatedAt`)}}function dr(e){let t=T(e);return{sessionId:E(t,`sessionId`),error:E(t,`error`)}}function fr(e){let t=T(e);return{...j(`archiveIdleDays`,Lt(t,`archiveIdleDays`)),...j(`deleteArchivedDays`,Lt(t,`deleteArchivedDays`))}}function pr(e){let t=T(e);return{cwd:E(t,`cwd`),archiveCount:O(t,`archiveCount`),deleteCount:O(t,`deleteCount`)}}function mr(e){let t=T(e);return{archiveCount:O(t,`archiveCount`),deleteCount:O(t,`deleteCount`)}}function hr(e){let t=T(e),n=E(t,`kind`);if(n!==`steer`&&n!==`followUp`)throw Error(`Invalid queued message kind`);return{kind:n,text:E(t,`text`)}}function gr(e){let t=T(e);return{input:O(t,`input`),output:O(t,`output`),cacheRead:O(t,`cacheRead`),cacheWrite:O(t,`cacheWrite`),total:O(t,`total`)}}function _r(e){let t=T(e);return{...j(`provider`,D(t,`provider`)),...j(`id`,D(t,`id`)),...j(`name`,D(t,`name`)),...j(`contextWindow`,Lt(t,`contextWindow`)),...j(`reasoning`,t.reasoning)}}function vr(e){return e===void 0?{}:{model:_r(e)}}function yr(e){let t=T(e);return{models:A(_r)(t.models)}}function br(e){if(typeof e!=`string`)throw Error(`Invalid thinking level`);return e}function xr(e){let t=T(e);return{levels:A(br)(t.levels)}}function Sr(e){if(e!==`oauth`&&e!==`api_key`)throw Error(`Invalid auth type`);return e}function Cr(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 wr(e){let t=T(e),n=t.source===void 0?void 0:Cr(t.source);return{configured:k(t,`configured`),...j(`source`,n),...j(`label`,D(t,`label`))}}function Tr(e){let t=T(e);return{id:E(t,`id`),name:E(t,`name`),authType:Sr(t.authType),status:wr(t.status)}}function Er(e){let t=T(e);return{providers:A(Tr)(t.providers)}}function Dr(e){let t=T(e);return{flowId:E(t,`flowId`),providerId:E(t,`providerId`),providerName:E(t,`providerName`),status:Or(t.status),progress:A(e=>{if(typeof e!=`string`)throw Error(`Expected progress item string`);return e})(t.progress),...j(`error`,D(t,`error`)),...j(`auth`,kr(t.auth)),...j(`prompt`,Ar(t.prompt)),...j(`select`,jr(t.select))}}function Or(e){if(e!==`running`&&e!==`complete`&&e!==`error`&&e!==`cancelled`)throw Error(`Invalid OAuth flow status`);return e}function kr(e){if(e===void 0)return;let t=T(e);return{url:E(t,`url`),...j(`instructions`,D(t,`instructions`))}}function Ar(e){if(e===void 0)return;let t=T(e),n=E(t,`kind`);if(n!==`prompt`&&n!==`manual`)throw Error(`Invalid OAuth prompt kind`);return{requestId:E(t,`requestId`),message:E(t,`message`),kind:n,...j(`placeholder`,D(t,`placeholder`)),...t.allowEmpty===!0?{allowEmpty:!0}:{}}}function jr(e){if(e===void 0)return;let t=T(e);return{requestId:E(t,`requestId`),message:E(t,`message`),options:A(ai)(t.options)}}function Mr(e){if(e===void 0)return{};let t=T(e);return{contextUsage:{tokens:vi(t,`tokens`),contextWindow:O(t,`contextWindow`),percent:vi(t,`percent`)}}}function Nr(e){let t=T(e),n=E(t,`source`);if(n!==`extension`&&n!==`prompt`&&n!==`skill`&&n!==`builtin`)throw Error(`Invalid command source`);return{name:E(t,`name`),source:n,...j(`description`,D(t,`description`))}}function Pr(e){let t=T(e),n=E(t,`kind`);if(n!==`tracked`&&n!==`untracked`&&n!==`other`)throw Error(`Invalid file kind`);return{path:E(t,`path`),kind:n}}function Fr(e){let t=T(e);return{path:E(t,`path`),entries:A(Ir)(t.entries),scannedAt:E(t,`scannedAt`),truncated:k(t,`truncated`)}}function Ir(e){let t=T(e),n=E(t,`type`);if(n!==`file`&&n!==`directory`&&n!==`symlink`)throw Error(`Invalid file tree entry type`);return{name:E(t,`name`),path:E(t,`path`),type:n,...j(`size`,Lt(t,`size`)),...j(`modifiedAt`,D(t,`modifiedAt`))}}function Lr(e){let t=T(e),n=E(t,`encoding`);if(n!==`utf8`)throw Error(`Invalid file encoding`);return{path:E(t,`path`),...j(`language`,D(t,`language`)),...j(`mediaType`,Vr(t.mediaType)),...j(`mimeType`,D(t,`mimeType`)),encoding:n,size:O(t,`size`),modifiedAt:E(t,`modifiedAt`),content:E(t,`content`),truncated:k(t,`truncated`),binary:k(t,`binary`)}}function Rr(e){let t=T(e);return{path:E(t,`path`),size:O(t,`size`),modifiedAt:E(t,`modifiedAt`),created:k(t,`created`)}}function zr(e){let t=T(e);return{path:E(t,`path`),existed:k(t,`existed`)}}function Br(e){let t=T(e);return{fromPath:E(t,`fromPath`),toPath:E(t,`toPath`),size:O(t,`size`),modifiedAt:E(t,`modifiedAt`)}}function Vr(e){if(e!==void 0){if(e!==`image`)throw Error(`Invalid file media type`);return e}}function Hr(e){let t=T(e);return{isGitRepo:k(t,`isGitRepo`),hash:E(t,`hash`),...j(`branch`,D(t,`branch`)),...j(`upstream`,D(t,`upstream`)),...j(`ahead`,Lt(t,`ahead`)),...j(`behind`,Lt(t,`behind`)),files:A(Ur)(t.files)}}function Ur(e){let t=T(e);return{path:E(t,`path`),...j(`oldPath`,D(t,`oldPath`)),index:Wr(t.index),workingTree:Wr(t.workingTree)}}function Wr(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 Gr(e){let t=T(e);return{...j(`path`,D(t,`path`)),staged:k(t,`staged`),hash:E(t,`hash`),diff:E(t,`diff`),truncated:k(t,`truncated`)}}function Kr(e){let t=T(e);return{id:E(t,`id`),cwd:E(t,`cwd`),name:E(t,`name`),createdAt:E(t,`createdAt`),exited:k(t,`exited`),...j(`exitCode`,Lt(t,`exitCode`)),...j(`commandRunId`,D(t,`commandRunId`))}}function qr(e){let t=T(e);return{id:E(t,`id`),origin:E(t,`origin`),projectId:E(t,`projectId`),workspaceId:E(t,`workspaceId`),terminalId:E(t,`terminalId`),title:E(t,`title`),command:E(t,`command`),status:Jr(t.status),...j(`exitCode`,Lt(t,`exitCode`)),createdAt:E(t,`createdAt`),...j(`startedAt`,D(t,`startedAt`)),...j(`completedAt`,D(t,`completedAt`)),metadata:Yr(t.metadata,`metadata`)}}function Jr(e){if(e!==`queued`&&e!==`running`&&e!==`succeeded`&&e!==`failed`)throw Error(`Invalid terminal command run status`);return e}function Yr(e,t){let n=T(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 Xr(e){let t=T(e);return{cwd:E(t,`cwd`),hasSessionActivity:k(t,`hasSessionActivity`),hasTerminalActivity:k(t,`hasTerminalActivity`),updatedAt:E(t,`updatedAt`)}}function Zr(e){let t=T(e);return{workspaces:A(Xr)(t.workspaces),generatedAt:E(t,`generatedAt`)}}function Qr(e){if(e!==void 0){if(!w(e)||Array.isArray(e))throw Error(`Invalid uploads field`);return{...j(`defaultFolder`,D(e,`defaultFolder`))}}}function $r(e){let t=T(e);return{packages:A(ti)(t.packages)}}function ei(e){let t=T(e),n=D(t,`source`),r=t.scope===void 0?void 0:ni(t.scope),i=Xn(t.removed,`removed`);return{action:ri(t.action),...j(`source`,n),...j(`scope`,r),...j(`removed`,i),packages:A(ti)(t.packages)}}function ti(e){let t=T(e);return{source:E(t,`source`),scope:ni(t.scope),filtered:k(t,`filtered`),...j(`installedPath`,D(t,`installedPath`))}}function ni(e){if(e!==`user`&&e!==`project`)throw Error(`Invalid Pi package scope`);return e}function ri(e){if(e!==`install`&&e!==`remove`&&e!==`update`)throw Error(`Invalid Pi package mutation action`);return e}function ii(e){let t=T(e),n=E(t,`type`);if(n===`unsupported`)return{type:n,message:E(t,`message`)};if(n===`select`)return{type:n,requestId:E(t,`requestId`),title:E(t,`title`),options:A(ai)(t.options)};if(n===`done`)return{type:n,...j(`message`,D(t,`message`)),...oi(t.session),...j(`promptDraft`,D(t,`promptDraft`))};throw Error(`Invalid command result type`)}function ai(e){let t=T(e);return{value:E(t,`value`),label:E(t,`label`),...j(`description`,D(t,`description`))}}function oi(e){return e===void 0?{}:{session:rr(e)}}function si(e){return{accepted:Rt(e,`accepted`)}}function ci(e){let t=T(e);return A(li)(t.attachments)}function li(e){let t=T(e);return{path:E(t,`path`),mimeType:E(t,`mimeType`),size:O(t,`size`)}}function ui(e){return{closed:Rt(e,`closed`)}}function di(e){return{aborted:Rt(e,`aborted`)}}function fi(e){return{stopped:Rt(e,`stopped`)}}function pi(e){let t=T(e);if(t.archived!==!0)throw Error(`Expected archived response`);let n=t.sessionIds===void 0?void 0:Yn(t.sessionIds,`sessionIds`),r=Lt(t,`archivedCount`),i=Lt(t,`skippedAlreadyArchivedCount`);return{archived:!0,...n===void 0?{}:{sessionIds:n},...r===void 0?{}:{archivedCount:r},...i===void 0?{}:{skippedAlreadyArchivedCount:i}}}function mi(e){return{restored:Rt(e,`restored`)}}function hi(e){return{deleted:Rt(e,`deleted`)}}function gi(e){return{detached:Rt(e,`detached`)}}function _i(e){return{reloaded:Rt(e,`reloaded`)}}function vi(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 yi(e){return typeof e==`string`?e:e.id}function bi(e){return typeof e==`string`?void 0:e.cwd}function xi(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 Si(e,t,n=`local`){let r=new URLSearchParams,i=bi(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(yi(e))}/messages${a===``?``:`?${a}`}`}function Ci(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`),Dt(bt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`))}function wi(e,t,n,r){let i=new URLSearchParams;return i.set(`path`,n),r?.modifiedAt!==void 0&&i.set(`v`,r.modifiedAt),Dt(bt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${i.toString()}`))}function Ti(e,t,n,r){let i=new URLSearchParams;return i.set(`path`,n),Dt(bt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/download?${i.toString()}`))}var N=(e=`local`)=>`api/machines/${encodeURIComponent(e)}`;function Ei(e){return typeof e==`string`?e:e.id}function Di(e){return typeof e==`string`?void 0:e.cwd}function Oi(e,t=`local`){return`${N(t)}/sessions/${encodeURIComponent(Ei(e))}`}function P(e,t,n=`local`){return`${Oi(e,n)}/${t}`}function ki(e,t,n=`local`){return`${P(e,t,n)}${ji(e)}`}function Ai(e,t=`local`){return`${Oi(e,t)}${ji(e)}`}function ji(e){let t=Di(e);return t===void 0||t===``?``:`?${new URLSearchParams({cwd:t}).toString()}`}function F(e,t={}){let n=Di(e);return JSON.stringify(n===void 0||n===``?t:{cwd:n,...t})}function Mi(e){return JSON.stringify({sessions:e.map(Ni)})}function Ni(e){let t=Ei(e),n=Di(e);return n===void 0||n===``?{id:t}:{id:t,cwd:n}}function Pi(e,t){let n=new URLSearchParams;t.projectId!==void 0&&n.set(`projectId`,t.projectId);let r=n.toString();return`${N(t.machineId)}/auth/${e}${r===``?``:`?${r}`}`}function Fi(e){return e===`local`?`api/pi-web/status`:`${N(e)}/pi-web/status`}var Ii={piWebStatus:(e=`local`)=>C(Fi(e),En),checkForUpdates:(e=`local`)=>C(`${Fi(e)}?refresh=1`,En,{cache:`no-store`}),piWebRuntime:()=>C(`api/pi-web/runtime`,Dn)},Li={machines:()=>C(`api/machines`,Vn),addMachine:e=>C(`api/machines`,Hn,{method:`POST`,body:JSON.stringify(e)}),deleteMachine:e=>C(`api/machines/${encodeURIComponent(e)}`,e=>e,{method:`DELETE`}),health:e=>C(`api/machines/${encodeURIComponent(e)}/health`,Un),runtime:(e,t=!1)=>C(`api/machines/${encodeURIComponent(e)}/runtime${t?`?refresh=1`:``}`,Wn,t?{cache:`no-store`}:{})};function Ri(e){return e===void 0?`api/config`:`${N(e)}/config`}function zi(e){return e===void 0?`api/plugins`:`${N(e)}/plugins`}var Bi={config:e=>C(Ri(e),nn),saveConfig:(e,t)=>C(Ri(t),nn,{method:`PUT`,body:JSON.stringify({config:e})})},Vi={status:()=>C(`/api/normal-auth/status`,qn),setup:e=>C(`/api/normal-auth/setup`,si,{method:`POST`,body:JSON.stringify({password:e})}),login:e=>C(`/api/normal-auth/login`,si,{method:`POST`,body:JSON.stringify({password:e})}),changePassword:(e,t)=>C(`/api/normal-auth/change-password`,si,{method:`POST`,body:JSON.stringify({currentPassword:e,newPassword:t})})},Hi={plugins:e=>C(zi(e),Cn)};function Ui(e=``,t){let n=t===void 0?`api/pi-packages`:`${N(t)}/pi-packages`;return e===``?n:`${n}/${e}`}var Wi={packages:e=>C(Ui(``,e),$r),install:(e,t)=>{let n={source:e};return C(Ui(`install`,t),ei,{method:`POST`,body:JSON.stringify(n)})},remove:(e,t,n)=>{let r=t===void 0?{source:e}:{source:e,scope:t};return C(Ui(`remove`,n),ei,{method:`POST`,body:JSON.stringify(r)})},update:(e,t)=>{let n=e===void 0?void 0:{source:e};return C(Ui(`update`,t),ei,{method:`POST`,...n===void 0?{}:{body:JSON.stringify(n)}})}},Gi={workspaceActivity:(e=`local`)=>C(`${N(e)}/activity`,Zr)},Ki={projects:(e=`local`)=>C(`${N(e)}/projects`,A(Qn)),addProject:(e,t,n,r=`local`)=>C(`${N(r)}/projects`,Qn,{method:`POST`,body:JSON.stringify({path:e,name:t,create:n})}),closeProject:(e,t=`local`)=>C(`${N(t)}/projects/${encodeURIComponent(e)}`,ui,{method:`DELETE`}),projectDirectories:(e,t=`local`)=>C(`${N(t)}/project-directories?q=${encodeURIComponent(e)}`,A(Pr))};function qi(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 C(`${N(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${o.toString()}`,Rr,{method:`PUT`,body:c,headers:{"Content-Type":s?`application/octet-stream`:`text/plain`}})}var Ji={workspaces:(e,t=`local`)=>C(`${N(t)}/projects/${encodeURIComponent(e)}/workspaces`,A($n)),deleteWorkspace:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}`,qr,{method:`DELETE`}),workspaceTree:(e,t,n=``,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(n)}`,Fr),workspaceFile:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`,Lr),optionalWorkspaceFile:(e,t,n,r=`local`)=>Pt(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}&optional=true`,Lr),createWorkspaceFile:(e,t,n,r=`local`)=>qi(e,t,n,new Uint8Array,void 0,r),writeWorkspaceFile:qi,deleteWorkspaceFile:(e,t,n,r=`local`)=>{let i=new URLSearchParams({path:n});return C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`,zr,{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`),C(`${N(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/move?${o.toString()}`,Br,{method:`POST`})},createWorkspaceDirectory:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/directory`,tr,{method:`POST`,body:JSON.stringify({path:n})}),moveWorkspaceDirectory:(e,t,n,r,i=`local`)=>C(`${N(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/directory`,tr,{method:`PATCH`,body:JSON.stringify({fromPath:n,toPath:r})}),deleteWorkspaceDirectory:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/directory?path=${encodeURIComponent(n)}`,nr,{method:`DELETE`}),downloadWorkspaceFile:(e,t,n,r=`local`)=>ea(e,t,n,r)},Yi={sessions:(e,t=`local`)=>C(`${N(t)}/sessions?cwd=${encodeURIComponent(e)}`,A(rr)),search:(e,t,n=`local`)=>C(`${N(n)}/sessions/search?${new URLSearchParams({cwd:e,q:t}).toString()}`,A(rr)),pinned:(e,t=`local`)=>C(`${N(t)}/sessions/pins?cwd=${encodeURIComponent(e)}`,ir),pin:(e,t=`local`)=>C(`${Oi(e,t)}/pin`,ar,{method:`PUT`,body:F(e)}),unpin:(e,t=`local`)=>C(`${Oi(e,t)}/pin${ji(e)}`,ar,{method:`DELETE`}),startSession:(e,t=`local`)=>C(`${N(t)}/sessions`,rr,{method:`POST`,body:JSON.stringify({cwd:e})}),cleanupPreview:(e,t=`local`)=>C(`${N(t)}/sessions/cleanup/preview`,sr,{method:`POST`,body:JSON.stringify(e)}),cleanup:(e,t=`local`)=>C(`${N(t)}/sessions/cleanup`,cr,{method:`POST`,body:JSON.stringify(e)}),archiveMany:(e,t=`local`)=>C(`${N(t)}/sessions/bulk/archive`,lr,{method:`POST`,body:Mi(e)}),deleteArchivedMany:(e,t=`local`)=>C(`${N(t)}/sessions/bulk/delete-archived`,ur,{method:`POST`,body:Mi(e)}),messages:(e,t,n=`local`)=>C(Si(e,t,n),Zn),status:(e,t=`local`)=>C(ki(e,`status`,t),or),models:(e,t=`local`)=>C(ki(e,`models`,t),yr),setModel:(e,t,n,r=`local`)=>C(P(e,`model`,r),or,{method:`POST`,body:F(e,{provider:t,modelId:n})}),cycleModel:(e,t,n=`local`)=>C(P(e,`model/cycle`,n),or,{method:`POST`,body:F(e,{direction:t})}),thinkingLevels:(e,t=`local`)=>C(ki(e,`thinking-levels`,t),xr),setThinkingLevel:(e,t,n=`local`)=>C(P(e,`thinking-level`,n),or,{method:`POST`,body:F(e,{level:t})}),cycleThinkingLevel:(e,t=`local`)=>C(P(e,`thinking-level/cycle`,t),or,{method:`POST`,body:F(e)}),commands:(e,t=`local`)=>C(ki(e,`commands`,t),A(Nr)),prompt:(e,t,n,r=`local`,i)=>C(P(e,`prompt`,r),si,{method:`POST`,body:F(e,{text:t,...n===void 0?{}:{streamingBehavior:n},...i!==void 0&&i.length>0?{attachments:i}:{}})}),saveAttachments:(e,t,n=`local`,r)=>C(P(e,`attachments`,n),ci,{method:`POST`,body:F(e,{attachments:t,...r===void 0?{}:{folder:r}})}),shell:(e,t,n=`local`)=>C(P(e,`shell`,n),si,{method:`POST`,body:F(e,{text:t})}),runCommand:(e,t,n=`local`)=>C(P(e,`commands/run`,n),ii,{method:`POST`,body:F(e,{text:t})}),respondToCommand:(e,t,n,r=`local`)=>C(P(e,`commands/respond`,r),ii,{method:`POST`,body:F(e,{requestId:t,value:n})}),abort:(e,t=`local`)=>C(P(e,`abort`,t),di,{method:`POST`,body:F(e)}),stop:(e,t=`local`)=>C(P(e,`stop`,t),fi,{method:`POST`,body:F(e)}),archive:(e,t=`local`)=>C(P(e,`archive`,t),pi,{method:`POST`,body:F(e)}),archiveWithDescendants:(e,t=`local`)=>C(P(e,`archive-tree`,t),pi,{method:`POST`,body:F(e)}),restore:(e,t=`local`)=>C(P(e,`restore`,t),mi,{method:`POST`,body:F(e)}),deleteArchived:(e,t=`local`)=>C(Ai(e,t),hi,{method:`DELETE`}),detachParent:(e,t=`local`)=>C(P(e,`detach-parent`,t),gi,{method:`POST`,body:F(e)}),reloadSession:(e,t=`local`)=>C(P(e,`reload`,t),_i,{method:`POST`,body:F(e)}),clearQueue:(e,t=`local`)=>C(P(e,`queue/clear`,t),or,{method:`POST`,body:F(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),e.projectId!==void 0&&t.set(`projectId`,e.projectId);let n=t.toString();return C(`${N(e.machineId)}/auth/providers${n===``?``:`?${n}`}`,Er)},saveApiKey:(e,t,n)=>C(Pi(`api-key`,n),si,{method:`POST`,body:JSON.stringify({providerId:e,key:t})}),logoutProvider:(e,t)=>C(Pi(`logout`,t),si,{method:`POST`,body:JSON.stringify({providerId:e})}),startOAuthLogin:(e,t)=>C(Pi(`oauth`,t),Dr,{method:`POST`,body:JSON.stringify({providerId:e})}),oauthFlow:(e,t)=>C(Pi(`oauth/${encodeURIComponent(e)}`,t),Dr),respondOAuthFlow:(e,t,n,r)=>C(Pi(`oauth/${encodeURIComponent(e)}/respond`,r),Dr,{method:`POST`,body:JSON.stringify({requestId:t,value:n})}),cancelOAuthFlow:(e,t)=>C(Pi(`oauth/${encodeURIComponent(e)}/cancel`,t),Dr,{method:`POST`})},Xi={terminals:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,A(Kr)),startTerminal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,Kr,{method:`POST`,body:JSON.stringify(n??{})}),closeWorkspaceTerminals:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,ui,{method:`DELETE`}),closeTerminal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}`,ui,{method:`DELETE`}),continueTerminal:(e,t,n,r=`local`)=>C(`${N(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/continue`,Kr,{method:`POST`}),runTerminalCommand:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,qr,{method:`POST`,body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:(e,t=`local`)=>C(`${N(t)}/terminal-command-runs${Qi(e)}`,A(qr)),getCommandRun:(e,t=`local`)=>Zi(e,t),cancelCommandRun:(e,t=`local`)=>C(`${N(t)}/terminal-command-runs/${encodeURIComponent(e)}/cancel`,qr,{method:`POST`})};async function Zi(e,t){return Pt(`${N(t)}/terminal-command-runs/${encodeURIComponent(e)}`,qr)}function Qi(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 $i(e){if(!ta(e))return;let t=e.error;return typeof t==`string`?t:void 0}async function ea(e,t,n,r){let i=await fetch(Ti(e,t,n,{machineId:r}));if(!i.ok){let e=await i.json().catch(()=>({}));throw Error($i(e)??i.statusText)}let a=await i.blob(),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o;let c=n.split(`/`).pop();s.download=c===void 0||c===``?`download`:c,document.body.append(s),s.click(),s.remove(),URL.revokeObjectURL(o)}function ta(e){return typeof e==`object`&&!!e}var na={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?C(`${N(n.machineId)}/projects/${encodeURIComponent(n.projectId)}/workspaces/${encodeURIComponent(n.workspaceId)}/files?${r.toString()}`,A(Pr)):(r.set(`cwd`,e),C(`${N(n.machineId)}/files?${r.toString()}`,A(Pr)))}},ra={gitStatus:(e,t,n=`local`)=>C(`${N(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/status`,Hr),gitDiff:(e,t,n,r=`local`)=>C(xi(r,e,t,n),Gr)},I={...Ii,...Li,...Bi,...Vi,...Hi,...Wi,...Gi,...Ki,...Ji,...Yi,...Xi,...na,...ra};function ia(e,t=`local`,n=yt()){let r=typeof e==`string`?void 0:e.cwd,i=r===void 0||r===``?``:`?${new URLSearchParams({cwd:r}).toString()}`,a=typeof e==`string`?e:e.id,o=xt(`${sa(t)}/sessions/${encodeURIComponent(a)}/events${i}`,void 0,n);return new WebSocket(Ot(o))}function aa(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(Ot(`${sa(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/socket${a}`))}function oa(e=`local`,t=yt()){let n=xt(`${sa(e)}/events`,void 0,t);return new WebSocket(Ot(n))}function sa(e){return`api/machines/${encodeURIComponent(e)}`}var ca=`.pi-web/uploads`,la=class extends Error{constructor(e=`Workspace upload cancelled`){super(e),this.name=`WorkspaceUploadCancelledError`}},ua=class extends Error{constructor(e,t){super(xa(e)),this.name=`WorkspaceUploadBatchError`,this.failures=e.map(e=>({...e})),this.responses=t.map(e=>({...e}))}};function da(e){return e?.uploads?.defaultFolder??`.pi-web/uploads`}function fa(e,t){return e?.uploads?.defaultFolder??t}function pa(e,t){let n=wa(e,`upload destination`,{allowEmpty:!0}),r=wa(t,`upload file name`,{allowEmpty:!1});return n===``?r:`${n}/${r}`}function ma(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`,Ci(e,t,n.path,_a(r)),!0),i.responseType=`json`,i.setRequestHeader(`Content-Type`,(n.contentType??n.file.type)||`application/octet-stream`),i.upload.onprogress=e=>{r.onProgress?.(va(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(Rr(Ea(i)))}catch(e){l(e instanceof Error?e:Error(String(e)))}return}l(Error(Da(i)))},i.onerror=()=>{l(Error(`Workspace upload failed`))},i.onabort=()=>{l(new la(o?void 0:`Workspace upload aborted`))},i.send(n.file)}),cancel:()=>{a||(o=!0,i.abort())}}}function ha(e,t,n,r={}){let i=r.destinationFolder??`.pi-web/uploads`,a=n.map((e,t)=>({index:t,name:e.name,path:pa(i,e.name),loaded:0,total:e.size,percent:ba(0,e.size),lengthComputable:!0,done:!1})),o,s=0,c={requested:!1},l=()=>{r.onProgress?.(ya(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 la;s=d;let f=n[d],p=a[d];if(!(f===void 0||p===void 0)){o=ma(e,t,{path:p.path,file:f},{...ga(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(Ca(e,c))throw e;let t=Sa(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 ua(u,i);return i})(),cancel:()=>{c.requested=!0,o?.cancel()}}}function ga(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 _a(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId}}}function va(e,t){let n=e.lengthComputable?e.total:t;return{loaded:e.loaded,total:n,percent:ba(e.loaded,n),lengthComputable:e.lengthComputable}}function ya(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:ba(i,r),done:n}}function ba(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}function xa(e){return e.length===1?e[0]?.error??`Workspace upload failed`:`${String(e.length)} files failed to upload`}function Sa(e){return e instanceof Error?e.message:String(e)}function Ca(e,t){return t.requested||e instanceof la}function wa(e,t,n){let r=e.trim();if(r===``){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(Ta(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 Ta(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function Ea(e){return e.response!==void 0&&e.response!==null&&e.response!==``?e.response:e.responseText===``?{}:JSON.parse(e.responseText)}function Da(e){let t=Oa(e);return ka(t)&&typeof t.error==`string`?t.error:e.statusText||`HTTP ${String(e.status)}`}function Oa(e){try{return Ea(e)}catch{return}}function ka(e){return typeof e==`object`&&!!e}function Aa(){return{sessions:[],pinnedSessionIds:[],sessionSearchQuery:``,sessionSearchResults:void 0,isSearchingSessions:!1,sessionSearchError:``,clientQueuedSessionMessages:{},startingSessionCount: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,selectedTerminalId:void 0,error:``}}function ja(){return{machines:[],selectedMachine:void 0,isLoadingMachines:!1,machineStatuses:{},machineRuntimes:{},projects:[],workspaces:[],sessions:[],pinnedSessionIds:[],sessionSearchQuery:``,sessionSearchResults:void 0,isSearchingSessions:!1,sessionSearchError:``,messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,sendingPrompts:{},clientQueuedSessionMessages:{},startingSessionCount:0,isLoadingProjects:!1,isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,status:void 0,activity:void 0,availableThinkingLevels:[],sessionStatuses:{},sessionActivities:{},workspaceActivities:{},machineActivities:{},workspacesByProjectId:{},workspaceDeletionRuns:{},commandDialog: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,activeTerminalCount:0,selectedTerminalId:void 0,piWebStatus:void 0,error:``}}function Ma(e,t){return t?.phase===`active`||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}function Na(e){return e!==void 0&&(e.hasSessionActivity||e.hasTerminalActivity)}function Pa(e,t){return`${e}:${t}`}function Fa(e,t){return`${e}:${t}`}function L(e){return e.selectedMachine?.id??`local`}var Ia=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}},La=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.refreshes=new Ia,this.api=n.api??Gi}refresh(e=L(this.getState())){return this.refreshes.request(e,async()=>{this.applyMachineActivitySnapshot(e,Ra(await this.api.workspaceActivity(e)))})}applyWorkspaceActivity(e,t=L(this.getState())){let n=this.getState(),r=L(n)===t,i=za(n.machineActivities[t]??(r?n.workspaceActivities:{}),e);this.setState({machineActivities:{...n.machineActivities,[t]:i},...r?{workspaceActivities:i}:{}})}applyMachineActivitySnapshot(e,t){let n=this.getState();this.setState({machineActivities:{...n.machineActivities,[e]:t},...L(n)===e?{workspaceActivities:t}:{}})}};function Ra(e){let t={};for(let n of e.workspaces)Na(n)&&(t[n.cwd]=n);return t}function za(e,t){let n={...e};return Na(t)?(n[t.cwd]=t,n):Object.fromEntries(Object.entries(n).filter(([e])=>e!==t.cwd))}var Ba=class{constructor(e,t,n,r){this.getState=e,this.setState=t,this.applyStatus=n,this.api=r.api??I,this.pollIntervalMs=r.pollIntervalMs??1e3,this.scope=r.scope}dispose(){this.stopPolling()}handleSlashCommand(e){let t=Va(e);return t===void 0?!1:(t.command===`login`?this.openLogin(t.providerId):this.openLogout(t.providerId),!0)}async openLogin(e){let t=this.captureTarget();if(t!==void 0){if(e!==void 0&&e!==``){await this.openLoginProvider(e,t);return}this.setState({authDialog:{step:`method`,target:t}})}}async chooseLoginMethod(e){let t=this.getState().authDialog;if(t?.step===`method`)try{let{providers:n}=await this.api.authProviders({mode:`login`,authType:e,...t.target});this.setState({authDialog:{step:`providers`,mode:`login`,authType:e,providers:n,target:t.target}})}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`?await this.startOAuth(r,n.target):this.setState({authDialog:{step:`apiKey`,provider:r,value:``,target:n.target}}))}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{let n=e.target;await this.api.saveApiKey(e.provider.id,t,n),this.closeDialog(),this.refreshStatus(n)}catch(t){this.setState({authDialog:{...e,saving:!1,error:String(t)}})}}async openLogout(e){let t=this.captureTarget();if(t!==void 0)try{let{providers:n}=await this.api.authProviders({mode:`logout`,...t});if(e!==void 0&&e!==``){let r=n.find(t=>t.id===e);r!==void 0&&!this.rejectRemoteOAuth(`logout`,r,t)?await this.logoutProviderForTarget(r.id,t):r===void 0&&this.setState({error:`No stored credentials for ${e}`});return}this.setState({authDialog:{step:`logout`,providers:n,target:t}})}catch(e){this.setState({error:String(e)})}}async logoutProvider(e){let t=this.getState().authDialog;if(t?.step!==`logout`)return;let n=t.providers.find(t=>t.id===e);n===void 0||this.rejectRemoteOAuth(`logout`,n,t.target)||await this.logoutProviderForTarget(e,t.target)}async logoutProviderForTarget(e,t){try{await this.api.logoutProvider(e,t),this.closeDialog(),this.refreshStatus(t)}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=e??t.inputValue??``,i={...t};delete i.error,this.setState({authDialog:{...i,responding:!0}});try{let e=await this.api.respondOAuthFlow(t.flow.flowId,n.requestId,r,t.target);this.updateOAuthFlow(e,t.target)}catch(e){this.setState({authDialog:{...t,responding:!1,error:String(e)}})}}async cancelOAuth(){let e=this.getState().authDialog;if(e?.step!==`oauth`){this.closeDialog();return}this.stopPolling();try{await this.api.cancelOAuthFlow(e.flow.flowId,e.target)}catch{}this.closeDialog()}closeDialog(){this.stopPolling(),this.setState({authDialog:void 0})}async openLoginProvider(e,t){try{let{providers:n}=await this.api.authProviders({mode:`login`,...t}),r=n.filter(t=>t.id===e);if(r.length===0){this.setState({error:`Auth provider not found: ${e}`});return}if(r.length>1){this.setState({authDialog:{step:`providers`,mode:`login`,providers:r,target:t}});return}let i=r[0];if(i===void 0)return;i.authType===`oauth`?await this.startOAuth(i,t):this.setState({authDialog:{step:`apiKey`,provider:i,value:``,target:t}})}catch(e){this.setState({error:String(e)})}}async startOAuth(e,t){if(!this.rejectRemoteOAuth(`login`,e,t))try{let n=await this.api.startOAuthLogin(e.id,t);this.updateOAuthFlow(n,t),this.startPolling(n.flowId)}catch(e){this.setState({error:String(e)})}}rejectRemoteOAuth(e,t,n){let r=this.getState().selectedMachine;if(t.authType!==`oauth`||n.machineKind!==`remote`)return!1;let i=r?.baseUrl??`that remote PI WEB instance`;return this.setState({error:`OAuth ${e} for remote machines must be configured directly on ${i}.`}),!0}updateOAuthFlow(e,t){if(e.status===`complete`){this.stopPolling(),this.closeDialog(),this.refreshStatus(t);return}(e.status===`error`||e.status===`cancelled`)&&this.stopPolling();let n=this.getState().authDialog,r=n?.step===`oauth`&&n.flow.flowId===e.flowId?n.inputValue??``:``,i=n?.step===`oauth`?n.flow.prompt?.requestId??n.flow.select?.requestId:void 0,a=e.prompt?.requestId??e.select?.requestId,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,inputValue:s,responding:c,target:t}})}startPolling(e){this.stopPolling(),this.pollTimer=window.setInterval(()=>{this.poll(e)},this.pollIntervalMs)}stopPolling(){this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(e){let t=this.getState().authDialog;if(t?.step!==`oauth`||t.flow.flowId!==e){this.stopPolling();return}try{this.updateOAuthFlow(await this.api.oauthFlow(e,t.target),t.target)}catch(e){this.stopPolling(),this.setState({authDialog:{...t,error:String(e)}})}}async refreshStatus(e){let t=this.session();if(t!==void 0&&this.targetStillSelected(e))try{this.applyStatus(await this.api.status(t,e.machineId))}catch{}}session(){let e=this.getState().selectedSession;if(!(e===void 0||e.archived===!0))return e}captureTarget(){let e=this.getState(),t=e.selectedMachine,n={machineId:L(e),...t?.kind===void 0?{}:{machineKind:t.kind}};if(this.scope===`management`)return n;let r=e.selectedProject;if(r===void 0){this.setState({error:`请先选择项目,再配置提供商认证。`});return}return{...n,projectId:r.id,projectName:r.name}}targetStillSelected(e){return L(this.getState())===e.machineId?e.projectId===void 0||this.getState().selectedProject?.id===e.projectId:!1}};function Va(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 Ha(e){return e.replaceAll(`:`,`.`)}function Ua(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 Wa(e,t){let n=Ua(e)[t];return Array.isArray(n)?n[0]:n===``?void 0:n}function Ga(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));Ka(i,r)}function Ka(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 qa(e){let t=e.files.map((t,n)=>{let r=t.size;return{index:n,name:t.name,path:pa(e.destinationFolder,t.name),size:t.size,loaded:0,total:r,percent:$a(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:$a(0,n),status:`uploading`,startedAt:e.startedAt}}function Ja(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 Ya(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=Qa(r);return{...e,files:r,currentFileIndex:r.length===0?-1:r.length-1,...i,status:`completed`,completedAt:n}}function Xa(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,...Qa(r),status:`error`,error:t,completedAt:n}}function Za(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,...Qa(r),status:`cancelled`,error:n,completedAt:t}}function Qa(e){let t=e.reduce((e,t)=>e+t.total,0);return{loaded:t,total:t,percent:e.length===0?0:1}}function $a(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}var eo=Ha(`core:workspace.files`),to=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??I,this.uploadWorkspaceFiles=r.uploadWorkspaceFiles??ha,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=L(this.getState()),r=await this.api.workspaceTree(e.id,t.id,``,n),i=await Promise.all(Object.keys(this.getState().expandedDirs).map(async r=>{try{return[r,(await this.api.workspaceTree(e.id,t.id,r,n)).entries]}catch(e){if(no(e))return;throw e}})),a=Object.fromEntries(i.filter(e=>e!==void 0));this.setState({fileTree:r.entries,expandedDirs:a,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:ao(this.getState().expandedDirs,e)});return}try{let r=await this.api.workspaceTree(t.id,n.id,e,L(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`}),Ga(eo,`file`,e),this.updateUrl({replace:!0}),await this.restoreFile(e)}selectDirectory(e){this.setState({selectedFilePath:e,selectedFileContent:void 0,workspaceTool:`core:workspace.files`,mainView:this.getState().mainView===`chat`?`chat`:`core:workspace.files`}),Ga(eo,`file`,void 0,{replace:!0}),this.updateUrl({replace:!0})}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,L(this.getState()));this.getState().selectedFilePath===e&&this.setState({selectedFileContent:r,error:``})}catch(t){if(this.getState().selectedFilePath!==e)return;if(no(t)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:``}),Ga(eo,`file`,void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(t)})}}}async createFile(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0||e===``))try{await this.api.createWorkspaceFile(t.id,n.id,e,L(this.getState())),await this.refreshFiles(),await this.selectFile(e),this.setState({error:``})}catch(e){this.setState({error:String(e)})}}async createDirectory(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0||e===``))try{await this.api.createWorkspaceDirectory(t.id,n.id,e,L(this.getState())),await this.refreshFiles(),this.selectDirectory(e),this.setState({error:``})}catch(e){this.setState({error:String(e)})}}async moveSelectedPath(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace,r=this.getState().selectedFilePath;if(!(t===void 0||n===void 0||r===void 0||r===``||e===``))try{let i=L(this.getState());oo(this.getState())===`directory`?(await this.api.moveWorkspaceDirectory(t.id,n.id,r,e,i),await this.refreshFiles(),this.selectDirectory(e)):(await this.api.moveWorkspaceFile(t.id,n.id,r,e,void 0,i),await this.refreshFiles(),await this.selectFile(e)),this.setState({error:``})}catch(e){this.setState({error:String(e)})}}async deleteSelectedPath(){let e=this.getState().selectedProject,t=this.getState().selectedWorkspace,n=this.getState().selectedFilePath;if(!(e===void 0||t===void 0||n===void 0||n===``))try{let r=L(this.getState());oo(this.getState())===`directory`?await this.api.deleteWorkspaceDirectory(e.id,t.id,n,r):await this.api.deleteWorkspaceFile(e.id,t.id,n,r),await this.refreshFiles(),this.clearSelection(),this.setState({error:``})}catch(e){this.setState({error:String(e)})}}async downloadSelectedFile(){let e=this.getState().selectedProject,t=this.getState().selectedWorkspace,n=this.getState().selectedFilePath;if(!(e===void 0||t===void 0||n===void 0||n===``||oo(this.getState())===`directory`))try{await this.api.downloadWorkspaceFile(e.id,t.id,n,L(this.getState())),this.setState({error:``})}catch(e){this.setState({error:String(e)})}}clearSelection(){this.setState({selectedFilePath:void 0,selectedFileContent:void 0}),Ga(eo,`file`,void 0,{replace:!0}),this.updateUrl({replace:!0})}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=L(this.getState()),a=t.overwrite??!1,o=t.createDirs??!0,s;try{s=qa({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(Za(t,this.now())),this.uploadTasks.get(e)?.cancel())}clearWorkspaceUpload(e){this.uploadTasks.get(e)?.cancel(),this.uploadTasks.delete(e),this.setState({workspaceUploadBatches:ao(this.getState().workspaceUploadBatches,e)})}updateUploadProgress(e,t){let n=this.getUploadBatch(e);n?.status===`uploading`&&this.setUploadBatch(Ja(n,t))}async completeUploadBatch(e,t,n){let r=this.getUploadBatch(e);if(r?.status!==`uploading`||(this.setUploadBatch(Ya(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 ua)||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(ro(t)){let e=Za(n,this.now());return this.setUploadBatch(e),e}let r=io(t),i=Xa(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&&L(t)===e.machineId}};function no(e){let t=String(e);return t.includes(`Path does not exist`)||t.includes(`ENOENT`)||t.includes(`no such file or directory`)}function ro(e){return e instanceof la}function io(e){return e instanceof Error?e.message:String(e)}function ao(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function oo(e){let t=e.selectedFilePath;return t===void 0?`file`:so(e.fileTree,e.expandedDirs,t)?.type===`directory`?`directory`:`file`}function so(e,t,n){let r=e.find(e=>e.path===n);if(r!==void 0)return r;for(let e of Object.values(t)){let t=e.find(e=>e.path===n);if(t!==void 0)return t}}var co=Ha(`core:workspace.git`),lo=class{constructor(e,t,n){this.getState=e,this.setState=t,this.updateUrl=n}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0}async refreshGit(){let e=this.getState().selectedProject,t=this.getState().selectedWorkspace;if(!(e===void 0||t===void 0))try{let n=await I.gitStatus(e.id,t.id,L(this.getState()));this.setState({gitStatus:n,gitStale:!1,error:``});let r=this.getState().selectedDiffPath;r!==void 0&&(n.files.some(e=>e.path===r)?await this.refreshDiff(r):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),Ga(co,`diff`,void 0,{replace:!0})))}catch(e){this.setState({error:String(e)})}}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`}),Ga(co,`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){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0))try{let[r,i]=await Promise.all([I.gitDiff(t.id,n.id,{path:e},L(this.getState())),I.gitDiff(t.id,n.id,{path:e,staged:!0},L(this.getState()))]);this.setState({selectedDiff:r,selectedStagedDiff:i,error:``})}catch(e){this.setState({error:String(e)})}}updatePolling(){this.dispose();let e=this.getState();(e.workspaceTool===`core:workspace.git`||e.mainView===`core:workspace.git`)&&(this.pollTimer=window.setInterval(()=>{this.refreshGit()},8e3))}},uo=class{constructor(e,t,n,r){this.getState=e,this.setState=t,this.updateUrl=n,this.projects=r}async loadMachines(e){this.setState({error:``,isLoadingMachines:!0});try{let t=await I.machines(),n=await this.selectInitialMachine(t,e),r=new Set(t.map(e=>e.id));this.setState({machines:t,selectedMachine:n,machineActivities:po(this.getState().machineActivities,r),machineRuntimes:po(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,...Aa()}),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 I.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 I.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:fo(this.getState().machineStatuses,e.id),machineRuntimes:fo(this.getState().machineRuntimes,e.id),machineActivities:fo(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 I.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`){try{let t=await I.runtime(e,!0);this.setState({machineRuntimes:{...this.getState().machineRuntimes,[t.machineId]:t}})}catch(e){this.setState({error:String(e)})}}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 I.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=>I.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=>I.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 fo(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function po(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)))}var mo=class{constructor(e,t,n){this.getState=e,this.setState=t,this.workspaces=n}async loadProjects(){let e=L(this.getState());this.setState({error:``,isLoadingProjects:!0});try{let t=await I.projects(e);if(L(this.getState())!==e)return;let n=new Set(t.map(e=>e.id)),r=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([e])=>n.has(e)));this.setState({projects:t,workspacesByProjectId:r})}catch(t){L(this.getState())===e&&this.setState({error:String(t)})}finally{L(this.getState())===e&&this.setState({isLoadingProjects:!1})}}async addProject(e,t){if(e.trim()!==``)try{let n=await I.addProject(e.trim(),void 0,t,L(this.getState())),r=this.getState().projects;this.setState({projects:[...r.filter(e=>e.id!==n.id),n],projectDialogOpen:!1}),await this.workspaces.selectProject(n)}catch(e){this.setState({error:String(e)})}}async closeProject(e){try{await I.closeProject(e,L(this.getState())),this.workspaces.forgetProject(e);let t=this.getState();this.setState({projects:t.projects.filter(t=>t.id!==e)}),t.selectedProject?.id===e&&this.workspaces.clearSelection()}catch(e){this.setState({error:String(e)})}}},ho=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.requestSequence=0,this.api=n.api??Ii,this.onRefreshError=n.onRefreshError??(()=>void 0)}async refresh(){let e=L(this.getState());if(this.pendingUpdateCheck?.machineId===e)return;let t=++this.requestSequence;try{let n=await this.api.piWebStatus(e);this.isCurrent(e,t)&&this.setState({piWebStatus:n})}catch(n){if(!this.isCurrent(e,t))return;this.setState({piWebStatus:void 0}),this.onRefreshError(e,n)}}checkForUpdates(){let e=L(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({piWebStatus:t}),go(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 L(this.getState())===e&&t===this.requestSequence}};function go(e){if(e.release.error!==void 0)throw Error(`PI WEB update check failed: ${e.release.error}`);if(e.release.skipped===!0)throw Error(`PI WEB update check was skipped because remote version checks are disabled by offline/version-check settings`)}var _o=`pi-web:cached-new-sessions:v1`,vo=`browserCachedNew`,yo=`local`;function bo(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function xo(e,t=yo,n=bo()){if(e.messageCount!==0||e.archived===!0)return;let r=Do(n).filter(n=>n.id!==e.id||n.machineId!==t);Oo([So(e,t),...r],n)}function So(e,t=yo){return{...e,browserCachedNew:!0,machineId:t}}function Co(e,t=yo,n=bo()){Oo(Do(n).filter(n=>n.id!==e||n.machineId!==t),n)}function wo(e,t,n=yo,r=bo()){let i=new Set(t.map(e=>e.id)),a=Do(r),o=a.filter(e=>e.machineId!==n||!i.has(e.id));return o.length!==a.length&&Oo(o,r),[...o.filter(t=>t.machineId===n&&t.cwd===e),...t]}function To(e){return e!==void 0&&Ao(e)&&e.browserCachedNew===!0}function Eo(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:yo},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt}}}function Do(e=bo()){try{let t=e?.getItem(_o);if(t==null||t===``)return[];let n=JSON.parse(t);return Array.isArray(n)?n.flatMap(e=>ko(e)):[]}catch{return[]}}function Oo(e,t=bo()){try{e.length===0?t?.removeItem(_o):t?.setItem(_o,JSON.stringify(e))}catch{}}function ko(e){if(!jo(e))return[];let t=Mo(e,`id`),n=Mo(e,`path`),r=Mo(e,`cwd`),i=Mo(e,`created`),a=Mo(e,`modified`),o=Mo(e,`firstMessage`),s=Po(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=No(e,`name`),l=No(e,`parentSessionPath`),u=No(e,`machineId`)??yo;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},machineId:u,browserCachedNew:!0}]}function Ao(e){return vo in e}function jo(e){return typeof e==`object`&&!!e}function Mo(e,t){let n=e[t];return typeof n==`string`?n:void 0}function No(e,t){let n=e[t];return n===void 0||typeof n!=`string`?void 0:n}function Po(e,t){let n=e[t];return typeof n==`number`?n:void 0}function Fo(e){return es(e.flatMap(Bo)).filter(e=>e.parts.length>0)}function Io(e,t){return{role:e,parts:[{type:`text`,text:t}]}}function Lo(e,t){let n=Ko(t);return n===void 0?e:{...e,meta:n}}function Ro(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,Io(t,n)]}function zo(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 Bo(e){if(Ho(e))return[e];if(R(e,`role`)===`bashExecution`)return[Lo(Yo(e),e)];let t=Xo(R(e,`role`)),n=Zo(cs(e,`content`),e),r=t===`user`?Uo(n):void 0;if(r!==void 0)return r.map(t=>Lo(t,e));let i=Go(e);if(t===`tool`)return[Lo({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?[Lo({role:o,parts:a,...i===void 0?{}:{source:i}},e)]:[],c=Vo(e);return c===void 0?s:[...s,Lo(c,e)]}function Vo(e){if(R(e,`role`)!==`assistant`||R(e,`stopReason`)!==`error`)return;let t=R(e,`errorMessage`)?.trim();return Io(`system`,`Model response failed: ${t===void 0||t===``?`The model returned an error.`:t}`)}function Ho(e){let t=R(e,`role`);return(t===`user`||t===`assistant`||t===`tool`||t===`system`||t===`bash`||t===`skill`)&&Array.isArray(cs(e,`parts`))}function Uo(e){if(e.length!==1||e[0]?.type!==`text`)return;let t=Wo(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 Wo(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 Go(e){let t=R(e,`source`);if(t===`compaction`||t===`branch_summary`)return t}function Ko(e){let t=qo(cs(e,`timestamp`)),n=Jo(e);if(!(t===void 0&&n===void 0))return{...t===void 0?{}:{timestamp:t},...n===void 0?{}:{model:n}}}function qo(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 Jo(e){if(R(e,`role`)!==`assistant`)return;let t=R(e,`provider`),n=R(e,`model`),r=R(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 Yo(e){let t=R(e,`command`)??``,n=ls(e,`excludeFromContext`)===!0?[`excluded from context`,``,`$ ${t}`]:[`$ ${t}`],r=cs(e,`output`);r!=null&&n.push(``,ds(r));let i=cs(e,`exitCode`);i!=null&&n.push(``,`exit ${ds(i)}`),ls(e,`cancelled`)===!0&&n.push(``,`cancelled`),ls(e,`truncated`)===!0&&n.push(``,`output truncated`);let a=R(e,`fullOutputPath`);return a!==void 0&&a!==``&&n.push(``,`full output: ${a}`),{role:`bash`,parts:[{type:`text`,text:n.join(`
|
|
4
4
|
`)}]}}function Xo(e){return e===`assistant`?`assistant`:e===`user`?`user`:e===`toolResult`?`tool`:`system`}function Zo(e,t){return typeof e==`string`?e===``?[]:[{type:`text`,text:e}]:Array.isArray(e)?e.flatMap(e=>{let t=R(e,`type`),n=R(e,`text`);if(t===`text`)return n!==void 0&&n!==``?[{type:`text`,text:n}]:[];if(t===`thinking`){let t=R(e,`thinking`)??n;return t!==void 0&&t!==``?[{type:`thinking`,text:t}]:[]}if(t===`toolCall`){let t=R(e,`name`)??`tool`,n=cs(e,`arguments`),r=R(e,`id`),i=t===`read`?$o(R(n,`path`)):void 0;return i===void 0?[{type:`toolCall`,...r===void 0?{}:{toolCallId:r},toolName:t,summary:as(n),...n===void 0?{}:{args:n}}]:[{type:`skillRead`,...i,...r===void 0?{}:{toolCallId:r}}]}if(t===`image`){let t=R(e,`data`),n=R(e,`mimeType`);return t!==void 0&&t!==``&&n!==void 0&&n!==``?[{type:`image`,mimeType:n,data:t}]:[{type:`text`,text:`[image]`}]}return is(e)}).map(e=>e.type===`text`&&R(t,`role`)===`toolResult`?Qo(e.text,t):e):is(e)}function Qo(e,t){let n=R(t,`toolCallId`),r=cs(t,`content`),i=cs(t,`details`);return{type:`toolResult`,...n===void 0?{}:{toolCallId:n},toolName:R(t,`toolName`)??`tool`,text:e,...r===void 0?{}:{content:r},...i===void 0?{}:{details:i},isError:ls(t,`isError`)===!0}}function $o(e){if(e===void 0||e===``)return;let t=e.replace(/\\/g,`/`);if(!t.endsWith(`/SKILL.md`)&&t!==`SKILL.md`)return;let n=t.split(`/`).at(-2);if(!(n===void 0||n===``))return{name:n,path:e}}function es(e){let t=[],n=new Map;for(let r of e){let e=[],i={...r.source===void 0?{}:{source:r.source},...r.meta===void 0?{}:{meta:r.meta}},a=()=>{e.length!==0&&(t.push({role:r.role,parts:e,...i}),e=[])};for(let o of r.parts){if(o.type===`toolCall`){a();let e=ts(o),r=t.length;t.push({role:`tool`,parts:[e],...i}),e.toolCallId!==void 0&&n.set(e.toolCallId,{lineIndex:r,partIndex:0});continue}if(o.type===`toolResult`){let e=o.toolCallId===void 0?void 0:n.get(o.toolCallId);if(e!==void 0&&ns(t,e,o)){n.delete(o.toolCallId??``);continue}}e.push(o)}a()}return t}function ts(e){return{type:`toolExecution`,...e.toolCallId===void 0?{}:{toolCallId:e.toolCallId},toolName:e.toolName,summary:e.summary,...e.args===void 0?{}:{args:e.args},status:`pending`}}function ns(e,t,n){let r=e[t.lineIndex],i=r?.parts[t.partIndex];if(r===void 0||i?.type!==`toolExecution`)return!1;let a=rs(n.details)??i.preview,o={...i,status:n.isError?`error`:`success`,resultText:n.text,...n.content===void 0?{}:{content:n.content},...n.details===void 0?{}:{details:n.details},...a===void 0?{}:{preview:a}};return e[t.lineIndex]={...r,parts:[...r.parts.slice(0,t.partIndex),o,...r.parts.slice(t.partIndex+1)]},!0}function rs(e){let t=cs(e,`preview`);if(!ss(t))return;let n=R(t,`diff`),r=R(t,`error`),i=us(t,`firstChangedLine`);if(!(n===void 0&&r===void 0&&i===void 0))return{...n===void 0?{}:{diff:n},...r===void 0?{}:{error:r},...i===void 0?{}:{firstChangedLine:i}}}function is(e){return e==null?[]:typeof e==`object`?[{type:`text`,text:as(e)}]:[{type:`text`,text:ds(e)}]}function as(e){if(!ss(e))return ds(e);let t=R(e,`command`);if(t!==void 0)return t;let n=R(e,`path`);if(n!==void 0)return n;if(typeof e.oldText==`string`&&typeof e.newText==`string`)return`edit text replacement`;let r=e.edits;return Array.isArray(r)?`${String(r.length)} edit${r.length===1?``:`s`}`:Object.entries(e).filter(([,e])=>e!=null).slice(0,3).map(([e,t])=>`${e}: ${os(t)}`).join(` · `)}function os(e){return typeof e==`string`?e.length>80?`${e.slice(0,77)}…`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`${String(e.length)} item${e.length===1?``:`s`}`:typeof e==`object`&&e?`object`:``}function ss(e){return typeof e==`object`&&!!e}function cs(e,t){return ss(e)?e[t]:void 0}function R(e,t){let n=cs(e,t);return typeof n==`string`?n:void 0}function ls(e,t){let n=cs(e,t);return typeof n==`boolean`?n:void 0}function us(e,t){let n=cs(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function ds(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):``}var fs=`pi-web:prompt-draft:`;function ps(e){return`${fs}${e}`}function ms(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function hs(e,t=ms()){try{return t?.getItem(ps(e))??``}catch{return``}}function gs(e,t,n=ms()){try{t?n?.setItem(ps(e),t):n?.removeItem(ps(e))}catch{}}function _s(e,t=ms()){try{t?.removeItem(ps(e))}catch{}}function vs(e,t,n=ms()){let r=hs(e,n);r!==``&&(gs(t,r,n),_s(e,n))}function ys(e,t){return Io(`bash`,`${t===!0?`不加入上下文
|
|
@@ -335,7 +335,7 @@ import{$ as e,A as t,J as n,P as r,Q as i,S as a,X as o,Z as s,d as c,f as l,j a
|
|
|
335
335
|
.review-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
336
336
|
.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; }
|
|
337
337
|
footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
|
|
338
|
-
`]}};z([b({attribute:!1})],Dd.prototype,`context`,void 0),z([S(`#workspace-upload-input`)],Dd.prototype,`uploadInput`,void 0),z([x()],Dd.prototype,`pendingUpload`,void 0),z([x()],Dd.prototype,`destinationFolder`,void 0),z([x()],Dd.prototype,`overwrite`,void 0),z([x()],Dd.prototype,`createDirs`,void 0),z([x()],Dd.prototype,`formError`,void 0),z([x()],Dd.prototype,`dragActive`,void 0),Dd=z([y(`workspace-files-panel`)],Dd);function Od(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 kd(e,t){if(e.length===0)return`请至少选择一个要上传的文件。`;for(let n of e)try{pa(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function Ad(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function jd(e,t,n){if(n!==void 0)return Ld(e,t,n)?.type}function Md(e,t){return e!==void 0&&e!==``&&t===`file`}function Nd(e,t,n){if(e===void 0||e===``)return n;if(t===`directory`)return zd(e,n);let r=Rd(e);return r===``?n:zd(r,n)}function Pd(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function Fd(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function Id(e,t){let n=window.prompt(e,t);if(n===null)return;let r=n.trim();return r===``?void 0:r}function Ld(e,t,n){let r=e.find(e=>e.path===n);if(r!==void 0)return r;for(let e of Object.values(t)){let t=e.find(e=>e.path===n);if(t!==void 0)return t}}function Rd(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function zd(e,t){return e===``?t:`${e.replace(/\/+$/u,``)}/${t.replace(/^\/+/u,``)}`}function Bd(e){return e==null?[]:Array.from(e)}function Vd(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function Hd(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} 个最近`:`${String(t)} 个上传中`}function Ud(e){let t=String(e.files.length);switch(e.status){case`completed`:return`已上传 ${t} 个文件`;case`error`:return`${t} 个文件上传失败`;case`cancelled`:return`已取消 ${t} 个文件的上传`;case`uploading`:return`正在上传 ${t} 个文件`}}function Wd(e){switch(e.status){case`completed`:return`完成`;case`error`:return`失败`;case`cancelled`:return`已取消`;case`uploading`:return Jd(e.percent)}}function Gd(e){return e.status===`uploading`?e.percent:1}function Kd(e){switch(e.status){case`pending`:return`待处理`;case`uploading`:return Jd(e.percent);case`completed`:return`完成`;case`error`:return`错误`;case`cancelled`:return`已取消`}}function qd(e){return e.error===void 0?e.response===void 0?`${e.path} · ${Xd(e.loaded)} / ${Xd(e.total)}`:`已写入 ${e.response.path}`:e.error}function Jd(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function Yd(){Ed(()=>import(`./CodeViewer-
|
|
338
|
+
`]}};z([b({attribute:!1})],Dd.prototype,`context`,void 0),z([S(`#workspace-upload-input`)],Dd.prototype,`uploadInput`,void 0),z([x()],Dd.prototype,`pendingUpload`,void 0),z([x()],Dd.prototype,`destinationFolder`,void 0),z([x()],Dd.prototype,`overwrite`,void 0),z([x()],Dd.prototype,`createDirs`,void 0),z([x()],Dd.prototype,`formError`,void 0),z([x()],Dd.prototype,`dragActive`,void 0),Dd=z([y(`workspace-files-panel`)],Dd);function Od(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 kd(e,t){if(e.length===0)return`请至少选择一个要上传的文件。`;for(let n of e)try{pa(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function Ad(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function jd(e,t,n){if(n!==void 0)return Ld(e,t,n)?.type}function Md(e,t){return e!==void 0&&e!==``&&t===`file`}function Nd(e,t,n){if(e===void 0||e===``)return n;if(t===`directory`)return zd(e,n);let r=Rd(e);return r===``?n:zd(r,n)}function Pd(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function Fd(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function Id(e,t){let n=window.prompt(e,t);if(n===null)return;let r=n.trim();return r===``?void 0:r}function Ld(e,t,n){let r=e.find(e=>e.path===n);if(r!==void 0)return r;for(let e of Object.values(t)){let t=e.find(e=>e.path===n);if(t!==void 0)return t}}function Rd(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function zd(e,t){return e===``?t:`${e.replace(/\/+$/u,``)}/${t.replace(/^\/+/u,``)}`}function Bd(e){return e==null?[]:Array.from(e)}function Vd(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function Hd(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} 个最近`:`${String(t)} 个上传中`}function Ud(e){let t=String(e.files.length);switch(e.status){case`completed`:return`已上传 ${t} 个文件`;case`error`:return`${t} 个文件上传失败`;case`cancelled`:return`已取消 ${t} 个文件的上传`;case`uploading`:return`正在上传 ${t} 个文件`}}function Wd(e){switch(e.status){case`completed`:return`完成`;case`error`:return`失败`;case`cancelled`:return`已取消`;case`uploading`:return Jd(e.percent)}}function Gd(e){return e.status===`uploading`?e.percent:1}function Kd(e){switch(e.status){case`pending`:return`待处理`;case`uploading`:return Jd(e.percent);case`completed`:return`完成`;case`error`:return`错误`;case`cancelled`:return`已取消`}}function qd(e){return e.error===void 0?e.response===void 0?`${e.path} · ${Xd(e.loaded)} / ${Xd(e.total)}`:`已写入 ${e.response.path}`:e.error}function Jd(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function Yd(){Ed(()=>import(`./CodeViewer-5vQNxhKQ.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)}function Xd(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`${Zd(t)} KB`;let n=t/1024;return n<1024?`${Zd(n)} MB`:`${Zd(n/1024)} GB`}function Zd(e){return e>=10?String(Math.round(e)):e.toFixed(1)}function Qd(){return[{id:`workspace.files`,title:`文件`,icon:yd(`files`),order:10,render:$d},{id:`workspace.git`,title:`Git`,icon:yd(`git`),order:20,visible:({workspace:e})=>e.isGitRepo,render:tf},{id:`workspace.terminal`,title:`终端`,icon:yd(`terminal`),order:30,badge:e=>e.activeTerminalCount>0?e.activeTerminalCount:void 0,render:ef}]}function $d(e){return g`<workspace-files-panel .context=${e}></workspace-files-panel>`}function ef(e){return of(),g`<terminal-panel .workspace=${e.workspace} .machineId=${e.machine.id} .selectedTerminalId=${e.selectedTerminalId} .autoStart=${e.terminalAutoStart} .onSelectTerminal=${e.onSelectTerminal}></terminal-panel>`}function tf(e){let t=e.gitStatus;return g`
|
|
339
339
|
<section class="toolbar">
|
|
340
340
|
<strong>Git</strong>
|
|
341
341
|
${e.gitStale?g`<span class="stale">过期</span>`:null}
|
|
@@ -366,7 +366,7 @@ import{$ as e,A as t,J as n,P as r,Q as i,S as a,X as o,Z as s,d as c,f as l,j a
|
|
|
366
366
|
<div class="viewer-header"><strong>${e.path??`diff`}</strong><small>${e.staged?`已暂存`:`未暂存`}${e.truncated?` · 已截断`:``}</small></div>
|
|
367
367
|
<unified-diff-viewer .diff=${e.diff}></unified-diff-viewer>
|
|
368
368
|
</section>
|
|
369
|
-
`}function af(){Ed(()=>import(`./UnifiedDiffViewer-zWHee3_J.js`),[],import.meta.url)}function of(){Ed(()=>import(`./TerminalPanel-DZ2ed4NZ.js`),__vite__mapDeps([4,5,6]),import.meta.url)}function sf(e){let t=e.branch??`分离 HEAD`,n=e.ahead??0,r=e.behind??0;return n===0&&r===0?t:`${t} · ↑${String(n)} ↓${String(r)}`}function cf(e,t){return(t===`unmodified`?e:t).slice(0,1).toUpperCase()}var lf={apiVersion:1,name:`PI WEB 核心`,activate:()=>{let e=!vt();return{contributions:{actions:e?cd():cd().filter(e=>e.id!==`view.terminal`),workspacePanels:e?Qd():Qd().filter(e=>e.id!==`workspace.terminal`)}}}},uf={"--pi-bg":`#0d1117`,"--pi-surface":`#161b22`,"--pi-surface-hover":`#21262d`,"--pi-terminal-bg":`#05070a`,"--pi-terminal-text":`#e6edf3`,"--pi-border":`#30363d`,"--pi-border-muted":`#21262d`,"--pi-text":`#e6edf3`,"--pi-text-secondary":`#c9d1d9`,"--pi-text-bright":`#f0f6fc`,"--pi-muted":`#8b949e`,"--pi-dim":`#6e7681`,"--pi-accent":`#58a6ff`,"--pi-accent-border":`#2f81f7`,"--pi-selection-bg":`#0d2847`,"--pi-success":`#3fb950`,"--pi-success-border":`#238636`,"--pi-success-bg":`#0f1b12`,"--pi-success-surface":`#0f2a16`,"--pi-success-ring":`#3fb95055`,"--pi-warning":`#d29922`,"--pi-warning-border":`#6e5200`,"--pi-warning-surface":`#1f1a10`,"--pi-danger":`#ff7b72`,"--pi-purple":`#d2a8ff`,"--pi-purple-border":`#a371f7`,"--pi-purple-surface":`#21132f`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#0d1117dd`,"--pi-bg-overlay":`#0d1117e6`,"--pi-success-bg-overlay":`#0f1b12ee`,"--pi-terminal-selection":`#264f78`},df={"--pi-bg":`#070912`,"--pi-surface":`#101527`,"--pi-surface-hover":`#151b31`,"--pi-terminal-bg":`#050710`,"--pi-terminal-text":`#f7f4ff`,"--pi-border":`#26304f`,"--pi-border-muted":`#26304f`,"--pi-text":`#f7f4ff`,"--pi-text-secondary":`#aaa4bd`,"--pi-text-bright":`#ffffff`,"--pi-muted":`#aaa4bd`,"--pi-dim":`#817a99`,"--pi-accent":`#7c3cff`,"--pi-accent-border":`#5a47b0`,"--pi-selection-bg":`#1d2547`,"--pi-success":`#00f0d8`,"--pi-success-border":`#00f0d8`,"--pi-success-bg":`#071e22`,"--pi-success-surface":`#092d31`,"--pi-success-ring":`#00f0d855`,"--pi-warning":`#ffb000`,"--pi-warning-border":`#ffb000`,"--pi-warning-surface":`#16140d`,"--pi-danger":`#ff4f7b`,"--pi-purple":`#b7a2ff`,"--pi-purple-border":`#7c3cff`,"--pi-purple-surface":`#181026`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#070912dd`,"--pi-bg-overlay":`#070912e6`,"--pi-success-bg-overlay":`#071e22ee`,"--pi-terminal-selection":`#3d4a78`},ff={"--pi-bg":`#f7f1e6`,"--pi-surface":`#fff9ee`,"--pi-surface-hover":`#f0e6d6`,"--pi-terminal-bg":`#15131b`,"--pi-terminal-text":`#fff9ee`,"--pi-border":`#c9bca8`,"--pi-border-muted":`#d8cdbc`,"--pi-text":`#15131b`,"--pi-text-secondary":`#15131b`,"--pi-text-bright":`#15131b`,"--pi-muted":`#5f586a`,"--pi-dim":`#766f7e`,"--pi-accent":`#6430d8`,"--pi-accent-border":`#6430d8`,"--pi-selection-bg":`#eadff8`,"--pi-success":`#008c82`,"--pi-success-border":`#008c82`,"--pi-success-bg":`#e1f4ef`,"--pi-success-surface":`#d7f0ec`,"--pi-success-ring":`#008c8255`,"--pi-warning":`#b05f00`,"--pi-warning-border":`#b05f00`,"--pi-warning-surface":`#fff2d2`,"--pi-danger":`#b51d49`,"--pi-purple":`#6430d8`,"--pi-purple-border":`#6430d8`,"--pi-purple-surface":`#eadff8`,"--pi-overlay":`#15131b66`,"--pi-shadow-soft":`#15131b22`,"--pi-shadow":`#15131b33`,"--pi-shadow-strong":`#15131b44`,"--pi-bg-overlay-soft":`#f7f1e6dd`,"--pi-bg-overlay":`#f7f1e6e6`,"--pi-success-bg-overlay":`#e1f4efee`,"--pi-terminal-selection":`#8d7b64`},pf={apiVersion:1,name:`PI WEB 主题`,activate:()=>({contributions:{themes:[{id:`pi-web-dark`,name:`PI WEB 深色`,description:`PI WEB 深色配色。`,order:10,colorScheme:`dark`,tokens:df},{id:`pi-web-light`,name:`PI WEB 浅色`,description:`PI WEB 浅色配色。`,order:20,colorScheme:`light`,tokens:ff},{id:`classic`,name:`PI WEB 经典`,description:`原始 PI WEB 深色配色。`,order:30,colorScheme:`dark`,tokens:uf}],themePairs:[{id:`pi-web`,name:`PI WEB`,description:`跟随系统浅色/深色偏好使用 PI WEB 主题。`,order:10,light:`pi-web-light`,dark:`pi-web-dark`}]}})},mf=/^[a-z][a-z0-9.-]*$/u;function hf(e){return mf.test(e)}var gf=`machine.`;function _f(e,t){if(e===``)throw Error(`Machine id is required`);if(!hf(t))throw Error(`Invalid PI WEB plugin id: ${t}`);return`${gf}${vf(e)}.${t}`}function vf(e){return[...new TextEncoder().encode(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function yf(e=`pi-web-plugins/manifest.json`,t={}){let n=Dt(e),r=await Sf(n);if(r===void 0)return[];let i=[];for(let e of r.plugins)if(t.shouldLoadPlugin?.(e)!==!1)try{let r=bf(e.module,n),a=Tf(await(t.moduleLoader??xf)(r),r);i.push({id:t.machineId===void 0?e.id:_f(t.machineId,e.id),plugin:a,machineSpecific:e.machineSpecific,...t.machineId===void 0?{}:{machineId:t.machineId,sourcePluginId:e.id}})}catch(t){console.warn(`Failed to load PI WEB plugin ${e.module}`,t)}return i}function bf(e,t,n){return e.startsWith(`/`)?n===void 0?Dt(e):Dt(e,n):new URL(e,t).toString()}async function xf(e){return Ed(()=>import(e),[],import.meta.url)}async function Sf(e){let t=await fetch(e,{cache:`no-store`});if(t.status!==404){if(!t.ok)throw Error(`Failed to load plugin manifest: ${t.statusText}`);return Cf(await t.json())}}function Cf(e){if(!Df(e)||!Array.isArray(e.plugins))throw Error(`Invalid plugin manifest`);return{plugins:e.plugins.map(e=>{if(!Df(e)||typeof e.id!=`string`||e.id===``||typeof e.module!=`string`||e.module===``)throw Error(`Invalid plugin manifest entry`);return{id:e.id,module:e.module,machineSpecific:wf(e.machineSpecific)}})}}function wf(e){if(e===void 0)return!1;if(typeof e!=`boolean`)throw Error(`Invalid plugin manifest entry`);return e}function Tf(e,t){if(!Df(e))throw Error(`Plugin module ${t} did not export an object`);let n=e.default;if(!Ef(n))throw Error(`Plugin module ${t} default export is not a PiWebPlugin`);return n}function Ef(e){return Df(e)&&e.apiVersion===1&&typeof e.name==`string`&&typeof e.activate==`function`}function Df(e){return typeof e==`object`&&!!e}var Of=/^[a-z][a-z0-9.-]*$/u,kf=/^[a-z][a-z0-9.-]*$/u,Af=new WeakMap,jf=new WeakMap,Mf=class{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabels=[],this.themes=[],this.themePairs=[],this.pluginIds=new Set,this.gatewayPluginIds=new Set,this.gatewayMachineSpecificPluginIds=new Set,this.remoteMachineSpecificPluginIds=new Map,this.contributionIds=new Set}register(e){let{id:t,plugin:n}=e;this.validatePluginId(t);let r=this.parseMachineSpecific(t,e.machineSpecific);if(this.pluginIds.has(t))throw Error(`Duplicate plugin id: ${t}`);if(this.isRemoteDuplicateHiddenByGateway(e.sourcePluginId,e.machineId,r))return;this.pluginIds.add(t);let i=n.apiVersion;if(i!==1)throw Error(`Unsupported plugin API version for ${t}: ${String(i)}`);let a=n.activate({apiVersion:1,pluginId:t,html:g,svg:Je}).contributions;for(let n of a.actions??[])this.actions.push(this.qualifyAction(t,n,e.machineId,e.sourcePluginId));for(let n of a.workspacePanels??[])this.workspacePanels.push(this.qualifyWorkspacePanel(t,n,e.machineId,e.sourcePluginId));for(let n of a.workspaceLabels??[])this.workspaceLabels.push(this.qualifyWorkspaceLabelContribution(t,n,e.machineId,e.sourcePluginId));if(e.machineId===void 0){for(let e of a.themes??[])this.themes.push(this.qualifyTheme(t,e));for(let e of a.themePairs??[])this.themePairs.push(this.qualifyThemePair(t,e));this.gatewayPluginIds.add(t),r&&this.gatewayMachineSpecificPluginIds.add(t)}else e.sourcePluginId!==void 0&&r&&Lf(this.remoteMachineSpecificPluginIds,e.sourcePluginId,e.machineId)}shouldLoadRemotePlugin(e,t=!1){return!this.gatewayPluginIds.has(e)||this.gatewayMachineSpecificPluginIds.has(e)||t}getActions(e){let t=zf(e);return this.actions.filter(e=>this.isContributionActive(e.pluginId,e.machineId,t,e.sourcePluginId)).map(t=>{let n=Nf(e,t.pluginId),r=t.enabled?.(n),i=r===!1?t.disabledReason?.(n):void 0,a={id:t.id,pluginId:t.pluginId,localId:t.localId,...t.machineId===void 0?{}:{machineId:t.machineId},title:t.title,run:()=>t.run(n)};return t.description!==void 0&&(a.description=t.description),t.shortcut!==void 0&&(a.shortcut=t.shortcut),t.group!==void 0&&(a.group=t.group),r!==void 0&&(a.enabled=r),i!==void 0&&i!==``&&(a.disabledReason=i),a})}getWorkspacePanels(){return[...this.workspacePanels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.title.localeCompare(t.title))}getThemes(){return[...this.themes].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getThemePairs(){return[...this.themePairs].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getWorkspaceLabelItems(e){return[...this.workspaceLabels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.id.localeCompare(t.id)).flatMap(t=>t.visible?.(e)===!1?[]:t.items(e))}qualifyAction(e,t,n,r){let i=this.qualify(e,t.id);return{...t,id:i,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},...r===void 0?{}:{sourcePluginId:r}}}qualifyWorkspacePanel(e,t,n,r){let i=this.qualify(e,t.id),a=t.badge,o=t.visible;return{...t,id:i,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(o?.(Pf(t,e))??!0),...a===void 0?{}:{badge:t=>this.isContributionActive(e,n,t.machine.id,r)?a(Pf(t,e)):void 0},render:n=>t.render(Pf(n,e))}}qualifyWorkspaceLabelContribution(e,t,n,r){let i=this.qualify(e,t.id),a=t.visible,o=t.items;return{...t,id:i,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(a?.(t)??!0),items:t=>this.isContributionActive(e,n,t.machine.id,r)?o(t):[]}}qualifyTheme(e,t){let n=this.qualify(e,t.id);return{...t,id:n,pluginId:e,localId:t.id}}qualifyThemePair(e,t){let n=this.qualify(e,t.id);return{...t,id:n,pluginId:e,localId:t.id,light:this.qualifyReference(e,t.light),dark:this.qualifyReference(e,t.dark)}}qualify(e,t){this.validateLocalId(t);let n=`${e}:${t}`;if(this.contributionIds.has(n))throw Error(`Duplicate contribution id: ${n}`);return this.contributionIds.add(n),n}qualifyReference(e,t){return this.validateLocalId(t),`${e}:${t}`}isContributionActive(e,t,n,r){return t===void 0?!this.isGatewayPluginHiddenForMachine(e,n):t===n&&!this.isRemotePluginHiddenByGateway(r,t)}isRemoteDuplicateHiddenByGateway(e,t,n){return e!==void 0&&t!==void 0&&this.gatewayPluginIds.has(e)&&!this.gatewayMachineSpecificPluginIds.has(e)&&!n}isRemotePluginHiddenByGateway(e,t){return e===void 0||this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0?!1:this.gatewayPluginIds.has(e)}isGatewayPluginHiddenForMachine(e,t){return t!==`local`&&(this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0)}validatePluginId(e){if(!Of.test(e))throw Error(`Invalid plugin id: ${e}`)}validateLocalId(e){if(!kf.test(e))throw Error(`Invalid contribution id: ${e}`)}parseMachineSpecific(e,t){if(t===void 0)return!1;if(typeof t!=`boolean`)throw Error(`Invalid plugin machineSpecific value for ${e}: ${Rf(t)}`);return t}};function Nf(e,t){return Af.get(e)?.(t)??e}function Pf(e,t){return jf.get(e)?.(t)??e}function Ff(e,t){return Af.set(e,t),e}function If(e,t){return jf.set(e,t),e}function Lf(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function Rf(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`||typeof e==`function`||e==null)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function zf(e){return e.state.selectedMachine?.id??`local`}var Bf=[`(display-mode: standalone)`,`(display-mode: fullscreen)`,`(display-mode: minimal-ui)`];function Vf(){return typeof window>`u`||!(`matchMedia`in window)?[]:Bf.map(e=>window.matchMedia(e))}function Hf(e,t=Uf()){return e.some(e=>e.matches)||Wf(t)}function Uf(){return typeof navigator>`u`?void 0:navigator}function Wf(e){return e!==void 0&&`standalone`in e&&e.standalone===!0}var Gf=class{constructor(e=Kf()){this.scheduler=e}repair(e){if(!e){this.clear();return}this.resetViewportScroll(),this.repairFrame!==void 0&&this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll(),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll()})}),this.repairTimer!==void 0&&this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=this.scheduler.setTimeout(()=>{this.repairTimer=void 0,this.resetViewportScroll()},250)}clear(){this.repairFrame!==void 0&&(this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=void 0),this.repairTimer!==void 0&&(this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=void 0)}resetViewportScroll(){this.scheduler.scrollTo(0,0);let e=this.scheduler.documentElement;e!==void 0&&(e.scrollTop=0);let t=this.scheduler.body;t!==void 0&&(t.scrollTop=0)}};function Kf(){return{requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)},setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},scrollTo(e,t){window.scrollTo(e,t)},get documentElement(){return typeof document>`u`?void 0:document.documentElement},get body(){return typeof document>`u`?void 0:document.body}}}var qf=`(max-width: 760px)`,Jf=`(max-width: 1180px)`,Yf=class{constructor(e,t={}){this.host=e,this.onMobileNavigationMediaChange=e=>{this.isMobileNavigationLayout!==e.matches&&(this.isMobileNavigationLayout=e.matches,this.host.requestUpdate())},this.onStackedWorkspaceMediaChange=e=>{this.isStackedWorkspaceLayout!==e.matches&&(this.isStackedWorkspaceLayout=e.matches,this.host.requestUpdate())},this.onPwaDisplayModeChange=()=>{let e=Hf(this.pwaDisplayModeMedia);this.isPwaDisplayMode!==e&&(this.isPwaDisplayMode=e,this.host.requestUpdate())},e.addController(this),this.mobileNavigationMedia=t.mobileNavigationMedia??Xf(),this.stackedWorkspaceMedia=t.stackedWorkspaceMedia??Zf(),this.pwaDisplayModeMedia=t.pwaDisplayModeMedia??Vf(),this.viewportPositionRepairer=t.viewportPositionRepairer??new Gf,this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.isStackedWorkspaceLayout=this.stackedWorkspaceMedia?.matches??!1,this.isPwaDisplayMode=Hf(this.pwaDisplayModeMedia)}hostConnected(){this.mobileNavigationMedia?.addEventListener(`change`,this.onMobileNavigationMediaChange),this.stackedWorkspaceMedia?.addEventListener(`change`,this.onStackedWorkspaceMediaChange);for(let e of this.pwaDisplayModeMedia)e.addEventListener(`change`,this.onPwaDisplayModeChange)}hostDisconnected(){this.mobileNavigationMedia?.removeEventListener(`change`,this.onMobileNavigationMediaChange),this.stackedWorkspaceMedia?.removeEventListener(`change`,this.onStackedWorkspaceMediaChange);for(let e of this.pwaDisplayModeMedia)e.removeEventListener(`change`,this.onPwaDisplayModeChange);this.viewportPositionRepairer.clear()}shouldAutoFocusPrompt(){return!this.isMobileNavigationLayout&&!this.isPwaDisplayMode}shouldShowAppRefreshInHeader(){return this.isPwaDisplayMode&&!this.isMobileNavigationLayout}shouldShowAppRefreshInContextBar(){return this.isPwaDisplayMode&&this.isMobileNavigationLayout}defaultRouteView(){return this.normalizedMainView(void 0,!1)}normalizedMainView(e,t){return Qf(e,{isMobileNavigationLayout:this.isMobileNavigationLayout,isStackedWorkspaceLayout:this.isStackedWorkspaceLayout,hasSelectedSession:t})}repairViewportPosition(){this.viewportPositionRepairer.repair(this.shouldRepairViewportPosition())}shouldRepairViewportPosition(){return this.isMobileNavigationLayout||this.isPwaDisplayMode}};function Xf(){if(!(typeof window>`u`||!(`matchMedia`in window)))return window.matchMedia(qf)}function Zf(){if(!(typeof window>`u`||!(`matchMedia`in window)))return window.matchMedia(Jf)}function Qf(e,t){let n=e??(t.isMobileNavigationLayout?`navigation`:`chat`);return t.isMobileNavigationLayout||!t.isStackedWorkspaceLayout||!t.hasSelectedSession||n===`navigation`||n===`chat`?n:`chat`}var $f=class{constructor(e,t={}){this.callbacks=e,this.refreshes=new Ia,this.connected=!1,this.onFocus=()=>{this.handleResumeSignal()},this.onVisibilityChange=()=>{this.isDocumentVisible()&&this.handleResumeSignal()},this.windowTarget=t.windowTarget??ep(),this.documentTarget=t.documentTarget??tp(),this.isDocumentVisible=t.isDocumentVisible??np,this.scheduleFrame=t.scheduleFrame??rp}connect(){this.connected||(this.connected=!0,this.windowTarget?.addEventListener(`focus`,this.onFocus),this.documentTarget?.addEventListener(`visibilitychange`,this.onVisibilityChange))}disconnect(){this.connected&&(this.connected=!1,this.windowTarget?.removeEventListener(`focus`,this.onFocus),this.documentTarget?.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.scheduledRefresh?.cancel(),this.scheduledRefresh=void 0)}handleResumeSignal(){this.callbacks.onResumeSignal(),this.scheduledRefresh===void 0&&(this.scheduledRefresh=this.scheduleFrame(()=>{this.scheduledRefresh=void 0,this.connected&&this.refreshes.request(`browser-resume`,async()=>{this.connected&&await this.callbacks.refreshAfterResume()}).catch(e=>{this.callbacks.onRefreshError(e)})}))}};function ep(){return typeof window>`u`?void 0:window}function tp(){return typeof document>`u`?void 0:document}function np(){return typeof document>`u`||document.visibilityState===`visible`}function rp(e){if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){let t=window.requestAnimationFrame(()=>{e()});return{cancel:()=>{window.cancelAnimationFrame(t)}}}let t=globalThis.setTimeout(e,0);return{cancel:()=>{globalThis.clearTimeout(t)}}}var ip=[`machines`,`projects`,`workspaces`,`sessions`];function ap(e){return e.selectedProject===void 0?`projects`:e.selectedWorkspace===void 0?`workspaces`:`sessions`}function op(e,t){if(e!==`none`)return e??ap(t)}function sp(e,t){return t.isMobileLayout?op(t.expanded,t.state)!==e:t.collapsedSections?.includes(e)??!1}function cp(e,t,n){return n.isMobileLayout?op(e,n.state)===t?`none`:t:e}function lp(e,t,n){return n?t:e}function up(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),pp(n)}function dp(e){return ip[ip.indexOf(e)+1]}var fp=class{hostConnected(){}constructor(e,t,n){this.host=e,this.getState=t,this.isMobileLayout=n,this.collapsedSections=[],e.addController(this)}expandedSection(){return op(this.expanded,this.getState())}isCollapsed(e){return sp(e,{isMobileLayout:this.isMobileLayout(),expanded:this.expanded,state:this.getState(),collapsedSections:this.collapsedSections})}toggle(e){if(this.isMobileLayout()){this.setExpanded(cp(this.expanded,e,{isMobileLayout:!0,state:this.getState()}));return}this.setCollapsedSections(up(this.collapsedSections,e))}expand(e){if(this.isMobileLayout()){this.setExpanded(lp(this.expanded,e,!0));return}this.setCollapsedSections(this.collapsedSections.filter(t=>t!==e))}advanceAfterSelection(e){if(!this.isMobileLayout())return;let t=dp(e);t!==void 0&&this.expand(t)}open(e,t){this.isMobileLayout()&&(this.expand(e),t())}setExpanded(e){this.expanded!==e&&(this.expanded=e,this.host.requestUpdate())}setCollapsedSections(e){mp(this.collapsedSections,e)||(this.collapsedSections=e,this.host.requestUpdate())}};function pp(e){let t=new Set(e);return ip.filter(e=>t.has(e))}function mp(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var hp=class{hostConnected(){}constructor(e){this.host=e,this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,e.addController(this)}toggleNavigationPanel(){this.navigationPanelCollapsed=!this.navigationPanelCollapsed,this.host.requestUpdate()}toggleWorkspacePanel(){this.workspacePanelCollapsed=!this.workspacePanelCollapsed,this.host.requestUpdate()}expandNavigationPanel(){this.navigationPanelCollapsed&&(this.navigationPanelCollapsed=!1,this.host.requestUpdate())}expandWorkspacePanel(){this.workspacePanelCollapsed&&(this.workspacePanelCollapsed=!1,this.host.requestUpdate())}shellClass(e){return[`shell`,gp(e),...this.navigationPanelCollapsed?[`navigation-panel-collapsed`]:[],...this.workspacePanelCollapsed?[`workspace-panel-collapsed`]:[]].join(` `)}};function gp(e){return e===`navigation`?`navigation-view`:e===`chat`?`chat-view`:`workspace-view`}var _p=`pi-web:panel-sizes:v1`,vp={navigation:{minWidth:180,maxWidth:4096,defaultWidth:340,keyboardStep:24,largeKeyboardStep:72},workspace:{minWidth:240,maxWidth:4096,defaultWidth:480,keyboardStep:24,largeKeyboardStep:72}},yp=class{constructor(e,t={}){this.host=e,e.addController(this),this.storage=t.storage??Np(),this.panelSizes=Tp(this.storage)}hostConnected(){}constraints(e){return bp(e)}panelWidth(e,t){return wp(e,t??this.storedPanelWidth(e)??this.constraints(e).defaultWidth)}resizePanel(e,t,n={}){let r=wp(e,t);this.storedPanelWidth(e)!==r&&(this.panelSizes=kp(this.panelSizes,e,r),n.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanel(e,t={}){this.storedPanelWidth(e)!==void 0&&(this.panelSizes=Ap(this.panelSizes,e),t.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanels(e={}){this.panelSizes.navigationPanelWidth===void 0&&this.panelSizes.workspacePanelWidth===void 0||(this.panelSizes={},e.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}persistPanelSizes(){Ep(this.panelSizes,this.storage)}shellStyle(e={}){let t=[];return this.panelSizes.navigationPanelWidth!==void 0&&t.push(`--navigation-panel-size: ${Mp(wp(`navigation`,this.panelSizes.navigationPanelWidth,e.navigation))};`),this.panelSizes.workspacePanelWidth!==void 0&&t.push(`--workspace-panel-size: ${Mp(wp(`workspace`,this.panelSizes.workspacePanelWidth,e.workspace))};`),t.join(` `)}storedPanelWidth(e){return e===`navigation`?this.panelSizes.navigationPanelWidth:this.panelSizes.workspacePanelWidth}};function bp(e){return vp[e]}function xp(e,t,n){return e===`navigation`?n-t:t-n}function Sp(e,t,n,r,i=bp(e)){return wp(e,t+xp(e,n,r),i)}function Cp(e,t,n,r={}){let i=r.constraints??bp(e);if(n===`Home`)return i.minWidth;if(n===`End`)return i.maxWidth;let a=jp(e,n,r.largeStep===!0?i.largeKeyboardStep:i.keyboardStep);if(a!==void 0)return wp(e,t+a,i)}function wp(e,t,n=bp(e)){return Number.isFinite(t)?Math.round(Math.min(Math.max(t,n.minWidth),n.maxWidth)):n.defaultWidth}function Tp(e=Np()){try{let t=e?.getItem(_p);return t==null||t===``?{}:Dp(JSON.parse(t))}catch{return{}}}function Ep(e,t=Np()){if(t!==void 0)try{if(e.navigationPanelWidth===void 0&&e.workspacePanelWidth===void 0){t.removeItem(_p);return}let n={version:1};e.navigationPanelWidth!==void 0&&(n.navigationPanelWidth=wp(`navigation`,e.navigationPanelWidth)),e.workspacePanelWidth!==void 0&&(n.workspacePanelWidth=wp(`workspace`,e.workspacePanelWidth)),t.setItem(_p,JSON.stringify(n))}catch{}}function Dp(e){if(!Pp(e)||e.version!==1)return{};let t={},n=Op(e.navigationPanelWidth),r=Op(e.workspacePanelWidth);return n!==void 0&&(t.navigationPanelWidth=wp(`navigation`,n)),r!==void 0&&(t.workspacePanelWidth=wp(`workspace`,r)),t}function Op(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function kp(e,t,n){return t===`navigation`?{...e,navigationPanelWidth:n}:{...e,workspacePanelWidth:n}}function Ap(e,t){return t===`navigation`?e.workspacePanelWidth===void 0?{}:{workspacePanelWidth:e.workspacePanelWidth}:e.navigationPanelWidth===void 0?{}:{navigationPanelWidth:e.navigationPanelWidth}}function jp(e,t,n){if(e===`navigation`)return t===`ArrowRight`?n:t===`ArrowLeft`?-n:void 0;if(t===`ArrowLeft`)return n;if(t===`ArrowRight`)return-n}function Mp(e){return`${String(Math.round(e))}px`}function Np(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function Pp(e){return typeof e==`object`&&!!e}function Fp(){let e=new URLSearchParams(window.location.search);return{machineId:e.get(`machine`)??void 0,projectId:e.get(`project`)??void 0,workspaceId:e.get(`workspace`)??void 0,sessionId:e.get(`session`)??void 0,tool:Lp(e.get(`tool`)),view:Rp(e.get(`view`))}}function Ip(e,t){let n=new URL(window.location.href);n.searchParams.delete(`machine`),n.searchParams.delete(`project`),n.searchParams.delete(`workspace`),n.searchParams.delete(`session`),n.searchParams.delete(`tool`),n.searchParams.delete(`view`),e.machineId!==void 0&&e.machineId!==``&&e.machineId!==`local`&&n.searchParams.set(`machine`,e.machineId),e.projectId!==void 0&&e.projectId!==``&&n.searchParams.set(`project`,e.projectId),e.workspaceId!==void 0&&e.workspaceId!==``&&n.searchParams.set(`workspace`,e.workspaceId),e.sessionId!==void 0&&e.sessionId!==``&&n.searchParams.set(`session`,e.sessionId),e.tool!==void 0&&n.searchParams.set(`tool`,e.tool),e.view!==void 0&&n.searchParams.set(`view`,e.view),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t?.replace===!0?window.history.replaceState({},``,n):window.history.pushState({},``,n))}function Lp(e){return e===`files`?`core:workspace.files`:e===`git`?`core:workspace.git`:zp(e)?e:void 0}function Rp(e){return e===`chat`?`chat`:e===`files`?`core:workspace.files`:e===`git`?`core:workspace.git`:zp(e)?e:void 0}function zp(e){return e!==null&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function Bp(){return Hp(new URLSearchParams(window.location.search).get(`settings`))}function Vp(e,t){let n=new URL(window.location.href);e===void 0?n.searchParams.delete(`settings`):n.searchParams.set(`settings`,e),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t?.replace===!0?window.history.replaceState({},``,n):window.history.pushState({},``,n))}function Hp(e){if(e===`general`)return`general`;if(e===`sessiond`||e===`sessions`)return`sessiond`;if(e===`packages`||e===`pi-packages`)return`packages`;if(e===`plugins`)return`plugins`;if(e===`shortcuts`||e===`keyboard`||e===`keyboard-shortcuts`)return`shortcuts`}function Up(e,t){return t===void 0?e:e.map(e=>Gp(e,t))}function Wp(e,t){let n=new Set(nu(e,t,{enabledOnly:!0}).filter(e=>e.active).map(e=>e.action.id));return Up(e,t).map(e=>e.shortcut!==void 0&&!n.has(e.id)?Kp(e):e)}function Gp(e,t){if(!Object.hasOwn(t,e.id))return e;let n=t[e.id];return n===void 0?e:n===null?Kp(e):{...e,shortcut:n}}function Kp(e){let t={...e};return delete t.shortcut,t}function qp(e,t){let n=t.api??Xi,r=t.pollIntervalMs??1e3,i=t.setTimeout??Xp(),a=t.clearTimeout??Zp();return{async runCommand(o){let s=await n.runTerminalCommand(e,o);return o.open===!0&&t.openTerminal(o.workspace,{terminalId:s.terminalId}),{run:s,completed:Jp(s,n,r,i,a)}},listCommandRuns:e=>n.listCommandRuns(e),getCommandRun:e=>n.getCommandRun(e),open:e=>{t.openTerminal(void 0,e)}}}function Jp(e,t,n,r,i){return Yp(e)?Promise.resolve(e):new Promise((a,o)=>{let s,c=!1,l=e=>{c||(c=!0,s!==void 0&&i(s),a(e))},u=e=>{c||(c=!0,s!==void 0&&i(s),o(e instanceof Error?e:Error(String(e))))},d=()=>{t.getCommandRun(e.id).then(e=>{if(e!==void 0&&Yp(e)){l(e);return}s=r(d,n)}).catch(u)};s=r(d,n)})}function Yp(e){return e.status===`succeeded`||e.status===`failed`}function Xp(){return(e,t)=>globalThis.setTimeout(e,t)}function Zp(){return e=>{globalThis.clearTimeout(e)}}function Qp(e,t){return t[e.path]}function $p(e){if(e?.hasSessionActivity===!0)return`session`;if(e?.hasTerminalActivity===!0)return`terminal`}function em(e,t,n){return nm(rm(e,t,n))}function tm(e){return nm(Object.values(e??{}))}function nm(e){if(e.some(e=>e.hasSessionActivity))return`session`;if(e.some(e=>e.hasTerminalActivity))return`terminal`}function rm(e,t,n){let r=new Set(t.filter(t=>t.projectId===e.id).map(e=>e.path)),i=new Map;for(let e of r){let t=n[e];t!==void 0&&i.set(t.cwd,t)}for(let t of Object.values(n))(t.cwd===e.path||t.cwd.startsWith(`${e.path}/`))&&i.set(t.cwd,t);return[...i.values()]}function im(e,t=`活跃`){if(e!==void 0)return g`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`}function am(e,t=`活跃`){let n=im(e,t);if(n!==void 0)return g`<span class="action-activity">${n}</span>`}var om=0,sm=120;function cm(e,t={}){if(typeof HTMLElement>`u`||typeof window>`u`||!(e instanceof HTMLElement))return``;let n=e.getBoundingClientRect(),r=t.constrainTo===`viewport`?um():lm(e),i=window.innerWidth,a=window.innerHeight,o=Math.max(0,r.left),s=Math.min(i,r.right),c=Math.max(0,r.top),l=Math.min(a,r.bottom),u=Math.min(n.right,s),d=l-n.bottom-om,f=n.top-c-om;return[...d<sm&&f>d?[`bottom: ${dm(a-n.top+om)};`,`max-height: ${dm(Math.max(0,f))};`]:[`top: ${dm(n.bottom+om)};`,`max-height: ${dm(Math.max(0,d))};`],`right: ${dm(Math.max(0,i-u))};`,`max-width: ${dm(Math.max(0,u-o))};`].join(` `)}function lm(e){let t=e.getRootNode();return typeof ShadowRoot<`u`&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():um()}function um(){return{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function dm(e){return`${String(Math.round(e))}px`}var fm=class{constructor(e){this.host=e,this.menuStyle=``,this.onDocumentClick=e=>{e.composedPath().includes(this.host)||this.close()},e.addController(this)}hostConnected(){document.addEventListener(`click`,this.onDocumentClick)}hostDisconnected(){document.removeEventListener(`click`,this.onDocumentClick)}isOpen(e){return this.openId===e}toggle(e,t){if(this.openId===e){this.close();return}this.menuStyle=cm(t,{constrainTo:`viewport`}),this.openId=e,this.host.requestUpdate()}close(){this.openId===void 0&&this.menuStyle===``||(this.openId=void 0,this.menuStyle=``,this.host.requestUpdate())}closeIfOpenIdMissing(e){this.openId!==void 0&&!e(this.openId)&&this.close()}closeIf(e){e&&this.close()}closeForEscape(e,t){return e.key!==`Escape`||this.openId!==t?!1:(e.preventDefault(),e.stopPropagation(),this.close(),!0)}},pm=[`a[href]`,`button`,`input`,`select`,`textarea`,`summary`,`[role='button']`,`[role='link']`,`[contenteditable='true']`].join(`,`);function mm(e){return e.composedPath().some(e=>hm(e,pm))}function hm(e,t){if(typeof Element<`u`&&e instanceof Element)return e.matches(t);if(!(`matches`in e))return!1;let{matches:n}=e;return typeof n==`function`&&n.call(e,t)===!0}function gm(e,t){mm(e)||t()}function _m(e,t){return mm(e)?!1:e.key===`Enter`||e.key===` `?(e.preventDefault(),t.activate(),!0):e.key===`ArrowUp`?ym(e,()=>{bm(e.currentTarget,-1)}):e.key===`ArrowDown`?ym(e,()=>{bm(e.currentTarget,1)}):e.key===`Home`?ym(e,()=>{xm(e.currentTarget,0)}):e.key===`End`?ym(e,()=>{xm(e.currentTarget,-1)}):e.key===`ArrowLeft`&&t.previousSection!==void 0?ym(e,t.previousSection):e.key===`ArrowRight`&&t.nextSection!==void 0?ym(e,t.nextSection):e.key===`Escape`&&t.cancel!==void 0&&ym(e,t.cancel)}function vm(e,t={}){let n=e.querySelector(`.action-row.selected`)??e.querySelector(`.action-row`)??(t.fallbackSelector===void 0?void 0:e.querySelector(t.fallbackSelector));return n==null?!1:(n.focus(),n.scrollIntoView({block:`nearest`}),!0)}function ym(e,t){return e.preventDefault(),e.stopPropagation?.(),t(),!0}function bm(e,t){let n=Cm(e),r=Tm(e);if(r===void 0||n.length===0)return;let i=n.indexOf(r);i<0||Sm(n,i+t)}function xm(e,t){let n=Cm(e);n.length!==0&&Sm(n,t<0?n.length-1:t)}function Sm(e,t){let n=e[Math.min(Math.max(t,0),e.length-1)];n?.focus(),n?.scrollIntoView({block:`nearest`})}function Cm(e){let t=Tm(e)?.getRootNode();return t===void 0||!wm(t)?[]:Array.from(t.querySelectorAll(`.action-row`))}function wm(e){return typeof Document<`u`&&e instanceof Document||typeof DocumentFragment<`u`&&e instanceof DocumentFragment}function Tm(e){if(!(typeof HTMLElement>`u`||!(e instanceof HTMLElement)))return e.closest(`.action-row`)??void 0}var Em=h`
|
|
369
|
+
`}function af(){Ed(()=>import(`./UnifiedDiffViewer-DXLMHyO2.js`),[],import.meta.url)}function of(){Ed(()=>import(`./TerminalPanel-Ctz1zP84.js`),__vite__mapDeps([4,5,6]),import.meta.url)}function sf(e){let t=e.branch??`分离 HEAD`,n=e.ahead??0,r=e.behind??0;return n===0&&r===0?t:`${t} · ↑${String(n)} ↓${String(r)}`}function cf(e,t){return(t===`unmodified`?e:t).slice(0,1).toUpperCase()}var lf={apiVersion:1,name:`PI WEB 核心`,activate:()=>{let e=!vt();return{contributions:{actions:e?cd():cd().filter(e=>e.id!==`view.terminal`),workspacePanels:e?Qd():Qd().filter(e=>e.id!==`workspace.terminal`)}}}},uf={"--pi-bg":`#0d1117`,"--pi-surface":`#161b22`,"--pi-surface-hover":`#21262d`,"--pi-terminal-bg":`#05070a`,"--pi-terminal-text":`#e6edf3`,"--pi-border":`#30363d`,"--pi-border-muted":`#21262d`,"--pi-text":`#e6edf3`,"--pi-text-secondary":`#c9d1d9`,"--pi-text-bright":`#f0f6fc`,"--pi-muted":`#8b949e`,"--pi-dim":`#6e7681`,"--pi-accent":`#58a6ff`,"--pi-accent-border":`#2f81f7`,"--pi-selection-bg":`#0d2847`,"--pi-success":`#3fb950`,"--pi-success-border":`#238636`,"--pi-success-bg":`#0f1b12`,"--pi-success-surface":`#0f2a16`,"--pi-success-ring":`#3fb95055`,"--pi-warning":`#d29922`,"--pi-warning-border":`#6e5200`,"--pi-warning-surface":`#1f1a10`,"--pi-danger":`#ff7b72`,"--pi-purple":`#d2a8ff`,"--pi-purple-border":`#a371f7`,"--pi-purple-surface":`#21132f`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#0d1117dd`,"--pi-bg-overlay":`#0d1117e6`,"--pi-success-bg-overlay":`#0f1b12ee`,"--pi-terminal-selection":`#264f78`},df={"--pi-bg":`#070912`,"--pi-surface":`#101527`,"--pi-surface-hover":`#151b31`,"--pi-terminal-bg":`#050710`,"--pi-terminal-text":`#f7f4ff`,"--pi-border":`#26304f`,"--pi-border-muted":`#26304f`,"--pi-text":`#f7f4ff`,"--pi-text-secondary":`#aaa4bd`,"--pi-text-bright":`#ffffff`,"--pi-muted":`#aaa4bd`,"--pi-dim":`#817a99`,"--pi-accent":`#7c3cff`,"--pi-accent-border":`#5a47b0`,"--pi-selection-bg":`#1d2547`,"--pi-success":`#00f0d8`,"--pi-success-border":`#00f0d8`,"--pi-success-bg":`#071e22`,"--pi-success-surface":`#092d31`,"--pi-success-ring":`#00f0d855`,"--pi-warning":`#ffb000`,"--pi-warning-border":`#ffb000`,"--pi-warning-surface":`#16140d`,"--pi-danger":`#ff4f7b`,"--pi-purple":`#b7a2ff`,"--pi-purple-border":`#7c3cff`,"--pi-purple-surface":`#181026`,"--pi-overlay":`#0008`,"--pi-shadow-soft":`#0006`,"--pi-shadow":`#0008`,"--pi-shadow-strong":`#000b`,"--pi-bg-overlay-soft":`#070912dd`,"--pi-bg-overlay":`#070912e6`,"--pi-success-bg-overlay":`#071e22ee`,"--pi-terminal-selection":`#3d4a78`},ff={"--pi-bg":`#f7f1e6`,"--pi-surface":`#fff9ee`,"--pi-surface-hover":`#f0e6d6`,"--pi-terminal-bg":`#15131b`,"--pi-terminal-text":`#fff9ee`,"--pi-border":`#c9bca8`,"--pi-border-muted":`#d8cdbc`,"--pi-text":`#15131b`,"--pi-text-secondary":`#15131b`,"--pi-text-bright":`#15131b`,"--pi-muted":`#5f586a`,"--pi-dim":`#766f7e`,"--pi-accent":`#6430d8`,"--pi-accent-border":`#6430d8`,"--pi-selection-bg":`#eadff8`,"--pi-success":`#008c82`,"--pi-success-border":`#008c82`,"--pi-success-bg":`#e1f4ef`,"--pi-success-surface":`#d7f0ec`,"--pi-success-ring":`#008c8255`,"--pi-warning":`#b05f00`,"--pi-warning-border":`#b05f00`,"--pi-warning-surface":`#fff2d2`,"--pi-danger":`#b51d49`,"--pi-purple":`#6430d8`,"--pi-purple-border":`#6430d8`,"--pi-purple-surface":`#eadff8`,"--pi-overlay":`#15131b66`,"--pi-shadow-soft":`#15131b22`,"--pi-shadow":`#15131b33`,"--pi-shadow-strong":`#15131b44`,"--pi-bg-overlay-soft":`#f7f1e6dd`,"--pi-bg-overlay":`#f7f1e6e6`,"--pi-success-bg-overlay":`#e1f4efee`,"--pi-terminal-selection":`#8d7b64`},pf={apiVersion:1,name:`PI WEB 主题`,activate:()=>({contributions:{themes:[{id:`pi-web-dark`,name:`PI WEB 深色`,description:`PI WEB 深色配色。`,order:10,colorScheme:`dark`,tokens:df},{id:`pi-web-light`,name:`PI WEB 浅色`,description:`PI WEB 浅色配色。`,order:20,colorScheme:`light`,tokens:ff},{id:`classic`,name:`PI WEB 经典`,description:`原始 PI WEB 深色配色。`,order:30,colorScheme:`dark`,tokens:uf}],themePairs:[{id:`pi-web`,name:`PI WEB`,description:`跟随系统浅色/深色偏好使用 PI WEB 主题。`,order:10,light:`pi-web-light`,dark:`pi-web-dark`}]}})},mf=/^[a-z][a-z0-9.-]*$/u;function hf(e){return mf.test(e)}var gf=`machine.`;function _f(e,t){if(e===``)throw Error(`Machine id is required`);if(!hf(t))throw Error(`Invalid PI WEB plugin id: ${t}`);return`${gf}${vf(e)}.${t}`}function vf(e){return[...new TextEncoder().encode(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function yf(e=`pi-web-plugins/manifest.json`,t={}){let n=Dt(e),r=await Sf(n);if(r===void 0)return[];let i=[];for(let e of r.plugins)if(t.shouldLoadPlugin?.(e)!==!1)try{let r=bf(e.module,n),a=Tf(await(t.moduleLoader??xf)(r),r);i.push({id:t.machineId===void 0?e.id:_f(t.machineId,e.id),plugin:a,machineSpecific:e.machineSpecific,...t.machineId===void 0?{}:{machineId:t.machineId,sourcePluginId:e.id}})}catch(t){console.warn(`Failed to load PI WEB plugin ${e.module}`,t)}return i}function bf(e,t,n){return e.startsWith(`/`)?n===void 0?Dt(e):Dt(e,n):new URL(e,t).toString()}async function xf(e){return Ed(()=>import(e),[],import.meta.url)}async function Sf(e){let t=await fetch(e,{cache:`no-store`});if(t.status!==404){if(!t.ok)throw Error(`Failed to load plugin manifest: ${t.statusText}`);return Cf(await t.json())}}function Cf(e){if(!Df(e)||!Array.isArray(e.plugins))throw Error(`Invalid plugin manifest`);return{plugins:e.plugins.map(e=>{if(!Df(e)||typeof e.id!=`string`||e.id===``||typeof e.module!=`string`||e.module===``)throw Error(`Invalid plugin manifest entry`);return{id:e.id,module:e.module,machineSpecific:wf(e.machineSpecific)}})}}function wf(e){if(e===void 0)return!1;if(typeof e!=`boolean`)throw Error(`Invalid plugin manifest entry`);return e}function Tf(e,t){if(!Df(e))throw Error(`Plugin module ${t} did not export an object`);let n=e.default;if(!Ef(n))throw Error(`Plugin module ${t} default export is not a PiWebPlugin`);return n}function Ef(e){return Df(e)&&e.apiVersion===1&&typeof e.name==`string`&&typeof e.activate==`function`}function Df(e){return typeof e==`object`&&!!e}var Of=/^[a-z][a-z0-9.-]*$/u,kf=/^[a-z][a-z0-9.-]*$/u,Af=new WeakMap,jf=new WeakMap,Mf=class{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabels=[],this.themes=[],this.themePairs=[],this.pluginIds=new Set,this.gatewayPluginIds=new Set,this.gatewayMachineSpecificPluginIds=new Set,this.remoteMachineSpecificPluginIds=new Map,this.contributionIds=new Set}register(e){let{id:t,plugin:n}=e;this.validatePluginId(t);let r=this.parseMachineSpecific(t,e.machineSpecific);if(this.pluginIds.has(t))throw Error(`Duplicate plugin id: ${t}`);if(this.isRemoteDuplicateHiddenByGateway(e.sourcePluginId,e.machineId,r))return;this.pluginIds.add(t);let i=n.apiVersion;if(i!==1)throw Error(`Unsupported plugin API version for ${t}: ${String(i)}`);let a=n.activate({apiVersion:1,pluginId:t,html:g,svg:Je}).contributions;for(let n of a.actions??[])this.actions.push(this.qualifyAction(t,n,e.machineId,e.sourcePluginId));for(let n of a.workspacePanels??[])this.workspacePanels.push(this.qualifyWorkspacePanel(t,n,e.machineId,e.sourcePluginId));for(let n of a.workspaceLabels??[])this.workspaceLabels.push(this.qualifyWorkspaceLabelContribution(t,n,e.machineId,e.sourcePluginId));if(e.machineId===void 0){for(let e of a.themes??[])this.themes.push(this.qualifyTheme(t,e));for(let e of a.themePairs??[])this.themePairs.push(this.qualifyThemePair(t,e));this.gatewayPluginIds.add(t),r&&this.gatewayMachineSpecificPluginIds.add(t)}else e.sourcePluginId!==void 0&&r&&Lf(this.remoteMachineSpecificPluginIds,e.sourcePluginId,e.machineId)}shouldLoadRemotePlugin(e,t=!1){return!this.gatewayPluginIds.has(e)||this.gatewayMachineSpecificPluginIds.has(e)||t}getActions(e){let t=zf(e);return this.actions.filter(e=>this.isContributionActive(e.pluginId,e.machineId,t,e.sourcePluginId)).map(t=>{let n=Nf(e,t.pluginId),r=t.enabled?.(n),i=r===!1?t.disabledReason?.(n):void 0,a={id:t.id,pluginId:t.pluginId,localId:t.localId,...t.machineId===void 0?{}:{machineId:t.machineId},title:t.title,run:()=>t.run(n)};return t.description!==void 0&&(a.description=t.description),t.shortcut!==void 0&&(a.shortcut=t.shortcut),t.group!==void 0&&(a.group=t.group),r!==void 0&&(a.enabled=r),i!==void 0&&i!==``&&(a.disabledReason=i),a})}getWorkspacePanels(){return[...this.workspacePanels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.title.localeCompare(t.title))}getThemes(){return[...this.themes].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getThemePairs(){return[...this.themePairs].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.name.localeCompare(t.name))}getWorkspaceLabelItems(e){return[...this.workspaceLabels].sort((e,t)=>(e.order??1e3)-(t.order??1e3)||e.id.localeCompare(t.id)).flatMap(t=>t.visible?.(e)===!1?[]:t.items(e))}qualifyAction(e,t,n,r){let i=this.qualify(e,t.id);return{...t,id:i,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},...r===void 0?{}:{sourcePluginId:r}}}qualifyWorkspacePanel(e,t,n,r){let i=this.qualify(e,t.id),a=t.badge,o=t.visible;return{...t,id:i,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(o?.(Pf(t,e))??!0),...a===void 0?{}:{badge:t=>this.isContributionActive(e,n,t.machine.id,r)?a(Pf(t,e)):void 0},render:n=>t.render(Pf(n,e))}}qualifyWorkspaceLabelContribution(e,t,n,r){let i=this.qualify(e,t.id),a=t.visible,o=t.items;return{...t,id:i,pluginId:e,localId:t.id,...n===void 0?{}:{machineId:n},visible:t=>this.isContributionActive(e,n,t.machine.id,r)&&(a?.(t)??!0),items:t=>this.isContributionActive(e,n,t.machine.id,r)?o(t):[]}}qualifyTheme(e,t){let n=this.qualify(e,t.id);return{...t,id:n,pluginId:e,localId:t.id}}qualifyThemePair(e,t){let n=this.qualify(e,t.id);return{...t,id:n,pluginId:e,localId:t.id,light:this.qualifyReference(e,t.light),dark:this.qualifyReference(e,t.dark)}}qualify(e,t){this.validateLocalId(t);let n=`${e}:${t}`;if(this.contributionIds.has(n))throw Error(`Duplicate contribution id: ${n}`);return this.contributionIds.add(n),n}qualifyReference(e,t){return this.validateLocalId(t),`${e}:${t}`}isContributionActive(e,t,n,r){return t===void 0?!this.isGatewayPluginHiddenForMachine(e,n):t===n&&!this.isRemotePluginHiddenByGateway(r,t)}isRemoteDuplicateHiddenByGateway(e,t,n){return e!==void 0&&t!==void 0&&this.gatewayPluginIds.has(e)&&!this.gatewayMachineSpecificPluginIds.has(e)&&!n}isRemotePluginHiddenByGateway(e,t){return e===void 0||this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0?!1:this.gatewayPluginIds.has(e)}isGatewayPluginHiddenForMachine(e,t){return t!==`local`&&(this.gatewayMachineSpecificPluginIds.has(e)||this.remoteMachineSpecificPluginIds.get(e)?.has(t)===!0)}validatePluginId(e){if(!Of.test(e))throw Error(`Invalid plugin id: ${e}`)}validateLocalId(e){if(!kf.test(e))throw Error(`Invalid contribution id: ${e}`)}parseMachineSpecific(e,t){if(t===void 0)return!1;if(typeof t!=`boolean`)throw Error(`Invalid plugin machineSpecific value for ${e}: ${Rf(t)}`);return t}};function Nf(e,t){return Af.get(e)?.(t)??e}function Pf(e,t){return jf.get(e)?.(t)??e}function Ff(e,t){return Af.set(e,t),e}function If(e,t){return jf.set(e,t),e}function Lf(e,t,n){let r=e.get(t);r===void 0?e.set(t,new Set([n])):r.add(n)}function Rf(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`||typeof e==`function`||e==null)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function zf(e){return e.state.selectedMachine?.id??`local`}var Bf=[`(display-mode: standalone)`,`(display-mode: fullscreen)`,`(display-mode: minimal-ui)`];function Vf(){return typeof window>`u`||!(`matchMedia`in window)?[]:Bf.map(e=>window.matchMedia(e))}function Hf(e,t=Uf()){return e.some(e=>e.matches)||Wf(t)}function Uf(){return typeof navigator>`u`?void 0:navigator}function Wf(e){return e!==void 0&&`standalone`in e&&e.standalone===!0}var Gf=class{constructor(e=Kf()){this.scheduler=e}repair(e){if(!e){this.clear();return}this.resetViewportScroll(),this.repairFrame!==void 0&&this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll(),this.repairFrame=this.scheduler.requestAnimationFrame(()=>{this.repairFrame=void 0,this.resetViewportScroll()})}),this.repairTimer!==void 0&&this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=this.scheduler.setTimeout(()=>{this.repairTimer=void 0,this.resetViewportScroll()},250)}clear(){this.repairFrame!==void 0&&(this.scheduler.cancelAnimationFrame(this.repairFrame),this.repairFrame=void 0),this.repairTimer!==void 0&&(this.scheduler.clearTimeout(this.repairTimer),this.repairTimer=void 0)}resetViewportScroll(){this.scheduler.scrollTo(0,0);let e=this.scheduler.documentElement;e!==void 0&&(e.scrollTop=0);let t=this.scheduler.body;t!==void 0&&(t.scrollTop=0)}};function Kf(){return{requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)},setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},scrollTo(e,t){window.scrollTo(e,t)},get documentElement(){return typeof document>`u`?void 0:document.documentElement},get body(){return typeof document>`u`?void 0:document.body}}}var qf=`(max-width: 760px)`,Jf=`(max-width: 1180px)`,Yf=class{constructor(e,t={}){this.host=e,this.onMobileNavigationMediaChange=e=>{this.isMobileNavigationLayout!==e.matches&&(this.isMobileNavigationLayout=e.matches,this.host.requestUpdate())},this.onStackedWorkspaceMediaChange=e=>{this.isStackedWorkspaceLayout!==e.matches&&(this.isStackedWorkspaceLayout=e.matches,this.host.requestUpdate())},this.onPwaDisplayModeChange=()=>{let e=Hf(this.pwaDisplayModeMedia);this.isPwaDisplayMode!==e&&(this.isPwaDisplayMode=e,this.host.requestUpdate())},e.addController(this),this.mobileNavigationMedia=t.mobileNavigationMedia??Xf(),this.stackedWorkspaceMedia=t.stackedWorkspaceMedia??Zf(),this.pwaDisplayModeMedia=t.pwaDisplayModeMedia??Vf(),this.viewportPositionRepairer=t.viewportPositionRepairer??new Gf,this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.isStackedWorkspaceLayout=this.stackedWorkspaceMedia?.matches??!1,this.isPwaDisplayMode=Hf(this.pwaDisplayModeMedia)}hostConnected(){this.mobileNavigationMedia?.addEventListener(`change`,this.onMobileNavigationMediaChange),this.stackedWorkspaceMedia?.addEventListener(`change`,this.onStackedWorkspaceMediaChange);for(let e of this.pwaDisplayModeMedia)e.addEventListener(`change`,this.onPwaDisplayModeChange)}hostDisconnected(){this.mobileNavigationMedia?.removeEventListener(`change`,this.onMobileNavigationMediaChange),this.stackedWorkspaceMedia?.removeEventListener(`change`,this.onStackedWorkspaceMediaChange);for(let e of this.pwaDisplayModeMedia)e.removeEventListener(`change`,this.onPwaDisplayModeChange);this.viewportPositionRepairer.clear()}shouldAutoFocusPrompt(){return!this.isMobileNavigationLayout&&!this.isPwaDisplayMode}shouldShowAppRefreshInHeader(){return this.isPwaDisplayMode&&!this.isMobileNavigationLayout}shouldShowAppRefreshInContextBar(){return this.isPwaDisplayMode&&this.isMobileNavigationLayout}defaultRouteView(){return this.normalizedMainView(void 0,!1)}normalizedMainView(e,t){return Qf(e,{isMobileNavigationLayout:this.isMobileNavigationLayout,isStackedWorkspaceLayout:this.isStackedWorkspaceLayout,hasSelectedSession:t})}repairViewportPosition(){this.viewportPositionRepairer.repair(this.shouldRepairViewportPosition())}shouldRepairViewportPosition(){return this.isMobileNavigationLayout||this.isPwaDisplayMode}};function Xf(){if(!(typeof window>`u`||!(`matchMedia`in window)))return window.matchMedia(qf)}function Zf(){if(!(typeof window>`u`||!(`matchMedia`in window)))return window.matchMedia(Jf)}function Qf(e,t){let n=e??(t.isMobileNavigationLayout?`navigation`:`chat`);return t.isMobileNavigationLayout||!t.isStackedWorkspaceLayout||!t.hasSelectedSession||n===`navigation`||n===`chat`?n:`chat`}var $f=class{constructor(e,t={}){this.callbacks=e,this.refreshes=new Ia,this.connected=!1,this.onFocus=()=>{this.handleResumeSignal()},this.onVisibilityChange=()=>{this.isDocumentVisible()&&this.handleResumeSignal()},this.windowTarget=t.windowTarget??ep(),this.documentTarget=t.documentTarget??tp(),this.isDocumentVisible=t.isDocumentVisible??np,this.scheduleFrame=t.scheduleFrame??rp}connect(){this.connected||(this.connected=!0,this.windowTarget?.addEventListener(`focus`,this.onFocus),this.documentTarget?.addEventListener(`visibilitychange`,this.onVisibilityChange))}disconnect(){this.connected&&(this.connected=!1,this.windowTarget?.removeEventListener(`focus`,this.onFocus),this.documentTarget?.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.scheduledRefresh?.cancel(),this.scheduledRefresh=void 0)}handleResumeSignal(){this.callbacks.onResumeSignal(),this.scheduledRefresh===void 0&&(this.scheduledRefresh=this.scheduleFrame(()=>{this.scheduledRefresh=void 0,this.connected&&this.refreshes.request(`browser-resume`,async()=>{this.connected&&await this.callbacks.refreshAfterResume()}).catch(e=>{this.callbacks.onRefreshError(e)})}))}};function ep(){return typeof window>`u`?void 0:window}function tp(){return typeof document>`u`?void 0:document}function np(){return typeof document>`u`||document.visibilityState===`visible`}function rp(e){if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){let t=window.requestAnimationFrame(()=>{e()});return{cancel:()=>{window.cancelAnimationFrame(t)}}}let t=globalThis.setTimeout(e,0);return{cancel:()=>{globalThis.clearTimeout(t)}}}var ip=[`machines`,`projects`,`workspaces`,`sessions`];function ap(e){return e.selectedProject===void 0?`projects`:e.selectedWorkspace===void 0?`workspaces`:`sessions`}function op(e,t){if(e!==`none`)return e??ap(t)}function sp(e,t){return t.isMobileLayout?op(t.expanded,t.state)!==e:t.collapsedSections?.includes(e)??!1}function cp(e,t,n){return n.isMobileLayout?op(e,n.state)===t?`none`:t:e}function lp(e,t,n){return n?t:e}function up(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),pp(n)}function dp(e){return ip[ip.indexOf(e)+1]}var fp=class{hostConnected(){}constructor(e,t,n){this.host=e,this.getState=t,this.isMobileLayout=n,this.collapsedSections=[],e.addController(this)}expandedSection(){return op(this.expanded,this.getState())}isCollapsed(e){return sp(e,{isMobileLayout:this.isMobileLayout(),expanded:this.expanded,state:this.getState(),collapsedSections:this.collapsedSections})}toggle(e){if(this.isMobileLayout()){this.setExpanded(cp(this.expanded,e,{isMobileLayout:!0,state:this.getState()}));return}this.setCollapsedSections(up(this.collapsedSections,e))}expand(e){if(this.isMobileLayout()){this.setExpanded(lp(this.expanded,e,!0));return}this.setCollapsedSections(this.collapsedSections.filter(t=>t!==e))}advanceAfterSelection(e){if(!this.isMobileLayout())return;let t=dp(e);t!==void 0&&this.expand(t)}open(e,t){this.isMobileLayout()&&(this.expand(e),t())}setExpanded(e){this.expanded!==e&&(this.expanded=e,this.host.requestUpdate())}setCollapsedSections(e){mp(this.collapsedSections,e)||(this.collapsedSections=e,this.host.requestUpdate())}};function pp(e){let t=new Set(e);return ip.filter(e=>t.has(e))}function mp(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var hp=class{hostConnected(){}constructor(e){this.host=e,this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,e.addController(this)}toggleNavigationPanel(){this.navigationPanelCollapsed=!this.navigationPanelCollapsed,this.host.requestUpdate()}toggleWorkspacePanel(){this.workspacePanelCollapsed=!this.workspacePanelCollapsed,this.host.requestUpdate()}expandNavigationPanel(){this.navigationPanelCollapsed&&(this.navigationPanelCollapsed=!1,this.host.requestUpdate())}expandWorkspacePanel(){this.workspacePanelCollapsed&&(this.workspacePanelCollapsed=!1,this.host.requestUpdate())}shellClass(e){return[`shell`,gp(e),...this.navigationPanelCollapsed?[`navigation-panel-collapsed`]:[],...this.workspacePanelCollapsed?[`workspace-panel-collapsed`]:[]].join(` `)}};function gp(e){return e===`navigation`?`navigation-view`:e===`chat`?`chat-view`:`workspace-view`}var _p=`pi-web:panel-sizes:v1`,vp={navigation:{minWidth:180,maxWidth:4096,defaultWidth:340,keyboardStep:24,largeKeyboardStep:72},workspace:{minWidth:240,maxWidth:4096,defaultWidth:480,keyboardStep:24,largeKeyboardStep:72}},yp=class{constructor(e,t={}){this.host=e,e.addController(this),this.storage=t.storage??Np(),this.panelSizes=Tp(this.storage)}hostConnected(){}constraints(e){return bp(e)}panelWidth(e,t){return wp(e,t??this.storedPanelWidth(e)??this.constraints(e).defaultWidth)}resizePanel(e,t,n={}){let r=wp(e,t);this.storedPanelWidth(e)!==r&&(this.panelSizes=kp(this.panelSizes,e,r),n.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanel(e,t={}){this.storedPanelWidth(e)!==void 0&&(this.panelSizes=Ap(this.panelSizes,e),t.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanels(e={}){this.panelSizes.navigationPanelWidth===void 0&&this.panelSizes.workspacePanelWidth===void 0||(this.panelSizes={},e.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}persistPanelSizes(){Ep(this.panelSizes,this.storage)}shellStyle(e={}){let t=[];return this.panelSizes.navigationPanelWidth!==void 0&&t.push(`--navigation-panel-size: ${Mp(wp(`navigation`,this.panelSizes.navigationPanelWidth,e.navigation))};`),this.panelSizes.workspacePanelWidth!==void 0&&t.push(`--workspace-panel-size: ${Mp(wp(`workspace`,this.panelSizes.workspacePanelWidth,e.workspace))};`),t.join(` `)}storedPanelWidth(e){return e===`navigation`?this.panelSizes.navigationPanelWidth:this.panelSizes.workspacePanelWidth}};function bp(e){return vp[e]}function xp(e,t,n){return e===`navigation`?n-t:t-n}function Sp(e,t,n,r,i=bp(e)){return wp(e,t+xp(e,n,r),i)}function Cp(e,t,n,r={}){let i=r.constraints??bp(e);if(n===`Home`)return i.minWidth;if(n===`End`)return i.maxWidth;let a=jp(e,n,r.largeStep===!0?i.largeKeyboardStep:i.keyboardStep);if(a!==void 0)return wp(e,t+a,i)}function wp(e,t,n=bp(e)){return Number.isFinite(t)?Math.round(Math.min(Math.max(t,n.minWidth),n.maxWidth)):n.defaultWidth}function Tp(e=Np()){try{let t=e?.getItem(_p);return t==null||t===``?{}:Dp(JSON.parse(t))}catch{return{}}}function Ep(e,t=Np()){if(t!==void 0)try{if(e.navigationPanelWidth===void 0&&e.workspacePanelWidth===void 0){t.removeItem(_p);return}let n={version:1};e.navigationPanelWidth!==void 0&&(n.navigationPanelWidth=wp(`navigation`,e.navigationPanelWidth)),e.workspacePanelWidth!==void 0&&(n.workspacePanelWidth=wp(`workspace`,e.workspacePanelWidth)),t.setItem(_p,JSON.stringify(n))}catch{}}function Dp(e){if(!Pp(e)||e.version!==1)return{};let t={},n=Op(e.navigationPanelWidth),r=Op(e.workspacePanelWidth);return n!==void 0&&(t.navigationPanelWidth=wp(`navigation`,n)),r!==void 0&&(t.workspacePanelWidth=wp(`workspace`,r)),t}function Op(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function kp(e,t,n){return t===`navigation`?{...e,navigationPanelWidth:n}:{...e,workspacePanelWidth:n}}function Ap(e,t){return t===`navigation`?e.workspacePanelWidth===void 0?{}:{workspacePanelWidth:e.workspacePanelWidth}:e.navigationPanelWidth===void 0?{}:{navigationPanelWidth:e.navigationPanelWidth}}function jp(e,t,n){if(e===`navigation`)return t===`ArrowRight`?n:t===`ArrowLeft`?-n:void 0;if(t===`ArrowLeft`)return n;if(t===`ArrowRight`)return-n}function Mp(e){return`${String(Math.round(e))}px`}function Np(){try{return typeof window>`u`?void 0:window.localStorage}catch{return}}function Pp(e){return typeof e==`object`&&!!e}function Fp(){let e=new URLSearchParams(window.location.search);return{machineId:e.get(`machine`)??void 0,projectId:e.get(`project`)??void 0,workspaceId:e.get(`workspace`)??void 0,sessionId:e.get(`session`)??void 0,tool:Lp(e.get(`tool`)),view:Rp(e.get(`view`))}}function Ip(e,t){let n=new URL(window.location.href);n.searchParams.delete(`machine`),n.searchParams.delete(`project`),n.searchParams.delete(`workspace`),n.searchParams.delete(`session`),n.searchParams.delete(`tool`),n.searchParams.delete(`view`),e.machineId!==void 0&&e.machineId!==``&&e.machineId!==`local`&&n.searchParams.set(`machine`,e.machineId),e.projectId!==void 0&&e.projectId!==``&&n.searchParams.set(`project`,e.projectId),e.workspaceId!==void 0&&e.workspaceId!==``&&n.searchParams.set(`workspace`,e.workspaceId),e.sessionId!==void 0&&e.sessionId!==``&&n.searchParams.set(`session`,e.sessionId),e.tool!==void 0&&n.searchParams.set(`tool`,e.tool),e.view!==void 0&&n.searchParams.set(`view`,e.view),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t?.replace===!0?window.history.replaceState({},``,n):window.history.pushState({},``,n))}function Lp(e){return e===`files`?`core:workspace.files`:e===`git`?`core:workspace.git`:zp(e)?e:void 0}function Rp(e){return e===`chat`?`chat`:e===`files`?`core:workspace.files`:e===`git`?`core:workspace.git`:zp(e)?e:void 0}function zp(e){return e!==null&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function Bp(){return Hp(new URLSearchParams(window.location.search).get(`settings`))}function Vp(e,t){let n=new URL(window.location.href);e===void 0?n.searchParams.delete(`settings`):n.searchParams.set(`settings`,e),`${n.pathname}${n.search}${n.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t?.replace===!0?window.history.replaceState({},``,n):window.history.pushState({},``,n))}function Hp(e){if(e===`general`)return`general`;if(e===`sessiond`||e===`sessions`)return`sessiond`;if(e===`packages`||e===`pi-packages`)return`packages`;if(e===`plugins`)return`plugins`;if(e===`shortcuts`||e===`keyboard`||e===`keyboard-shortcuts`)return`shortcuts`}function Up(e,t){return t===void 0?e:e.map(e=>Gp(e,t))}function Wp(e,t){let n=new Set(nu(e,t,{enabledOnly:!0}).filter(e=>e.active).map(e=>e.action.id));return Up(e,t).map(e=>e.shortcut!==void 0&&!n.has(e.id)?Kp(e):e)}function Gp(e,t){if(!Object.hasOwn(t,e.id))return e;let n=t[e.id];return n===void 0?e:n===null?Kp(e):{...e,shortcut:n}}function Kp(e){let t={...e};return delete t.shortcut,t}function qp(e,t){let n=t.api??Xi,r=t.pollIntervalMs??1e3,i=t.setTimeout??Xp(),a=t.clearTimeout??Zp();return{async runCommand(o){let s=await n.runTerminalCommand(e,o);return o.open===!0&&t.openTerminal(o.workspace,{terminalId:s.terminalId}),{run:s,completed:Jp(s,n,r,i,a)}},listCommandRuns:e=>n.listCommandRuns(e),getCommandRun:e=>n.getCommandRun(e),open:e=>{t.openTerminal(void 0,e)}}}function Jp(e,t,n,r,i){return Yp(e)?Promise.resolve(e):new Promise((a,o)=>{let s,c=!1,l=e=>{c||(c=!0,s!==void 0&&i(s),a(e))},u=e=>{c||(c=!0,s!==void 0&&i(s),o(e instanceof Error?e:Error(String(e))))},d=()=>{t.getCommandRun(e.id).then(e=>{if(e!==void 0&&Yp(e)){l(e);return}s=r(d,n)}).catch(u)};s=r(d,n)})}function Yp(e){return e.status===`succeeded`||e.status===`failed`}function Xp(){return(e,t)=>globalThis.setTimeout(e,t)}function Zp(){return e=>{globalThis.clearTimeout(e)}}function Qp(e,t){return t[e.path]}function $p(e){if(e?.hasSessionActivity===!0)return`session`;if(e?.hasTerminalActivity===!0)return`terminal`}function em(e,t,n){return nm(rm(e,t,n))}function tm(e){return nm(Object.values(e??{}))}function nm(e){if(e.some(e=>e.hasSessionActivity))return`session`;if(e.some(e=>e.hasTerminalActivity))return`terminal`}function rm(e,t,n){let r=new Set(t.filter(t=>t.projectId===e.id).map(e=>e.path)),i=new Map;for(let e of r){let t=n[e];t!==void 0&&i.set(t.cwd,t)}for(let t of Object.values(n))(t.cwd===e.path||t.cwd.startsWith(`${e.path}/`))&&i.set(t.cwd,t);return[...i.values()]}function im(e,t=`活跃`){if(e!==void 0)return g`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`}function am(e,t=`活跃`){let n=im(e,t);if(n!==void 0)return g`<span class="action-activity">${n}</span>`}var om=0,sm=120;function cm(e,t={}){if(typeof HTMLElement>`u`||typeof window>`u`||!(e instanceof HTMLElement))return``;let n=e.getBoundingClientRect(),r=t.constrainTo===`viewport`?um():lm(e),i=window.innerWidth,a=window.innerHeight,o=Math.max(0,r.left),s=Math.min(i,r.right),c=Math.max(0,r.top),l=Math.min(a,r.bottom),u=Math.min(n.right,s),d=l-n.bottom-om,f=n.top-c-om;return[...d<sm&&f>d?[`bottom: ${dm(a-n.top+om)};`,`max-height: ${dm(Math.max(0,f))};`]:[`top: ${dm(n.bottom+om)};`,`max-height: ${dm(Math.max(0,d))};`],`right: ${dm(Math.max(0,i-u))};`,`max-width: ${dm(Math.max(0,u-o))};`].join(` `)}function lm(e){let t=e.getRootNode();return typeof ShadowRoot<`u`&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():um()}function um(){return{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function dm(e){return`${String(Math.round(e))}px`}var fm=class{constructor(e){this.host=e,this.menuStyle=``,this.onDocumentClick=e=>{e.composedPath().includes(this.host)||this.close()},e.addController(this)}hostConnected(){document.addEventListener(`click`,this.onDocumentClick)}hostDisconnected(){document.removeEventListener(`click`,this.onDocumentClick)}isOpen(e){return this.openId===e}toggle(e,t){if(this.openId===e){this.close();return}this.menuStyle=cm(t,{constrainTo:`viewport`}),this.openId=e,this.host.requestUpdate()}close(){this.openId===void 0&&this.menuStyle===``||(this.openId=void 0,this.menuStyle=``,this.host.requestUpdate())}closeIfOpenIdMissing(e){this.openId!==void 0&&!e(this.openId)&&this.close()}closeIf(e){e&&this.close()}closeForEscape(e,t){return e.key!==`Escape`||this.openId!==t?!1:(e.preventDefault(),e.stopPropagation(),this.close(),!0)}},pm=[`a[href]`,`button`,`input`,`select`,`textarea`,`summary`,`[role='button']`,`[role='link']`,`[contenteditable='true']`].join(`,`);function mm(e){return e.composedPath().some(e=>hm(e,pm))}function hm(e,t){if(typeof Element<`u`&&e instanceof Element)return e.matches(t);if(!(`matches`in e))return!1;let{matches:n}=e;return typeof n==`function`&&n.call(e,t)===!0}function gm(e,t){mm(e)||t()}function _m(e,t){return mm(e)?!1:e.key===`Enter`||e.key===` `?(e.preventDefault(),t.activate(),!0):e.key===`ArrowUp`?ym(e,()=>{bm(e.currentTarget,-1)}):e.key===`ArrowDown`?ym(e,()=>{bm(e.currentTarget,1)}):e.key===`Home`?ym(e,()=>{xm(e.currentTarget,0)}):e.key===`End`?ym(e,()=>{xm(e.currentTarget,-1)}):e.key===`ArrowLeft`&&t.previousSection!==void 0?ym(e,t.previousSection):e.key===`ArrowRight`&&t.nextSection!==void 0?ym(e,t.nextSection):e.key===`Escape`&&t.cancel!==void 0&&ym(e,t.cancel)}function vm(e,t={}){let n=e.querySelector(`.action-row.selected`)??e.querySelector(`.action-row`)??(t.fallbackSelector===void 0?void 0:e.querySelector(t.fallbackSelector));return n==null?!1:(n.focus(),n.scrollIntoView({block:`nearest`}),!0)}function ym(e,t){return e.preventDefault(),e.stopPropagation?.(),t(),!0}function bm(e,t){let n=Cm(e),r=Tm(e);if(r===void 0||n.length===0)return;let i=n.indexOf(r);i<0||Sm(n,i+t)}function xm(e,t){let n=Cm(e);n.length!==0&&Sm(n,t<0?n.length-1:t)}function Sm(e,t){let n=e[Math.min(Math.max(t,0),e.length-1)];n?.focus(),n?.scrollIntoView({block:`nearest`})}function Cm(e){let t=Tm(e)?.getRootNode();return t===void 0||!wm(t)?[]:Array.from(t.querySelectorAll(`.action-row`))}function wm(e){return typeof Document<`u`&&e instanceof Document||typeof DocumentFragment<`u`&&e instanceof DocumentFragment}function Tm(e){if(!(typeof HTMLElement>`u`||!(e instanceof HTMLElement)))return e.closest(`.action-row`)??void 0}var Em=h`
|
|
370
370
|
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
371
371
|
:host([collapsed]) { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
372
372
|
section { box-sizing: border-box; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px; }
|
package/dist/client/index.html
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--pi-bg); color: var(--pi-text); }
|
|
54
54
|
body { min-height: 100dvh; }
|
|
55
55
|
</style>
|
|
56
|
-
<script type="module" crossorigin src="./assets/index-
|
|
56
|
+
<script type="module" crossorigin src="./assets/index-Jmsbve6u.js"></script>
|
|
57
57
|
<link rel="modulepreload" crossorigin href="./assets/vendor-editor-core-vUi74DnD.js">
|
|
58
58
|
<link rel="modulepreload" crossorigin href="./assets/vendor-editor-languages-DoaXUodB.js">
|
|
59
59
|
</head>
|
package/package.json
CHANGED