@jmfederico/pi-web 1.202606.6 → 1.202606.7
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/README.md +84 -296
- package/dist/cli.js +25 -7
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/CodeViewer-CQU9mJ74.js +4 -0
- package/dist/client/assets/{TerminalPanel-BZKsaE9s.js → TerminalPanel-DtfVBsqI.js} +1 -1
- package/dist/client/assets/UnifiedDiffViewer-BZQQK99S.js +34 -0
- package/dist/client/assets/index-CbE7df66.js +2742 -0
- package/dist/client/assets/{vendor-editor-core-Bc1A7SO7.js → vendor-editor-core-C7aWiQy0.js} +2 -2
- package/dist/client/assets/{vendor-editor-languages-D0CnB2js.js → vendor-editor-languages-EW34FfVy.js} +1 -1
- package/dist/client/index.html +3 -3
- package/dist/config.js +33 -1
- package/dist/config.js.map +1 -1
- package/dist/plugin-api.d.ts +30 -2
- package/dist/server/app.js +16 -4
- package/dist/server/app.js.map +1 -1
- package/dist/server/configRoutes.js +4 -1
- package/dist/server/configRoutes.js.map +1 -1
- package/dist/server/machines/machineClient.js +33 -5
- package/dist/server/machines/machineClient.js.map +1 -1
- package/dist/server/machines/machineProxyRoutes.js +18 -3
- package/dist/server/machines/machineProxyRoutes.js.map +1 -1
- package/dist/server/sessions/attachmentService.js +69 -11
- package/dist/server/sessions/attachmentService.js.map +1 -1
- package/dist/server/sessions/piSessionManagerGateway.js +20 -2
- package/dist/server/sessions/piSessionManagerGateway.js.map +1 -1
- package/dist/server/sessions/piSessionService.js +466 -33
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionCleanup.js +157 -0
- package/dist/server/sessions/sessionCleanup.js.map +1 -0
- package/dist/server/sessions/sessionRoutes.js +17 -0
- package/dist/server/sessions/sessionRoutes.js.map +1 -1
- package/dist/server/sessions/spawnSubsessionTool.js +6 -3
- package/dist/server/sessions/spawnSubsessionTool.js.map +1 -1
- package/dist/server/workspaceExplorerRoutes.js +55 -3
- package/dist/server/workspaceExplorerRoutes.js.map +1 -1
- package/dist/server/workspaces/fileContentService.js +112 -1
- package/dist/server/workspaces/fileContentService.js.map +1 -1
- package/dist/server/workspaces/pathSafety.js +16 -1
- package/dist/server/workspaces/pathSafety.js.map +1 -1
- package/dist/server/workspaces/projectPiWebConfig.js +6 -1
- package/dist/server/workspaces/projectPiWebConfig.js.map +1 -1
- package/dist/shared/apiTypes.d.ts +83 -6
- package/dist/shared/apiTypes.js +1 -0
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/capabilities.js +3 -2
- package/dist/shared/capabilities.js.map +1 -1
- package/dist/shared/federatedRoutes.js +5 -0
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/dist/shared/promptAttachments.js +30 -11
- package/dist/shared/promptAttachments.js.map +1 -1
- package/docs/config.md +40 -3
- package/docs/plugins.md +127 -3
- package/package.json +1 -1
- package/dist/client/assets/CodeViewer-Bv8l_MFi.js +0 -4
- package/dist/client/assets/index-C9oPLpm7.js +0 -2408
|
@@ -0,0 +1,2742 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeViewer-CQU9mJ74.js","assets/vendor-editor-core-C7aWiQy0.js","assets/vendor-editor-languages-EW34FfVy.js","assets/vendor-editor-legacy-B4QLsWF8.js","assets/UnifiedDiffViewer-BZQQK99S.js","assets/TerminalPanel-DtfVBsqI.js","assets/vendor-terminal-DjQ08hXu.js","assets/vendor-terminal-DDGTF8rc.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{Q as Br,v as et,J as as,R as Il,S as Al,G as Ml,U as Tl,V as El,W as Dl,A as Wl,X as Ol,Y as jl,Z as Hr,w as qr,_ as _l}from"./vendor-editor-core-C7aWiQy0.js";import{m as Ll,d as Fl,i as Nl}from"./vendor-editor-languages-EW34FfVy.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const n of o.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&s(n)}).observe(document,{childList:!0,subtree:!0});function i(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=i(r);fetch(r.href,o)}})();const hi=globalThis,er=hi.ShadowRoot&&(hi.ShadyCSS===void 0||hi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,tr=Symbol(),Kr=new WeakMap;let Nn=class{constructor(t,i,s){if(this._$cssResult$=!0,s!==tr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const i=this.t;if(er&&t===void 0){const s=i!==void 0&&i.length===1;s&&(t=Kr.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Kr.set(i,t))}return t}toString(){return this.cssText}};const Ul=e=>new Nn(typeof e=="string"?e:e+"",void 0,tr),O=(e,...t)=>{const i=e.length===1?e[0]:t.reduce((s,r,o)=>s+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[o+1],e[0]);return new Nn(i,e,tr)},zl=(e,t)=>{if(er)e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(const i of t){const s=document.createElement("style"),r=hi.litNonce;r!==void 0&&s.setAttribute("nonce",r),s.textContent=i.cssText,e.appendChild(s)}},Vr=er?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(const s of t.cssRules)i+=s.cssText;return Ul(i)})(e):e;const{is:Bl,defineProperty:Hl,getOwnPropertyDescriptor:ql,getOwnPropertyNames:Kl,getOwnPropertySymbols:Vl,getPrototypeOf:Gl}=Object,qi=globalThis,Gr=qi.trustedTypes,Ql=Gr?Gr.emptyScript:"",Jl=qi.reactiveElementPolyfillSupport,Nt=(e,t)=>e,Si={toAttribute(e,t){switch(t){case Boolean:e=e?Ql:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},ir=(e,t)=>!Bl(e,t),Qr={attribute:!0,type:String,converter:Si,reflect:!1,useDefault:!1,hasChanged:ir};Symbol.metadata??=Symbol("metadata"),qi.litPropertyMetadata??=new WeakMap;let vt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,i=Qr){if(i.state&&(i.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((i=Object.create(i)).wrapped=!0),this.elementProperties.set(t,i),!i.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(t,s,i);r!==void 0&&Hl(this.prototype,t,r)}}static getPropertyDescriptor(t,i,s){const{get:r,set:o}=ql(this.prototype,t)??{get(){return this[i]},set(n){this[i]=n}};return{get:r,set(n){const a=r?.call(this);o?.call(this,n),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Qr}static _$Ei(){if(this.hasOwnProperty(Nt("elementProperties")))return;const t=Gl(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Nt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Nt("properties"))){const i=this.properties,s=[...Kl(i),...Vl(i)];for(const r of s)this.createProperty(r,i[r])}const t=this[Symbol.metadata];if(t!==null){const i=litPropertyMetadata.get(t);if(i!==void 0)for(const[s,r]of i)this.elementProperties.set(s,r)}this._$Eh=new Map;for(const[i,s]of this.elementProperties){const r=this._$Eu(i,s);r!==void 0&&this._$Eh.set(r,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const r of s)i.unshift(Vr(r))}else t!==void 0&&i.push(Vr(t));return i}static _$Eu(t,i){const s=i.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.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(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,i=this.constructor.elementProperties;for(const s of i.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return zl(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,i,s){this._$AK(t,s)}_$ET(t,i){const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(r!==void 0&&s.reflect===!0){const o=(s.converter?.toAttribute!==void 0?s.converter:Si).toAttribute(i,s.type);this._$Em=t,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,i){const s=this.constructor,r=s._$Eh.get(t);if(r!==void 0&&this._$Em!==r){const o=s.getPropertyOptions(r),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Si;this._$Em=r;const a=n.fromAttribute(i,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(t,i,s,r=!1,o){if(t!==void 0){const n=this.constructor;if(r===!1&&(o=this[t]),s??=n.getPropertyOptions(t),!((s.hasChanged??ir)(o,i)||s.useDefault&&s.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,i,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,i,{useDefault:s,reflect:r,wrapped:o},n){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??i??this[t]),o!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(i=void 0),this._$AL.set(t,i)),r===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:n}=o,a=this[r];n!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(i)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(i)}willUpdate(t){}_$AE(t){this._$EO?.forEach(i=>i.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(i=>this._$ET(i,this[i])),this._$EM()}updated(t){}firstUpdated(t){}};vt.elementStyles=[],vt.shadowRootOptions={mode:"open"},vt[Nt("elementProperties")]=new Map,vt[Nt("finalized")]=new Map,Jl?.({ReactiveElement:vt}),(qi.reactiveElementVersions??=[]).push("2.1.2");const sr=globalThis,Jr=e=>e,ki=sr.trustedTypes,Zr=ki?ki.createPolicy("lit-html",{createHTML:e=>e}):void 0,Un="$lit$",Ge=`lit$${Math.random().toFixed(9).slice(2)}$`,zn="?"+Ge,Zl=`<${zn}>`,lt=document,zt=()=>lt.createComment(""),Bt=e=>e===null||typeof e!="object"&&typeof e!="function",rr=Array.isArray,Xl=e=>rr(e)||typeof e?.[Symbol.iterator]=="function",ls=`[
|
|
3
|
+
\f\r]`,It=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Xr=/-->/g,Yr=/>/g,tt=RegExp(`>|${ls}(?:([^\\s"'>=/]+)(${ls}*=${ls}*(?:[^
|
|
4
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),eo=/'/g,to=/"/g,Bn=/^(?:script|style|textarea|title)$/i,Hn=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),l=Hn(1),be=Hn(2),Ze=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),io=new WeakMap,ot=lt.createTreeWalker(lt,129);function qn(e,t){if(!rr(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zr!==void 0?Zr.createHTML(t):t}const Yl=(e,t)=>{const i=e.length-1,s=[];let r,o=t===2?"<svg>":t===3?"<math>":"",n=It;for(let a=0;a<i;a++){const c=e[a];let p,u,h=-1,f=0;for(;f<c.length&&(n.lastIndex=f,u=n.exec(c),u!==null);)f=n.lastIndex,n===It?u[1]==="!--"?n=Xr:u[1]!==void 0?n=Yr:u[2]!==void 0?(Bn.test(u[2])&&(r=RegExp("</"+u[2],"g")),n=tt):u[3]!==void 0&&(n=tt):n===tt?u[0]===">"?(n=r??It,h=-1):u[1]===void 0?h=-2:(h=n.lastIndex-u[2].length,p=u[1],n=u[3]===void 0?tt:u[3]==='"'?to:eo):n===to||n===eo?n=tt:n===Xr||n===Yr?n=It:(n=tt,r=void 0);const b=n===tt&&e[a+1].startsWith("/>")?" ":"";o+=n===It?c+Zl:h>=0?(s.push(p),c.slice(0,h)+Un+c.slice(h)+Ge+b):c+Ge+(h===-2?a:b)}return[qn(e,o+(e[i]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class Ht{constructor({strings:t,_$litType$:i},s){let r;this.parts=[];let o=0,n=0;const a=t.length-1,c=this.parts,[p,u]=Yl(t,i);if(this.el=Ht.createElement(p,s),ot.currentNode=this.el.content,i===2||i===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(r=ot.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const h of r.getAttributeNames())if(h.endsWith(Un)){const f=u[n++],b=r.getAttribute(h).split(Ge),P=/([.?@])?(.*)/.exec(f);c.push({type:1,index:o,name:P[2],strings:b,ctor:P[1]==="."?tc:P[1]==="?"?ic:P[1]==="@"?sc:Ki}),r.removeAttribute(h)}else h.startsWith(Ge)&&(c.push({type:6,index:o}),r.removeAttribute(h));if(Bn.test(r.tagName)){const h=r.textContent.split(Ge),f=h.length-1;if(f>0){r.textContent=ki?ki.emptyScript:"";for(let b=0;b<f;b++)r.append(h[b],zt()),ot.nextNode(),c.push({type:2,index:++o});r.append(h[f],zt())}}}else if(r.nodeType===8)if(r.data===zn)c.push({type:2,index:o});else{let h=-1;for(;(h=r.data.indexOf(Ge,h+1))!==-1;)c.push({type:7,index:o}),h+=Ge.length-1}o++}}static createElement(t,i){const s=lt.createElement("template");return s.innerHTML=t,s}}function xt(e,t,i=e,s){if(t===Ze)return t;let r=s!==void 0?i._$Co?.[s]:i._$Cl;const o=Bt(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,i,s)),s!==void 0?(i._$Co??=[])[s]=r:i._$Cl=r),r!==void 0&&(t=xt(e,r._$AS(e,t.values),r,s)),t}class ec{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,r=(t?.creationScope??lt).importNode(i,!0);ot.currentNode=r;let o=ot.nextNode(),n=0,a=0,c=s[0];for(;c!==void 0;){if(n===c.index){let p;c.type===2?p=new $t(o,o.nextSibling,this,t):c.type===1?p=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(p=new rc(o,this,t)),this._$AV.push(p),c=s[++a]}n!==c?.index&&(o=ot.nextNode(),n++)}return ot.currentNode=lt,r}p(t){let i=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class $t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,r){this.type=2,this._$AH=U,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return i!==void 0&&t?.nodeType===11&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=xt(this,t,i),Bt(t)?t===U||t==null||t===""?(this._$AH!==U&&this._$AR(),this._$AH=U):t!==this._$AH&&t!==Ze&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Xl(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==U&&Bt(this._$AH)?this._$AA.nextSibling.data=t:this.T(lt.createTextNode(t)),this._$AH=t}$(t){const{values:i,_$litType$:s}=t,r=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=Ht.createElement(qn(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===r)this._$AH.p(i);else{const o=new ec(r,this),n=o.u(this.options);o.p(i),this.T(n),this._$AH=o}}_$AC(t){let i=io.get(t.strings);return i===void 0&&io.set(t.strings,i=new Ht(t)),i}k(t){rr(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,r=0;for(const o of t)r===i.length?i.push(s=new $t(this.O(zt()),this.O(zt()),this,this.options)):s=i[r],s._$AI(o),r++;r<i.length&&(this._$AR(s&&s._$AB.nextSibling,r),i.length=r)}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t!==this._$AB;){const s=Jr(t).nextSibling;Jr(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}let Ki=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,r,o){this.type=1,this._$AH=U,this._$AN=void 0,this.element=t,this.name=i,this._$AM=r,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=U}_$AI(t,i=this,s,r){const o=this.strings;let n=!1;if(o===void 0)t=xt(this,t,i,0),n=!Bt(t)||t!==this._$AH&&t!==Ze,n&&(this._$AH=t);else{const a=t;let c,p;for(t=o[0],c=0;c<o.length-1;c++)p=xt(this,a[s+c],i,c),p===Ze&&(p=this._$AH[c]),n||=!Bt(p)||p!==this._$AH[c],p===U?t=U:t!==U&&(t+=(p??"")+o[c+1]),this._$AH[c]=p}n&&!r&&this.j(t)}j(t){t===U?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},tc=class extends Ki{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===U?void 0:t}},ic=class extends Ki{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==U)}},sc=class extends Ki{constructor(t,i,s,r,o){super(t,i,s,r,o),this.type=5}_$AI(t,i=this){if((t=xt(this,t,i,0)??U)===Ze)return;const s=this._$AH,r=t===U&&s!==U||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==U&&(s===U||r);r&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},rc=class{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){xt(this,t)}};const oc={I:$t},nc=sr.litHtmlPolyfillSupport;nc?.(Ht,$t),(sr.litHtmlVersions??=[]).push("3.3.3");const ac=(e,t,i)=>{const s=i?.renderBefore??t;let r=s._$litPart$;if(r===void 0){const o=i?.renderBefore??null;s._$litPart$=r=new $t(t.insertBefore(zt(),o),o,void 0,i??{})}return r._$AI(e),r};const or=globalThis;let M=class extends vt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ac(i,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Ze}};M._$litElement$=!0,M.finalized=!0,or.litElementHydrateSupport?.({LitElement:M});const lc=or.litElementPolyfillSupport;lc?.({LitElement:M});(or.litElementVersions??=[]).push("4.2.2");const D=e=>(t,i)=>{i!==void 0?i.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const cc={attribute:!0,type:String,converter:Si,reflect:!1,hasChanged:ir},dc=(e=cc,t,i)=>{const{kind:s,metadata:r}=i;let o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(i.name,e),s==="accessor"){const{name:n}=i;return{set(a){const c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(s==="setter"){const{name:n}=i;return function(a){const c=this[n];t.call(this,a),this.requestUpdate(n,c,e,!0,a)}}throw Error("Unsupported decorator location: "+s)};function d(e){return(t,i)=>typeof i=="object"?dc(e,t,i):((s,r,o)=>{const n=r.hasOwnProperty(o);return r.constructor.createProperty(o,s),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,i)}function v(e){return d({...e,state:!0,attribute:!1})}const pc=(e,t,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,i),i);function z(e,t){return(i,s,r)=>{const o=n=>n.renderRoot?.querySelector(e)??null;return pc(i,s,{get(){return o(this)}})}}async function x(e,t,i){const s=new Headers(i?.headers);i?.body!==void 0&&!s.has("content-type")&&s.set("content-type","application/json");const r=await fetch(e,{...i,headers:s});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(hc(n)??r.statusText)}const o=await r.json();return t(o)}function hc(e){if(uc(e))return typeof e.error=="string"?e.error:void 0}function uc(e){return typeof e=="object"&&e!==null}const Qe={sessionsDeleteArchived:"sessions.deleteArchived",sessionsCleanup:"sessions.cleanup",sessionsReload:"sessions.reload",promptAttachments:"prompt.attachments",workspaceFileSuggestions:"workspace.fileSuggestions"},fc=Object.values(Qe),gc=new Set(fc);function mc(e){return typeof e=="string"&&gc.has(e)}function nt(e,t){return e?.capabilities?.includes(t)===!0}function Je(e){return typeof e=="object"&&e!==null}function y(e){if(!Je(e))throw new Error("Expected object response");return e}function m(e,t){const i=e[t];if(typeof i!="string")throw new Error(`Expected string field: ${t}`);return i}function $(e,t){const i=e[t];if(i!==void 0){if(typeof i!="string")throw new Error(`Expected optional string field: ${t}`);return i}}function q(e,t){const i=e[t];if(typeof i!="number")throw new Error(`Expected number field: ${t}`);return i}function E(e,t){const i=e[t];if(typeof i!="boolean")throw new Error(`Expected boolean field: ${t}`);return i}function F(e){return t=>{if(!Array.isArray(t))throw new Error("Expected array response");return t.map(e)}}function vc(e){if(!Array.isArray(e))throw new Error("Expected array response");return e}function $i(e,t){if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))throw new Error(`Expected string array field: ${t}`);return e}function bc(e){if(Array.isArray(e))return{messages:e,start:0,total:e.length};const t=y(e);return{messages:vc(t.messages),start:q(t,"start"),total:q(t,"total")}}function wc(e){const t=y(e);return F(Kn)(t.machines)}function Kn(e){const t=y(e),i=Sc(t,"kind"),s=$(t,"baseUrl"),r=Vn(t,"status"),o=$(t,"statusMessage");return{id:m(t,"id"),name:m(t,"name"),kind:i,...s===void 0?{}:{baseUrl:s},createdAt:m(t,"createdAt"),updatedAt:m(t,"updatedAt"),...r===void 0?{}:{status:r},...o===void 0?{}:{statusMessage:o}}}function yc(e){const t=y(e),i=Vn(t,"status"),s=$(t,"error");return{machineId:m(t,"machineId"),ok:E(t,"ok"),checkedAt:m(t,"checkedAt"),...i===void 0?{}:{status:i},...t.web===void 0?{}:{web:Pi(t.web)},...t.sessiond===void 0?{}:{sessiond:Pi(t.sessiond)},...s===void 0?{}:{error:s}}}function xc(e){const t=y(e),i=$(t,"error");return{machineId:m(t,"machineId"),ok:E(t,"ok"),checkedAt:m(t,"checkedAt"),...w("packageName",$(t,"packageName")),...w("generatedAt",$(t,"generatedAt")),...t.components===void 0?{}:{components:Xn(t.components)},...t.capabilities===void 0?{}:{capabilities:nr(t.capabilities)},...i===void 0?{}:{error:i}}}function Sc(e,t){const i=m(e,t);if(i!=="local"&&i!=="remote")throw new Error(`Expected machine kind field: ${t}`);return i}function Vn(e,t){const i=$(e,t);if(i!==void 0){if(i!=="unknown"&&i!=="online"&&i!=="offline"&&i!=="error")throw new Error(`Expected machine status field: ${t}`);return i}}function so(e){const t=y(e);return{id:m(t,"id"),name:m(t,"name"),path:m(t,"path"),createdAt:m(t,"createdAt")}}function kc(e){const t=y(e),i=$(t,"branch");return{id:m(t,"id"),projectId:m(t,"projectId"),path:m(t,"path"),label:m(t,"label"),...i===void 0?{}:{branch:i},isMain:E(t,"isMain"),isGitRepo:E(t,"isGitRepo"),isGitWorktree:E(t,"isGitWorktree"),...w("effectiveConfig",$c(t.effectiveConfig))}}function $c(e){if(e!==void 0){if(!Je(e)||Array.isArray(e))throw new Error("Invalid workspace effectiveConfig field");return{...w("uploads",Zn(e.uploads))}}}function Ws(e){const t=y(e),i=$(t,"name"),s=$(t,"parentSessionPath"),r=$(t,"archivedAt");return{id:m(t,"id"),path:m(t,"path"),cwd:m(t,"cwd"),...i===void 0?{}:{name:i},created:m(t,"created"),modified:m(t,"modified"),messageCount:q(t,"messageCount"),firstMessage:m(t,"firstMessage"),...s===void 0?{}:{parentSessionPath:s},...t.archived===!0?{archived:!0}:{},...r===void 0?{}:{archivedAt:r}}}function At(e){const t=y(e);return{sessionId:m(t,"sessionId"),isStreaming:E(t,"isStreaming"),isCompacting:E(t,"isCompacting"),isBashRunning:E(t,"isBashRunning"),pendingMessageCount:q(t,"pendingMessageCount"),queuedMessages:t.queuedMessages===void 0?[]:F(Ac)(t.queuedMessages),...w("messageCount",ue(t,"messageCount")),tokens:Mc(t.tokens),cost:q(t,"cost"),...Tc(t.model),...Hc(t.contextUsage),...w("thinkingLevel",$(t,"thinkingLevel"))}}function Gn(e){const t=y(e),i=t.skippedBusySessionIds===void 0?void 0:$i(t.skippedBusySessionIds,"skippedBusySessionIds");return{generatedAt:m(t,"generatedAt"),thresholds:Cc(t.thresholds),projects:F(Rc)(t.projects),totals:Ic(t.totals),...i===void 0?{}:{skippedBusySessionIds:i}}}function Pc(e){const t=y(e);return{...Gn(t),archivedSessionIds:$i(t.archivedSessionIds,"archivedSessionIds"),deletedSessionIds:$i(t.deletedSessionIds,"deletedSessionIds")}}function Cc(e){const t=y(e);return{...w("archiveIdleDays",ue(t,"archiveIdleDays")),...w("deleteArchivedDays",ue(t,"deleteArchivedDays"))}}function Rc(e){const t=y(e);return{cwd:m(t,"cwd"),archiveCount:q(t,"archiveCount"),deleteCount:q(t,"deleteCount")}}function Ic(e){const t=y(e);return{archiveCount:q(t,"archiveCount"),deleteCount:q(t,"deleteCount")}}function Ac(e){const t=y(e),i=m(t,"kind");if(i!=="steer"&&i!=="followUp")throw new Error("Invalid queued message kind");return{kind:i,text:m(t,"text")}}function Mc(e){const t=y(e);return{input:q(t,"input"),output:q(t,"output"),cacheRead:q(t,"cacheRead"),cacheWrite:q(t,"cacheWrite"),total:q(t,"total")}}function Qn(e){const t=y(e);return{...w("provider",$(t,"provider")),...w("id",$(t,"id")),...w("name",$(t,"name")),...w("contextWindow",ue(t,"contextWindow")),...w("reasoning",t.reasoning)}}function Tc(e){return e===void 0?{}:{model:Qn(e)}}function Ec(e){const t=y(e);return{models:F(Qn)(t.models)}}function Dc(e){if(typeof e!="string")throw new Error("Invalid thinking level");return e}function Wc(e){const t=y(e);return{levels:F(Dc)(t.levels)}}function Oc(e){if(e!=="oauth"&&e!=="api_key")throw new Error("Invalid auth type");return e}function jc(e){if(e!=="stored"&&e!=="runtime"&&e!=="environment"&&e!=="fallback"&&e!=="models_json_key"&&e!=="models_json_command")throw new Error("Invalid auth status source");return e}function _c(e){const t=y(e),i=t.source===void 0?void 0:jc(t.source);return{configured:E(t,"configured"),...w("source",i),...w("label",$(t,"label"))}}function Lc(e){const t=y(e);return{id:m(t,"id"),name:m(t,"name"),authType:Oc(t.authType),status:_c(t.status)}}function Fc(e){const t=y(e);return{providers:F(Lc)(t.providers)}}function ti(e){const t=y(e);return{flowId:m(t,"flowId"),providerId:m(t,"providerId"),providerName:m(t,"providerName"),status:Nc(t.status),progress:F(s=>{if(typeof s!="string")throw new Error("Expected progress item string");return s})(t.progress),...w("error",$(t,"error")),...w("auth",Uc(t.auth)),...w("prompt",zc(t.prompt)),...w("select",Bc(t.select))}}function Nc(e){if(e!=="running"&&e!=="complete"&&e!=="error"&&e!=="cancelled")throw new Error("Invalid OAuth flow status");return e}function Uc(e){if(e===void 0)return;const t=y(e);return{url:m(t,"url"),...w("instructions",$(t,"instructions"))}}function zc(e){if(e===void 0)return;const t=y(e),i=m(t,"kind");if(i!=="prompt"&&i!=="manual")throw new Error("Invalid OAuth prompt kind");return{requestId:m(t,"requestId"),message:m(t,"message"),kind:i,...w("placeholder",$(t,"placeholder")),...t.allowEmpty===!0?{allowEmpty:!0}:{}}}function Bc(e){if(e===void 0)return;const t=y(e);return{requestId:m(t,"requestId"),message:m(t,"message"),options:F(ea)(t.options)}}function Hc(e){if(e===void 0)return{};const t=y(e);return{contextUsage:{tokens:ho(t,"tokens"),contextWindow:q(t,"contextWindow"),percent:ho(t,"percent")}}}function qc(e){const t=y(e),i=m(t,"source");if(i!=="extension"&&i!=="prompt"&&i!=="skill"&&i!=="builtin")throw new Error("Invalid command source");return{name:m(t,"name"),source:i,...w("description",$(t,"description"))}}function Os(e){const t=y(e),i=m(t,"kind");if(i!=="tracked"&&i!=="untracked"&&i!=="other")throw new Error("Invalid file kind");return{path:m(t,"path"),kind:i}}function Kc(e){const t=y(e);return{path:m(t,"path"),entries:F(Vc)(t.entries),scannedAt:m(t,"scannedAt"),truncated:E(t,"truncated")}}function Vc(e){const t=y(e),i=m(t,"type");if(i!=="file"&&i!=="directory"&&i!=="symlink")throw new Error("Invalid file tree entry type");return{name:m(t,"name"),path:m(t,"path"),type:i,...w("size",ue(t,"size")),...w("modifiedAt",$(t,"modifiedAt"))}}function Gc(e){const t=y(e),i=m(t,"encoding");if(i!=="utf8")throw new Error("Invalid file encoding");return{path:m(t,"path"),...w("language",$(t,"language")),...w("mediaType",Zc(t.mediaType)),...w("mimeType",$(t,"mimeType")),encoding:i,size:q(t,"size"),modifiedAt:m(t,"modifiedAt"),content:m(t,"content"),truncated:E(t,"truncated"),binary:E(t,"binary")}}function Jn(e){const t=y(e);return{path:m(t,"path"),size:q(t,"size"),modifiedAt:m(t,"modifiedAt"),created:E(t,"created")}}function Qc(e){const t=y(e);return{path:m(t,"path"),existed:E(t,"existed")}}function Jc(e){const t=y(e);return{fromPath:m(t,"fromPath"),toPath:m(t,"toPath"),size:q(t,"size"),modifiedAt:m(t,"modifiedAt")}}function Zc(e){if(e!==void 0){if(e!=="image")throw new Error("Invalid file media type");return e}}function Xc(e){const t=y(e);return{isGitRepo:E(t,"isGitRepo"),hash:m(t,"hash"),...w("branch",$(t,"branch")),...w("upstream",$(t,"upstream")),...w("ahead",ue(t,"ahead")),...w("behind",ue(t,"behind")),files:F(Yc)(t.files)}}function Yc(e){const t=y(e);return{path:m(t,"path"),...w("oldPath",$(t,"oldPath")),index:ro(t.index),workingTree:ro(t.workingTree)}}function ro(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 new Error("Invalid git file state")}}function ed(e){const t=y(e);return{...w("path",$(t,"path")),staged:E(t,"staged"),hash:m(t,"hash"),diff:m(t,"diff"),truncated:E(t,"truncated")}}function cs(e){const t=y(e);return{id:m(t,"id"),cwd:m(t,"cwd"),name:m(t,"name"),createdAt:m(t,"createdAt"),exited:E(t,"exited"),...w("exitCode",ue(t,"exitCode")),...w("commandRunId",$(t,"commandRunId"))}}function Ut(e){const t=y(e);return{id:m(t,"id"),origin:m(t,"origin"),projectId:m(t,"projectId"),workspaceId:m(t,"workspaceId"),terminalId:m(t,"terminalId"),title:m(t,"title"),command:m(t,"command"),status:td(t.status),...w("exitCode",ue(t,"exitCode")),createdAt:m(t,"createdAt"),...w("startedAt",$(t,"startedAt")),...w("completedAt",$(t,"completedAt")),metadata:id(t.metadata,"metadata")}}function td(e){if(e!=="queued"&&e!=="running"&&e!=="succeeded"&&e!=="failed")throw new Error("Invalid terminal command run status");return e}function id(e,t){const i=y(e);return Object.fromEntries(Object.entries(i).map(([s,r])=>{if(typeof r!="string")throw new Error(`Expected string record field: ${t}.${s}`);return[s,r]}))}function sd(e){const t=y(e);return{cwd:m(t,"cwd"),hasSessionActivity:E(t,"hasSessionActivity"),hasTerminalActivity:E(t,"hasTerminalActivity"),updatedAt:m(t,"updatedAt")}}function rd(e){const t=y(e);return{workspaces:F(sd)(t.workspaces),generatedAt:m(t,"generatedAt")}}function oo(e){const t=y(e);return{path:m(t,"path"),exists:E(t,"exists"),config:no(t.config),effectiveConfig:no(t.effectiveConfig),envOverrides:hd(t.envOverrides)}}function no(e){const t=y(e);return{...w("host",$(t,"host")),...w("port",ue(t,"port")),...w("allowedHosts",od(t.allowedHosts)),...w("shortcuts",dd(t.shortcuts)),...w("plugins",pd(t.plugins)),...w("pathAccess",nd(t.pathAccess)),...w("uploads",Zn(t.uploads)),...w("maxUploadBytes",ue(t,"maxUploadBytes")),...w("spawnSessions",po(t,"spawnSessions")),...w("subsessions",po(t,"subsessions"))}}function od(e){if(e!==void 0){if(e===!0)return!0;if(ld(e))return e;throw new Error("Invalid PI WEB allowedHosts field")}}function nd(e){if(e===void 0)return;if(!Je(e))throw new Error("Invalid PI WEB pathAccess field");const t=e.allowedPaths;return{...w("allowedPaths",ad(t,"pathAccess.allowedPaths"))}}function ad(e,t){if(e!==void 0){if(cd(e))return e;throw new Error(`Invalid PI WEB ${t} field`)}}function Zn(e){if(e!==void 0){if(!Je(e)||Array.isArray(e))throw new Error("Invalid PI WEB uploads field");return{...w("defaultFolder",$(e,"defaultFolder"))}}}function ld(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function cd(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t!=="")}function dd(e){if(e!==void 0){if(!Je(e)||Array.isArray(e))throw new Error("Invalid PI WEB shortcuts field");return Object.fromEntries(Object.entries(e).map(([t,i])=>{if(i!==null&&(typeof i!="string"||i===""))throw new Error("Invalid PI WEB shortcut field");return[t,i]}))}}function pd(e){if(e!==void 0){if(!Je(e)||Array.isArray(e))throw new Error("Invalid PI WEB plugins field");return Object.fromEntries(Object.entries(e).map(([t,i])=>{if(!Je(i)||Array.isArray(i))throw new Error("Invalid PI WEB plugin config field");const s=i.enabled;if(s!==void 0&&typeof s!="boolean")throw new Error("Invalid PI WEB plugin enabled field");const r=i.settings;if(r!==void 0&&(!Je(r)||Array.isArray(r)))throw new Error("Invalid PI WEB plugin settings field");return[t,i]}))}}function hd(e){const t=y(e);return{host:E(t,"host"),port:E(t,"port"),allowedHosts:E(t,"allowedHosts"),spawnSessions:E(t,"spawnSessions"),subsessions:E(t,"subsessions")}}function ud(e){const t=y(e);return{plugins:F(fd)(t.plugins)}}function fd(e){const t=y(e);return{id:m(t,"id"),module:m(t,"module"),source:m(t,"source"),scope:gd(t.scope),machineSpecific:md(t.machineSpecific,"machineSpecific")??!1,enabled:E(t,"enabled")}}function gd(e){if(e!=="bundled"&&e!=="local"&&e!=="user"&&e!=="project")throw new Error("Invalid PI WEB plugin scope");return e}function md(e,t){if(e!==void 0){if(typeof e!="boolean")throw new Error(`Expected optional boolean field: ${t}`);return e}}function vd(e){const t=y(e);return{packageName:m(t,"packageName"),generatedAt:m(t,"generatedAt"),components:wd(t.components),release:xd(t.release),commands:Sd(t.commands),messages:F(kd)(t.messages)}}function bd(e){const t=y(e);return{packageName:m(t,"packageName"),generatedAt:m(t,"generatedAt"),components:Xn(t.components),capabilities:nr(t.capabilities)}}function wd(e){const t=y(e);return{web:Pi(t.web),sessiond:Pi(t.sessiond)}}function Xn(e){const t=y(e);return{web:ao(t.web),sessiond:ao(t.sessiond)}}function ao(e){const t=y(e);return{component:Yn(t.component),label:m(t,"label"),...w("runtimeVersion",$(t,"runtimeVersion")),available:E(t,"available"),capabilities:nr(t.capabilities),...w("error",$(t,"error"))}}function Pi(e){const t=y(e);return{component:Yn(t.component),label:m(t,"label"),...w("runtimeVersion",$(t,"runtimeVersion")),...w("installedVersion",$(t,"installedVersion")),stale:E(t,"stale"),available:E(t,"available"),...w("installation",yd(t.installation)),...w("error",$(t,"error"))}}function yd(e){if(e===void 0)return;const t=y(e),i=m(t,"kind");if(i!=="pi-package"&&i!=="npm-global"&&i!=="local"&&i!=="unknown")throw new Error("Invalid PI WEB installation kind");const s=t.scope;if(s!==void 0&&s!=="user"&&s!=="project")throw new Error("Invalid PI WEB installation scope");return{kind:i,...w("path",$(t,"path")),...w("source",$(t,"source")),...s===void 0?{}:{scope:s},...w("npmRoot",$(t,"npmRoot"))}}function xd(e){const t=y(e);return{packageName:m(t,"packageName"),...w("latestVersion",$(t,"latestVersion")),updateAvailable:E(t,"updateAvailable"),...w("checkedAt",$(t,"checkedAt")),...t.skipped===!0?{skipped:!0}:{},...w("error",$(t,"error"))}}function Sd(e){const t=y(e);return{...w("update",$(t,"update")),...w("restart",$(t,"restart")),...w("restartWeb",$(t,"restartWeb")),...w("restartSessiond",$(t,"restartSessiond")),...w("status",$(t,"status"))}}function kd(e){const t=y(e);return{id:m(t,"id"),severity:$d(t.severity),title:m(t,"title"),body:m(t,"body"),...w("command",$(t,"command"))}}function Yn(e){if(e!=="web"&&e!=="sessiond")throw new Error("Invalid PI WEB service component");return e}function nr(e){if(!Array.isArray(e)||!e.every(mc))throw new Error("Invalid PI WEB capabilities");return e}function $d(e){if(e!=="info"&&e!=="warning"&&e!=="error")throw new Error("Invalid PI WEB status severity");return e}function lo(e){const t=y(e),i=m(t,"type");if(i==="unsupported")return{type:i,message:m(t,"message")};if(i==="select")return{type:i,requestId:m(t,"requestId"),title:m(t,"title"),options:F(ea)(t.options)};if(i==="done")return{type:i,...w("message",$(t,"message")),...Pd(t.session),...w("promptDraft",$(t,"promptDraft"))};throw new Error("Invalid command result type")}function ea(e){const t=y(e);return{value:m(t,"value"),label:m(t,"label"),...w("description",$(t,"description"))}}function Pd(e){return e===void 0?{}:{session:Ws(e)}}function ii(e){if(y(e).accepted!==!0)throw new Error("Expected accepted response");return{accepted:!0}}function Cd(e){const t=y(e);return F(Rd)(t.attachments)}function Rd(e){const t=y(e);return{path:m(t,"path"),mimeType:m(t,"mimeType"),size:q(t,"size")}}function js(e){if(y(e).closed!==!0)throw new Error("Expected closed response");return{closed:!0}}function Id(e){if(y(e).aborted!==!0)throw new Error("Expected aborted response");return{aborted:!0}}function Ad(e){if(y(e).stopped!==!0)throw new Error("Expected stopped response");return{stopped:!0}}function co(e){const t=y(e);if(t.archived!==!0)throw new Error("Expected archived response");const i=t.sessionIds===void 0?void 0:$i(t.sessionIds,"sessionIds"),s=ue(t,"archivedCount"),r=ue(t,"skippedAlreadyArchivedCount");return{archived:!0,...i===void 0?{}:{sessionIds:i},...s===void 0?{}:{archivedCount:s},...r===void 0?{}:{skippedAlreadyArchivedCount:r}}}function Md(e){if(y(e).restored!==!0)throw new Error("Expected restored response");return{restored:!0}}function Td(e){if(y(e).deleted!==!0)throw new Error("Expected deleted response");return{deleted:!0}}function Ed(e){if(y(e).detached!==!0)throw new Error("Expected detached response");return{detached:!0}}function Dd(e){if(y(e).reloaded!==!0)throw new Error("Expected reloaded response");return{reloaded:!0}}function po(e,t){const i=e[t];if(i!==void 0){if(typeof i!="boolean")throw new Error(`Invalid PI WEB ${t} field`);return i}}function ue(e,t){const i=e[t];if(i!==void 0){if(typeof i!="number")throw new Error(`Expected optional number field: ${t}`);return i}}function ho(e,t){const i=e[t];if(i===null)return null;if(typeof i!="number")throw new Error(`Expected number|null field: ${t}`);return i}function w(e,t){return t===void 0?{}:{[e]:t}}function Wd(e){return typeof e=="string"?e:e.id}function Od(e){return typeof e=="string"?void 0:e.cwd}function jd(e,t,i,s){const r=new URLSearchParams;s?.path!==void 0&&r.set("path",s.path),s?.staged===!0&&r.set("staged","true");const o=r.toString();return`/api/machines/${encodeURIComponent(e)}/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(i)}/git/diff${o?`?${o}`:""}`}function _d(e,t,i="local"){const s=new URLSearchParams,r=Od(e);r!==void 0&&r!==""&&s.set("cwd",r),t?.limit!==void 0&&s.set("limit",String(t.limit)),t?.before!==void 0&&s.set("before",String(t.before));const o=s.toString();return`/api/machines/${encodeURIComponent(i)}/sessions/${encodeURIComponent(Wd(e))}/messages${o===""?"":`?${o}`}`}function Ld(e,t,i,s){const r=new URLSearchParams({path:i});return s?.createDirs===!1&&r.set("createDirs","false"),s?.overwrite===!1&&r.set("overwrite","false"),`${`/api/machines/${encodeURIComponent(s?.machineId??"local")}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${r.toString()}`}function Fd(e,t,i,s){const r=new URLSearchParams;return r.set("path",i),s?.modifiedAt!==void 0&&r.set("v",s.modifiedAt),`${`/api/machines/${encodeURIComponent(s?.machineId??"local")}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${r.toString()}`}const I=(e="local")=>`/api/machines/${encodeURIComponent(e)}`;function Nd(e){return typeof e=="string"?e:e.id}function ta(e){return typeof e=="string"?void 0:e.cwd}function ia(e,t="local"){return`${I(t)}/sessions/${encodeURIComponent(Nd(e))}`}function Q(e,t,i="local"){return`${ia(e,i)}/${t}`}function si(e,t,i="local"){return`${Q(e,t,i)}${sa(e)}`}function Ud(e,t="local"){return`${ia(e,t)}${sa(e)}`}function sa(e){const t=ta(e);return t===void 0||t===""?"":`?${new URLSearchParams({cwd:t}).toString()}`}function X(e,t={}){const i=ta(e);return JSON.stringify(i===void 0||i===""?t:{cwd:i,...t})}const ra={piWebStatus:(e="local")=>x(e==="local"?"/api/pi-web/status":`${I(e)}/pi-web/status`,vd),piWebRuntime:()=>x("/api/pi-web/runtime",bd)},zd={machines:()=>x("/api/machines",wc),addMachine:e=>x("/api/machines",Kn,{method:"POST",body:JSON.stringify(e)}),deleteMachine:e=>x(`/api/machines/${encodeURIComponent(e)}`,t=>t,{method:"DELETE"}),health:e=>x(`/api/machines/${encodeURIComponent(e)}/health`,yc),runtime:e=>x(`/api/machines/${encodeURIComponent(e)}/runtime`,xc)},Ci={config:()=>x("/api/config",oo),saveConfig:e=>x("/api/config",oo,{method:"PUT",body:JSON.stringify({config:e})})},_s={plugins:()=>x("/api/plugins",ud)},oa={workspaceActivity:(e="local")=>x(`${I(e)}/activity`,rd)},Bd={projects:(e="local")=>x(`${I(e)}/projects`,F(so)),addProject:(e,t,i,s="local")=>x(`${I(s)}/projects`,so,{method:"POST",body:JSON.stringify({path:e,name:t,create:i})}),closeProject:(e,t="local")=>x(`${I(t)}/projects/${encodeURIComponent(e)}`,js,{method:"DELETE"}),projectDirectories:(e,t="local")=>x(`${I(t)}/project-directories?q=${encodeURIComponent(e)}`,F(Os))},bt={workspaces:(e,t="local")=>x(`${I(t)}/projects/${e}/workspaces`,F(kc)),deleteWorkspace:(e,t,i="local")=>x(`${I(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}`,Ut,{method:"DELETE"}),workspaceTree:(e,t,i="",s="local")=>x(`${I(s)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(i)}`,Kc),workspaceFile:(e,t,i,s="local")=>x(`${I(s)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(i)}`,Gc),writeWorkspaceFile:(e,t,i,s,r,o="local")=>{const n=new URLSearchParams({path:i});r?.createDirs===!1&&n.set("createDirs","false"),r?.overwrite===!1&&n.set("overwrite","false");const a=s instanceof Uint8Array,c=a?new Uint8Array(s):new TextEncoder().encode(s);return x(`${I(o)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${n.toString()}`,Jn,{method:"PUT",body:c,headers:{"Content-Type":a?"application/octet-stream":"text/plain"}})},deleteWorkspaceFile:(e,t,i,s="local")=>{const r=new URLSearchParams({path:i});return x(`${I(s)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${r.toString()}`,Qc,{method:"DELETE"})},moveWorkspaceFile:(e,t,i,s,r,o="local")=>{const n=new URLSearchParams({fromPath:i,toPath:s});return r?.createDirs===!1&&n.set("createDirs","false"),r?.overwrite===!0&&n.set("overwrite","true"),x(`${I(o)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/move?${n.toString()}`,Jc,{method:"POST"})}},Ls={sessions:(e,t="local")=>x(`${I(t)}/sessions?cwd=${encodeURIComponent(e)}`,F(Ws)),startSession:(e,t="local")=>x(`${I(t)}/sessions`,Ws,{method:"POST",body:JSON.stringify({cwd:e})}),cleanupPreview:(e,t="local")=>x(`${I(t)}/sessions/cleanup/preview`,Gn,{method:"POST",body:JSON.stringify(e)}),cleanup:(e,t="local")=>x(`${I(t)}/sessions/cleanup`,Pc,{method:"POST",body:JSON.stringify(e)}),messages:(e,t,i="local")=>x(_d(e,t,i),bc),status:(e,t="local")=>x(si(e,"status",t),At),models:(e,t="local")=>x(si(e,"models",t),Ec),setModel:(e,t,i,s="local")=>x(Q(e,"model",s),At,{method:"POST",body:X(e,{provider:t,modelId:i})}),cycleModel:(e,t,i="local")=>x(Q(e,"model/cycle",i),At,{method:"POST",body:X(e,{direction:t})}),thinkingLevels:(e,t="local")=>x(si(e,"thinking-levels",t),Wc),setThinkingLevel:(e,t,i="local")=>x(Q(e,"thinking-level",i),At,{method:"POST",body:X(e,{level:t})}),cycleThinkingLevel:(e,t="local")=>x(Q(e,"thinking-level/cycle",t),At,{method:"POST",body:X(e)}),commands:(e,t="local")=>x(si(e,"commands",t),F(qc)),prompt:(e,t,i,s="local",r)=>x(Q(e,"prompt",s),ii,{method:"POST",body:X(e,{text:t,...i===void 0?{}:{streamingBehavior:i},...r!==void 0&&r.length>0?{attachments:r}:{}})}),saveAttachments:(e,t,i="local",s)=>x(Q(e,"attachments",i),Cd,{method:"POST",body:X(e,{attachments:t,...s===void 0?{}:{folder:s}})}),shell:(e,t,i="local")=>x(Q(e,"shell",i),ii,{method:"POST",body:X(e,{text:t})}),runCommand:(e,t,i="local")=>x(Q(e,"commands/run",i),lo,{method:"POST",body:X(e,{text:t})}),respondToCommand:(e,t,i,s="local")=>x(Q(e,"commands/respond",s),lo,{method:"POST",body:X(e,{requestId:t,value:i})}),abort:(e,t="local")=>x(Q(e,"abort",t),Id,{method:"POST",body:X(e)}),stop:(e,t="local")=>x(Q(e,"stop",t),Ad,{method:"POST",body:X(e)}),archive:(e,t="local")=>x(Q(e,"archive",t),co,{method:"POST",body:X(e)}),archiveWithDescendants:(e,t="local")=>x(Q(e,"archive-tree",t),co,{method:"POST",body:X(e)}),restore:(e,t="local")=>x(Q(e,"restore",t),Md,{method:"POST",body:X(e)}),deleteArchived:(e,t="local")=>x(Ud(e,t),Td,{method:"DELETE"}),detachParent:(e,t="local")=>x(Q(e,"detach-parent",t),Ed,{method:"POST",body:X(e)}),reloadSession:(e,t="local")=>x(Q(e,"reload",t),Dd,{method:"POST",body:X(e)}),authProviders:e=>{const t=new URLSearchParams;e?.mode!==void 0&&t.set("mode",e.mode),e?.authType!==void 0&&t.set("authType",e.authType);const i=t.toString();return x(`${I(e?.machineId)}/auth/providers${i===""?"":`?${i}`}`,Fc)},saveApiKey:(e,t,i="local")=>x(`${I(i)}/auth/api-key`,ii,{method:"POST",body:JSON.stringify({providerId:e,key:t})}),logoutProvider:(e,t="local")=>x(`${I(t)}/auth/logout`,ii,{method:"POST",body:JSON.stringify({providerId:e})}),startOAuthLogin:(e,t="local")=>x(`${I(t)}/auth/oauth`,ti,{method:"POST",body:JSON.stringify({providerId:e})}),oauthFlow:(e,t="local")=>x(`${I(t)}/auth/oauth/${encodeURIComponent(e)}`,ti),respondOAuthFlow:(e,t,i,s="local")=>x(`${I(s)}/auth/oauth/${encodeURIComponent(e)}/respond`,ti,{method:"POST",body:JSON.stringify({requestId:t,value:i})}),cancelOAuthFlow:(e,t="local")=>x(`${I(t)}/auth/oauth/${encodeURIComponent(e)}/cancel`,ti,{method:"POST"})},wt={terminals:(e,t,i="local")=>x(`${I(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,F(cs)),startTerminal:(e,t,i,s="local")=>x(`${I(s)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,cs,{method:"POST",body:JSON.stringify(i??{})}),closeWorkspaceTerminals:(e,t,i="local")=>x(`${I(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,js,{method:"DELETE"}),closeTerminal:(e,t,i,s="local")=>x(`${I(s)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(i)}`,js,{method:"DELETE"}),continueTerminal:(e,t,i,s="local")=>x(`${I(s)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(i)}/continue`,cs,{method:"POST"}),runTerminalCommand:(e,t,i="local")=>x(`${I(i)}/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,Ut,{method:"POST",body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:(e,t="local")=>x(`${I(t)}/terminal-command-runs${qd(e)}`,F(Ut)),getCommandRun:(e,t="local")=>Hd(e,t),cancelCommandRun:(e,t="local")=>x(`${I(t)}/terminal-command-runs/${encodeURIComponent(e)}/cancel`,Ut,{method:"POST"})};async function Hd(e,t){const i=await fetch(`${I(t)}/terminal-command-runs/${encodeURIComponent(e)}`);if(i.status!==404){if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(Kd(s)??i.statusText)}return Ut(await i.json())}}function qd(e){if(e===void 0)return"";const 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));const i=t.toString();return i===""?"":`?${i}`}function Kd(e){if(!Vd(e))return;const t=e.error;return typeof t=="string"?t:void 0}function Vd(e){return typeof e=="object"&&e!==null}const Gd={files:(e,t,i={})=>{const s=new URLSearchParams({q:t});return i.kind!==void 0&&s.set("kind",i.kind),i.mode!==void 0&&s.set("mode",i.mode),i.scope!==void 0&&s.set("scope",i.scope),i.workspaceScoped===!0&&i.projectId!==void 0&&i.workspaceId!==void 0?x(`${I(i.machineId)}/projects/${encodeURIComponent(i.projectId)}/workspaces/${encodeURIComponent(i.workspaceId)}/files?${s.toString()}`,F(Os)):(s.set("cwd",e),x(`${I(i.machineId)}/files?${s.toString()}`,F(Os)))}},Qd={gitStatus:(e,t,i="local")=>x(`${I(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/status`,Xc),gitDiff:(e,t,i,s="local")=>x(jd(s,e,t,i),ed)},B={...ra,...zd,...Ci,..._s,...oa,...Bd,...bt,...Ls,...wt,...Gd,...Qd};function Jd(e,t="local"){const i=typeof e=="string"?void 0:e.cwd,s=i===void 0||i===""?"":`?${new URLSearchParams({cwd:i}).toString()}`,r=typeof e=="string"?e:e.id;return new WebSocket(`${lr()}${ar(t)}/sessions/${encodeURIComponent(r)}/events${s}`)}function u0(e,t,i,s,r="local"){const o=s===void 0?"":`?cols=${encodeURIComponent(String(s.cols))}&rows=${encodeURIComponent(String(s.rows))}`;return new WebSocket(`${lr()}${ar(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(i)}/socket${o}`)}function Zd(e="local"){return new WebSocket(`${lr()}${ar(e)}/events`)}function ar(e){return`/api/machines/${encodeURIComponent(e)}`}function lr(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`}const na=".pi-web/uploads";class Vi extends Error{constructor(t="Workspace upload cancelled"){super(t),this.name="WorkspaceUploadCancelledError"}}class aa extends Error{constructor(t,i){super(op(t)),this.name="WorkspaceUploadBatchError",this.failures=t.map(s=>({...s})),this.responses=i.map(s=>({...s}))}}function uo(e){return e?.uploads?.defaultFolder??na}function Xd(e,t){return e?.uploads?.defaultFolder??t}function cr(e,t){const i=fo(e,"upload destination",{allowEmpty:!0}),s=fo(t,"upload file name",{allowEmpty:!1});return i===""?s:`${i}/${s}`}function Yd(e,t,i,s={}){const r=s.xhrFactory?.()??new XMLHttpRequest;let o=!1,n=!1;return{promise:new Promise((c,p)=>{const u=f=>{o||(o=!0,p(f))},h=f=>{o||(o=!0,c(f))};r.open("PUT",Ld(e,t,i.path,ip(s)),!0),r.responseType="json",r.setRequestHeader("Content-Type",(i.contentType??i.file.type)||"application/octet-stream"),r.upload.onprogress=f=>{s.onProgress?.(sp(f,i.file.size))},r.onload=()=>{if(r.status>=200&&r.status<300){try{s.onProgress?.({loaded:i.file.size,total:i.file.size,percent:1,lengthComputable:!0}),h(Jn(la(r)))}catch(f){u(f instanceof Error?f:new Error(String(f)))}return}u(new Error(cp(r)))},r.onerror=()=>{u(new Error("Workspace upload failed"))},r.onabort=()=>{u(new Vi(n?void 0:"Workspace upload aborted"))},r.send(i.file)}),cancel:()=>{o||(n=!0,r.abort())}}}function ep(e,t,i,s={}){const r=s.destinationFolder??na,o=i.map((h,f)=>({index:f,name:h.name,path:cr(r,h.name),loaded:0,total:h.size,percent:dr(0,h.size),lengthComputable:!0,done:!1}));let n,a=0;const c={requested:!1},p=()=>{s.onProgress?.(rp(o,a,o.every(h=>h.done)))};return{promise:(async()=>{const h=[],f=[];for(let b=0;b<i.length;b+=1){if(c.requested)throw new Vi;a=b;const P=i[b],C=o[b];if(!(P===void 0||C===void 0)){n=Yd(e,t,{path:C.path,file:P},{...tp(s),onProgress:G=>{C.total=G.total,C.loaded=Math.min(G.loaded,C.total),C.percent=G.percent,C.lengthComputable=G.lengthComputable,p()}});try{const G=await n.promise;C.loaded=C.total,C.percent=1,C.lengthComputable=!0,C.done=!0,h.push(G),p()}catch(G){if(ap(G,c))throw G;const Ke=np(G);C.loaded=C.total,C.percent=1,C.lengthComputable=!0,C.done=!0,C.error=Ke,f.push({index:b,name:P.name,path:C.path,error:Ke}),p()}finally{n=void 0}}}if(f.length>0)throw new aa(f,h);return h})(),cancel:()=>{c.requested=!0,n?.cancel()}}}function tp(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 ip(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId}}}function sp(e,t){const i=e.lengthComputable?e.total:t;return{loaded:e.loaded,total:i,percent:dr(e.loaded,i),lengthComputable:e.lengthComputable}}function rp(e,t,i){const s=e.reduce((o,n)=>o+n.total,0),r=e.reduce((o,n)=>o+n.loaded,0);return{currentFileIndex:t,files:e.map(o=>({...o})),loaded:r,total:s,percent:dr(r,s),done:i}}function dr(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}function op(e){return e.length===1?e[0]?.error??"Workspace upload failed":`${String(e.length)} files failed to upload`}function np(e){return e instanceof Error?e.message:String(e)}function ap(e,t){return t.requested||e instanceof Vi}function fo(e,t,i){const s=e.trim();if(s===""){if(i.allowEmpty)return"";throw new Error(`${t} must not be empty`)}if(lp(s))throw new Error(`${t} must be workspace-relative`);const r=s.split(/[\\/]+/u).filter(o=>o!==""&&o!==".");if(r.length===0){if(i.allowEmpty)return"";throw new Error(`${t} must not be empty`)}if(r.some(o=>o===".."))throw new Error(`${t} must not contain path traversal`);return r.join("/")}function lp(e){const t=e.replace(/\\/g,"/");return t.startsWith("/")||/^[A-Za-z]:\//u.test(t)}function la(e){return e.response!==void 0&&e.response!==null&&e.response!==""?e.response:e.responseText===""?{}:JSON.parse(e.responseText)}function cp(e){const t=dp(e);return pp(t)&&typeof t.error=="string"?t.error:e.statusText||`HTTP ${String(e.status)}`}function dp(e){try{return la(e)}catch{return}}function pp(e){return typeof e=="object"&&e!==null}function ui(){return{sessions:[],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 hp(){return{machines:[],selectedMachine:void 0,isLoadingMachines:!1,machineStatuses:{},machineRuntimes:{},projects:[],workspaces:[],sessions:[],messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,sendingPrompts:{},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 Xe(e,t){return t?.phase==="active"||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}function ca(e){return e!==void 0&&(e.hasSessionActivity||e.hasTerminalActivity)}const da="local";function ds(e,t){return`${e}:${t}`}function pa(e,t){return`${e}:${t}`}function g(e){return e.selectedMachine?.id??da}class up{constructor(t,i,s={}){this.getState=t,this.setState=i,this.api=s.api??oa}async refresh(t=g(this.getState())){this.applyMachineActivitySnapshot(t,fp(await this.api.workspaceActivity(t)))}applyWorkspaceActivity(t,i=g(this.getState())){const s=this.getState(),r=g(s)===i,o=s.machineActivities[i]??(r?s.workspaceActivities:{}),n=gp(o,t);this.setState({machineActivities:{...s.machineActivities,[i]:n},...r?{workspaceActivities:n}:{}})}applyMachineActivitySnapshot(t,i){const s=this.getState();this.setState({machineActivities:{...s.machineActivities,[t]:i},...g(s)===t?{workspaceActivities:i}:{}})}}function fp(e){const t={};for(const i of e.workspaces)ca(i)&&(t[i.cwd]=i);return t}function gp(e,t){const i={...e};return ca(t)?(i[t.cwd]=t,i):Object.fromEntries(Object.entries(i).filter(([s])=>s!==t.cwd))}class mp{constructor(t,i,s,r={}){this.getState=t,this.setState=i,this.applyStatus=s,this.api=r.api??B,this.pollIntervalMs=r.pollIntervalMs??1e3}dispose(){this.stopPolling()}handleSlashCommand(t){const i=vp(t);return i===void 0?!1:(i.command==="login"?this.openLogin(i.providerId):this.openLogout(i.providerId),!0)}async openLogin(t){if(t!==void 0&&t!==""){await this.openLoginProvider(t);return}this.setState({authDialog:{step:"method"}})}async chooseLoginMethod(t){try{const{providers:i}=await this.api.authProviders({mode:"login",authType:t,machineId:g(this.getState())});this.setState({authDialog:{step:"providers",mode:"login",authType:t,providers:i}})}catch(i){this.setState({error:String(i)})}}async selectLoginProvider(t,i){const s=this.getState().authDialog;if(s?.step!=="providers")return;const r=s.providers.find(o=>o.id===t&&(i===void 0||o.authType===i));r!==void 0&&(r.authType==="oauth"?await this.startOAuth(r):this.setState({authDialog:{step:"apiKey",provider:r,value:""}}))}updateApiKey(t){const i=this.getState().authDialog;if(i?.step!=="apiKey")return;const s={...i};delete s.error,this.setState({authDialog:{...s,value:t}})}async saveApiKey(){const t=this.getState().authDialog;if(t?.step!=="apiKey")return;const i=t.value.trim();if(i===""){this.setState({authDialog:{...t,error:"API key is required"}});return}const s={...t};delete s.error,this.setState({authDialog:{...s,saving:!0}});try{await this.api.saveApiKey(t.provider.id,i,g(this.getState())),this.closeDialog(),this.refreshStatus()}catch(r){this.setState({authDialog:{...t,saving:!1,error:String(r)}})}}async openLogout(t){try{const{providers:i}=await this.api.authProviders({mode:"logout",machineId:g(this.getState())});if(t!==void 0&&t!==""){const s=i.find(r=>r.id===t);s!==void 0&&!this.rejectRemoteOAuth("logout",s)?await this.logoutProvider(s.id):s===void 0&&this.setState({error:`No stored credentials for ${t}`});return}this.setState({authDialog:{step:"logout",providers:i}})}catch(i){this.setState({error:String(i)})}}async logoutProvider(t){const i=this.getState().authDialog,s=i?.step==="logout"?i.providers.find(r=>r.id===t):void 0;if(!(s!==void 0&&this.rejectRemoteOAuth("logout",s)))try{await this.api.logoutProvider(t,g(this.getState())),this.closeDialog(),this.refreshStatus()}catch(r){this.setState({error:String(r)})}}updateOAuthInput(t){const i=this.getState().authDialog;if(i?.step!=="oauth")return;const s={...i};delete s.error,this.setState({authDialog:{...s,inputValue:t}})}async respondOAuth(t){const i=this.getState().authDialog;if(i?.step!=="oauth")return;const s=i.flow.prompt??i.flow.select;if(s===void 0)return;const r=t??i.inputValue??"",o={...i};delete o.error,this.setState({authDialog:{...o,responding:!0}});try{const n=await this.api.respondOAuthFlow(i.flow.flowId,s.requestId,r,g(this.getState()));this.updateOAuthFlow(n)}catch(n){this.setState({authDialog:{...i,responding:!1,error:String(n)}})}}async cancelOAuth(){const t=this.getState().authDialog;if(t?.step!=="oauth"){this.closeDialog();return}this.stopPolling();try{await this.api.cancelOAuthFlow(t.flow.flowId,g(this.getState()))}catch{}this.closeDialog()}closeDialog(){this.stopPolling(),this.setState({authDialog:void 0})}async openLoginProvider(t){try{const{providers:i}=await this.api.authProviders({mode:"login",machineId:g(this.getState())}),s=i.filter(o=>o.id===t);if(s.length===0){this.setState({error:`Auth provider not found: ${t}`});return}if(s.length>1){this.setState({authDialog:{step:"providers",mode:"login",providers:s}});return}const r=s[0];if(r===void 0)return;r.authType==="oauth"?await this.startOAuth(r):this.setState({authDialog:{step:"apiKey",provider:r,value:""}})}catch(i){this.setState({error:String(i)})}}async startOAuth(t){if(!this.rejectRemoteOAuth("login",t))try{const i=await this.api.startOAuthLogin(t.id,g(this.getState()));this.updateOAuthFlow(i),this.startPolling(i.flowId)}catch(i){this.setState({error:String(i)})}}rejectRemoteOAuth(t,i){const s=this.getState().selectedMachine;if(i.authType!=="oauth"||s?.kind!=="remote")return!1;const r=s.baseUrl??"that remote PI WEB instance";return this.setState({error:`OAuth ${t} for remote machines must be configured directly on ${r}.`}),!0}updateOAuthFlow(t){if(t.status==="complete"){this.stopPolling(),this.closeDialog(),this.refreshStatus();return}(t.status==="error"||t.status==="cancelled")&&this.stopPolling();const i=this.getState().authDialog,s=i?.step==="oauth"&&i.flow.flowId===t.flowId?i.inputValue??"":"",r=i?.step==="oauth"?i.flow.prompt?.requestId??i.flow.select?.requestId:void 0,o=t.prompt?.requestId??t.select?.requestId,n=r!==void 0&&r===o,a=n?s:"",c=n&&i?.step==="oauth"?i.responding===!0:!1;this.setState({authDialog:{step:"oauth",flow:t,inputValue:a,responding:c}})}startPolling(t){this.stopPolling(),this.pollTimer=window.setInterval(()=>{this.poll(t)},this.pollIntervalMs)}stopPolling(){this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(t){const i=this.getState().authDialog;if(i?.step!=="oauth"||i.flow.flowId!==t){this.stopPolling();return}try{this.updateOAuthFlow(await this.api.oauthFlow(t,g(this.getState())))}catch(s){this.stopPolling(),this.setState({authDialog:{...i,error:String(s)}})}}async refreshStatus(){const t=this.session();if(t!==void 0)try{this.applyStatus(await this.api.status(t,g(this.getState())))}catch{}}session(){const t=this.getState().selectedSession;if(!(t===void 0||t.archived===!0))return t}}function vp(e){const t=e.trim(),i=/^\/(login|logout)(?:\s+(\S+))?\s*$/u.exec(t);if(i===null)return;const s=i[1];if(s!=="login"&&s!=="logout")return;const r=i[2];return r===void 0||r===""?{command:s}:{command:s,providerId:r}}function Vt(e){return e.replaceAll(":",".")}function bp(e){const t=new URLSearchParams(window.location.search),i=`${e}--`,s={};for(const[r,o]of t.entries()){if(!r.startsWith(i))continue;const n=r.slice(i.length),a=s[n];a===void 0?s[n]=o:Array.isArray(a)?a.push(o):s[n]=[a,o]}return s}function ps(e,t){const i=bp(e)[t];return Array.isArray(i)?i[0]:i===""?void 0:i}function Re(e,t,i,s){const r=new URL(window.location.href),o=`${e}--${t}`;if(r.searchParams.delete(o),i!=null&&i!=="")if(Array.isArray(i))for(const n of i)r.searchParams.append(o,String(n));else r.searchParams.set(o,String(i));wp(r,s)}function wp(e,t){const i=`${e.pathname}${e.search}${e.hash}`,s=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==s&&(t?.replace===!0?window.history.replaceState({},"",e):window.history.pushState({},"",e))}function yp(e){const t=e.files.map((s,r)=>{const o=s.size;return{index:r,name:s.name,path:cr(e.destinationFolder,s.name),size:s.size,loaded:0,total:o,percent:mo(0,o),lengthComputable:!0,status:r===0?"uploading":"pending"}}),i=t.reduce((s,r)=>s+r.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:i,percent:mo(0,i),status:"uploading",startedAt:e.startedAt}}function xp(e,t){const i=new Map(t.files.map(r=>[r.index,r])),s=e.files.map(r=>{const o=i.get(r.index);if(o===void 0)return r;const n={...r,path:o.path,loaded:o.loaded,total:o.total,percent:o.percent,lengthComputable:o.lengthComputable,status:o.error!==void 0?"error":o.done?"completed":t.currentFileIndex===r.index?"uploading":r.status};return o.error===void 0?delete n.error:n.error=o.error,n});return{...e,files:s,currentFileIndex:t.currentFileIndex,loaded:t.loaded,total:t.total,percent:t.percent}}function Sp(e,t,i){const s=e.files.map((o,n)=>{const a=t[n];return{...o,...a===void 0?{}:{path:a.path,response:a},loaded:o.total,percent:1,lengthComputable:!0,status:"completed"}}),r=pr(s);return{...e,files:s,currentFileIndex:s.length===0?-1:s.length-1,...r,status:"completed",completedAt:i}}function kp(e,t,i){const s=e.files.map(r=>r.status==="completed"||r.status==="error"?r:r.status==="uploading"||r.index===e.currentFileIndex?{...r,status:"error",error:t}:{...r,status:"cancelled",error:"Not uploaded because an earlier file failed."});return{...e,files:s,...pr(s),status:"error",error:t,completedAt:i}}function go(e,t){const i="Upload cancelled",s=e.files.map(r=>r.status==="completed"||r.status==="error"?r:{...r,status:"cancelled",error:i});return{...e,files:s,...pr(s),status:"cancelled",error:i,completedAt:t}}function pr(e){const t=e.reduce((i,s)=>i+s.total,0);return{loaded:t,total:t,percent:e.length===0?0:1}}function mo(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}const vo=Vt("core:workspace.files");class $p{constructor(t,i,s,r={}){this.getState=t,this.setState=i,this.updateUrl=s,this.uploadTasks=new Map,this.uploadBatchSequence=0,this.api=r.api??B,this.uploadWorkspaceFiles=r.uploadWorkspaceFiles??ep,this.createUploadBatchId=r.createUploadBatchId??(()=>(this.uploadBatchSequence+=1,`workspace-upload-${String(this.uploadBatchSequence)}`)),this.now=r.now??(()=>new Date().toISOString())}async refreshFiles(){const t=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(t===void 0||i===void 0))try{const s=g(this.getState()),r=await this.api.workspaceTree(t.id,i.id,"",s),o={...this.getState().expandedDirs};await Promise.all(Object.keys(o).map(async n=>{o[n]=(await this.api.workspaceTree(t.id,i.id,n,s)).entries})),this.setState({fileTree:r.entries,expandedDirs:o,fileTreeStale:!1,error:""})}catch(s){this.setState({error:String(s)})}}async expandDir(t){const i=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(i===void 0||s===void 0)){if(this.getState().expandedDirs[t]!==void 0){this.setState({expandedDirs:bo(this.getState().expandedDirs,t)});return}try{const r=await this.api.workspaceTree(i.id,s.id,t,g(this.getState()));this.setState({expandedDirs:{...this.getState().expandedDirs,[t]:r.entries},error:""})}catch(r){this.setState({error:String(r)})}}}async selectFile(t){this.setState({selectedFilePath:t,selectedFileContent:void 0,workspaceTool:"core:workspace.files",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.files"}),Re(vo,"file",t),this.updateUrl({replace:!0}),await this.restoreFile(t)}async restoreFile(t){const i=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(i===void 0||s===void 0)){this.setState({selectedFilePath:t,selectedFileContent:void 0});try{const r=await this.api.workspaceFile(i.id,s.id,t,g(this.getState()));this.getState().selectedFilePath===t&&this.setState({selectedFileContent:r,error:""})}catch(r){if(this.getState().selectedFilePath!==t)return;if(Pp(r)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:""}),Re(vo,"file",void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(r)})}}}startWorkspaceUpload(t,i){const s=this.getState().selectedProject,r=this.getState().selectedWorkspace;if(s===void 0||r===void 0){this.setState({error:"Select a workspace before uploading files."});return}if(t.length===0)return;const o=g(this.getState()),n=i.overwrite??!1,a=i.createDirs??!0;let c;try{c=yp({id:this.createUploadBatchId(),projectId:s.id,workspaceId:r.id,machineId:o,destinationFolder:i.destinationFolder,overwrite:n,createDirs:a,files:t,startedAt:this.now()})}catch(h){this.setState({error:String(h)});return}this.setUploadBatch(c);let p;try{p=this.uploadWorkspaceFiles(s.id,r.id,t,{destinationFolder:i.destinationFolder,machineId:o,overwrite:n,createDirs:a,onProgress:h=>{this.updateUploadProgress(c.id,h)}})}catch(h){return this.failUploadBatch(c.id,h),{batchId:c.id,done:Promise.resolve()}}this.uploadTasks.set(c.id,p);const u=p.promise.then(async h=>{await this.completeUploadBatch(c.id,h,i)}).catch(async h=>{await this.handleUploadFailure(c.id,h,i)}).finally(()=>{this.uploadTasks.delete(c.id)});return{batchId:c.id,done:u}}cancelWorkspaceUpload(t){const i=this.getUploadBatch(t);i?.status==="uploading"&&(this.setUploadBatch(go(i,this.now())),this.uploadTasks.get(t)?.cancel())}clearWorkspaceUpload(t){this.uploadTasks.get(t)?.cancel(),this.uploadTasks.delete(t),this.setState({workspaceUploadBatches:bo(this.getState().workspaceUploadBatches,t)})}updateUploadProgress(t,i){const s=this.getUploadBatch(t);s?.status==="uploading"&&this.setUploadBatch(xp(s,i))}async completeUploadBatch(t,i,s){const r=this.getUploadBatch(t);if(r?.status!=="uploading"||(this.setUploadBatch(Sp(r,i,this.now()),{error:""}),!this.isCurrentWorkspaceBatch(r)))return;await this.refreshFiles();const o=i[0]?.path;s.selectUploadedFile!==!1&&o!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(o)}async handleUploadFailure(t,i,s){const r=this.failUploadBatch(t,i);if(!(i instanceof aa)||i.responses.length===0||r===void 0||!this.isCurrentWorkspaceBatch(r))return;await this.refreshFiles();const o=i.responses[0]?.path;s.selectUploadedFile!==!1&&o!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(o)}failUploadBatch(t,i){const s=this.getUploadBatch(t);if(s?.status!=="uploading")return;if(Cp(i)){const n=go(s,this.now());return this.setUploadBatch(n),n}const r=Rp(i),o=kp(s,r,this.now());return this.setUploadBatch(o,{error:r}),o}getUploadBatch(t){return this.getState().workspaceUploadBatches[t]}setUploadBatch(t,i={}){this.setState({workspaceUploadBatches:{...this.getState().workspaceUploadBatches,[t.id]:t},...i})}isCurrentWorkspaceBatch(t){const i=this.getState();return i.selectedProject?.id===t.projectId&&i.selectedWorkspace?.id===t.workspaceId&&g(i)===t.machineId}}function Pp(e){const t=String(e);return t.includes("Path does not exist")||t.includes("ENOENT")||t.includes("no such file or directory")}function Cp(e){return e instanceof Vi}function Rp(e){return e instanceof Error?e.message:String(e)}function bo(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}const wo=Vt("core:workspace.git");class Ip{constructor(t,i,s){this.getState=t,this.setState=i,this.updateUrl=s}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0}async refreshGit(){const t=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(t===void 0||i===void 0))try{const s=await B.gitStatus(t.id,i.id,g(this.getState()));this.setState({gitStatus:s,gitStale:!1,error:""});const r=this.getState().selectedDiffPath;r!==void 0&&(s.files.some(o=>o.path===r)?await this.refreshDiff(r):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),Re(wo,"diff",void 0,{replace:!0})))}catch(s){this.setState({error:String(s)})}}async selectDiff(t){this.setState({selectedDiffPath:t,selectedDiff:void 0,selectedStagedDiff:void 0,workspaceTool:"core:workspace.git",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.git"}),Re(wo,"diff",t),this.updateUrl({replace:!0}),await this.refreshDiff(t)}async restoreDiff(t){this.setState({selectedDiffPath:t,selectedDiff:void 0,selectedStagedDiff:void 0}),await this.refreshDiff(t)}async refreshDiff(t){const i=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(i===void 0||s===void 0))try{const[r,o]=await Promise.all([B.gitDiff(i.id,s.id,{path:t},g(this.getState())),B.gitDiff(i.id,s.id,{path:t,staged:!0},g(this.getState()))]);this.setState({selectedDiff:r,selectedStagedDiff:o,error:""})}catch(r){this.setState({error:String(r)})}}updatePolling(){this.dispose();const t=this.getState();(t.workspaceTool==="core:workspace.git"||t.mainView==="core:workspace.git")&&(this.pollTimer=window.setInterval(()=>{this.refreshGit()},8e3))}}class Ap{constructor(t,i,s,r){this.getState=t,this.setState=i,this.updateUrl=s,this.projects=r}async loadMachines(t){this.setState({error:"",isLoadingMachines:!0});try{const i=await B.machines(),s=await this.selectInitialMachine(i,t),r=new Set(i.map(o=>o.id));this.setState({machines:i,selectedMachine:s,machineActivities:yo(this.getState().machineActivities,r),machineRuntimes:yo(this.getState().machineRuntimes,r)}),this.refreshMachineHealthFor(i),this.refreshMachineRuntimeFor(i)}catch(i){this.setState({error:String(i)})}finally{this.setState({isLoadingMachines:!1})}}async selectMachine(t,i={}){this.getState().selectedMachine?.id!==t.id&&(this.setState({selectedMachine:t,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,...ui()}),i.updateUrl!==!1&&this.updateUrl(),await this.projects.loadProjects(),this.refreshMachineHealth(t.id),this.refreshMachineRuntime(t.id))}async addMachine(t){this.setState({error:""});try{const i=await B.addMachine(t);return this.setState({machines:[...this.getState().machines.filter(s=>s.id!==i.id),i]}),await this.selectMachine(i),i}catch(i){this.setState({error:String(i)});return}}async deleteMachine(t=this.getState().selectedMachine,i={}){if(t!==void 0){if(t.kind==="local"){this.setState({error:"The local machine cannot be removed."});return}try{const s=this.getState().selectedMachine?.id===t.id;await B.deleteMachine(t.id);const r=this.getState().machines.filter(n=>n.id!==t.id),o=r.find(n=>n.id==="local")??r[0];return this.setState({machines:r,machineStatuses:hs(this.getState().machineStatuses,t.id),machineRuntimes:hs(this.getState().machineRuntimes,t.id),machineActivities:hs(this.getState().machineActivities,t.id)}),s&&o!==void 0?(i.selectFallback===!1||await this.selectMachine(o),o):void 0}catch(s){this.setState({error:String(s)});return}}}async refreshMachineHealth(t=this.getState().selectedMachine?.id??"local"){try{const i=await B.health(t);return this.setState({machineStatuses:{...this.getState().machineStatuses,[i.machineId]:i}}),i}catch(i){this.setState({error:String(i)});return}}async refreshMachineRuntime(t=this.getState().selectedMachine?.id??"local"){try{const i=await B.runtime(t);this.setState({machineRuntimes:{...this.getState().machineRuntimes,[i.machineId]:i}})}catch(i){this.setState({error:String(i)})}}async selectInitialMachine(t,i){const s=t.find(o=>o.id===(i??"local"));if(s===void 0)return this.localMachine(t);if(s.kind!=="remote")return s;const r=await this.safeRemoteHealth(s);return this.setState({machineStatuses:{...this.getState().machineStatuses,[r.machineId]:r},...r.ok?{}:{error:`${s.name} is unavailable; reconnecting…`}}),s}async safeRemoteHealth(t){try{return await B.health(t.id)}catch(i){return{machineId:t.id,ok:!1,checkedAt:new Date().toISOString(),status:"offline",error:i instanceof Error?i.message:String(i)}}}localMachine(t){return t.find(i=>i.id==="local")??t[0]}async refreshMachineHealthFor(t){const i=await Promise.allSettled(t.map(r=>B.health(r.id))),s=Object.fromEntries(i.flatMap(r=>r.status==="fulfilled"?[[r.value.machineId,r.value]]:[]));Object.keys(s).length>0&&this.setState({machineStatuses:{...this.getState().machineStatuses,...s}})}async refreshMachineRuntimeFor(t){const i=await Promise.allSettled(t.map(r=>B.runtime(r.id))),s=Object.fromEntries(i.flatMap(r=>r.status==="fulfilled"?[[r.value.machineId,r.value]]:[]));Object.keys(s).length>0&&this.setState({machineRuntimes:{...this.getState().machineRuntimes,...s}})}}function hs(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}function yo(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>t.has(i)))}class Mp{constructor(t,i,s){this.getState=t,this.setState=i,this.workspaces=s}async loadProjects(){const t=g(this.getState());this.setState({error:"",isLoadingProjects:!0});try{const i=await B.projects(t);if(g(this.getState())!==t)return;const s=new Set(i.map(o=>o.id)),r=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([o])=>s.has(o)));this.setState({projects:i,workspacesByProjectId:r})}catch(i){g(this.getState())===t&&this.setState({error:String(i)})}finally{g(this.getState())===t&&this.setState({isLoadingProjects:!1})}}async addProject(t,i){if(t.trim()!=="")try{const s=await B.addProject(t.trim(),void 0,i,g(this.getState())),r=this.getState().projects;this.setState({projects:[...r.filter(o=>o.id!==s.id),s],projectDialogOpen:!1}),await this.workspaces.selectProject(s)}catch(s){this.setState({error:String(s)})}}async closeProject(t){try{await B.closeProject(t,g(this.getState())),this.workspaces.forgetProject(t);const i=this.getState();this.setState({projects:i.projects.filter(s=>s.id!==t)}),i.selectedProject?.id===t&&this.workspaces.clearSelection()}catch(i){this.setState({error:String(i)})}}}const Fs="pi-web:cached-new-sessions:v1",Tp="browserCachedNew",Pt="local";function Gt(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function xo(e,t=Pt,i=Gt()){if(e.messageCount!==0||e.archived===!0)return;const s=hr(i).filter(r=>r.id!==e.id||r.machineId!==t);ur([Ns(e,t),...s],i)}function Ns(e,t=Pt){return{...e,browserCachedNew:!0,machineId:t}}function So(e,t=Pt,i=Gt()){const s=hr(i).filter(r=>r.id!==e||r.machineId!==t);ur(s,i)}function ha(e,t,i=Pt,s=Gt()){const r=new Set(t.map(c=>c.id)),o=hr(s),n=o.filter(c=>c.machineId!==i||!r.has(c.id));return n.length!==o.length&&ur(n,s),[...n.filter(c=>c.machineId===i&&c.cwd===e),...t]}function Y(e){return e===void 0?!1:Wp(e)&&e.browserCachedNew===!0}function Ep(e){return{id:e.id,path:e.path,cwd:e.cwd,...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:Pt},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt}}}function hr(e=Gt()){try{const t=e?.getItem(Fs);if(t==null||t==="")return[];const i=JSON.parse(t);return Array.isArray(i)?i.flatMap(s=>Dp(s)):[]}catch{return[]}}function ur(e,t=Gt()){try{e.length===0?t?.removeItem(Fs):t?.setItem(Fs,JSON.stringify(e))}catch{}}function Dp(e){if(!Op(e))return[];const t=ft(e,"id"),i=ft(e,"path"),s=ft(e,"cwd"),r=ft(e,"created"),o=ft(e,"modified"),n=ft(e,"firstMessage"),a=jp(e,"messageCount");if(t===void 0||i===void 0||s===void 0||r===void 0||o===void 0||n===void 0||a!==0)return[];const c=us(e,"name"),p=us(e,"parentSessionPath"),u=us(e,"machineId")??Pt;return[{id:t,path:i,cwd:s,...c===void 0?{}:{name:c},created:r,modified:o,messageCount:a,firstMessage:n,...p===void 0?{}:{parentSessionPath:p},machineId:u,browserCachedNew:!0}]}function Wp(e){return Tp in e}function Op(e){return typeof e=="object"&&e!==null}function ft(e,t){const i=e[t];return typeof i=="string"?i:void 0}function us(e,t){const i=e[t];return i===void 0||typeof i!="string"?void 0:i}function jp(e,t){const i=e[t];return typeof i=="number"?i:void 0}function _p(e){return Yp(e.flatMap(fr)).filter(t=>t.parts.length>0)}function Oe(e,t){return{role:e,parts:[{type:"text",text:t}]}}function Mt(e,t){const i=qp(t);return i===void 0?e:{...e,meta:i}}function Lp(e,t,i){if(i==="")return e;const s=e.at(-1),r=s?.parts.at(-1);return s?.role===t&&r?.type==="text"?[...e.slice(0,-1),{...s,parts:[...s.parts.slice(0,-1),{...r,text:r.text+i}]}]:s?.role===t?[...e.slice(0,-1),{...s,parts:[...s.parts,{type:"text",text:i}]}]:[...e,Oe(t,i)]}function Fp(e,t){if(t==="")return e;const i=e.at(-1),s=i?.parts.at(-1);return i?.role==="assistant"&&s?.type==="thinking"?[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...s,text:s.text+t}]}]:i?.role==="assistant"?[...e.slice(0,-1),{...i,parts:[...i.parts,{type:"thinking",text:t}]}]:[...e,{role:"assistant",parts:[{type:"thinking",text:t}]}]}function fr(e){if(Up(e))return[e];if(j(e,"role")==="bashExecution")return[Mt(Gp(e),e)];const t=Qp(j(e,"role")),i=Jp(ye(e,"content"),e),s=t==="user"?zp(i):void 0;if(s!==void 0)return s.map(p=>Mt(p,e));const r=Hp(e);if(t==="tool")return[Mt({role:t,parts:i,...r===void 0?{}:{source:r}},e)];const o=i.filter(p=>p.type!=="empty"),n=t==="assistant"&&o.length>0&&o.every(p=>p.type==="skillRead")?"skill":t,a=o.length>0?[Mt({role:n,parts:o,...r===void 0?{}:{source:r}},e)]:[],c=Np(e);return c===void 0?a:[...a,Mt(c,e)]}function Np(e){if(j(e,"role")!=="assistant"||j(e,"stopReason")!=="error")return;const t=j(e,"errorMessage")?.trim();return Oe("system",`Model response failed: ${t===void 0||t===""?"The model returned an error.":t}`)}function Up(e){const t=j(e,"role");return(t==="user"||t==="assistant"||t==="tool"||t==="system"||t==="bash"||t==="skill")&&Array.isArray(ye(e,"parts"))}function zp(e){if(e.length!==1||e[0]?.type!=="text")return;const t=Bp(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 Bp(e){const t=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(e);if(t===null)return;const i=t[4]?.trim();return{name:t[1]??"skill",location:t[2]??"",content:t[3]??"",...i===void 0||i===""?{}:{userMessage:i}}}function Hp(e){const t=j(e,"source");if(t==="compaction"||t==="branch_summary")return t}function qp(e){const t=Kp(ye(e,"timestamp")),i=Vp(e);if(!(t===void 0&&i===void 0))return{...t===void 0?{}:{timestamp:t},...i===void 0?{}:{model:i}}}function Kp(e){if(typeof e=="number"&&Number.isFinite(e))return new Date(e).toISOString();if(typeof e!="string"||e==="")return;const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function Vp(e){if(j(e,"role")!=="assistant")return;const t=j(e,"provider"),i=j(e,"model"),s=j(e,"responseModel");if(!((t===void 0||t==="")&&(i===void 0||i==="")&&(s===void 0||s==="")))return{...t===void 0||t===""?{}:{provider:t},...i===void 0||i===""?{}:{id:i},...s===void 0||s===""?{}:{responseId:s}}}function Gp(e){const t=j(e,"command")??"",i=fi(e,"excludeFromContext")===!0?["excluded from context","",`$ ${t}`]:[`$ ${t}`],s=ye(e,"output");s!=null&&i.push("",Ii(s));const r=ye(e,"exitCode");r!=null&&i.push("",`exit ${Ii(r)}`),fi(e,"cancelled")===!0&&i.push("","cancelled"),fi(e,"truncated")===!0&&i.push("","output truncated");const o=j(e,"fullOutputPath");return o!==void 0&&o!==""&&i.push("",`full output: ${o}`),{role:"bash",parts:[{type:"text",text:i.join(`
|
|
5
|
+
`)}]}}function Qp(e){return e==="assistant"?"assistant":e==="user"?"user":e==="toolResult"?"tool":"system"}function Jp(e,t){return typeof e=="string"?e!==""?[{type:"text",text:e}]:[]:Array.isArray(e)?e.flatMap(i=>{const s=j(i,"type"),r=j(i,"text");if(s==="text")return r!==void 0&&r!==""?[{type:"text",text:r}]:[];if(s==="thinking"){const o=j(i,"thinking")??r;return o!==void 0&&o!==""?[{type:"thinking",text:o}]:[]}if(s==="toolCall"){const o=j(i,"name")??"tool",n=ye(i,"arguments"),a=j(i,"id"),c=o==="read"?Xp(j(n,"path")):void 0;return c!==void 0?[{type:"skillRead",...c,...a===void 0?{}:{toolCallId:a}}]:[{type:"toolCall",...a===void 0?{}:{toolCallId:a},toolName:o,summary:Qt(n),...n===void 0?{}:{args:n}}]}if(s==="image"){const o=j(i,"data"),n=j(i,"mimeType");return o!==void 0&&o!==""&&n!==void 0&&n!==""?[{type:"image",mimeType:n,data:o}]:[{type:"text",text:"[image]"}]}return ko(i)}).map(i=>i.type==="text"&&j(t,"role")==="toolResult"?Zp(i.text,t):i):ko(e)}function Zp(e,t){const i=j(t,"toolCallId"),s=ye(t,"content"),r=ye(t,"details");return{type:"toolResult",...i===void 0?{}:{toolCallId:i},toolName:j(t,"toolName")??"tool",text:e,...s===void 0?{}:{content:s},...r===void 0?{}:{details:r},isError:fi(t,"isError")===!0}}function Xp(e){if(e===void 0||e==="")return;const t=e.replace(/\\/g,"/");if(!t.endsWith("/SKILL.md")&&t!=="SKILL.md")return;const i=t.split("/").at(-2);if(!(i===void 0||i===""))return{name:i,path:e}}function Yp(e){const t=[],i=new Map;for(const s of e){let r=[];const o={...s.source===void 0?{}:{source:s.source},...s.meta===void 0?{}:{meta:s.meta}},n=()=>{r.length!==0&&(t.push({role:s.role,parts:r,...o}),r=[])};for(const a of s.parts){if(a.type==="toolCall"){n();const c=eh(a),p=t.length;t.push({role:"tool",parts:[c],...o}),c.toolCallId!==void 0&&i.set(c.toolCallId,{lineIndex:p,partIndex:0});continue}if(a.type==="toolResult"){const c=a.toolCallId===void 0?void 0:i.get(a.toolCallId);if(c!==void 0&&th(t,c,a)){i.delete(a.toolCallId??"");continue}}r.push(a)}n()}return t}function eh(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 th(e,t,i){const s=e[t.lineIndex],r=s?.parts[t.partIndex];if(s===void 0||r?.type!=="toolExecution")return!1;const o=Ri(i.details)??r.preview,n={...r,status:i.isError?"error":"success",resultText:i.text,...i.content===void 0?{}:{content:i.content},...i.details===void 0?{}:{details:i.details},...o===void 0?{}:{preview:o}};return e[t.lineIndex]={...s,parts:[...s.parts.slice(0,t.partIndex),n,...s.parts.slice(t.partIndex+1)]},!0}function Ri(e){const t=ye(e,"preview");if(!gr(t))return;const i=j(t,"diff"),s=j(t,"error"),r=sh(t,"firstChangedLine");if(!(i===void 0&&s===void 0&&r===void 0))return{...i===void 0?{}:{diff:i},...s===void 0?{}:{error:s},...r===void 0?{}:{firstChangedLine:r}}}function ko(e){return e==null?[]:typeof e=="object"?[{type:"text",text:Qt(e)}]:[{type:"text",text:Ii(e)}]}function Qt(e){if(!gr(e))return Ii(e);const t=j(e,"command");if(t!==void 0)return t;const i=j(e,"path");if(i!==void 0)return i;if(typeof e.oldText=="string"&&typeof e.newText=="string")return"edit text replacement";const s=e.edits;return Array.isArray(s)?`${String(s.length)} edit${s.length===1?"":"s"}`:Object.entries(e).filter(([,o])=>o!=null).slice(0,3).map(([o,n])=>`${o}: ${ih(n)}`).join(" · ")}function ih(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!==null?"object":""}function gr(e){return typeof e=="object"&&e!==null}function ye(e,t){return gr(e)?e[t]:void 0}function j(e,t){const i=ye(e,t);return typeof i=="string"?i:void 0}function fi(e,t){const i=ye(e,t);return typeof i=="boolean"?i:void 0}function sh(e,t){const i=ye(e,t);return typeof i=="number"&&Number.isFinite(i)?i:void 0}function Ii(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):""}const rh="pi-web:prompt-draft:";function Ai(e){return`${rh}${e}`}function Gi(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function ua(e,t=Gi()){try{return t?.getItem(Ai(e))??""}catch{return""}}function Mi(e,t,i=Gi()){try{t?i?.setItem(Ai(e),t):i?.removeItem(Ai(e))}catch{}}function mr(e,t=Gi()){try{t?.removeItem(Ai(e))}catch{}}function oh(e,t,i=Gi()){const s=ua(e,i);s!==""&&(Mi(t,s,i),mr(e,i))}function nh(e,t){return Oe("bash",`${t===!0?`excluded from context
|
|
6
|
+
|
|
7
|
+
`:""}$ ${e}`)}function ah(e,t){const i=e.at(-1),s=i?.parts.at(-1);if(i?.role!=="bash"||s?.type!=="text")return[...e,Oe("bash",t)];const r=ch(s.text)?"":`
|
|
8
|
+
|
|
9
|
+
`;return[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...s,text:s.text+r+t}]}]}function lh(e,t){const i=e.at(-1),s=i?.parts.at(-1);if(i?.role!=="bash"||s?.type!=="text")return e;const r=[];return!s.text.includes(`
|
|
10
|
+
|
|
11
|
+
`)&&(t.output===void 0||t.output==="")&&r.push("(no output)"),t.isError===!0&&r.push(t.output??"Bash command failed"),t.exitCode!=null&&r.push(`exit ${String(t.exitCode)}`),t.cancelled===!0&&r.push("cancelled"),t.truncated===!0&&r.push("output truncated"),t.fullOutputPath!==void 0&&t.fullOutputPath!==""&&r.push(`full output: ${t.fullOutputPath}`),r.length===0?e:[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...s,text:`${s.text}
|
|
12
|
+
|
|
13
|
+
${r.join(`
|
|
14
|
+
`)}`}]}]}function ch(e){const t=e.lastIndexOf(`
|
|
15
|
+
|
|
16
|
+
`),i=e.lastIndexOf("$ ");return t>i}function dh(e,t){if(t.type==="message.append")return $h(e,t.message);if(t.type==="assistant.delta")return Lp(e,"assistant",t.text);if(t.type==="assistant.thinking.delta")return Fp(e,t.text);if(t.type==="tool.start")return gh(e,t);if(t.type==="tool.update")return ga(e,t.toolCallId,i=>mh(i,t));if(t.type==="tool.end")return fa(e,t.toolCallId,t.toolName,Qt(t.content),t.text,t.isError,t.content,t.details);if(t.type==="shell.start")return[...e,nh(t.command,t.excludeFromContext)];if(t.type==="shell.chunk")return ah(e,t.chunk);if(t.type==="shell.end")return lh(e,t);if(t.type==="command.output")return[...e,Oe(t.level==="error"?"system":"tool",t.message)];if(t.type==="session.error")return[...e,Oe("system",t.message)];if(t.type==="message.end")return t.message===void 0?void 0:ph(e,t.message)}function ph(e,t){const i=vh(t);if(i!==void 0)return fa(e,i.toolCallId,i.toolName,Qt(i.content),i.text,i.isError,i.content,i.details);const s=fr(t);if(s.length===0)return;const r=s.map(o=>o.role==="assistant"?uh(o):o).filter(o=>o.parts.length>0);return r.length===0?e:r.reduce((o,n)=>hh(o,n),e)}function hh(e,t){const i=bh(e,t);if(i.length>0)return wh(e,i,t);const s=e.at(-1);return s?.role!==t.role?[...e,t]:t.role==="assistant"||kh(s,t)?[...e.slice(0,-1),t]:[...e,t]}function uh(e){return{...e,parts:e.parts.filter(t=>t.type!=="toolCall")}}function fh(e){if(e===void 0||e==="")return;const t=e.replace(/\\/g,"/");if(!t.endsWith("/SKILL.md")&&t!=="SKILL.md")return;const i=t.split("/").at(-2);if(!(i===void 0||i===""))return{name:i,path:e}}function gh(e,t){const i=t.toolName==="read"?fh(at(t.args,"path")):void 0;if(i!==void 0)return Ph(e,{role:"skill",parts:[{type:"skillRead",...i,...t.toolCallId===""?{}:{toolCallId:t.toolCallId}}]});const s={type:"toolExecution",...t.toolCallId===""?{}:{toolCallId:t.toolCallId},toolName:t.toolName,summary:t.summary||Qt(t.args),...t.args===void 0?{}:{args:t.args},status:"running"};return[...e,{role:"tool",parts:[s]}]}function mh(e,t){const i=Ri(t.details)??e.preview;return{...e,status:e.status==="pending"?"running":e.status,...t.text===""?{}:{resultText:t.text},...t.content===void 0?{}:{content:t.content},...t.details===void 0?{}:{details:t.details},...i===void 0?{}:{preview:i}}}function fa(e,t,i,s,r,o,n,a){const c=ga(e,t,h=>{const f=Ri(a)??h.preview;return{...h,status:o?"error":"success",resultText:r,...n===void 0?{}:{content:n},...a===void 0?{}:{details:a},...f===void 0?{}:{preview:f}}});if(c!==e)return c;const p=Ri(a),u={type:"toolExecution",...t===void 0||t===""?{}:{toolCallId:t},toolName:i,summary:s,status:o?"error":"success",resultText:r,...n===void 0?{}:{content:n},...a===void 0?{}:{details:a},...p===void 0?{}:{preview:p}};return[...e,{role:"tool",parts:[u]}]}function ga(e,t,i){if(t===void 0||t==="")return e;for(let s=e.length-1;s>=0;s--){const r=e[s];if(r===void 0)continue;const o=r.parts.findIndex(c=>c.type==="toolExecution"&&c.toolCallId===t);if(o<0)continue;const n=r.parts[o];if(n?.type!=="toolExecution")continue;const a={...r,parts:[...r.parts.slice(0,o),i(n),...r.parts.slice(o+1)]};return[...e.slice(0,s),a,...e.slice(s+1)]}return e}function vh(e){if(at(e,"role")!=="toolResult")return;const t=at(e,"toolCallId"),i=Ei(e,"content");return{...t===void 0?{}:{toolCallId:t},toolName:at(e,"toolName")??"tool",text:ma(i),isError:Ah(e,"isError")===!0,content:i,details:Ei(e,"details")}}function ma(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(ma).filter(t=>t!=="").join(`
|
|
17
|
+
`);if(typeof e=="object"&&e!==null){const t=at(e,"text")??at(e,"content")??at(e,"output");if(t!==void 0)return t}return""}function bh(e,t){const i=Ti(t);if(i.length===0)return[];const s=[];let r=i.length;const o=ba(e)+1;for(let n=e.length-1;n>=o;n--){const a=Ti(e[n]);if(a.length===0)continue;const c=r-a.length;if(!(c<0)&&Sh(a,i.slice(c,r))&&(s.unshift(n),r=c,r===0))return s}return[]}function wh(e,t,i){const s=yh(e,t,i),r=s[0];if(r===void 0)return e;const o=new Set(s),n=[];for(let a=0;a<e.length;a++){a===r&&n.push(i);const c=e[a];c!==void 0&&!o.has(a)&&n.push(c)}return n}function yh(e,t,i){const s=t[0];if(i.role!=="assistant"||s===void 0)return t;const r=s-1;return xh(e[r])?[r,...t]:t}function xh(e){return e?.role==="assistant"&&e.parts.length>0&&e.parts.every(t=>t.type==="text"||t.type==="thinking")}function Ti(e){return e===void 0?[]:e.parts.filter(t=>t.type==="skillRead")}function Sh(e,t){return e.length===t.length&&e.every((i,s)=>va(i,t[s]))}function va(e,t){return t===void 0?!1:e.toolCallId!==void 0&&t.toolCallId!==void 0?e.toolCallId===t.toolCallId:$o(e.path)===$o(t.path)||e.name===t.name}function $o(e){return e.replace(/\\/g,"/")}function kh(e,t){return Po(e)===Po(t)}function Po(e){return e.parts.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
18
|
+
|
|
19
|
+
`)}function $h(e,t){const i=fr(t);return i.length===0?e:[...e,...i]}function Ph(e,t){const i=e.at(-1);return Ch(e,t)?e:i?.role===t.role&&t.role!=="skill"?[...e.slice(0,-1),{...i,parts:[...i.parts,...t.parts]}]:[...e,t]}function Ch(e,t){const i=Ti(t);if(t.role!=="skill"||i.length===0)return!1;const s=ba(e)+1;return i.every(r=>Rh(e,r,s))}function Rh(e,t,i){for(let s=e.length-1;s>=i;s--)if(Ti(e[s]).some(r=>va(r,t)))return!0;return!1}function ba(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.role==="user")return t;return-1}function Ih(e){return typeof e=="object"&&e!==null}function Ei(e,t){return Ih(e)?e[t]:void 0}function at(e,t){const i=Ei(e,t);return typeof i=="string"?i:void 0}function Ah(e,t){const i=Ei(e,t);return typeof i=="boolean"?i:void 0}const Mh="pi-web:chat-history:v2:",Th=1800*1e3;function Eh(e){try{const t=sessionStorage.getItem(Di(e));if(t===null||t==="")return;const i=JSON.parse(t);if(!Lh(i))return;if(Date.now()-i.savedAt>Th){sessionStorage.removeItem(Di(e));return}return{messages:i.messages,start:i.start,total:i.total}}catch{return}}function Dh(e,t){try{sessionStorage.setItem(Di(e),JSON.stringify({...t,savedAt:Date.now()}))}catch{}}function Wh(e){try{sessionStorage.removeItem(Di(e))}catch{}}function Oh(e,t){if(e===void 0||!Us(e))return t;if(!Us(t))return e;if(jh(e,t))return t;const i=Math.min(e.start,t.start),s=Math.max(e.start+e.messages.length,t.start+t.messages.length),r=new Array(s-i);return Co(r,i,e),Co(r,i,t),_h(r)?t:{start:i,total:Math.max(e.total,t.total),messages:r}}function jh(e,t){return e.total>t.total&&e.start===0&&t.start===0&&t.messages.length===t.total}function _h(e){for(let t=0;t<e.length;t+=1)if(!(t in e)||e[t]===void 0)return!0;return!1}function Co(e,t,i){i.messages.forEach((s,r)=>{e[i.start-t+r]=s})}function Di(e){return`${Mh}${e}`}function Lh(e){if(typeof e!="object"||e===null||!("messages"in e)||!("start"in e)||!("total"in e)||!("savedAt"in e))return!1;const{messages:t,start:i,total:s,savedAt:r}=e;return Array.isArray(t)&&typeof i=="number"&&typeof s=="number"&&typeof r=="number"&&Us({messages:t,start:i,total:s})}function Us(e){return Number.isInteger(e.start)&&Number.isInteger(e.total)&&e.start>=0&&e.total>=e.start&&e.messages.length<=e.total-e.start&&!e.messages.some(Fh)}function Fh(e){return typeof e=="object"&&e!==null&&"role"in e&&"parts"in e&&!("content"in e)&&typeof e.role=="string"&&Array.isArray(e.parts)}const Nh={read:Eh,write:Dh,remove:Wh};class Uh{constructor(t=Nh){this.cache=t,this.rawHistoryPages=new Map}cachedView(t){return Ro(this.rawHistoryPage(t))}mergeHistory(t,i){const s=Oh(this.rawHistoryPage(t),i);return this.rawHistoryPages.set(t,s),this.cache.write(t,s),Ro(s)}applyLiveEvent(t,i){return dh(t,i)}discard(t){this.rawHistoryPages.delete(t),this.cache.remove?.(t)}rawHistoryPage(t){const i=this.rawHistoryPages.get(t)??this.cache.read(t);return i!==void 0&&this.rawHistoryPages.set(t,i),i}}function Ro(e){const t=e?.start??0;return{messages:_p(e?.messages??[]),messagePageStart:t,messagePageEnd:t+(e?.messages.length??0),messagePageTotal:e?.total??0}}function wa(e,t=e.length){const i=e.slice(0,t),s=zh(i,t);if(s!==void 0)return s;const r=Bh(i,t);if(r!==void 0)return r;const o=Math.max(i.lastIndexOf(" "),i.lastIndexOf(`
|
|
20
|
+
`))+1,n=i.slice(o);if(i.slice(0,o).endsWith("@ "))return{kind:"file",query:n,from:o-2,to:t,fileScope:"all",allPrefix:"@ "};if(n.startsWith("/")&&o===0)return{kind:"command",query:n.slice(1),from:o,to:t};if(n.startsWith("!@"))return{kind:"file",query:n.slice(2),from:o,to:t,fileScope:"all",allPrefix:"!@"};if(n.startsWith("@"))return{kind:"file",query:n.slice(1),from:o,to:t,fileScope:"tracked"}}function ya(e,t,i){const s=i??"@";return!t&&!e.includes(" ")?`${s}${e}`:`${s}"${e}"`}function zh(e,t){const i=e.lastIndexOf('"');if(i===-1)return;const s=e.slice(0,i);if(s.endsWith("!@"))return{kind:"file",query:e.slice(i+1),from:s.length-2,to:t,fileScope:"all",allPrefix:"!@",quoted:!0};if(s.endsWith("@"))return{kind:"file",query:e.slice(i+1),from:s.length-1,to:t,fileScope:"tracked",quoted:!0};if(s.endsWith("@ "))return{kind:"file",query:e.slice(i+1),from:s.length-2,to:t,fileScope:"all",allPrefix:"@ ",quoted:!0}}function Bh(e,t){const i=e.lastIndexOf(`
|
|
21
|
+
`)+1,s=e.slice(i),r=Io(s,"@ "),o=Io(s,"!@"),n=Math.max(r,o);if(n===-1)return;const a=n===o?"!@":"@ ",c=i+n,p=c+a.length;return{kind:"file",query:e.slice(p),from:c,to:t,fileScope:"all",allPrefix:a}}function Io(e,t){for(let i=e.lastIndexOf(t);i>=0;i=e.lastIndexOf(t,i-1))if(i===0||Hh(e[i-1]))return i;return-1}function Hh(e){return e===" "||e===" "}function vr(e){const t=e.trimStart();return t.startsWith("!@")?{kind:"file"}:t.startsWith("!")?{kind:"shell",excludeFromContext:t.startsWith("!!")}:Kh(e).startsWith("/")?{kind:"command"}:wa(e)?.kind==="file"?{kind:"file"}:{kind:"normal"}}function qh(e){return vr(e).kind==="shell"}function Kh(e){const t=Math.max(e.lastIndexOf(" "),e.lastIndexOf(`
|
|
22
|
+
`))+1;return e.slice(t)}class Vh{constructor(){this.reconnectDelay=500,this.shouldReconnect=!1,this.hasOpened=!1,this.machineId="local"}connect(t,i,s,r="local"){this.close(),this.machineId=r,this.session=t,this.onEvent=i,this.onReconnect=s,this.shouldReconnect=!0,this.open()}setHandler(t){this.onEvent=t}close(){this.shouldReconnect=!1,window.clearTimeout(this.reconnectTimer),Sa(this.socket),this.socket=void 0,this.session=void 0,this.onEvent=void 0,this.onReconnect=void 0,this.hasOpened=!1,this.machineId="local"}open(){if(this.session===void 0||this.session.id===""||this.session.cwd===""||!this.shouldReconnect)return;const t=Jd(this.session,this.machineId);this.socket=t,t.onopen=()=>{this.reconnectDelay=500,this.hasOpened&&this.onReconnect?.(),this.hasOpened=!0},t.onmessage=i=>{this.handleMessage(i.data)},t.onerror=()=>{t.close()},t.onclose=()=>{this.socket===t&&(this.socket=void 0),this.scheduleReconnect()}}scheduleReconnect(){if(!this.shouldReconnect)return;window.clearTimeout(this.reconnectTimer);const t=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*1.6,5e3),this.reconnectTimer=window.setTimeout(()=>{this.open()},t)}async handleMessage(t){const i=await xa(t);Gh(i)&&this.onEvent?.(i)}}class Ao{constructor(){this.reconnectDelay=500,this.shouldReconnect=!1,this.machineId="local"}connect(t,i,s="local"){this.close(),this.machineId=s,this.onEvent=t,this.onOpen=i,this.shouldReconnect=!0,this.open()}close(){this.shouldReconnect=!1,window.clearTimeout(this.reconnectTimer),Sa(this.socket),this.socket=void 0,this.onEvent=void 0,this.onOpen=void 0,this.machineId="local"}open(){if(!this.shouldReconnect)return;const t=Zd(this.machineId);this.socket=t,t.onopen=()=>{this.reconnectDelay=500,this.onOpen?.()},t.onmessage=i=>{this.handleMessage(i.data)},t.onerror=()=>{t.close()},t.onclose=()=>{this.socket===t&&(this.socket=void 0),this.scheduleReconnect()}}scheduleReconnect(){if(!this.shouldReconnect)return;window.clearTimeout(this.reconnectTimer);const t=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*1.6,5e3),this.reconnectTimer=window.setTimeout(()=>{this.open()},t)}async handleMessage(t){const i=await xa(t);Jh(i)&&this.onEvent?.(i)}}function Gh(e){const t=br(e);return["message.append","assistant.delta","assistant.thinking.delta","tool.start","tool.update","tool.end","shell.start","shell.chunk","shell.end","agent.start","agent.end","message.end","status.update","activity.update","command.output","session.error","session.name","session.created","pi.event"].includes(t)}function Qh(e){const t=br(e);return t==="status.update"||t==="activity.update"||t==="session.name"||t==="session.created"}function Jh(e){const t=br(e);return Qh(e)||t==="terminal.created"||t==="terminal.exited"||t==="terminal.closed"||t==="workspace.activity"}function br(e){if(typeof e!="object"||e===null||!("type"in e))return"";const t=e.type;return typeof t=="string"?t:""}async function xa(e){try{return typeof e=="string"?JSON.parse(e):e instanceof Blob?JSON.parse(await e.text()):e instanceof ArrayBuffer?JSON.parse(new TextDecoder().decode(e)):void 0}catch{return}}function Sa(e){if(e!==void 0){if(e.onmessage=null,e.onerror=null,e.onclose=null,e.readyState===WebSocket.CONNECTING){e.onopen=()=>{e.close()};return}e.close()}}function Jt(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}class Qi{constructor(t,i,s=Jt()){this.storageKey=t,this.storage=s,this.values=new Map;for(const[r,o]of Zh(t,i,s))this.values.set(r,o)}get(t){return this.values.get(t)}set(t,i){this.values.set(t,i),this.save()}delete(t){this.values.delete(t),this.save()}entries(){return[...this.values.entries()]}save(){try{if(this.values.size===0){this.storage?.removeItem(this.storageKey);return}const t={version:1,entries:[...this.values.entries()]};this.storage?.setItem(this.storageKey,JSON.stringify(t))}catch{}}}function wr(e){return typeof e=="string"&&e!==""?e:void 0}function Zh(e,t,i){try{const s=i?.getItem(e);if(s==null||s==="")return[];const r=JSON.parse(s);if(!Xh(r))return[];const o=[];for(const n of r.entries){const a=n[0],c=t(n[1]);c!==void 0&&o.push([a,c])}return o}catch{return[]}}function Xh(e){return!Yh(e)||e.version!==1||!Array.isArray(e.entries)?!1:e.entries.every(t=>Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&t[0]!=="")}function Yh(e){return typeof e=="object"&&e!==null}class eu{constructor(){this.sessionIdsByCwd=new Map}latestSessionId(t){return this.sessionIdsByCwd.get(t)}rememberSession(t){this.sessionIdsByCwd.set(t.cwd,t.id)}forgetWorkspace(t){this.sessionIdsByCwd.delete(t)}}const tu="pi-web:session-selection:v1";class iu{constructor(t=Jt()){this.sessionIdsByCwd=new Qi(tu,wr,t)}latestSessionId(t){return this.sessionIdsByCwd.get(t)}rememberSession(t){this.sessionIdsByCwd.set(t.cwd,t.id)}forgetWorkspace(t){this.sessionIdsByCwd.delete(t)}}function su(e,t){const i=t?.targetSessionId;if(i!==void 0&&i!=="")return ou(e,i);const s=t?.latestSessionId;return s!==void 0&&s!==""?e.find(r=>r.id===s)??e.find(r=>r.archived!==!0):e.find(r=>r.archived!==!0)}function ru(e,t){return t?.archived!==!0?!1:!e.some(i=>i.archived!==!0)}function ou(e,t){return e.find(i=>i.id===t||i.id.startsWith(t))}function nu(e,t,i){return gi(e,[t],i)}function gi(e,t,i){const s=new Set(t);return e.map(r=>s.has(r.id)?{...r,archived:!0,archivedAt:i}:r)}function au(e,t,i){return mi(e,t,[i])}function mi(e,t,i){if(t===void 0||!i.includes(t))return{type:"unchanged"};const s=new Set(i),r=e.find(o=>!s.has(o.id)&&o.archived!==!0);return r===void 0?{type:"clear"}:{type:"select",session:r}}const Tt=100;class lu{constructor(t,i,s,r=new eu,o={}){this.getState=t,this.setState=i,this.updateUrl=s,this.sessionSelection=r,this.selectionSeq=0,this.pendingTranscriptEvents=[],this.socket=o.socket??new Vh,this.api=o.api??B,this.transcripts=o.transcripts??new Uh}applyGlobalEvent(t){t.type==="status.update"?this.applyStatus(t.status):t.type==="activity.update"?this.applyActivity(t.activity):t.type==="session.created"?this.applyCreatedSession(t.session):this.applySessionName(t.sessionId,t.name)}dispose(){this.socket.close(),this.clearPendingTranscriptEvents()}clearActiveSession(){this.selectionSeq+=1,this.socket.close(),this.catchupStreamSessionId=void 0,this.clearPendingTranscriptEvents(),this.setState({selectedSession:void 0,messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:void 0,activity:void 0,availableThinkingLevels:[]})}deselectSession(t){const i=this.getState(),s=i.selectedSession?.cwd??i.selectedWorkspace?.path;t?.forgetRememberedSelection===!0&&s!==void 0&&this.sessionSelection.forgetWorkspace(this.workspaceSelectionKey(s)),this.clearActiveSession(),t?.updateUrl!==!1&&this.updateUrl()}clearSelectionAfterArchivedCollapse(){const t=this.getState();ru(t.sessions,t.selectedSession)&&this.deselectSession({forgetRememberedSelection:!0})}async startSession(){const t=this.getState().selectedWorkspace;if(t)try{const i=g(this.getState()),s=await this.api.startSession(t.path,i);xo(s,i);const r=Ns(s,i);this.setState({sessions:[r,...this.getState().sessions.filter(o=>o.id!==r.id)]}),await this.selectSession(r)}catch(i){this.setState({error:String(i)})}}preferredSession(t,i,s){return su(i,{targetSessionId:s,latestSessionId:this.sessionSelection.latestSessionId(this.workspaceSelectionKey(t))})}async selectSession(t,i){this.sessionSelection.rememberSession({...t,cwd:this.workspaceSelectionKey(t.cwd)});const s=++this.selectionSeq;this.socket.close(),this.catchupStreamSessionId=void 0,this.clearPendingTranscriptEvents();const r=this.sessionCacheKey(t.id),o=this.transcripts.cachedView(r);this.setState({selectedSession:t,...o,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:t.archived===!0?void 0:this.getState().sessionStatuses[t.id],activity:t.archived===!0?void 0:this.getState().sessionActivities[t.id]});try{if(t.archived===!0){const u=await this.api.messages(t,{limit:Tt},g(this.getState()));if(s!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;const h=this.transcripts.mergeHistory(r,u);this.setState({...h,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:void 0,activity:void 0}),i?.updateUrl!==!1&&this.updateUrl();return}const n=[];this.socket.connect(t,u=>n.push(u),()=>{this.refreshSelectedSession(t.id)},g(this.getState()));const[a,c]=await Promise.all([this.api.messages(t,{limit:Tt},g(this.getState())),this.api.status(t,g(this.getState()))]);if(s!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;const p=this.transcripts.mergeHistory(r,a);this.setState({...p,isLoadingEarlierMessages:!1,...this.setStreamCatchup(c.isStreaming?t.id:void 0),status:c,activity:this.getState().sessionActivities[t.id],availableThinkingLevels:[]}),this.applyStatus(c),this.refreshAvailableThinkingLevels();for(const u of n)this.applyEvent(u);this.socket.setHandler(u=>{this.applyEvent(u)}),i?.updateUrl!==!1&&this.updateUrl()}catch(n){if(s!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;if(Y(t)&&vu(n)){await this.recreateCachedNewSession(t,i);return}this.setState({error:String(n)})}}async loadEarlierMessages(){const t=this.getState(),i=t.selectedSession;if(!(!i||t.isLoadingEarlierMessages||t.messagePageStart<=0)){this.setState({isLoadingEarlierMessages:!0});try{const s=await this.api.messages(i,{before:t.messagePageStart,limit:Tt},g(this.getState()));if(this.getState().selectedSession?.id!==i.id)return;const r=this.transcripts.mergeHistory(this.sessionCacheKey(i.id),s);this.setState(r)}catch(s){this.setState({error:String(s)})}finally{this.getState().selectedSession?.id===i.id&&this.setState({isLoadingEarlierMessages:!1})}}}async send(t,i,s,r="inline"){const o=t.trim(),n=s!==void 0&&s.length>0;if(!n&&o.startsWith("/"))return this.runCommand(t);if(!n&&qh(t))return this.runShell(t);const a=this.getState().selectedSession;if(!a||a.archived===!0)return;const c=a.id,p=g(this.getState());n&&this.markSendingPrompt(c,!0);try{if(n&&r==="folder"){const h=(await this.api.saveAttachments(a,s,p)).map(b=>ya(b.path,!1)).join(" "),f=t===""?h:`${t}
|
|
23
|
+
|
|
24
|
+
${h}`;await this.api.prompt(a,f,i,p)}else await this.api.prompt(a,t,i,p,s);this.markCachedNewSessionPersisted(a)}catch(u){this.setState({error:String(u)})}finally{n&&this.markSendingPrompt(c,!1)}}markSendingPrompt(t,i){const s=this.getState().sendingPrompts;i?s[t]!==!0&&this.setState({sendingPrompts:{...s,[t]:!0}}):t in s&&this.setState({sendingPrompts:ka(s,t)})}async runShell(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0)){this.setState({messages:[...this.getState().messages,Oe("user",t)]});try{await this.api.shell(i,t,g(this.getState())),this.markCachedNewSessionPersisted(i)}catch(s){this.setState({messages:[...this.getState().messages,Oe("system",String(s))],error:String(s)})}}}async runCommand(t){const i=this.getState().selectedSession;if(!i||i.archived===!0)return;const s=i.id;this.markSendingPrompt(s,!0);try{this.applyCommandResult(await this.api.runCommand(i,t,g(this.getState()))),this.markCachedNewSessionPersisted(i)}catch(r){this.setState({messages:[...this.getState().messages,Oe("system",String(r))],error:String(r)})}finally{this.markSendingPrompt(s,!1)}}async respondToCommand(t,i){const s=this.getState().selectedSession;if(s){this.setState({commandDialog:void 0});try{this.applyCommandResult(await this.api.respondToCommand(s,t,i,g(this.getState())))}catch(r){this.setState({error:String(r)})}}}cancelCommand(){this.setState({commandDialog:void 0})}applySessionStatus(t){this.applyStatus(t)}async archiveSession(t=this.getState().selectedSession){if(t){if(Y(t)){await this.deleteCachedNewSession(t);return}try{await this.api.archive(t,g(this.getState()));const i=this.getState(),s=nu(i.sessions,t.id,new Date().toISOString()),r=au(s,i.selectedSession?.id,t.id);this.setState({sessions:s}),r.type==="select"?await this.selectSession(r.session):r.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}catch(i){this.setState({error:String(i)})}}}async archiveSessionWithDescendants(t=this.getState().selectedSession){if(!(!t||Y(t)))try{const i=await this.api.archiveWithDescendants(t,g(this.getState())),s=i.sessionIds!==void 0&&i.sessionIds.length>0?i.sessionIds:[t.id],r=this.getState(),o=gi(r.sessions,s,new Date().toISOString()),n=mi(o,r.selectedSession?.id,s);this.setState({sessions:o}),n.type==="select"?await this.selectSession(n.session):n.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}catch(i){this.setState({error:String(i)})}}async archiveSessions(t){const i=To(t).filter(n=>n.archived!==!0&&!Y(n));if(i.length===0)return;const s=g(this.getState()),r=await Promise.allSettled(i.map(async n=>(await this.api.archive(n,s),n.id))),o=Eo(r);if(o.length>0){const n=this.getState(),a=gi(n.sessions,o,new Date().toISOString()),c=mi(a,n.selectedSession?.id,o);this.setState({sessions:a}),c.type==="select"?await this.selectSession(c.session):c.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}this.applyBulkSessionError("Archive",r)}async deleteArchivedSessions(t){const i=To(t).filter(a=>a.archived===!0);if(i.length===0)return;const s=g(this.getState()),r=this.getState().machineRuntimes[s];if(r?.ok!==!0||!nt(r,Qe.sessionsDeleteArchived)){this.setState({error:"Deleting archived sessions requires an updated Pi-Web runtime on this machine."});return}const o=await Promise.allSettled(i.map(async a=>(await this.api.deleteArchived(a,s),a.id))),n=Eo(o);if(n.length>0){const a=new Set(n),c=this.getState(),p=c.sessions.filter(u=>!a.has(u.id));if(this.setState({sessions:p}),c.selectedSession!==void 0&&a.has(c.selectedSession.id)){const u=p.find(h=>h.archived!==!0)??p[0];u!==void 0?await this.selectSession(u):this.deselectSession({forgetRememberedSelection:!0})}}this.applyBulkSessionError("Delete",o)}async applySessionCleanupResult(t,i=g(this.getState())){if(g(this.getState())!==i)return;const s=t.archivedSessionIds,r=t.deletedSessionIds;if(s.length>0||r.length>0){const o=this.getState(),n=new Set(r),a=[...s,...r],c=gi(o.sessions,s,t.generatedAt).filter(u=>!n.has(u.id)),p=o.selectedSession!==void 0&&a.includes(o.selectedSession.id);if(this.setState({sessions:c,sessionStatuses:Mo(o.sessionStatuses,a),sessionActivities:Mo(o.sessionActivities,a),...p?{status:void 0,activity:void 0}:{}}),o.selectedSession!==void 0&&n.has(o.selectedSession.id)){const u=c.find(h=>h.archived!==!0)??c[0];u!==void 0?await this.selectSession(u):this.deselectSession({forgetRememberedSelection:!0})}else{const u=mi(c,o.selectedSession?.id,s);u.type==="select"?await this.selectSession(u.session):u.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}}await this.refreshCurrentWorkspaceSessions(i)}async refreshCurrentWorkspaceSessions(t=g(this.getState())){const i=this.getState().selectedWorkspace;if(i!==void 0)try{const s=ha(i.path,await this.api.sessions(i.path,t),t);if(g(this.getState())!==t||this.getState().selectedWorkspace?.id!==i.id)return;const r=this.getState().selectedSession;if(this.setState({sessions:s}),r===void 0)return;const o=s.find(a=>a.id===r.id);if(o!==void 0){o!==r&&this.setState({selectedSession:o});return}const n=s.find(a=>a.archived!==!0)??s[0];n!==void 0?await this.selectSession(n):this.deselectSession({forgetRememberedSelection:!0})}catch(s){g(this.getState())===t&&this.getState().selectedWorkspace?.id===i.id&&this.setState({error:String(s)})}}async deleteCachedNewSession(t=this.getState().selectedSession){if(!Y(t))return;this.api.stop(t,g(this.getState())).catch(()=>{}),So(t.id,g(this.getState())),mr(this.sessionCacheKey(t.id));const i=this.getState().sessions.filter(r=>r.id!==t.id);if(this.setState({sessions:i}),this.getState().selectedSession?.id!==t.id)return;const s=i.find(r=>r.archived!==!0)??i[0];s!==void 0?await this.selectSession(s):(this.clearActiveSession(),this.updateUrl())}async restoreSession(t=this.getState().selectedSession){if(t)try{await this.api.restore(t,g(this.getState()));const i={...t};delete i.archived,delete i.archivedAt,this.replaceSession(i),this.getState().selectedSession?.id===i.id&&await this.selectSession(i)}catch(i){this.setState({error:String(i)})}}async reloadSession(t=this.getState().selectedSession){if(t===void 0||Y(t)||t.archived===!0)return;const i=g(this.getState()),s=this.getState().machineRuntimes[i];if(s?.ok!==!0||!nt(s,Qe.sessionsReload)){this.setState({error:"Reloading sessions requires an updated Pi-Web runtime on this machine."});return}try{await this.api.reloadSession(t.id,i),this.transcripts.discard(this.sessionCacheKey(t.id)),this.getState().selectedSession?.id===t.id&&await this.selectSession(t,{updateUrl:!1})}catch(r){this.setState({error:String(r)})}}async detachParent(t=this.getState().selectedSession){if(t?.parentSessionPath!==void 0)try{await this.api.detachParent(t,g(this.getState()));const i={...t};delete i.parentSessionPath,this.replaceSession(i)}catch(i){this.setState({error:String(i)})}}async listModels(){const t=this.getState().selectedSession;if(!t||t.archived===!0)return[];try{return(await this.api.models(t,g(this.getState()))).models}catch(i){return this.setState({error:String(i)}),[]}}async setModel(t,i){const s=this.getState().selectedSession;if(!(!s||s.archived===!0))try{this.applyStatus(await this.api.setModel(s,t,i,g(this.getState()))),await this.refreshAvailableThinkingLevels()}catch(r){this.setState({error:String(r)})}}async cycleModel(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0))try{this.applyStatus(await this.api.cycleModel(i,t,g(this.getState()))),await this.refreshAvailableThinkingLevels()}catch(s){this.setState({error:String(s)})}}async listThinkingLevels(){const t=this.getState().selectedSession;if(!t||t.archived===!0)return[];try{return(await this.api.thinkingLevels(t,g(this.getState()))).levels}catch(i){return this.setState({error:String(i)}),[]}}async refreshAvailableThinkingLevels(){const t=this.getState().selectedSession;if(!t||t.archived===!0){this.getState().availableThinkingLevels.length>0&&this.setState({availableThinkingLevels:[]});return}const i=await this.listThinkingLevels();this.getState().selectedSession?.id===t.id&&this.setState({availableThinkingLevels:i})}async setThinkingLevel(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0))try{this.applyStatus(await this.api.setThinkingLevel(i,t,g(this.getState())))}catch(s){this.setState({error:String(s)})}}async cycleThinkingLevel(){const t=this.getState().selectedSession;if(!(!t||t.archived===!0))try{this.applyStatus(await this.api.cycleThinkingLevel(t,g(this.getState())))}catch(i){this.setState({error:String(i)})}}async stopActiveWork(){const t=this.getState().selectedSession;if(t)try{await this.api.abort(t,g(this.getState()))}catch(i){this.setState({error:String(i)})}}async refreshSelectedSession(t=this.getState().selectedSession?.id){const i=this.getState().selectedSession;if(!(t===void 0||i?.id!==t||i.archived===!0))try{this.flushPendingTranscriptEvents();const[s,r]=await Promise.all([this.api.messages(i,{limit:Tt},g(this.getState())),this.api.status(i,g(this.getState()))]);if(this.getState().selectedSession?.id!==t)return;const o=this.transcripts.mergeHistory(this.sessionCacheKey(t),s);this.setState({...o,status:r,activity:this.getState().sessionActivities[t],...this.setStreamCatchup(r.isStreaming?t:void 0)}),this.applyStatus(r)}catch(s){this.getState().selectedSession?.id===t&&this.setState({error:String(s)})}}applyBulkSessionError(t,i){const s=du(i);s.length!==0&&this.setState({error:`${t} failed for ${String(s.length)} session${s.length===1?"":"s"}: ${s.join("; ")}`})}sessionCacheKey(t){return pa(g(this.getState()),t)}workspaceSelectionKey(t){return`${g(this.getState())}:${t}`}replaceSession(t){const i=this.getState().selectedSession;this.setState({sessions:this.getState().sessions.map(s=>s.id===t.id?t:s),selectedSession:i?.id===t.id?t:i})}async recreateCachedNewSession(t,i){try{const s=g(this.getState()),r=await this.api.startSession(t.cwd,s);xo(r,s),oh(this.sessionCacheKey(t.id),this.sessionCacheKey(r.id)),So(t.id,s);const o=Ns(r,s);this.setState({sessions:[o,...this.getState().sessions.filter(n=>n.id!==t.id)],error:""}),await this.selectSession(o,{updateUrl:!1}),this.updateUrl(i?.updateUrl===!1?{replace:!0}:void 0)}catch(s){this.setState({error:String(s)})}}markCachedNewSessionPersisted(t){if(!Y(t))return;const i=this.getState().sessions.find(s=>s.id===t.id)??t;this.replaceSession(Ep(i))}applyCommandResult(t){if(t.type==="select"){this.setState({commandDialog:t});return}const i=(t.type==="unsupported",t.message);if(i!==void 0&&i!==""&&this.setState({messages:[...this.getState().messages,Oe(t.type==="unsupported"?"system":"tool",i)]}),t.type==="done"&&t.session){t.promptDraft!==void 0&&Mi(this.sessionCacheKey(t.session.id),t.promptDraft);const s=this.getState().selectedSession,r=[t.session,...this.getState().sessions.filter(o=>o.id!==t.session?.id)];this.setState({sessions:r,selectedSession:s?.id===t.session.id?t.session:s}),s?.id!==t.session.id&&this.selectSession(t.session)}}applyCreatedSession(t){const i=this.getState();i.selectedWorkspace?.path===t.cwd&&(i.sessions.some(s=>s.id===t.id)||this.setState({sessions:[t,...i.sessions]}))}applyActivity(t){this.setState({sessionActivities:{...this.getState().sessionActivities,[t.sessionId]:t},activity:this.getState().selectedSession?.id===t.sessionId?t:this.getState().activity})}applyStatus(t){const i=this.getState(),s=i.sessionActivities[t.sessionId]?.phase==="active"&&!Xe(t);this.setState({sessionStatuses:{...i.sessionStatuses,[t.sessionId]:t},...fu(i,t.sessionId,t.messageCount),...s?{sessionActivities:cu(i.sessionActivities,t.sessionId)}:{},status:i.selectedSession?.id===t.sessionId?t:i.status,activity:i.selectedSession?.id===t.sessionId&&s?void 0:i.activity}),t.isStreaming||this.finishStreamCatchup(t.sessionId)}applySessionName(t,i){const s=o=>{if(o.id!==t)return o;const n={...o};return i===void 0||i===""?delete n.name:n.name=i,n},r=this.getState().selectedSession;this.setState({sessions:this.getState().sessions.map(s),selectedSession:r===void 0?void 0:s(r)})}applyEvent(t){const i=this.getState().selectedSession?.id;if(this.catchupStreamSessionId!==void 0&&this.catchupStreamSessionId===i){if(t.type==="message.end"||t.type==="agent.end"){this.finishStreamCatchup(this.catchupStreamSessionId);return}if(gu(t))return}if(mu(t)){this.queueTranscriptEvent(t);return}this.flushPendingTranscriptEvents();const s=this.transcripts.applyLiveEvent(this.getState().messages,t);s?this.setState({messages:s}):t.type==="status.update"?this.applyStatus(t.status):t.type==="activity.update"?this.applyActivity(t.activity):t.type==="session.name"&&this.applySessionName(t.sessionId,t.name)}queueTranscriptEvent(t){this.pendingTranscriptEvents.push(t),this.pendingTranscriptFrame===void 0&&(this.pendingTranscriptFrame=requestAnimationFrame(()=>{this.pendingTranscriptFrame=void 0,this.flushPendingTranscriptEvents()}))}flushPendingTranscriptEvents(){if(this.pendingTranscriptEvents.length===0)return;const t=this.pendingTranscriptEvents;this.pendingTranscriptEvents=[];let i=this.getState().messages;for(const s of t)i=this.transcripts.applyLiveEvent(i,s)??i;i!==this.getState().messages&&this.setState({messages:i})}clearPendingTranscriptEvents(){this.pendingTranscriptEvents=[],this.pendingTranscriptFrame!==void 0&&(cancelAnimationFrame(this.pendingTranscriptFrame),this.pendingTranscriptFrame=void 0)}setStreamCatchup(t){return this.catchupStreamSessionId=t,{isReceivingPartialStream:t!==void 0}}finishStreamCatchup(t){const i=this.getState().selectedSession?.id===t;(this.catchupStreamSessionId===t||i&&this.getState().isReceivingPartialStream)&&(this.catchupStreamSessionId=void 0,i&&this.setState({isReceivingPartialStream:!1}),this.refreshMessages(t))}async refreshMessages(t){try{const i=this.getState().selectedSession;if(i?.id!==t)return;const s=await this.api.messages(i,{limit:Tt},g(this.getState()));if(this.getState().selectedSession?.id!==t)return;this.setState(this.transcripts.mergeHistory(this.sessionCacheKey(t),s))}catch(i){this.getState().selectedSession?.id===t&&this.setState({error:String(i)})}}}function cu(e,t){return ka(e,t)}function ka(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}function Mo(e,t){if(t.length===0)return e;const i=new Set(t);return Object.fromEntries(Object.entries(e).filter(([s])=>!i.has(s)))}function To(e){const t=new Set,i=[];for(const s of e)t.has(s.id)||(t.add(s.id),i.push(s));return i}function Eo(e){return e.filter(pu).map(t=>t.value)}function du(e){return e.filter(hu).map(t=>uu(t.reason))}function pu(e){return e.status==="fulfilled"}function hu(e){return e.status==="rejected"}function uu(e){return e instanceof Error?e.message:String(e)}function fu(e,t,i){if(i===void 0)return{};const r=e.sessions.some(n=>n.id===t&&n.messageCount!==i)?e.sessions.map(n=>n.id===t?{...n,messageCount:i}:n):void 0,o=e.selectedSession?.id===t&&e.selectedSession.messageCount!==i?{...e.selectedSession,messageCount:i}:e.selectedSession;return{...r===void 0?{}:{sessions:r},...o!==e.selectedSession?{selectedSession:o}:{}}}function gu(e){return["message.append","assistant.delta","assistant.thinking.delta","tool.start","tool.update","tool.end","shell.start","shell.chunk","shell.end","command.output","session.error"].includes(e.type)}function mu(e){return e.type==="assistant.delta"||e.type==="assistant.thinking.delta"||e.type==="shell.chunk"}function vu(e){return e instanceof Error&&e.message.toLowerCase().includes("session not found")}class bu{constructor(){this.workspaceIdsByProject=new Map}latestWorkspaceId(t){return this.workspaceIdsByProject.get(t)}rememberWorkspace(t){this.workspaceIdsByProject.set(t.projectId,t.id)}forgetProject(t){this.workspaceIdsByProject.delete(t)}}const wu="pi-web:workspace-selection:v1";class yu{constructor(t=Jt()){this.workspaceIdsByProject=new Qi(wu,wr,t)}latestWorkspaceId(t){return this.workspaceIdsByProject.get(t)}rememberWorkspace(t){this.workspaceIdsByProject.set(t.projectId,t.id)}forgetProject(t){this.workspaceIdsByProject.delete(t)}}function xu(e,t){const i=t?.targetWorkspaceId;if(i!==void 0&&i!=="")return e.find(r=>r.id===i);const s=t?.latestWorkspaceId;return s!==void 0&&s!==""?e.find(r=>r.id===s)??e[0]:e[0]}class Su{constructor(t,i,s,r,o=new bu,n={}){this.getState=t,this.setState=i,this.updateUrl=s,this.sessions=r,this.workspaceSelection=o,this.api=n.api??B}clearSelection(t){this.sessions.clearActiveSession(),this.setState({selectedProject:void 0,selectedWorkspace:void 0,workspaces:[],isLoadingWorkspaces:!1,...ui()}),t?.updateUrl!==!1&&this.updateUrl()}forgetProject(t){this.workspaceSelection.forgetProject(ds(g(this.getState()),t));const i=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([s])=>s!==t));this.setState({workspacesByProjectId:i})}async selectProject(t,i){const s=g(this.getState());this.sessions.clearActiveSession(),this.setState({selectedProject:t,selectedWorkspace:void 0,workspaces:[],isLoadingWorkspaces:!0,...ui()});try{const r=await this.api.workspaces(t.id,s);if(g(this.getState())!==s||this.getState().selectedProject?.id!==t.id)return;this.setState({workspaces:r,workspacesByProjectId:{...this.getState().workspacesByProjectId,[t.id]:r},isLoadingWorkspaces:!1});const o=xu(r,{targetWorkspaceId:i?.workspaceId,latestWorkspaceId:this.workspaceSelection.latestWorkspaceId(ds(s,t.id))});o?await this.selectWorkspace(o,{sessionId:i?.sessionId,updateUrl:i?.updateUrl}):i?.updateUrl!==!1&&this.updateUrl()}catch(r){g(this.getState())===s&&this.getState().selectedProject?.id===t.id&&this.setState({error:String(r),isLoadingWorkspaces:!1})}}async selectWorkspace(t,i){const s=g(this.getState());this.workspaceSelection.rememberWorkspace({...t,projectId:ds(s,t.projectId)}),this.sessions.clearActiveSession(),this.setState({selectedWorkspace:t,isLoadingWorkspaces:!1,...ui()});try{const r=ha(t.path,await this.api.sessions(t.path,s),s);if(g(this.getState())!==s||this.getState().selectedWorkspace?.id!==t.id||this.getState().selectedProject?.id!==t.projectId)return;this.setState({sessions:r});const o=this.sessions.preferredSession(t.path,r,i?.sessionId);o?await this.sessions.selectSession(o,{updateUrl:i?.updateUrl}):i?.updateUrl!==!1&&this.updateUrl()}catch(r){g(this.getState())===s&&this.getState().selectedWorkspace?.id===t.id&&this.setState({error:String(r)})}}async refreshProjectWorkspaces(t){const i=this.getState().projects.find(r=>r.id===t);if(i===void 0)throw new Error("Project not found");const s=await this.api.workspaces(i.id,g(this.getState()));return this.applyProjectWorkspaces(i.id,s),s}async refreshAfterWorkspaceDeleted(t,i){const s=await this.refreshProjectWorkspaces(t),r=this.getState();if(r.selectedProject?.id!==t||r.selectedWorkspace?.id!==i)return;const o=$u(s);o!==void 0?await this.selectWorkspace(o):this.clearSelection()}applyProjectWorkspaces(t,i){const s=this.getState(),r={...s.workspacesByProjectId,[t]:i};s.selectedProject?.id===t?this.setState({workspaces:i,workspacesByProjectId:r}):this.setState({workspacesByProjectId:r})}}function ku(e){return e!==void 0&&e.isGitWorktree&&!e.isMain}function $u(e){return e.find(t=>t.isMain)??e[0]}const Pu="pi-web:machine-navigation:v1";class Cu{constructor(t=Jt()){this.snapshotsByMachine=new Qi(Pu,Iu,t)}latest(t){const i=this.snapshotsByMachine.get(t);return i?.machineId===t?Oo(i):void 0}remember(t){this.snapshotsByMachine.set(t.machineId,Oo(t))}forget(t){this.snapshotsByMachine.delete(t)}}function Ru(e){return{machineId:e,surface:{}}}function Do(e){const t=e.selectedWorkspace!==void 0;return{machineId:e.selectedMachine?.id??da,projectId:e.selectedProject?.id,workspaceId:e.selectedWorkspace?.id,sessionId:e.selectedSession?.id,tool:e.workspaceTool,view:e.mainView,surface:{selectedFilePath:t?e.selectedFilePath:void 0,selectedDiffPath:t?e.selectedDiffPath:void 0,selectedTerminalId:t?e.selectedTerminalId:void 0}}}function Wo(e){return{machineId:e.machineId,projectId:e.projectId,workspaceId:e.workspaceId,sessionId:e.sessionId,tool:e.tool,view:e.view==="navigation"?void 0:e.view}}function Oo(e){return{...e,surface:{...e.surface}}}function Iu(e){if(!Pa(e))return;const t=Ne(e,"machineId");if(t===void 0)return;const i=$a(Ne(e,"tool")),s=Mu(Ne(e,"view"));return{machineId:t,projectId:Ne(e,"projectId"),workspaceId:Ne(e,"workspaceId"),sessionId:Ne(e,"sessionId"),...i===void 0?{}:{tool:i},...s===void 0?{}:{view:s},surface:Au(e.surface)}}function Au(e){return Pa(e)?{selectedFilePath:Ne(e,"selectedFilePath"),selectedDiffPath:Ne(e,"selectedDiffPath"),selectedTerminalId:Ne(e,"selectedTerminalId")}:{}}function Mu(e){return e==="navigation"||e==="chat"?e:$a(e)}function $a(e){return Tu(e)?e:void 0}function Tu(e){return e!==void 0&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function Ne(e,t){const i=e[t];return typeof i=="string"&&i!==""?i:void 0}function Pa(e){return typeof e=="object"&&e!==null}const Eu="pi-web:terminal-selection:v1";class Du{constructor(t=Jt()){this.terminalIdsByCwd=new Qi(Eu,wr,t)}latestTerminalId(t){return this.terminalIdsByCwd.get(t)}rememberTerminal(t,i){this.terminalIdsByCwd.set(t,i)}forgetWorkspace(t){this.terminalIdsByCwd.delete(t)}forgetTerminal(t){for(const[i,s]of this.terminalIdsByCwd.entries())s===t&&this.terminalIdsByCwd.delete(i)}}function f0(e,t){const i=t?.targetTerminalId;if(i!==void 0&&i!=="")return e.find(r=>r.id===i);const s=t?.latestTerminalId;return s!==void 0&&s!==""?e.find(r=>r.id===s)??e.find(r=>!r.exited)??e[0]:e.find(r=>!r.exited)??e[0]}function g0(e){return e.find(t=>!t.exited)??e[0]}const Ca=1200,Wu=["mod","alt","shift"];class Ou{constructor(){this.pendingTokens=[]}handle(t,i,s={}){const r=Ia(t);if(r===void 0)return!1;const o=yr(i,s.shortcuts,{enabledOnly:!0}).filter(n=>n.active).map(n=>({action:n.action,tokens:n.tokens}));if(this.pendingTokens.length>0){if(this.handleSequence([...this.pendingTokens,r],o))return!0;if(this.clearPending(),!qt(r))return!1}else if(!qt(r))return!1;return this.handleSequence([r],o)}reset(){this.clearPending()}handleSequence(t,i){const s=i.find(o=>qu(o.tokens,t));return s!==void 0?(this.clearPending(),s.action.run(),!0):i.some(o=>xr(o.tokens,t))?(this.setPending(t),!0):!1}setPending(t){this.clearPending(),this.pendingTokens=t,this.pendingTimer=globalThis.setTimeout(()=>{this.pendingTokens=[],this.pendingTimer=void 0},Ca)}clearPending(){this.pendingTokens=[],this.pendingTimer!==void 0&&(globalThis.clearTimeout(this.pendingTimer),this.pendingTimer=void 0)}}function yr(e,t,i={}){const s=e.flatMap((p,u)=>{if(i.enabledOnly===!0&&p.enabled===!1)return[];const h=ju(p,t,u);return h===void 0?[]:[h]}),r=new Map;for(const p of s)r.set(p.key,[...r.get(p.key)??[],p]);const o=new Map;for(const p of r.values()){const u=[...p].sort(zs)[0];u!==void 0&&o.set(u.key,u)}const n=[...o.values()].sort(Fu),a=new Map,c=new Map;for(const p of s){const u=o.get(p.key);if(u===void 0)continue;const h=Nu(u,n)??u;c.set(p,h),p!==h&&a.set(h,[...a.get(h)??[],p])}return s.map(p=>{const u=c.get(p),h=u===p,f=u===void 0||h?void 0:jo(u),b=h?[...a.get(p)??[]].sort(zs).map(jo):[];return{...p,active:h,shadows:b,...f===void 0?{}:{shadowedBy:f}}}).sort((p,u)=>p.order-u.order)}function fs(e){return Aa(e,{requireFirstChordActivator:!0})}function Ra(e){const t=Aa(e,{requireFirstChordActivator:!1});return t.ok?t.tokens:[]}function vi(e){return Ra(e).map(t=>t.split("+").map(Ta).join("+")).join(" ")}function Ia(e){if(e.isComposing)return;const t=Bu(e.key);if(t===void 0)return;const i=[];return(e.metaKey||e.ctrlKey)&&i.push("mod"),e.altKey&&i.push("alt"),e.shiftKey&&i.push("shift"),i.push(t),i.join("+")}function qt(e){return e.split("+").includes("mod")||e.split("+").includes("alt")}function ju(e,t,i){const s=_u(e.id,t);if(s===null)return;const r=s??e.shortcut;if(r===void 0||r==="")return;const o=Ra(r),n=o[0];if(!(n===void 0||!qt(n)))return{action:e,shortcut:o.join(" "),source:s===void 0?"default":"custom",tokens:o,key:Lu(o),order:i}}function _u(e,t){if(!(t===void 0||!Object.hasOwn(t,e)))return t[e]}function Lu(e){return e.join("\0")}function jo(e){return{action:e.action,shortcut:e.shortcut,source:e.source}}function zs(e,t){return _o(e.source)-_o(t.source)||Lo(e.action.id,t.action.id)||Lo(e.action.title,t.action.title)||e.order-t.order}function Fu(e,t){return e.tokens.length-t.tokens.length||zs(e,t)}function Nu(e,t){return t.find(i=>i!==e&&i.tokens.length<e.tokens.length&&xr(e.tokens,i.tokens))}function _o(e){switch(e){case"custom":return 0;case"default":return 1}}function Lo(e,t){return e<t?-1:e>t?1:0}function Aa(e,t){const i=e.trim().toLowerCase().replace(/\s*\+\s*/gu,"+");if(i==="")return{ok:!1,message:"Enter a shortcut, choose None, or reset to the default."};const s=[],r=i.split(/\s+/u).filter(o=>o!=="");for(const[o,n]of r.entries()){const a=Uu(n);if(!a.ok)return a;if(o===0&&t.requireFirstChordActivator&&!qt(a.token))return{ok:!1,message:"Shortcuts must start with Ctrl/⌘ or Alt so normal typing is not captured."};s.push(a.token)}return{ok:!0,shortcut:s.join(" "),tokens:s}}function Uu(e){const t=e.split("+").filter(o=>o!=="");if(t.length===0)return{ok:!1,message:"Shortcut chords must include a key."};const i=new Set;let s;for(const o of t){const n=zu(o);if(n!==void 0){if(i.has(n))return{ok:!1,message:`Shortcut has duplicate ${Ta(n)} modifiers.`};i.add(n);continue}const a=Ma(o);if(a===void 0)return{ok:!1,message:`Unsupported shortcut key: ${o}`};if(s!==void 0)return{ok:!1,message:"Each shortcut chord can include only one non-modifier key."};s=a}return s===void 0?{ok:!1,message:"Shortcut chords must include a key."}:{ok:!0,token:[...Wu.filter(o=>i.has(o)),s].join("+")}}function zu(e){switch(e){case"mod":case"meta":case"cmd":case"command":case"ctrl":case"control":case"primary":return"mod";case"alt":case"option":case"opt":return"alt";case"shift":return"shift";default:return}}function Ma(e){const t=Hu(e);if(t!==void 0)return t;if(/^f(?:[1-9]|1[0-9]|2[0-4])$/u.test(e)||e.length===1)return e}function Bu(e){if(e===" ")return"space";const t=e.toLowerCase();return Ma(t)}function Hu(e){switch(e){case" ":case"spacebar":case"space":return"space";case"esc":case"escape":return"escape";case"return":case"enter":return"enter";case"del":case"delete":return"delete";case"backspace":return"backspace";case"tab":return"tab";case"up":case"arrowup":return"arrowup";case"down":case"arrowdown":return"arrowdown";case"left":case"arrowleft":return"arrowleft";case"right":case"arrowright":return"arrowright";case"pageup":case"pagedown":case"home":case"end":return e;case"+":case"plus":return"plus";case"period":case"dot":return".";case"comma":return",";case"slash":return"/";case"backslash":return"\\";case"minus":return"-";default:return}}function Ta(e){return e==="mod"?Fo()?"⌘":"Ctrl":e==="shift"?"Shift":e==="alt"?Fo()?"⌥":"Alt":e==="enter"?"Enter":e==="escape"?"Esc":e==="space"?"Space":e==="tab"?"Tab":e==="backspace"?"Backspace":e==="delete"?"Delete":e==="arrowup"?"↑":e==="arrowdown"?"↓":e==="arrowleft"?"←":e==="arrowright"?"→":e==="pageup"?"PageUp":e==="pagedown"?"PageDown":e==="home"?"Home":e==="end"?"End":e==="plus"?"+":/^f(?:[1-9]|1[0-9]|2[0-4])$/u.test(e)||e.length===1?e.toUpperCase():`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function qu(e,t){return e.length===t.length&&xr(e,t)}function xr(e,t){return t.every((i,s)=>e[s]===i)}function Fo(){return typeof navigator<"u"&&navigator.userAgent.toLowerCase().includes("mac")}const Ku={archiveIdleEnabled:!0,archiveIdleDays:"30",deleteArchivedEnabled:!1,deleteArchivedDays:"90"};function Lt(e){if(!e.archiveIdleEnabled&&!e.deleteArchivedEnabled)return{ok:!1,error:"Enable at least one cleanup action."};const t={archiveIdleDays:null,deleteArchivedDays:null};if(e.archiveIdleEnabled){const i=zo(e.archiveIdleDays,"Archive idle sessions after");if(typeof i=="string")return{ok:!1,error:i};t.archiveIdleDays=i}if(e.deleteArchivedEnabled){const i=zo(e.deleteArchivedDays,"Delete archived sessions after");if(typeof i=="string")return{ok:!1,error:i};t.deleteArchivedDays=i}return{ok:!0,request:t}}function St(e){return JSON.stringify({archiveIdleDays:e?.archiveIdleDays??null,deleteArchivedDays:e?.deleteArchivedDays??null})}function No(e){if(!e.canCleanup||e.loading===!0||e.running===!0||e.preview===void 0)return!1;const t=Lt(e.draft);return!t.ok||St(t.request)!==St(e.previewRequest)?!1:bi(e.preview)}function bi(e){return e.totals.archiveCount>0||e.totals.deleteCount>0}function Ea(e,t){const i=e.projects.map(r=>r.cwd);if(t===void 0)return i;const s=new Set(t);return i.filter(r=>s.has(r))}function Uo(e,t){const i=new Set(Ea(e,t)),s=e.projects.filter(r=>i.has(r.cwd));return{...e,projects:s,totals:s.reduce((r,o)=>({archiveCount:r.archiveCount+o.archiveCount,deleteCount:r.deleteCount+o.deleteCount}),{archiveCount:0,deleteCount:0})}}function Vu(e,t){return t(Gu(e))}function Gu(e){const t=e.totals.archiveCount,i=e.totals.deleteCount,s=[];return t>0&&s.push(`archive ${String(t)} idle ${t===1?"session":"sessions"}`),i>0&&s.push(`permanently delete ${String(i)} archived ${i===1?"session":"sessions"}`),`Run cleanup and ${s.length===0?"run cleanup":s.join(" and ")}?
|
|
25
|
+
|
|
26
|
+
Permanent deletion only applies to archived sessions and cannot be undone.`}function Qu(e){return`Update and restart Pi-Web on ${e??"this machine"} to clean up sessions.`}function zo(e,t){const i=e.trim();if(i==="")return`${t} must be set.`;const s=Number(i);return!Number.isInteger(s)||s<0?`${t} must be a non-negative whole number of days.`:s}const Sr="themes:classic",Ju="themes:pi-web-dark",Zu={themeId:Ju,auto:!0},Da="pi-web-app-theme",Xu=["--pi-bg","--pi-surface","--pi-surface-hover","--pi-terminal-bg","--pi-terminal-text","--pi-border","--pi-border-muted","--pi-text","--pi-text-secondary","--pi-text-bright","--pi-muted","--pi-dim","--pi-accent","--pi-accent-border","--pi-selection-bg","--pi-success","--pi-success-border","--pi-success-bg","--pi-success-surface","--pi-success-ring","--pi-warning","--pi-warning-border","--pi-warning-surface","--pi-danger","--pi-purple","--pi-purple-border","--pi-purple-surface","--pi-overlay","--pi-shadow-soft","--pi-shadow","--pi-shadow-strong","--pi-bg-overlay-soft","--pi-bg-overlay","--pi-success-bg-overlay","--pi-terminal-selection"],Yu=/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u;function ef(){try{const e=window.localStorage.getItem(Da);return e===null?void 0:nf(e)}catch{return}}function tf(e){try{window.localStorage.setItem(Da,JSON.stringify(e))}catch{}}function sf(e){const t=document.documentElement;t.dataset.piWebTheme=e.id,t.style.colorScheme=e.colorScheme;for(const i of Xu){const s=e.tokens[i];typeof s=="string"&&s!==""?t.style.setProperty(i,s):t.style.removeProperty(i)}}function rf(e){const t=of(e.themes,e.fallbackThemeId??Sr),i=e.themes.find(n=>n.id===e.preference.themeId)??t;if(i===void 0)return{selectedTheme:void 0,activeTheme:void 0,selectedThemePair:void 0,fallbackTheme:t};const s=Wa(e.themePairs,i.id);if(!e.preference.auto||s===void 0)return{selectedTheme:i,activeTheme:i,selectedThemePair:s,fallbackTheme:t};const r=e.prefersLight?s.light:s.dark,o=e.themes.find(n=>n.id===r)??i;return{selectedTheme:i,activeTheme:o,selectedThemePair:s,fallbackTheme:t}}function of(e,t=Sr){return e.find(i=>i.id===t)??e[0]}function Wa(e,t){return e.find(i=>i.light===t||i.dark===t)}function nf(e){const t=e.trim();if(t!=="")try{const i=JSON.parse(t);return af(i)?i:void 0}catch{return}}function af(e){if(!lf(e))return!1;const t=e.themeId,i=e.auto;return cf(t)&&typeof i=="boolean"}function lf(e){return typeof e=="object"&&e!==null}function cf(e){return typeof e=="string"&&Yu.test(e)}const df="workspace.delete",pf="pi.operation",hf="target.workspaceId";function uf(e){return{...e===void 0?{}:{projectId:e},metadata:{[pf]:df}}}function ff(e){const t={};for(const i of e){const s=Bs(i);if(s===void 0)continue;const r=t[s];(r===void 0||i.createdAt.localeCompare(r.createdAt)>=0)&&(t[s]=i)}return t}function gf(e){return Object.entries(e).filter(([,t])=>Wi(t)).map(([t])=>t)}function Oa(e,t){if(t===void 0)return!1;const i=e.workspaceDeletionRuns[t.id];return i!==void 0&&Wi(i)}function Bs(e){return e.metadata[hf]}function Wi(e){return e.status==="queued"||e.status==="running"}function mf(){return[{id:"actions.show",title:"Show Actions",description:"Open the command palette",shortcut:"mod+k",group:"General",run:e=>{e.openActionPalette()}},{id:"prompt.focus",title:"Focus Prompt",description:"Move keyboard focus to the message composer",shortcut:"mod+g c",group:"General",run:e=>{e.focusPrompt()}},{id:"machine.add",title:"Add Machine",description:"Register another PI WEB runtime reachable from this gateway",group:"Machine",run:e=>e.addMachine()},{id:"machine.refresh",title:"Refresh Selected Machine",description:"Check whether the selected PI WEB runtime is online",group:"Machine",run:e=>e.refreshSelectedMachine()},{id:"machine.open",title:"Open Selected Machine PI WEB",description:"Open the selected remote PI WEB directly in a new tab",group:"Machine",enabled:e=>e.state.selectedMachine?.kind==="remote"&&e.state.selectedMachine.baseUrl!==void 0,run:e=>e.openSelectedMachine()},{id:"machine.remove",title:"Remove Selected Machine",description:"Remove the selected remote machine from this gateway",group:"Machine",enabled:e=>e.state.selectedMachine?.kind==="remote",run:e=>e.removeSelectedMachine()},{id:"project.add",title:"Add Project",group:"Project",run:e=>e.addProject()},{id:"auth.login",title:"Configure Provider Authentication",description:"Run /login without tying authentication to a session",group:"General",run:e=>e.configureAuth()},{id:"auth.logout",title:"Remove Provider Authentication",description:"Run /logout for stored pi credentials",group:"General",run:e=>e.logoutAuth()},{id:"theme.select",title:"Select Theme",description:"Choose the PI WEB color theme",group:"Preferences",run:e=>{e.openThemePicker()}},{id:"settings.open",title:"Open Settings",description:"Manage PI WEB configuration and keyboard shortcuts",shortcut:"mod+,",group:"Preferences",run:e=>{e.piWebUnstable?.openSettings?.()}},{id:"app.reload-page",title:"Full Page Reload",description:"Reload the PI WEB browser page",group:"General",run:e=>{e.reloadPage()}},{id:"view.chat",title:"Go to Chat",shortcut:"mod+1",group:"Navigation",run:e=>{e.focusPrompt()}},{id:"view.files",title:"Go to Files",shortcut:"mod+2",group:"Navigation",enabled:Et,run:e=>{e.selectMainView("core:workspace.files")}},{id:"view.git",title:"Go to Git",shortcut:"mod+3",group:"Navigation",enabled:Bo,run:e=>{e.selectMainView("core:workspace.git")}},{id:"view.terminal",title:"Go to Terminal",shortcut:"mod+4",group:"Navigation",enabled:Et,run:e=>{e.selectMainView("core:workspace.terminal")}},{id:"workspace.refresh-files",title:"Refresh Files",shortcut:"mod+shift+f",group:"Workspace",enabled:Et,run:e=>e.refreshFiles()},{id:"workspace.refresh-git",title:"Refresh Git",shortcut:"mod+shift+g",group:"Workspace",enabled:Bo,run:e=>e.refreshGit()},{id:"workspace.refresh-current",title:"Refresh Current Panel",shortcut:"mod+shift+r",group:"Workspace",enabled:Et,run:e=>e.state.workspaceTool==="core:workspace.git"&&e.state.selectedWorkspace?.isGitRepo===!0?e.refreshGit():e.refreshFiles()},{id:"workspace.delete",title:"Delete Workspace",description:"Remove the selected Git worktree",group:"Workspace",enabled:vf,run:e=>e.deleteWorkspace()},{id:"session.start",title:"Start Session",shortcut:"mod+enter",group:"Session",enabled:Et,run:e=>e.startSession()},{id:"session.archive",title:"Archive Session",description:"Archive the selected session",group:"Session",enabled:bf,run:e=>e.archiveSession()},{id:"session.reload",title:"Reload Session",description:"Re-read the selected session from disk to pick up entries written by another process",group:"Session",enabled:yf,disabledReason:ja,run:e=>e.reloadSession()},{id:"session.delete",title:"Delete New Session",description:"Delete the selected browser-cached new session",group:"Session",enabled:wf,run:e=>e.deleteCachedNewSession()},{id:"session.stop",title:"Stop Active Work",shortcut:"mod+.",group:"Session",enabled:e=>e.state.selectedSession!==void 0&&Xe(e.state.status,e.state.activity),run:e=>e.stopActiveWork()}]}function Et(e){return e.state.selectedWorkspace!==void 0}function Bo(e){return e.state.selectedWorkspace?.isGitRepo===!0}function vf(e){const t=e.state.selectedWorkspace;return t!==void 0&&t.isGitWorktree&&!t.isMain&&!Oa(e.state,t)}function bf(e){const t=e.state.selectedSession;return t!==void 0&&t.archived!==!0&&!Y(t)}function wf(e){return Y(e.state.selectedSession)}function yf(e){const t=e.state.selectedSession;return t===void 0||t.archived===!0||Y(t)||ja(e)!==void 0?!1:!Xe(e.state.status,e.state.activity)}function ja(e){const t=e.state.selectedSession;if(!(t===void 0||t.archived===!0||Y(t))&&!Xe(e.state.status,e.state.activity))return xf(e.state,Qe.sessionsReload,"reload sessions")}function xf(e,t,i){const s=e.machineRuntimes[g(e)];if(!(s?.ok===!0&&nt(s,t)))return`Update and restart Pi-Web on ${e.selectedMachine?.name??"this machine"} to ${i}.`}const Sf="modulepreload",kf=function(e){return"/"+e},Ho={},kr=function(t,i,s){let r=Promise.resolve();if(i&&i.length>0){let c=function(p){return Promise.all(p.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const n=document.querySelector("meta[property=csp-nonce]"),a=n?.nonce||n?.getAttribute("nonce");r=c(i.map(p=>{if(p=kf(p),p in Ho)return;Ho[p]=!0;const u=p.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${h}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Sf,u||(f.as="script"),f.crossOrigin="",f.href=p,a&&f.setAttribute("nonce",a),document.head.appendChild(f),u)return new Promise((b,P)=>{f.addEventListener("load",b),f.addEventListener("error",()=>P(new Error(`Unable to preload CSS for ${p}`)))})}))}function o(n){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=n,window.dispatchEvent(a),!a.defaultPrevented)throw n}return r.then(n=>{for(const a of n||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function $f(e){return typeof e!="string"?l`<span class="tab-custom-icon" aria-hidden="true">${e}</span>`:wi(e)}function wi(e){switch(e){case"navigation":return be`
|
|
27
|
+
<svg class="tab-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
28
|
+
<circle cx="6" cy="7" r="1.5"></circle>
|
|
29
|
+
<path d="M10 7h8"></path>
|
|
30
|
+
<circle cx="6" cy="12" r="1.5"></circle>
|
|
31
|
+
<path d="M10 12h8"></path>
|
|
32
|
+
<circle cx="6" cy="17" r="1.5"></circle>
|
|
33
|
+
<path d="M10 17h8"></path>
|
|
34
|
+
</svg>
|
|
35
|
+
`;case"chat":return be`
|
|
36
|
+
<svg class="tab-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
37
|
+
<path d="M7 5h10a3 3 0 0 1 3 3v5a3 3 0 0 1-3 3h-6l-5 4v-4H7a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3Z"></path>
|
|
38
|
+
<path d="M8 9h8"></path>
|
|
39
|
+
<path d="M8 13h5"></path>
|
|
40
|
+
</svg>
|
|
41
|
+
`;case"files":return be`
|
|
42
|
+
<svg class="tab-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
43
|
+
<path d="M3 7a2 2 0 0 1 2-2h4l2 2.5h8a2 2 0 0 1 2 2V17a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"></path>
|
|
44
|
+
</svg>
|
|
45
|
+
`;case"git":return be`
|
|
46
|
+
<svg class="tab-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
47
|
+
<circle cx="6" cy="6" r="2"></circle>
|
|
48
|
+
<circle cx="18" cy="6" r="2"></circle>
|
|
49
|
+
<circle cx="12" cy="18" r="2"></circle>
|
|
50
|
+
<path d="M8 6h6"></path>
|
|
51
|
+
<path d="M6 8v2a6 6 0 0 0 6 6"></path>
|
|
52
|
+
<path d="M18 8v2a6 6 0 0 1-6 6"></path>
|
|
53
|
+
</svg>
|
|
54
|
+
`;case"terminal":return be`
|
|
55
|
+
<svg class="tab-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
56
|
+
<rect x="3" y="5" width="18" height="14" rx="2"></rect>
|
|
57
|
+
<path d="m7 10 3 3-3 3"></path>
|
|
58
|
+
<path d="M12 16h5"></path>
|
|
59
|
+
</svg>
|
|
60
|
+
`}}const Pf=10*1024*1024,Cf="10 MB",Rf=O`
|
|
61
|
+
/* Mobile browsers already subtract browser controls from 100dvh; reserve bottom safe area only in standalone PWA modes. */
|
|
62
|
+
:host { --pi-app-safe-area-bottom: 0px; position: fixed; top: 0; right: 0; left: 0; display: block; height: 100dvh; box-sizing: border-box; overflow: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) var(--pi-app-safe-area-bottom) env(safe-area-inset-left); color: var(--pi-text); background: var(--pi-bg); font: 14px system-ui, sans-serif; }
|
|
63
|
+
:host([pwa-display-mode]) { --pi-app-safe-area-bottom: env(safe-area-inset-bottom); }
|
|
64
|
+
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
|
|
65
|
+
:host { --pi-app-safe-area-bottom: env(safe-area-inset-bottom); }
|
|
66
|
+
}
|
|
67
|
+
.shell { --navigation-panel-size: 340px; --workspace-panel-size: minmax(360px, 42vw); --navigation-panel-width: var(--navigation-panel-size); --workspace-panel-width: var(--workspace-panel-size); display: grid; grid-template-columns: var(--navigation-panel-width) 1px minmax(320px, 1fr) 1px var(--workspace-panel-width); height: 100%; min-height: 0; }
|
|
68
|
+
aside { grid-column: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
69
|
+
aside app-navigation-panel { flex: 1 1 auto; min-height: 0; }
|
|
70
|
+
header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
71
|
+
.header-actions { display: flex; align-items: center; gap: 8px; }
|
|
72
|
+
project-list, workspace-list { flex: 0 0 auto; max-height: 26%; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--pi-border-muted); }
|
|
73
|
+
session-list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
74
|
+
main { grid-column: 3; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
|
|
75
|
+
.context-bar { position: relative; flex: 0 0 auto; min-width: 0; display: none; align-items: center; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
76
|
+
.context-bar::before, .context-bar::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
77
|
+
.context-bar::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
78
|
+
.context-bar::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
79
|
+
.context-bar.can-scroll-left::before, .context-bar.can-scroll-right::after { opacity: 1; }
|
|
80
|
+
.context-bar-label { display: none; }
|
|
81
|
+
.context-items { flex: 1 1 auto; min-width: 0; display: flex; align-items: stretch; gap: 5px; margin: 0; padding: 0 8px; list-style: none; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-padding-inline: 8px; scrollbar-width: thin; }
|
|
82
|
+
.context-bar.has-context-actions .context-items { padding-right: 52px; scroll-padding-inline: 8px 52px; }
|
|
83
|
+
.context-item { flex: 0 0 auto; min-width: 0; display: flex; }
|
|
84
|
+
.context-actions { position: absolute; top: 6px; right: 0; bottom: 6px; z-index: 3; display: flex; align-items: center; padding: 0 8px 0 0; pointer-events: none; }
|
|
85
|
+
.context-actions::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; z-index: 0; width: 26px; background: var(--pi-bg); pointer-events: none; }
|
|
86
|
+
.context-chip { flex: 0 0 auto; min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 4px 8px; font: inherit; text-align: left; }
|
|
87
|
+
.context-chip:hover { background: var(--pi-surface-hover); }
|
|
88
|
+
.context-chip:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; }
|
|
89
|
+
.context-chip.empty { border-style: dashed; color: var(--pi-muted); }
|
|
90
|
+
.context-kind { display: none; }
|
|
91
|
+
.context-value { min-width: 0; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
92
|
+
app-mobile-main-tabs { display: none; }
|
|
93
|
+
.mobile-tabs-frame { position: relative; display: none; flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
94
|
+
.mobile-tabs-frame::before, .mobile-tabs-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
95
|
+
.mobile-tabs-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
96
|
+
.mobile-tabs-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
97
|
+
.mobile-tabs-frame.can-scroll-left::before, .mobile-tabs-frame.can-scroll-right::after { opacity: 1; }
|
|
98
|
+
.mobile-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
99
|
+
.mobile-tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
100
|
+
.mobile-navigation-tab, .mobile-navigation-panel { display: none; }
|
|
101
|
+
.mobile-tabs button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
102
|
+
.tab-badge { display: inline-block; min-width: 14px; margin-left: 4px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
103
|
+
.navigation-panel-edge, .workspace-panel-edge { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
|
104
|
+
.navigation-panel-edge { grid-column: 2; }
|
|
105
|
+
.workspace-panel-edge { grid-column: 4; }
|
|
106
|
+
.navigation-panel-edge-button, .workspace-panel-edge-button { position: relative; z-index: 1; box-sizing: border-box; display: grid; place-items: center; width: 18px; height: 48px; padding: 0; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-bg); color: var(--pi-muted); opacity: .75; cursor: pointer; }
|
|
107
|
+
.navigation-panel-edge-button:hover, .navigation-panel-edge-button:focus-visible, .workspace-panel-edge-button:hover, .workspace-panel-edge-button:focus-visible { color: var(--pi-text); background: var(--pi-surface-hover); opacity: 1; }
|
|
108
|
+
.shell.navigation-panel-collapsed .navigation-panel-edge-button { transform: translateX(calc(50% - .5px)); }
|
|
109
|
+
.shell.workspace-panel-collapsed .workspace-panel-edge-button { transform: translateX(calc(-50% + .5px)); }
|
|
110
|
+
.navigation-panel-edge-icon, .workspace-panel-edge-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
111
|
+
workspace-panel { grid-column: 5; min-width: 0; min-height: 0; overflow: hidden; }
|
|
112
|
+
@media (min-width: 1181px) {
|
|
113
|
+
.shell.navigation-panel-collapsed { --navigation-panel-width: 0px; }
|
|
114
|
+
.shell.navigation-panel-collapsed > aside { display: none; }
|
|
115
|
+
.shell.workspace-panel-collapsed { --workspace-panel-width: 0px; }
|
|
116
|
+
.shell.workspace-panel-collapsed > workspace-panel { display: none; }
|
|
117
|
+
}
|
|
118
|
+
@media (max-width: 1180px) {
|
|
119
|
+
.shell { grid-template-columns: var(--navigation-panel-width) 1px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
|
120
|
+
.shell.navigation-panel-collapsed { --navigation-panel-width: 0px; }
|
|
121
|
+
.shell.navigation-panel-collapsed > aside { display: none; }
|
|
122
|
+
aside { grid-row: 1 / 3; }
|
|
123
|
+
.navigation-panel-edge { grid-row: 1 / 3; }
|
|
124
|
+
main { grid-column: 3; grid-row: 1 / 3; }
|
|
125
|
+
app-mobile-main-tabs { display: block; flex: 0 0 auto; min-width: 0; }
|
|
126
|
+
.mobile-tabs-frame { display: flex; }
|
|
127
|
+
.shell.workspace-view main { grid-row: 1; min-height: auto; }
|
|
128
|
+
.shell.workspace-view > workspace-panel { grid-column: 3; grid-row: 2; display: flex; border-left: 0; }
|
|
129
|
+
.shell:not(.workspace-view) > workspace-panel { display: none; }
|
|
130
|
+
.workspace-panel-edge { display: none; }
|
|
131
|
+
main.workspace-view chat-view, main.workspace-view prompt-editor, main.workspace-view status-bar,
|
|
132
|
+
main.workspace-view .empty { display: none; }
|
|
133
|
+
main.workspace-view { overflow: hidden; }
|
|
134
|
+
}
|
|
135
|
+
@media (max-width: 760px) {
|
|
136
|
+
.shell { grid-template-columns: minmax(0, 1fr); }
|
|
137
|
+
aside, .navigation-panel-edge { display: none; }
|
|
138
|
+
main, .shell.workspace-view > workspace-panel { grid-column: 1; }
|
|
139
|
+
.context-bar { display: flex; }
|
|
140
|
+
.mobile-navigation-tab { display: block; }
|
|
141
|
+
main.navigation-view chat-view, main.navigation-view prompt-editor, main.navigation-view status-bar,
|
|
142
|
+
main.navigation-view .empty { display: none; }
|
|
143
|
+
main.navigation-view .mobile-navigation-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
|
144
|
+
main.navigation-view .mobile-navigation-panel app-navigation-panel { flex: 1 1 auto; min-height: 0; }
|
|
145
|
+
main.navigation-view .mobile-navigation-panel project-list,
|
|
146
|
+
main.navigation-view .mobile-navigation-panel workspace-list,
|
|
147
|
+
main.navigation-view .mobile-navigation-panel session-list { flex: 1 1 auto; max-height: none; min-height: 0; overflow: hidden; }
|
|
148
|
+
main.navigation-view .mobile-navigation-panel project-list[collapsed],
|
|
149
|
+
main.navigation-view .mobile-navigation-panel workspace-list[collapsed],
|
|
150
|
+
main.navigation-view .mobile-navigation-panel session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
151
|
+
}
|
|
152
|
+
status-bar { flex: 0 0 auto; }
|
|
153
|
+
chat-view { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
154
|
+
prompt-editor { flex: 0 0 auto; }
|
|
155
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
156
|
+
.empty { margin: auto; color: var(--pi-muted); }
|
|
157
|
+
.error { padding: 10px 16px; border-bottom: 1px solid var(--pi-border); color: var(--pi-danger); }
|
|
158
|
+
`,_a=O`
|
|
159
|
+
:host { display: flex; flex-direction: column; min-height: 0; color: var(--pi-text); background: var(--pi-bg); font: 13px system-ui, sans-serif; container-type: inline-size; }
|
|
160
|
+
header { flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); }
|
|
161
|
+
.workspace-header-scroll-frame { position: relative; min-width: 0; background: var(--pi-bg); }
|
|
162
|
+
.workspace-header-scroll-frame::before, .workspace-header-scroll-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 18px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
163
|
+
.workspace-header-scroll-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
164
|
+
.workspace-header-scroll-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
165
|
+
.workspace-header-scroll-frame.can-scroll-left::before, .workspace-header-scroll-frame.can-scroll-right::after { opacity: 1; }
|
|
166
|
+
.workspace-header-strip { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
167
|
+
.tabs { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
|
|
168
|
+
.tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
169
|
+
.tabs button.icon-tab { min-width: 34px; }
|
|
170
|
+
button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 7px; cursor: pointer; }
|
|
171
|
+
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
172
|
+
.tab-icon { flex: 0 0 auto; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
173
|
+
.tab-custom-icon { flex: 0 0 auto; width: 16px; height: 16px; display: inline-grid; place-items: center; color: currentColor; pointer-events: none; }
|
|
174
|
+
.tab-custom-icon svg { width: 16px; height: 16px; pointer-events: none; }
|
|
175
|
+
.tab-label { min-width: 0; }
|
|
176
|
+
.tab-badge { flex: 0 0 auto; display: inline-block; min-width: 14px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
177
|
+
@container (max-width: 430px) {
|
|
178
|
+
.tabs button.icon-tab { justify-content: center; padding-inline: 7px; }
|
|
179
|
+
.tabs button.icon-tab .tab-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
180
|
+
}
|
|
181
|
+
.panel-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
|
|
182
|
+
.empty-state { box-sizing: border-box; width: min(100%, 380px); margin: auto; padding: 24px; display: grid; gap: 8px; color: var(--pi-muted); text-align: center; }
|
|
183
|
+
.empty-state h2 { margin: 0; color: var(--pi-text); font-size: 15px; line-height: 1.3; }
|
|
184
|
+
.empty-state p { margin: 0; line-height: 1.45; }
|
|
185
|
+
small, .muted { color: var(--pi-muted); }
|
|
186
|
+
@media (max-width: 1180px) { header { display: none; } }
|
|
187
|
+
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
188
|
+
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
189
|
+
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
190
|
+
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
191
|
+
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
192
|
+
.toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
193
|
+
.toolbar button { margin-left: auto; }
|
|
194
|
+
.stale { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); padding: 1px 6px; font-size: 12px; }
|
|
195
|
+
.split { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: minmax(160px, 34%) minmax(0, 1fr); }
|
|
196
|
+
.list { min-height: 0; overflow: auto; border-bottom: 1px solid var(--pi-border); padding: 6px; }
|
|
197
|
+
.row { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px; width: 100%; border: 0; border-radius: 5px; background: transparent; text-align: left; padding: 4px 6px 4px calc(6px + var(--depth, 0) * 14px); }
|
|
198
|
+
.row:hover, .row.selected { background: var(--pi-selection-bg); }
|
|
199
|
+
.row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
200
|
+
.summary { margin: 4px 6px 8px; color: var(--pi-muted); }
|
|
201
|
+
.viewer { min-height: 0; overflow: auto; display: flex; flex-direction: column; }
|
|
202
|
+
.diffs { flex: 1 1 auto; min-height: 0; overflow: auto; display: grid; grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
|
|
203
|
+
.diffs.single { grid-template-rows: minmax(0, 1fr); }
|
|
204
|
+
.diff-section { min-height: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--pi-border); }
|
|
205
|
+
.diff-section:last-child { border-bottom: 0; }
|
|
206
|
+
.viewer-header { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
207
|
+
.viewer-header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
208
|
+
code-viewer, unified-diff-viewer { flex: 1 1 auto; min-height: 0; }
|
|
209
|
+
.image-preview { flex: 1 1 auto; min-height: 0; box-sizing: border-box; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 16px; }
|
|
210
|
+
.image-preview img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--pi-border-muted); border-radius: 8px; background-color: var(--pi-surface); background-image: linear-gradient(45deg, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 25%, transparent 25%), linear-gradient(-45deg, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 75%), linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; box-shadow: 0 8px 24px var(--pi-shadow-soft); }
|
|
211
|
+
pre { margin: 0; padding: 10px; overflow: auto; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
212
|
+
p { margin: 10px; }
|
|
213
|
+
`,Ji=O`
|
|
214
|
+
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
215
|
+
:host([collapsed]) { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
216
|
+
section { box-sizing: border-box; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px; }
|
|
217
|
+
h2 { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
218
|
+
.list-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
219
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
220
|
+
section > button { display: block; width: 100%; text-align: left; margin: 6px 0; }
|
|
221
|
+
.subheading { margin-top: 14px; }
|
|
222
|
+
.section-toggle { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; color: inherit; padding: 0; font: inherit; text-align: left; text-transform: inherit; }
|
|
223
|
+
.section-toggle span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
224
|
+
.section-title { display: grid; gap: 2px; min-width: 0; }
|
|
225
|
+
.section-toggle .section-selected { display: block; color: var(--pi-text); font-size: 12px; font-weight: 600; line-height: 1.25; text-transform: none; }
|
|
226
|
+
.section-toggle .section-count { flex: 0 0 auto; display: inline; color: var(--pi-muted); font-size: inherit; }
|
|
227
|
+
.section-toggle small { display: inline; color: inherit; font-size: inherit; }
|
|
228
|
+
.action-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 6px 0; cursor: pointer; }
|
|
229
|
+
.action-row:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; border-radius: 8px; }
|
|
230
|
+
.action-row.selected .action-main, .action-row.selected .action-menu-toggle { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
231
|
+
.action-row.archived .action-main { color: var(--pi-muted); }
|
|
232
|
+
.action-main { position: relative; box-sizing: border-box; min-width: 0; width: 100%; border: 1px solid var(--pi-border); border-top-right-radius: 0; border-bottom-right-radius: 0; border-top-left-radius: 8px; border-bottom-left-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 22px 7px calc(9px + var(--depth, 0) * 16px); text-align: left; }
|
|
233
|
+
.action-name { display: -webkit-box; max-height: 2.5em; overflow: hidden; overflow-wrap: anywhere; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
|
234
|
+
.action-row:not(.selected):hover .action-main { background: var(--pi-surface-hover); }
|
|
235
|
+
.workspace-row .action-main { border-radius: 8px 0 0 8px; }
|
|
236
|
+
.workspace-primary { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
|
|
237
|
+
.workspace-primary-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
238
|
+
.workspace-status { flex: 0 0 auto; color: var(--pi-warning); font-size: 12px; }
|
|
239
|
+
.workspace-secondary { margin-top: 3px; }
|
|
240
|
+
.workspace-menu-panel { width: max-content; min-width: min(120px, calc(100vw - 16px)); padding: 8px; }
|
|
241
|
+
.workspace-menu-actions { margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
242
|
+
.workspace-menu-actions button.danger { color: var(--pi-danger); }
|
|
243
|
+
.workspace-menu-actions button.danger:hover, .workspace-menu-actions button.danger:focus { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
244
|
+
.workspace-menu-details { display: grid; gap: 6px; margin: 0; }
|
|
245
|
+
.workspace-detail-row { display: grid; grid-template-columns: minmax(58px, max-content) minmax(0, 1fr); gap: 8px; align-items: baseline; }
|
|
246
|
+
.workspace-detail-row dt { color: var(--pi-muted); font-size: 12px; white-space: normal; }
|
|
247
|
+
.workspace-detail-row dd { min-width: 0; margin: 0; overflow-wrap: anywhere; white-space: normal; }
|
|
248
|
+
.tree-marker { color: var(--pi-dim); margin-right: 5px; }
|
|
249
|
+
.badge { display: inline-block; margin-left: 5px; border: 1px solid var(--pi-border); border-radius: 999px; color: var(--pi-muted); padding: 0 5px; font-size: 11px; font-weight: 400; }
|
|
250
|
+
.action-activity { position: absolute; top: 5px; right: 6px; z-index: 1; display: grid; place-items: center; width: 10px; height: 10px; }
|
|
251
|
+
.action-activity .activity-indicator { margin: 0; vertical-align: 0; }
|
|
252
|
+
.activity-indicator { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--pi-success); animation: pulse 1s ease-in-out infinite; vertical-align: 1px; }
|
|
253
|
+
.activity-indicator.session { border-radius: 50%; background: var(--pi-success); }
|
|
254
|
+
.activity-indicator.terminal { border-radius: 2px; background: var(--pi-accent); }
|
|
255
|
+
/* Client-side sending (upload in flight); distinct from server activity, which propagates to workspace/machine rows. */
|
|
256
|
+
.activity-indicator.sending { border-radius: 50%; background: var(--pi-warning); }
|
|
257
|
+
.action-menu { position: relative; align-self: stretch; }
|
|
258
|
+
.action-menu-toggle { display: grid; place-items: center; height: 100%; min-width: 32px; padding: 0; color: var(--pi-muted); border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
|
|
259
|
+
.action-menu-toggle:hover { color: var(--pi-text); background: var(--pi-surface-hover); }
|
|
260
|
+
.action-menu-panel { position: fixed; z-index: 50; box-sizing: border-box; min-width: min(120px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); overflow-wrap: anywhere; }
|
|
261
|
+
.action-menu-panel button { display: block; width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; border: 0; background: transparent; color: var(--pi-text); }
|
|
262
|
+
.action-menu-panel button:hover { background: var(--pi-selection-bg); }
|
|
263
|
+
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
264
|
+
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
265
|
+
small { display: block; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
266
|
+
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
267
|
+
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
268
|
+
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
269
|
+
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
270
|
+
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
271
|
+
.workspace-detail-row .workspace-label { overflow: visible; white-space: normal; flex-wrap: wrap; }
|
|
272
|
+
.workspace-detail-row .workspace-label-base, .workspace-detail-row .workspace-label-item, .workspace-detail-row .workspace-label-render { overflow: visible; text-overflow: clip; overflow-wrap: anywhere; white-space: normal; }
|
|
273
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
274
|
+
`,If=O`
|
|
275
|
+
:host { position: relative; z-index: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
276
|
+
.chat-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
277
|
+
.chat { height: 100%; min-height: 0; overflow: auto; overflow-anchor: none; padding: 26px 16px 64px; box-sizing: border-box; }
|
|
278
|
+
.scroll-marker { display: block; height: 0; overflow: hidden; pointer-events: none; }
|
|
279
|
+
.activity-dock { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 8px; min-width: 0; box-sizing: border-box; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-bg-overlay); color: var(--pi-muted); padding: 8px 12px; font-size: 13px; pointer-events: none; box-shadow: 0 8px 28px var(--pi-shadow); backdrop-filter: blur(6px); }
|
|
280
|
+
.activity-dock.active { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-bg-overlay); }
|
|
281
|
+
.activity-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
282
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
|
|
283
|
+
.activity-dock.active .dot { animation: pulse 1s ease-in-out infinite; opacity: 1; }
|
|
284
|
+
.msg { max-width: 100%; min-width: 0; box-sizing: border-box; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); overflow: visible; }
|
|
285
|
+
.msg.assistant { background: var(--pi-surface); }
|
|
286
|
+
.msg.user { border-color: var(--pi-accent-border); background: var(--pi-selection-bg); }
|
|
287
|
+
.msg.tool { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); color: var(--pi-warning); }
|
|
288
|
+
.msg.tool-execution-shell { padding: 0; border: 0; background: transparent; color: var(--pi-text); }
|
|
289
|
+
.msg.system { color: var(--pi-danger); }
|
|
290
|
+
.msg.bash { border-color: var(--pi-success); background: var(--pi-success-bg); }
|
|
291
|
+
.msg.skill { border-color: var(--pi-purple-border); background: var(--pi-purple-surface); }
|
|
292
|
+
.msg.event-group { padding: 0; border-color: var(--pi-border); background: var(--pi-bg); color: var(--pi-muted); }
|
|
293
|
+
.msg.event-group.live { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
294
|
+
.msg.event-group > summary { position: sticky; top: -26px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); color: var(--pi-muted); }
|
|
295
|
+
.msg.event-group.live > summary { border-bottom-color: var(--pi-success-border); background: var(--pi-success-bg); color: var(--pi-success); }
|
|
296
|
+
.msg.event-group > summary .label { margin: 0; }
|
|
297
|
+
.group-body { padding: 0 12px 12px; }
|
|
298
|
+
.chat-image { display: block; max-width: 100%; max-height: 320px; margin: 8px 0 0; border: 1px solid var(--pi-border-muted); border-radius: 8px; object-fit: contain; }
|
|
299
|
+
.group-msg { max-width: 100%; min-width: 0; box-sizing: border-box; padding: 10px 0; border-top: 1px solid var(--pi-border-muted); color: var(--pi-text); overflow: visible; }
|
|
300
|
+
.group-msg.tool { color: var(--pi-warning); }
|
|
301
|
+
.group-msg.tool-execution-shell { color: var(--pi-text); }
|
|
302
|
+
.group-msg.system { color: var(--pi-danger); }
|
|
303
|
+
.group-msg.bash { color: var(--pi-success); }
|
|
304
|
+
.history-boundary { position: relative; z-index: 5; display: grid; gap: 3px; justify-items: center; margin: 0 0 14px; color: var(--pi-muted); font-size: 12px; text-align: center; }
|
|
305
|
+
.history-load-button { border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text-secondary); padding: 5px 12px; font: 12px system-ui, sans-serif; cursor: pointer; }
|
|
306
|
+
.history-load-button:hover, .history-load-button:focus { border-color: var(--pi-accent); color: var(--pi-text-bright); }
|
|
307
|
+
.history-load-button:disabled { cursor: default; opacity: .55; }
|
|
308
|
+
.queued-messages { max-width: 100%; min-width: 0; box-sizing: border-box; display: grid; gap: 8px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-warning-border); border-radius: 10px; background: var(--pi-warning-surface); color: var(--pi-text); overflow: hidden; }
|
|
309
|
+
.queued-header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
|
|
310
|
+
.queued-header strong { color: var(--pi-warning); }
|
|
311
|
+
.queued-header small { color: var(--pi-muted); }
|
|
312
|
+
.queued-message { display: grid; gap: 4px; padding-top: 8px; border-top: 1px solid var(--pi-border); }
|
|
313
|
+
.queued-message:first-of-type { padding-top: 0; border-top: 0; }
|
|
314
|
+
.queued-kind { color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
315
|
+
.session-activity { max-width: 100%; min-width: 0; box-sizing: border-box; display: grid; gap: 4px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); color: var(--pi-text); overflow: hidden; }
|
|
316
|
+
.session-activity.compacting { border-color: var(--pi-purple-border); background: var(--pi-purple-surface); }
|
|
317
|
+
.session-activity.receiving { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
318
|
+
.session-activity strong { color: var(--pi-purple); }
|
|
319
|
+
.session-activity.receiving strong { color: var(--pi-success); }
|
|
320
|
+
.session-activity span, .session-activity small { color: var(--pi-muted); }
|
|
321
|
+
.history-boundary small { color: var(--pi-dim); }
|
|
322
|
+
.msg-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; margin-bottom: 8px; }
|
|
323
|
+
.msg > .msg-header { position: sticky; top: -26px; z-index: 4; margin: -12px -12px 8px; padding: 7px 10px 6px; border-radius: 9px 9px 0 0; border-bottom: 1px solid color-mix(in srgb, var(--pi-border-muted) 35%, transparent); background: var(--pi-surface); box-shadow: 0 8px 18px var(--pi-shadow-soft); }
|
|
324
|
+
.msg.user > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-accent-border) 35%, transparent); background: var(--pi-selection-bg); }
|
|
325
|
+
.msg.assistant > .msg-header .label { color: var(--pi-text-secondary); }
|
|
326
|
+
.msg.user > .msg-header .label { color: var(--pi-accent); }
|
|
327
|
+
.msg.tool > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-warning-border) 35%, transparent); background: var(--pi-warning-surface); }
|
|
328
|
+
.msg.bash > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-success) 35%, transparent); background: var(--pi-success-bg); }
|
|
329
|
+
.msg.skill > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-purple-border) 35%, transparent); background: var(--pi-purple-surface); }
|
|
330
|
+
.group-msg > .msg-header { position: sticky; top: -26px; z-index: 4; margin: -10px 0 8px; padding: 7px 0 6px; border-bottom: 1px solid color-mix(in srgb, var(--pi-border-muted) 35%, transparent); background: var(--pi-bg); }
|
|
331
|
+
.msg-header-trailing { min-width: 0; display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
|
|
332
|
+
.msg-actions { display: inline-flex; gap: 6px; opacity: 0; transition: opacity .12s ease; }
|
|
333
|
+
.msg-action { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 0; font: 14px system-ui, sans-serif; line-height: 1; cursor: pointer; }
|
|
334
|
+
.msg-action:hover, .msg-action:focus { color: var(--pi-text); border-color: var(--pi-accent); }
|
|
335
|
+
.msg:hover > .msg-header .msg-actions, .msg:focus-within > .msg-header .msg-actions, .group-msg:hover > .msg-header .msg-actions, .group-msg:focus-within > .msg-header .msg-actions { opacity: 1; }
|
|
336
|
+
.label { display: block; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
337
|
+
.msg-header .label { margin: 0; }
|
|
338
|
+
.msg-meta { min-width: 0; opacity: .28; border: 0; background: transparent; color: var(--pi-dim); padding: 0; font: 11px system-ui, sans-serif; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .12s ease, max-width .12s ease; cursor: pointer; user-select: text; -webkit-user-select: text; }
|
|
339
|
+
.msg:hover > .msg-header .msg-meta, .msg:focus-within > .msg-header .msg-meta, .group-msg:hover > .msg-header .msg-meta, .group-msg:focus-within > .msg-header .msg-meta, .msg-meta:focus, .msg-meta.expanded { opacity: 1; }
|
|
340
|
+
.msg-meta:focus { outline: 1px solid var(--pi-border); outline-offset: 3px; border-radius: 4px; }
|
|
341
|
+
@media (hover: none) {
|
|
342
|
+
.msg-actions { opacity: 1; }
|
|
343
|
+
.msg-meta { opacity: .75; max-width: 26px; }
|
|
344
|
+
.msg-meta::before { content: "ⓘ"; font-size: 13px; }
|
|
345
|
+
.msg-meta:focus, .msg-meta.expanded { opacity: 1; max-width: 75%; }
|
|
346
|
+
.msg-meta:focus::before, .msg-meta.expanded::before { content: ""; }
|
|
347
|
+
}
|
|
348
|
+
formatted-text.part { display: block; }
|
|
349
|
+
formatted-text.part, .queued-message formatted-text { text-align: start; unicode-bidi: plaintext; }
|
|
350
|
+
.part { max-width: 100%; min-width: 0; box-sizing: border-box; overflow: visible; }
|
|
351
|
+
.part + .part { margin-top: 10px; }
|
|
352
|
+
.tool-line { color: var(--pi-warning); }
|
|
353
|
+
.summary { color: var(--pi-muted); margin-left: 6px; }
|
|
354
|
+
.part:is(details) { border-top: 1px solid var(--pi-border); padding-top: 8px; }
|
|
355
|
+
.part > formatted-text { display: block; max-width: 100%; min-width: 0; overflow: visible; }
|
|
356
|
+
.skill-invocation, .skill-read { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); padding: 8px 10px; }
|
|
357
|
+
.skill-invocation > summary, .skill-read > strong { color: var(--pi-purple); }
|
|
358
|
+
.skill-invocation > small, .skill-read > small { display: block; margin: 6px 0 0; color: var(--pi-muted); }
|
|
359
|
+
summary { cursor: pointer; color: var(--pi-muted); }
|
|
360
|
+
pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; direction: ltr; text-align: left; unicode-bidi: isolate; }
|
|
361
|
+
.shell-output { color: var(--pi-text); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; direction: ltr; text-align: left; unicode-bidi: isolate; }
|
|
362
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
363
|
+
`,Af=O`
|
|
364
|
+
:host { display: block; }
|
|
365
|
+
.formatted { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; text-align: start; unicode-bidi: plaintext; }
|
|
366
|
+
p, ul, ol, pre, blockquote, table, .code-block-wrapper { margin: 0 0 10px; }
|
|
367
|
+
:is(p, ul, ol, pre, blockquote, table, .code-block-wrapper):last-child { margin-bottom: 0; }
|
|
368
|
+
ul, ol { padding-left: 22px; }
|
|
369
|
+
li + li { margin-top: 3px; }
|
|
370
|
+
code { border: 1px solid var(--pi-border); border-radius: 4px; background: var(--pi-bg); padding: 1px 4px; font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; text-align: left; unicode-bidi: isolate; }
|
|
371
|
+
.code-block-wrapper { position: relative; }
|
|
372
|
+
.code-block-wrapper pre { margin: 0; padding-right: 40px; }
|
|
373
|
+
pre { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); padding: 10px; overflow-x: auto; overflow-y: hidden; direction: ltr; text-align: left; unicode-bidi: isolate; }
|
|
374
|
+
pre code { border: 0; padding: 0; background: transparent; }
|
|
375
|
+
.code-copy-button { position: absolute; top: 6px; right: 6px; z-index: 1; display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 0; font: 14px system-ui, sans-serif; line-height: 1; cursor: pointer; }
|
|
376
|
+
.code-copy-button:hover, .code-copy-button:focus { color: var(--pi-text); border-color: var(--pi-accent); }
|
|
377
|
+
blockquote { border-left: 3px solid var(--pi-border); padding-left: 10px; color: var(--pi-muted); }
|
|
378
|
+
a { color: var(--pi-accent); }
|
|
379
|
+
h1, h2, h3, h4 { margin: 14px 0 8px; line-height: 1.2; }
|
|
380
|
+
h1:first-child, h2:first-child, h3:first-child, h4:first-child { margin-top: 0; }
|
|
381
|
+
h1 { font-size: 20px; }
|
|
382
|
+
h2 { font-size: 17px; }
|
|
383
|
+
h3 { font-size: 15px; }
|
|
384
|
+
h4 { font-size: 14px; }
|
|
385
|
+
table { border-collapse: collapse; display: block; overflow-x: auto; overflow-y: hidden; }
|
|
386
|
+
th, td { border: 1px solid var(--pi-border); padding: 4px 8px; }
|
|
387
|
+
th { background: var(--pi-surface); }
|
|
388
|
+
`,Mf=O`
|
|
389
|
+
:host { display: block; color: var(--pi-muted); font: 12px system-ui, sans-serif; }
|
|
390
|
+
.bar { display: flex; justify-content: flex-end; gap: 12px; align-items: center; min-width: 0; padding: 7px 12px; border-top: 1px solid var(--pi-border); background: var(--pi-bg); white-space: nowrap; overflow: hidden; }
|
|
391
|
+
span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
392
|
+
.activity { display: inline-flex; align-items: center; gap: 6px; color: var(--pi-muted); }
|
|
393
|
+
.activity.active { color: var(--pi-success); }
|
|
394
|
+
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
|
|
395
|
+
.activity.active .dot { animation: pulse 1s ease-in-out infinite; opacity: 1; }
|
|
396
|
+
.muted { color: var(--pi-dim); }
|
|
397
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
398
|
+
`,Tf=O`
|
|
399
|
+
:host { display: block; }
|
|
400
|
+
.menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 10; max-height: 260px; overflow: auto; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 10px 30px var(--pi-shadow); }
|
|
401
|
+
button { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 4px 10px; width: 100%; border: 0; border-bottom: 1px solid var(--pi-border); border-radius: 0; background: transparent; color: var(--pi-text); padding: 8px 10px; text-align: left; cursor: pointer; }
|
|
402
|
+
button:last-child { border-bottom: 0; }
|
|
403
|
+
button.selected, button:hover { background: var(--pi-selection-bg); }
|
|
404
|
+
span { color: var(--pi-muted); font-size: 12px; }
|
|
405
|
+
small { grid-column: 1 / -1; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
406
|
+
`,La=O`
|
|
407
|
+
:host { position: fixed; inset: 0; z-index: 10; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
408
|
+
.backdrop { display: grid; place-items: center; width: 100%; height: 100%; background: var(--pi-overlay); }
|
|
409
|
+
section { width: min(720px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 40px)); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
410
|
+
header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
411
|
+
.options { min-height: 0; overflow: auto; outline: none; }
|
|
412
|
+
button { border: 0; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
413
|
+
header button { font-size: 20px; color: var(--pi-muted); }
|
|
414
|
+
input { margin: 10px 12px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); font: 14px system-ui, sans-serif; padding: 8px 10px; outline: none; }
|
|
415
|
+
input:focus { border-color: var(--pi-accent); }
|
|
416
|
+
.options button { display: block; width: 100%; padding: 10px 12px; border-bottom: 1px solid var(--pi-border-muted); text-align: left; }
|
|
417
|
+
.options button.selected, .options button:hover { background: var(--pi-selection-bg); }
|
|
418
|
+
small { display: block; margin-top: 4px; color: var(--pi-muted); }
|
|
419
|
+
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
420
|
+
`,Ef=O`
|
|
421
|
+
:host { position: fixed; inset: 0; z-index: 20; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
422
|
+
.backdrop { --palette-top: min(12dvh, 90px); --palette-bottom: max(20px, env(safe-area-inset-bottom)); display: grid; align-items: start; justify-items: center; width: 100%; height: 100dvh; background: var(--pi-overlay); padding: var(--palette-top) 20px var(--palette-bottom); box-sizing: border-box; overflow: hidden; }
|
|
423
|
+
section { width: min(720px, 100%); max-height: min(640px, calc(100dvh - var(--palette-top) - var(--palette-bottom))); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
424
|
+
header { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px; border-bottom: 1px solid var(--pi-border); }
|
|
425
|
+
input { min-width: 0; border: 0; outline: none; background: transparent; color: var(--pi-text); font: 16px system-ui, sans-serif; padding: 8px; }
|
|
426
|
+
input::placeholder { color: var(--pi-dim); }
|
|
427
|
+
button { border: 0; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
428
|
+
header button { color: var(--pi-muted); font-size: 22px; padding: 2px 8px; }
|
|
429
|
+
.options { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
430
|
+
.options button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; width: 100%; padding: 10px 12px; border-bottom: 1px solid var(--pi-border-muted); text-align: left; }
|
|
431
|
+
.options button.selected, .options button:hover:not(:disabled) { background: var(--pi-selection-bg); }
|
|
432
|
+
.options button:disabled { cursor: not-allowed; opacity: .68; }
|
|
433
|
+
.options button.disabled.selected { background: color-mix(in srgb, var(--pi-selection-bg) 55%, transparent); }
|
|
434
|
+
.main { min-width: 0; }
|
|
435
|
+
strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
436
|
+
small { display: block; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
437
|
+
.disabled-reason { color: var(--pi-warning); }
|
|
438
|
+
.group { grid-column: 1 / -1; font-size: 12px; }
|
|
439
|
+
kbd { align-self: center; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 2px 6px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
|
|
440
|
+
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
441
|
+
`,Df=O`
|
|
442
|
+
:host { position: relative; z-index: 5; display: block; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
443
|
+
footer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; border-top: 1px solid var(--pi-border); }
|
|
444
|
+
footer.shell-mode { border-top-color: var(--pi-success); background: var(--pi-success-bg); }
|
|
445
|
+
.editor-wrap { position: relative; min-width: 0; }
|
|
446
|
+
.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; white-space: nowrap; }
|
|
447
|
+
.compact-status { display: flex; min-width: 0; align-items: center; gap: 6px; color: var(--pi-muted); font-size: 12px; flex: 1 1 0; }
|
|
448
|
+
.compact-status > button { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
449
|
+
.select-model { max-width: min(42vw, 320px); }
|
|
450
|
+
.icon-button { flex: 0 0 auto; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; }
|
|
451
|
+
.icon-button .prompt-action-icon, .icon-button .prompt-thinking-gauge { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
452
|
+
.icon-button .prompt-action-icon-filled { fill: currentColor; stroke: none; }
|
|
453
|
+
.send-button:not(:disabled) { color: var(--pi-accent, var(--pi-text)); }
|
|
454
|
+
.stop-button:not(:disabled) { color: var(--pi-danger); }
|
|
455
|
+
.select-thinking .prompt-thinking-gauge .gauge-bar { fill: currentColor; stroke: none; opacity: .28; }
|
|
456
|
+
.select-thinking .prompt-thinking-gauge .gauge-bar-active { opacity: 1; }
|
|
457
|
+
.editor-attach { position: absolute; right: 8px; bottom: 8px; z-index: 2; width: 30px; height: 30px; }
|
|
458
|
+
.editor-attach .prompt-action-icon { width: 16px; height: 16px; }
|
|
459
|
+
textarea, .markdown-editor .cm-editor { box-sizing: border-box; width: 100%; min-height: 54px; max-height: 220px; resize: none; overflow: hidden; border-radius: 8px; border: 1px solid var(--pi-border); background: var(--pi-bg); color: var(--pi-text); font: 16px/1.4 system-ui, sans-serif; }
|
|
460
|
+
textarea { overflow-y: auto; padding: 8px; }
|
|
461
|
+
.markdown-editor .cm-scroller { max-height: 220px; overflow-y: auto; font-family: system-ui, sans-serif; line-height: 1.4; }
|
|
462
|
+
.markdown-editor .cm-content { min-height: 38px; padding: 8px 44px 8px 8px; caret-color: var(--pi-text); text-align: start; unicode-bidi: plaintext; }
|
|
463
|
+
.markdown-editor .cm-line { padding: 0; unicode-bidi: plaintext; }
|
|
464
|
+
.markdown-editor .cm-placeholder { color: var(--pi-dim); }
|
|
465
|
+
.markdown-editor .cm-focused { outline: none; }
|
|
466
|
+
.shell-mode textarea, .shell-mode .markdown-editor .cm-editor { border-color: var(--pi-success); box-shadow: 0 0 0 1px var(--pi-success-ring); }
|
|
467
|
+
.mode-hint { position: absolute; right: 46px; bottom: 8px; max-width: calc(100% - 54px); border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 2px 8px; font-size: 12px; pointer-events: none; }
|
|
468
|
+
.attachments { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
|
|
469
|
+
.attachment-chip { position: relative; width: 56px; height: 56px; border: 1px solid var(--pi-border); border-radius: 8px; overflow: hidden; background: var(--pi-bg); }
|
|
470
|
+
.attachment-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
471
|
+
.attachment-chip-file { display: grid; place-items: center; }
|
|
472
|
+
.attachment-file-preview { display: grid; place-items: center; width: 34px; height: 26px; border: 1px solid var(--pi-border-muted); border-radius: 4px; background: var(--pi-surface); color: var(--pi-muted); font: 700 10px/1 system-ui, sans-serif; letter-spacing: .03em; }
|
|
473
|
+
.attachment-file-name { position: absolute; right: 4px; bottom: 3px; left: 4px; overflow: hidden; color: var(--pi-muted); font-size: 10px; line-height: 1.2; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
|
|
474
|
+
.attachment-remove { position: absolute; top: 1px; right: 1px; width: 18px; height: 18px; padding: 0; line-height: 16px; border-radius: 50%; border: 1px solid var(--pi-border); background: var(--pi-surface); color: var(--pi-text); font-size: 13px; cursor: pointer; }
|
|
475
|
+
.attachment-delivery select { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 7px; font: 12px system-ui, sans-serif; }
|
|
476
|
+
.attachment-error { flex-basis: 100%; color: var(--pi-danger); font-size: 12px; }
|
|
477
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
478
|
+
button:disabled, textarea:disabled, .markdown-editor-disabled .cm-editor { opacity: .5; cursor: not-allowed; }
|
|
479
|
+
@media (max-width: 640px) {
|
|
480
|
+
footer { gap: 8px; padding: 8px; }
|
|
481
|
+
.actions { gap: 6px; }
|
|
482
|
+
.compact-status { flex: 1 1 220px; gap: 4px; }
|
|
483
|
+
.select-model { max-width: min(58vw, 260px); }
|
|
484
|
+
button { padding: 6px 8px; }
|
|
485
|
+
}
|
|
486
|
+
@media (max-width: 430px) {
|
|
487
|
+
.compact-status { flex-basis: 170px; font-size: 11px; }
|
|
488
|
+
.select-model { max-width: 48vw; }
|
|
489
|
+
button { padding: 5px 7px; }
|
|
490
|
+
.icon-button { width: 34px; height: 34px; }
|
|
491
|
+
}
|
|
492
|
+
`;var Wf=Object.defineProperty,Of=Object.getOwnPropertyDescriptor,Be=(e,t,i,s)=>{for(var r=s>1?void 0:s?Of(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Wf(t,i,r),r};let Me=class extends M{constructor(){super(...arguments),this.destinationFolder="",this.overwrite=!1,this.createDirs=!0,this.formError="",this.dragActive=!1,this.dragDepth=0,this.openFilePicker=()=>{this.uploadInput?.click()},this.handleFileInputChange=e=>{const t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0,i=Ko(t?.files);t!==void 0&&(t.value=""),i.length>0&&this.openUploadReview(i)},this.handleDragEnter=e=>{ri(e)&&(e.preventDefault(),this.dragDepth+=1,this.dragActive=!0)},this.handleDragOver=e=>{ri(e)&&(e.preventDefault(),e.dataTransfer!==null&&(e.dataTransfer.dropEffect="copy"),this.dragActive=!0)},this.handleDragLeave=e=>{ri(e)&&(e.preventDefault(),this.dragDepth=Math.max(0,this.dragDepth-1),this.dragDepth===0&&(this.dragActive=!1))},this.handleDrop=e=>{if(!ri(e))return;e.preventDefault(),this.dragDepth=0,this.dragActive=!1;const t=Ko(e.dataTransfer?.files),i=this.context;t.length>0&&i!==void 0&&Ff(i,t)},this.handleDestinationInput=e=>{const t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0;this.destinationFolder=t?.value??"",this.formError=""},this.handleCreateDirsChange=e=>{const t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0;this.createDirs=t?.checked??!0},this.handleOverwriteChange=e=>{const t=e.currentTarget instanceof HTMLInputElement?e.currentTarget:void 0;this.overwrite=t?.checked??!1},this.handleDialogKeyDown=e=>{e.key==="Escape"&&(e.preventDefault(),this.closeUploadDialog())}}willUpdate(e){if(!e.has("context"))return;const t=e.get("context");t!==void 0&&this.context!==void 0&&qo(t)!==qo(this.context)&&this.resetPendingUpload()}render(){const e=this.context;return e===void 0?l`<p class="muted">Files unavailable.</p>`:l`
|
|
493
|
+
<section
|
|
494
|
+
class=${this.dragActive?"files-panel dragging":"files-panel"}
|
|
495
|
+
@dragenter=${this.handleDragEnter}
|
|
496
|
+
@dragover=${this.handleDragOver}
|
|
497
|
+
@dragleave=${this.handleDragLeave}
|
|
498
|
+
@drop=${this.handleDrop}
|
|
499
|
+
>
|
|
500
|
+
<section class="toolbar">
|
|
501
|
+
<strong>Files</strong>
|
|
502
|
+
${e.fileTreeStale?l`<span class="stale">stale</span>`:null}
|
|
503
|
+
<div class="toolbar-actions">
|
|
504
|
+
<button @click=${this.openFilePicker}>Upload</button>
|
|
505
|
+
<button @click=${e.onRefreshFiles}>Refresh</button>
|
|
506
|
+
</div>
|
|
507
|
+
<input id="workspace-upload-input" class="visually-hidden" type="file" multiple @change=${this.handleFileInputChange} />
|
|
508
|
+
</section>
|
|
509
|
+
${this.renderUploadProgress(e)}
|
|
510
|
+
<section class="split">
|
|
511
|
+
<div class="list tree">
|
|
512
|
+
${e.fileTree.length===0?l`<p class="muted">No files loaded.</p>`:e.fileTree.map(t=>this.renderTreeEntry(e,t,0))}
|
|
513
|
+
</div>
|
|
514
|
+
<div class="viewer">
|
|
515
|
+
${this.renderFileViewer(e)}
|
|
516
|
+
</div>
|
|
517
|
+
</section>
|
|
518
|
+
<div class="drop-overlay" aria-hidden=${this.dragActive?"false":"true"}>
|
|
519
|
+
<div>
|
|
520
|
+
<strong>Drop files to upload</strong>
|
|
521
|
+
<span>Uploads immediately to the default folder.</span>
|
|
522
|
+
</div>
|
|
523
|
+
</div>
|
|
524
|
+
${this.pendingUpload===void 0?null:this.renderUploadDialog(e,this.pendingUpload)}
|
|
525
|
+
</section>
|
|
526
|
+
`}renderTreeEntry(e,t,i){const s=e.expandedDirs[t.path],r=s!==void 0,o=t.type!=="directory"&&e.selectedFilePath===t.path;return l`
|
|
527
|
+
<button class=${o?"row selected":"row"} style=${`--depth:${String(i)}`} @click=${()=>{this.selectTreeEntry(e,t)}}>
|
|
528
|
+
<span>${t.type==="directory"?r?"▾":"▸":"·"}</span>
|
|
529
|
+
<span>${t.name}</span>
|
|
530
|
+
</button>
|
|
531
|
+
${r?s.map(n=>this.renderTreeEntry(e,n,i+1)):null}
|
|
532
|
+
`}selectTreeEntry(e,t){t.type==="directory"?e.onExpandDir(t.path):e.onSelectFile(t.path)}renderFileViewer(e){const t=e.selectedFileContent;return e.selectedFilePath===void 0||e.selectedFilePath===""?l`<p class="muted">Select a file.</p>`:t===void 0?l`<p class="muted">Loading ${e.selectedFilePath}…</p>`:t.mediaType==="image"?this.renderImageViewer(e,t):t.binary?l`<p class="muted">Binary file: ${t.path} · ${yt(t.size)}</p>`:(Kf(),l`
|
|
533
|
+
<div class="viewer-header"><strong>${t.path}</strong><small>${t.language??"text"}${t.truncated?" · truncated":""}</small></div>
|
|
534
|
+
<code-viewer .content=${t.content} .language=${t.language}></code-viewer>
|
|
535
|
+
`)}renderImageViewer(e,t){const i=`${t.mimeType??"image"} · ${yt(t.size)}`;if(t.size>Pf)return l`
|
|
536
|
+
<div class="viewer-header"><strong>${t.path}</strong><small>${i}</small></div>
|
|
537
|
+
<p class="muted">Image too large to preview: ${yt(t.size)} · limit ${Cf}</p>
|
|
538
|
+
`;const s=Fd(e.workspace.projectId,e.workspace.id,t.path,{modifiedAt:t.modifiedAt,machineId:e.machine.id});return l`
|
|
539
|
+
<div class="viewer-header"><strong>${t.path}</strong><small>${i}</small></div>
|
|
540
|
+
<div class="image-preview">
|
|
541
|
+
<img src=${s} alt=${t.path} decoding="async" />
|
|
542
|
+
</div>
|
|
543
|
+
`}renderUploadProgress(e){const t=jf(e.state.workspaceUploadBatches,{projectId:e.workspace.projectId,workspaceId:e.workspace.id,machineId:e.machine.id});return t.length===0?null:l`
|
|
544
|
+
<section class="upload-progress" aria-label="Workspace uploads">
|
|
545
|
+
<div class="upload-progress-header">
|
|
546
|
+
<strong>Uploads</strong>
|
|
547
|
+
<small>${Nf(t)}</small>
|
|
548
|
+
</div>
|
|
549
|
+
${t.map(i=>this.renderUploadBatch(e,i))}
|
|
550
|
+
</section>
|
|
551
|
+
`}renderUploadBatch(e,t){return l`
|
|
552
|
+
<article class=${`upload-batch ${t.status}`}>
|
|
553
|
+
<div class="upload-batch-heading">
|
|
554
|
+
<div>
|
|
555
|
+
<strong>${Uf(t)}</strong>
|
|
556
|
+
<small>${t.destinationFolder===""?"workspace root":t.destinationFolder}</small>
|
|
557
|
+
</div>
|
|
558
|
+
<span>${zf(t)}</span>
|
|
559
|
+
</div>
|
|
560
|
+
<progress max="1" .value=${Bf(t)}></progress>
|
|
561
|
+
<div class="upload-file-list">
|
|
562
|
+
${t.files.map(i=>this.renderUploadFile(i))}
|
|
563
|
+
</div>
|
|
564
|
+
<div class="upload-actions">
|
|
565
|
+
${t.status==="uploading"?l`<button @click=${()=>{e.onCancelWorkspaceUpload(t.id)}}>Cancel</button>`:l`<button @click=${()=>{e.onClearWorkspaceUpload(t.id)}}>Dismiss</button>`}
|
|
566
|
+
</div>
|
|
567
|
+
</article>
|
|
568
|
+
`}renderUploadFile(e){const t=qf(e);return l`
|
|
569
|
+
<div class=${`upload-file ${e.status}`}>
|
|
570
|
+
<div class="upload-file-main">
|
|
571
|
+
<span>${e.name}</span>
|
|
572
|
+
<small>${t}</small>
|
|
573
|
+
</div>
|
|
574
|
+
<span class="upload-file-status">${Hf(e)}</span>
|
|
575
|
+
</div>
|
|
576
|
+
`}renderUploadDialog(e,t){const i=t.files.length;return l`
|
|
577
|
+
<div class="dialog-backdrop" @mousedown=${()=>{this.closeUploadDialog()}}>
|
|
578
|
+
<section class="upload-dialog" role="dialog" aria-modal="true" aria-label="Review file upload" @mousedown=${s=>{s.stopPropagation()}} @keydown=${this.handleDialogKeyDown}>
|
|
579
|
+
<header>
|
|
580
|
+
<div>
|
|
581
|
+
<span class="eyebrow">Upload</span>
|
|
582
|
+
<h2>Review ${i===1?"file":`${String(i)} files`}</h2>
|
|
583
|
+
</div>
|
|
584
|
+
<button class="close-button" title="Cancel upload" aria-label="Cancel upload" @click=${()=>{this.closeUploadDialog()}}>×</button>
|
|
585
|
+
</header>
|
|
586
|
+
<form @submit=${s=>{this.submitUploadReview(s,e,t)}}>
|
|
587
|
+
<label>
|
|
588
|
+
<span>Destination folder</span>
|
|
589
|
+
<input .value=${this.destinationFolder} placeholder=${e.workspaceUploadDefaultFolder} @input=${this.handleDestinationInput} />
|
|
590
|
+
<small>Workspace-relative. Leave empty to upload at the workspace root.</small>
|
|
591
|
+
</label>
|
|
592
|
+
<div class="dialog-options">
|
|
593
|
+
<label>
|
|
594
|
+
<input type="checkbox" .checked=${this.createDirs} @change=${this.handleCreateDirsChange} />
|
|
595
|
+
<span>Create parent folders</span>
|
|
596
|
+
</label>
|
|
597
|
+
<label>
|
|
598
|
+
<input type="checkbox" .checked=${this.overwrite} @change=${this.handleOverwriteChange} />
|
|
599
|
+
<span>Overwrite existing files</span>
|
|
600
|
+
</label>
|
|
601
|
+
</div>
|
|
602
|
+
<section class="review-files" aria-label="Files to upload">
|
|
603
|
+
<strong>${i===1?"File":"Files"}</strong>
|
|
604
|
+
${t.files.map(s=>l`
|
|
605
|
+
<div class="review-file">
|
|
606
|
+
<span>${s.name}</span>
|
|
607
|
+
<small>${yt(s.size)}</small>
|
|
608
|
+
</div>
|
|
609
|
+
`)}
|
|
610
|
+
</section>
|
|
611
|
+
${this.formError===""?null:l`<div class="dialog-error" role="alert">${this.formError}</div>`}
|
|
612
|
+
<footer>
|
|
613
|
+
<button type="button" @click=${()=>{this.closeUploadDialog()}}>Cancel</button>
|
|
614
|
+
<button type="submit">Upload</button>
|
|
615
|
+
</footer>
|
|
616
|
+
</form>
|
|
617
|
+
</section>
|
|
618
|
+
</div>
|
|
619
|
+
`}openUploadReview(e){const t=this.context,i=Lf(t?.workspaceUploadDefaultFolder??"");this.pendingUpload={files:e},this.destinationFolder=i.destinationFolder,this.overwrite=i.overwrite,this.createDirs=i.createDirs,this.formError=""}submitUploadReview(e,t,i){e.preventDefault();const s=_f(i.files,this.destinationFolder);if(s!==void 0){this.formError=s;return}t.onStartWorkspaceUpload(i.files,{destinationFolder:this.destinationFolder,createDirs:this.createDirs,overwrite:this.overwrite,selectUploadedFile:!0})!==void 0&&this.closeUploadDialog()}closeUploadDialog(){this.pendingUpload=void 0,this.formError=""}resetPendingUpload(){this.closeUploadDialog(),this.dragDepth=0,this.dragActive=!1}};Me.styles=[_a,O`
|
|
620
|
+
:host { flex: 1 1 auto; }
|
|
621
|
+
.files-panel { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
|
622
|
+
.toolbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
|
|
623
|
+
.toolbar .toolbar-actions button { margin-left: 0; }
|
|
624
|
+
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
625
|
+
.drop-overlay { position: absolute; inset: 52px 10px 10px; z-index: 15; display: grid; place-items: center; border: 2px dashed var(--pi-accent); border-radius: 12px; background: color-mix(in srgb, var(--pi-bg-overlay) 90%, var(--pi-accent) 10%); color: var(--pi-text); opacity: 0; pointer-events: none; transition: opacity .12s ease; }
|
|
626
|
+
.files-panel.dragging .drop-overlay { opacity: 1; }
|
|
627
|
+
.drop-overlay div { display: grid; gap: 4px; justify-items: center; padding: 18px; border-radius: 10px; background: var(--pi-bg-overlay); box-shadow: 0 8px 24px var(--pi-shadow); }
|
|
628
|
+
.drop-overlay span { color: var(--pi-muted); }
|
|
629
|
+
.upload-progress { flex: 0 0 auto; display: grid; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); background: color-mix(in srgb, var(--pi-surface) 55%, transparent); }
|
|
630
|
+
.upload-progress-header, .upload-batch-heading, .upload-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
631
|
+
.upload-batch { display: grid; gap: 6px; border: 1px solid var(--pi-border-muted); border-radius: 8px; background: var(--pi-bg); padding: 8px; }
|
|
632
|
+
.upload-batch.error { border-color: var(--pi-danger); }
|
|
633
|
+
.upload-batch.cancelled { border-color: var(--pi-warning-border); }
|
|
634
|
+
.upload-batch.completed { border-color: var(--pi-success-border); }
|
|
635
|
+
.upload-batch-heading > div { min-width: 0; display: grid; gap: 2px; }
|
|
636
|
+
.upload-batch-heading strong, .upload-batch-heading small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
637
|
+
progress { width: 100%; accent-color: var(--pi-accent); }
|
|
638
|
+
.upload-file-list { display: grid; gap: 4px; max-height: 180px; overflow: auto; padding-right: 2px; }
|
|
639
|
+
.upload-file { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--pi-muted); }
|
|
640
|
+
.upload-file.completed .upload-file-status { color: var(--pi-success); }
|
|
641
|
+
.upload-file.error { color: var(--pi-danger); }
|
|
642
|
+
.upload-file.cancelled .upload-file-status { color: var(--pi-warning); }
|
|
643
|
+
.upload-file-main { min-width: 0; display: grid; gap: 1px; }
|
|
644
|
+
.upload-file-main span, .upload-file-main small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
645
|
+
.upload-file-status { font-size: 12px; white-space: nowrap; }
|
|
646
|
+
.upload-actions { justify-content: end; }
|
|
647
|
+
.dialog-backdrop { position: fixed; inset: 0; z-index: 100; box-sizing: border-box; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: var(--pi-overlay); }
|
|
648
|
+
.upload-dialog { box-sizing: border-box; width: min(560px, 100%); max-height: min(720px, 100%); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 14px; background: var(--pi-bg); box-shadow: 0 18px 70px var(--pi-shadow-strong); }
|
|
649
|
+
.upload-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
650
|
+
.upload-dialog h2 { margin: 2px 0 0; font-size: 18px; line-height: 1.2; }
|
|
651
|
+
.eyebrow { color: var(--pi-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
|
|
652
|
+
.close-button { font-size: 20px; line-height: 1; padding: 4px 9px; }
|
|
653
|
+
form { min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow: auto; padding: 16px; }
|
|
654
|
+
form > label { display: grid; gap: 6px; }
|
|
655
|
+
form > label > span, .review-files > strong { font-weight: 600; }
|
|
656
|
+
input[type="text"], form > label > input:not([type]) { box-sizing: border-box; width: 100%; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 8px 9px; font: inherit; }
|
|
657
|
+
input:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 1px; }
|
|
658
|
+
.dialog-options { display: grid; gap: 8px; }
|
|
659
|
+
.dialog-options label { display: flex; align-items: center; gap: 8px; color: var(--pi-text); }
|
|
660
|
+
.review-files { display: grid; gap: 6px; min-height: 0; max-height: 180px; overflow: auto; border: 1px solid var(--pi-border-muted); border-radius: 8px; padding: 8px; }
|
|
661
|
+
.review-file { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: baseline; }
|
|
662
|
+
.review-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
663
|
+
.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; }
|
|
664
|
+
footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
|
|
665
|
+
`];Be([d({attribute:!1})],Me.prototype,"context",2);Be([z("#workspace-upload-input")],Me.prototype,"uploadInput",2);Be([v()],Me.prototype,"pendingUpload",2);Be([v()],Me.prototype,"destinationFolder",2);Be([v()],Me.prototype,"overwrite",2);Be([v()],Me.prototype,"createDirs",2);Be([v()],Me.prototype,"formError",2);Be([v()],Me.prototype,"dragActive",2);Me=Be([D("workspace-files-panel")],Me);function jf(e,t){return Object.values(e).filter(i=>i.projectId===t.projectId&&i.workspaceId===t.workspaceId&&i.machineId===t.machineId).sort((i,s)=>s.startedAt.localeCompare(i.startedAt))}function _f(e,t){if(e.length===0)return"Choose at least one file to upload.";for(const i of e)try{cr(t,i.name)}catch(s){return s instanceof Error?s.message:String(s)}}function Lf(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function Ff(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function qo(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function Ko(e){return e==null?[]:Array.from(e)}function ri(e){return Array.from(e.dataTransfer?.types??[]).includes("Files")}function Nf(e){const t=e.filter(i=>i.status==="uploading").length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function Uf(e){const t=e.files.length,i=t===1?"file":"files";switch(e.status){case"completed":return`Uploaded ${String(t)} ${i}`;case"error":return`Upload failed for ${String(t)} ${i}`;case"cancelled":return`Upload cancelled for ${String(t)} ${i}`;case"uploading":return`Uploading ${String(t)} ${i}`}}function zf(e){switch(e.status){case"completed":return"Done";case"error":return"Failed";case"cancelled":return"Cancelled";case"uploading":return Fa(e.percent)}}function Bf(e){return e.status==="uploading"?e.percent:1}function Hf(e){switch(e.status){case"pending":return"Pending";case"uploading":return Fa(e.percent);case"completed":return"Done";case"error":return"Error";case"cancelled":return"Cancelled"}}function qf(e){return e.error!==void 0?e.error:e.response!==void 0?`Wrote ${e.response.path}`:`${e.path} · ${yt(e.loaded)} / ${yt(e.total)}`}function Fa(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function Kf(){kr(()=>import("./CodeViewer-CQU9mJ74.js"),__vite__mapDeps([0,1,2,3]))}function yt(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${String(e)} B`;const t=e/1024;if(t<1024)return`${gs(t)} KB`;const i=t/1024;return i<1024?`${gs(i)} MB`:`${gs(i/1024)} GB`}function gs(e){return e>=10?String(Math.round(e)):e.toFixed(1)}function Vf(){return[{id:"workspace.files",title:"Files",icon:wi("files"),order:10,render:Gf},{id:"workspace.git",title:"Git",icon:wi("git"),order:20,visible:({workspace:e})=>e.isGitRepo,render:Jf},{id:"workspace.terminal",title:"Terminal",icon:wi("terminal"),order:30,badge:e=>e.activeTerminalCount>0?e.activeTerminalCount:void 0,render:Qf}]}function Gf(e){return l`<workspace-files-panel .context=${e}></workspace-files-panel>`}function Qf(e){return eg(),l`<terminal-panel .workspace=${e.workspace} .machineId=${e.machine.id} .selectedTerminalId=${e.selectedTerminalId} .autoStart=${e.terminalAutoStart} .onSelectTerminal=${e.onSelectTerminal}></terminal-panel>`}function Jf(e){const t=e.gitStatus;return l`
|
|
666
|
+
<section class="toolbar">
|
|
667
|
+
<strong>Git</strong>
|
|
668
|
+
${e.gitStale?l`<span class="stale">stale</span>`:null}
|
|
669
|
+
<button @click=${e.onRefreshGit}>Refresh</button>
|
|
670
|
+
</section>
|
|
671
|
+
<section class="split">
|
|
672
|
+
<div class="list">
|
|
673
|
+
${t===void 0?l`<p class="muted">No status loaded.</p>`:t.isGitRepo?l`
|
|
674
|
+
<p class="summary">${tg(t)}</p>
|
|
675
|
+
${t.files.length===0?l`<p class="muted">No changes.</p>`:t.files.map(i=>l`
|
|
676
|
+
<button class="row ${e.selectedDiffPath===i.path?"selected":""}" @click=${()=>{e.onSelectDiff(i.path)}}>
|
|
677
|
+
<span>${ig(i.index,i.workingTree)}</span>
|
|
678
|
+
<span>${i.path}</span>
|
|
679
|
+
</button>
|
|
680
|
+
`)}
|
|
681
|
+
`:l`<p class="muted">Not a git repository.</p>`}
|
|
682
|
+
</div>
|
|
683
|
+
<div class="viewer">
|
|
684
|
+
${Zf(e)}
|
|
685
|
+
</div>
|
|
686
|
+
</section>
|
|
687
|
+
`}function Zf(e){if(e.selectedDiffPath===void 0||e.selectedDiffPath==="")return l`<p class="muted">Select a changed file.</p>`;const t=e.selectedDiff,i=e.selectedStagedDiff;if(t===void 0||i===void 0)return l`<p class="muted">Loading diff…</p>`;const s=[i,t].filter(r=>r.diff!=="");return s.length===0?l`<p class="muted">No staged or unstaged diff.</p>`:l`
|
|
688
|
+
<div class=${s.length===1?"diffs single":"diffs"}>
|
|
689
|
+
${s.map(r=>Xf(r))}
|
|
690
|
+
</div>
|
|
691
|
+
`}function Xf(e){return Yf(),l`
|
|
692
|
+
<section class="diff-section">
|
|
693
|
+
<div class="viewer-header"><strong>${e.path??"diff"}</strong><small>${e.staged?"staged":"unstaged"}${e.truncated?" · truncated":""}</small></div>
|
|
694
|
+
<unified-diff-viewer .diff=${e.diff}></unified-diff-viewer>
|
|
695
|
+
</section>
|
|
696
|
+
`}function Yf(){kr(()=>import("./UnifiedDiffViewer-BZQQK99S.js"),__vite__mapDeps([4,1,2]))}function eg(){kr(()=>import("./TerminalPanel-DtfVBsqI.js"),__vite__mapDeps([5,6,7,1,2]))}function tg(e){const t=e.branch??"detached",i=e.ahead??0,s=e.behind??0;return i===0&&s===0?t:`${t} · ↑${String(i)} ↓${String(s)}`}function ig(e,t){return(t!=="unmodified"?t:e).slice(0,1).toUpperCase()}const sg={apiVersion:1,name:"PI WEB Core",activate:()=>({contributions:{actions:mf(),workspacePanels:Vf()}})},rg={"--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"},og={"--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"},ng={"--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"},ag={apiVersion:1,name:"PI WEB Themes",activate:()=>({contributions:{themes:[{id:"pi-web-dark",name:"PI WEB Dark",description:"Dark PI WEB palette.",order:10,colorScheme:"dark",tokens:og},{id:"pi-web-light",name:"PI WEB Light",description:"Light PI WEB palette.",order:20,colorScheme:"light",tokens:ng},{id:"classic",name:"PI WEB Classic",description:"The original PI WEB dark palette.",order:30,colorScheme:"dark",tokens:rg}],themePairs:[{id:"pi-web",name:"PI WEB",description:"Follow the system light/dark preference with PI WEB themes.",order:10,light:"pi-web-light",dark:"pi-web-dark"}]}})},lg=/^[a-z][a-z0-9.-]*$/u;function cg(e){return lg.test(e)}const dg="machine.";function pg(e,t){if(e==="")throw new Error("Machine id is required");if(!cg(t))throw new Error(`Invalid PI WEB plugin id: ${t}`);return`${dg}${hg(e)}.${t}`}function hg(e){return[...new TextEncoder().encode(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function Vo(e="/pi-web-plugins/manifest.json",t={}){const i=await ug(e);if(i===void 0)return[];const s=[];for(const r of i.plugins)if(t.shouldLoadPlugin?.(r)!==!1)try{const o=new URL(r.module,new URL(e,window.location.href)).toString(),n=await import(o),a=mg(n,o);s.push({id:t.machineId===void 0?r.id:pg(t.machineId,r.id),plugin:a,machineSpecific:r.machineSpecific,...t.machineId===void 0?{}:{machineId:t.machineId,sourcePluginId:r.id}})}catch(o){console.warn(`Failed to load PI WEB plugin ${r.module}`,o)}return s}async function ug(e){const t=await fetch(e,{cache:"no-store"});if(t.status!==404){if(!t.ok)throw new Error(`Failed to load plugin manifest: ${t.statusText}`);return fg(await t.json())}}function fg(e){if(!Oi(e)||!Array.isArray(e.plugins))throw new Error("Invalid plugin manifest");return{plugins:e.plugins.map(t=>{if(!Oi(t)||typeof t.id!="string"||t.id===""||typeof t.module!="string"||t.module==="")throw new Error("Invalid plugin manifest entry");return{id:t.id,module:t.module,machineSpecific:gg(t.machineSpecific)}})}}function gg(e){if(e===void 0)return!1;if(typeof e!="boolean")throw new Error("Invalid plugin manifest entry");return e}function mg(e,t){if(!Oi(e))throw new Error(`Plugin module ${t} did not export an object`);const i=e.default;if(!vg(i))throw new Error(`Plugin module ${t} default export is not a PiWebPlugin`);return i}function vg(e){return Oi(e)&&e.apiVersion===1&&typeof e.name=="string"&&typeof e.activate=="function"}function Oi(e){return typeof e=="object"&&e!==null}const bg=/^[a-z][a-z0-9.-]*$/u,wg=/^[a-z][a-z0-9.-]*$/u,Na=new WeakMap,Ua=new WeakMap;class yg{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(t){const{id:i,plugin:s}=t;this.validatePluginId(i);const r=this.parseMachineSpecific(i,t.machineSpecific);if(this.pluginIds.has(i))throw new Error(`Duplicate plugin id: ${i}`);if(this.isRemoteDuplicateHiddenByGateway(t.sourcePluginId,t.machineId,r))return;this.pluginIds.add(i);const o=s.apiVersion;if(o!==1)throw new Error(`Unsupported plugin API version for ${i}: ${String(o)}`);const a=s.activate({apiVersion:1,pluginId:i,html:l,svg:be}).contributions;for(const c of a.actions??[])this.actions.push(this.qualifyAction(i,c,t.machineId,t.sourcePluginId));for(const c of a.workspacePanels??[])this.workspacePanels.push(this.qualifyWorkspacePanel(i,c,t.machineId,t.sourcePluginId));for(const c of a.workspaceLabels??[])this.workspaceLabels.push(this.qualifyWorkspaceLabelContribution(i,c,t.machineId,t.sourcePluginId));if(t.machineId===void 0){for(const c of a.themes??[])this.themes.push(this.qualifyTheme(i,c));for(const c of a.themePairs??[])this.themePairs.push(this.qualifyThemePair(i,c));this.gatewayPluginIds.add(i),r&&this.gatewayMachineSpecificPluginIds.add(i)}else t.sourcePluginId!==void 0&&r&&$g(this.remoteMachineSpecificPluginIds,t.sourcePluginId,t.machineId)}shouldLoadRemotePlugin(t,i=!1){return!this.gatewayPluginIds.has(t)||this.gatewayMachineSpecificPluginIds.has(t)||i}getActions(t){const i=Cg(t);return this.actions.filter(s=>this.isContributionActive(s.pluginId,s.machineId,i,s.sourcePluginId)).map(s=>{const r=xg(t,s.pluginId),o=s.enabled?.(r),n=o===!1?s.disabledReason?.(r):void 0,a={id:s.id,pluginId:s.pluginId,localId:s.localId,...s.machineId===void 0?{}:{machineId:s.machineId},title:s.title,run:()=>s.run(r)};return s.description!==void 0&&(a.description=s.description),s.shortcut!==void 0&&(a.shortcut=s.shortcut),s.group!==void 0&&(a.group=s.group),o!==void 0&&(a.enabled=o),n!==void 0&&n!==""&&(a.disabledReason=n),a})}getWorkspacePanels(){return[...this.workspacePanels].sort((t,i)=>(t.order??1e3)-(i.order??1e3)||t.title.localeCompare(i.title))}getThemes(){return[...this.themes].sort((t,i)=>(t.order??1e3)-(i.order??1e3)||t.name.localeCompare(i.name))}getThemePairs(){return[...this.themePairs].sort((t,i)=>(t.order??1e3)-(i.order??1e3)||t.name.localeCompare(i.name))}getWorkspaceLabelItems(t){return[...this.workspaceLabels].sort((i,s)=>(i.order??1e3)-(s.order??1e3)||i.id.localeCompare(s.id)).flatMap(i=>i.visible?.(t)===!1?[]:i.items(t))}qualifyAction(t,i,s,r){const o=this.qualify(t,i.id);return{...i,id:o,pluginId:t,localId:i.id,...s===void 0?{}:{machineId:s},...r===void 0?{}:{sourcePluginId:r}}}qualifyWorkspacePanel(t,i,s,r){const o=this.qualify(t,i.id),n=i.badge,a=i.visible;return{...i,id:o,pluginId:t,localId:i.id,...s===void 0?{}:{machineId:s},visible:c=>this.isContributionActive(t,s,c.machine.id,r)&&(a?.(ms(c,t))??!0),...n===void 0?{}:{badge:c=>this.isContributionActive(t,s,c.machine.id,r)?n(ms(c,t)):void 0},render:c=>i.render(ms(c,t))}}qualifyWorkspaceLabelContribution(t,i,s,r){const o=this.qualify(t,i.id),n=i.visible,a=i.items;return{...i,id:o,pluginId:t,localId:i.id,...s===void 0?{}:{machineId:s},visible:c=>this.isContributionActive(t,s,c.machine.id,r)&&(n?.(c)??!0),items:c=>this.isContributionActive(t,s,c.machine.id,r)?a(c):[]}}qualifyTheme(t,i){const s=this.qualify(t,i.id);return{...i,id:s,pluginId:t,localId:i.id}}qualifyThemePair(t,i){const s=this.qualify(t,i.id);return{...i,id:s,pluginId:t,localId:i.id,light:this.qualifyReference(t,i.light),dark:this.qualifyReference(t,i.dark)}}qualify(t,i){this.validateLocalId(i);const s=`${t}:${i}`;if(this.contributionIds.has(s))throw new Error(`Duplicate contribution id: ${s}`);return this.contributionIds.add(s),s}qualifyReference(t,i){return this.validateLocalId(i),`${t}:${i}`}isContributionActive(t,i,s,r){return i===void 0?!this.isGatewayPluginHiddenForMachine(t,s):i===s&&!this.isRemotePluginHiddenByGateway(r,i)}isRemoteDuplicateHiddenByGateway(t,i,s){return t!==void 0&&i!==void 0&&this.gatewayPluginIds.has(t)&&!this.gatewayMachineSpecificPluginIds.has(t)&&!s}isRemotePluginHiddenByGateway(t,i){return t===void 0||this.gatewayMachineSpecificPluginIds.has(t)||this.remoteMachineSpecificPluginIds.get(t)?.has(i)===!0?!1:this.gatewayPluginIds.has(t)}isGatewayPluginHiddenForMachine(t,i){return i!=="local"&&(this.gatewayMachineSpecificPluginIds.has(t)||this.remoteMachineSpecificPluginIds.get(t)?.has(i)===!0)}validatePluginId(t){if(!bg.test(t))throw new Error(`Invalid plugin id: ${t}`)}validateLocalId(t){if(!wg.test(t))throw new Error(`Invalid contribution id: ${t}`)}parseMachineSpecific(t,i){if(i===void 0)return!1;if(typeof i!="boolean")throw new Error(`Invalid plugin machineSpecific value for ${t}: ${Pg(i)}`);return i}}function xg(e,t){return Na.get(e)?.(t)??e}function ms(e,t){return Ua.get(e)?.(t)??e}function Sg(e,t){return Na.set(e,t),e}function kg(e,t){return Ua.set(e,t),e}function $g(e,t,i){const s=e.get(t);s===void 0?e.set(t,new Set([i])):s.add(i)}function Pg(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||e===void 0)return String(e);try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function Cg(e){return e.state.selectedMachine?.id??"local"}const Rg=["(display-mode: standalone)","(display-mode: fullscreen)","(display-mode: minimal-ui)"];function Ig(){return typeof window>"u"||!("matchMedia"in window)?[]:Rg.map(e=>window.matchMedia(e))}function Go(e,t=Ag()){return e.some(i=>i.matches)||Mg(t)}function Ag(){return typeof navigator>"u"?void 0:navigator}function Mg(e){return e!==void 0&&"standalone"in e&&e.standalone===!0}const Tg=250;class Eg{constructor(t=Dg()){this.scheduler=t}repair(t){if(!t){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()},Tg)}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);const t=this.scheduler.documentElement;t!==void 0&&(t.scrollTop=0);const i=this.scheduler.body;i!==void 0&&(i.scrollTop=0)}}function Dg(){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}}}const Wg="(max-width: 760px)";class Og{constructor(t,i={}){this.host=t,this.onMobileNavigationMediaChange=s=>{this.isMobileNavigationLayout!==s.matches&&(this.isMobileNavigationLayout=s.matches,this.host.requestUpdate())},this.onPwaDisplayModeChange=()=>{const s=Go(this.pwaDisplayModeMedia);this.isPwaDisplayMode!==s&&(this.isPwaDisplayMode=s,this.host.requestUpdate())},t.addController(this),this.mobileNavigationMedia=i.mobileNavigationMedia??jg(),this.pwaDisplayModeMedia=i.pwaDisplayModeMedia??Ig(),this.viewportPositionRepairer=i.viewportPositionRepairer??new Eg,this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.isPwaDisplayMode=Go(this.pwaDisplayModeMedia)}hostConnected(){this.mobileNavigationMedia?.addEventListener("change",this.onMobileNavigationMediaChange);for(const t of this.pwaDisplayModeMedia)t.addEventListener("change",this.onPwaDisplayModeChange)}hostDisconnected(){this.mobileNavigationMedia?.removeEventListener("change",this.onMobileNavigationMediaChange);for(const t of this.pwaDisplayModeMedia)t.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.isMobileNavigationLayout?"navigation":"chat"}repairViewportPosition(){this.viewportPositionRepairer.repair(this.shouldRepairViewportPosition())}shouldRepairViewportPosition(){return this.isMobileNavigationLayout||this.isPwaDisplayMode}}function jg(){if(!(typeof window>"u"||!("matchMedia"in window)))return window.matchMedia(Wg)}const ji=["machines","projects","workspaces","sessions"];function _g(e){return e.selectedProject===void 0?"projects":e.selectedWorkspace===void 0?"workspaces":"sessions"}function $r(e,t){if(e!=="none")return e??_g(t)}function Lg(e,t){return t.isMobileLayout?$r(t.expanded,t.state)!==e:t.collapsedSections?.includes(e)??!1}function Fg(e,t,i){return $r(e,i.state)===t?"none":t}function Ng(e,t,i){return i?t:e}function Ug(e,t){const i=new Set(e);return i.has(t)?i.delete(t):i.add(t),Hg(i)}function zg(e){return ji[ji.indexOf(e)+1]}class Bg{constructor(t,i,s){this.host=t,this.getState=i,this.isMobileLayout=s,this.collapsedSections=[],t.addController(this)}hostConnected(){}expandedSection(){return $r(this.expanded,this.getState())}isCollapsed(t){return Lg(t,{isMobileLayout:this.isMobileLayout(),expanded:this.expanded,state:this.getState(),collapsedSections:this.collapsedSections})}toggle(t){if(this.isMobileLayout()){this.setExpanded(Fg(this.expanded,t,{state:this.getState()}));return}this.setCollapsedSections(Ug(this.collapsedSections,t))}expand(t){if(this.isMobileLayout()){this.setExpanded(Ng(this.expanded,t,!0));return}this.setCollapsedSections(this.collapsedSections.filter(i=>i!==t))}advanceAfterSelection(t){if(!this.isMobileLayout())return;const i=zg(t);i!==void 0&&this.expand(i)}open(t,i){this.isMobileLayout()&&(this.expand(t),i())}setExpanded(t){this.expanded!==t&&(this.expanded=t,this.host.requestUpdate())}setCollapsedSections(t){qg(this.collapsedSections,t)||(this.collapsedSections=t,this.host.requestUpdate())}}function Hg(e){const t=new Set(e);return ji.filter(i=>t.has(i))}function qg(e,t){return e.length===t.length&&e.every((i,s)=>i===t[s])}class Kg{constructor(t){this.host=t,this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,t.addController(this)}hostConnected(){}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(t){return["shell",za(t),...this.navigationPanelCollapsed?["navigation-panel-collapsed"]:[],...this.workspacePanelCollapsed?["workspace-panel-collapsed"]:[]].join(" ")}}function za(e){return e==="navigation"?"navigation-view":e==="chat"?"chat-view":"workspace-view"}const Hs="pi-web:panel-sizes:v1",Vg={navigation:{minWidth:180,maxWidth:4096,defaultWidth:340,keyboardStep:24,largeKeyboardStep:72},workspace:{minWidth:240,maxWidth:4096,defaultWidth:480,keyboardStep:24,largeKeyboardStep:72}};class Gg{constructor(t,i={}){this.host=t,t.addController(this),this.storage=i.storage??Pr(),this.panelSizes=Xg(this.storage)}hostConnected(){}constraints(t){return Zt(t)}panelWidth(t,i){return we(t,i??this.storedPanelWidth(t)??this.constraints(t).defaultWidth)}resizePanel(t,i,s={}){const r=we(t,i);this.storedPanelWidth(t)!==r&&(this.panelSizes=tm(this.panelSizes,t,r),s.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanel(t,i={}){this.storedPanelWidth(t)!==void 0&&(this.panelSizes=im(this.panelSizes,t),i.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}resetPanels(t={}){this.panelSizes.navigationPanelWidth===void 0&&this.panelSizes.workspacePanelWidth===void 0||(this.panelSizes={},t.persist!==!1&&this.persistPanelSizes(),this.host.requestUpdate())}persistPanelSizes(){Yg(this.panelSizes,this.storage)}shellStyle(t={}){const i=[];return this.panelSizes.navigationPanelWidth!==void 0&&i.push(`--navigation-panel-size: ${Jo(we("navigation",this.panelSizes.navigationPanelWidth,t.navigation))};`),this.panelSizes.workspacePanelWidth!==void 0&&i.push(`--workspace-panel-size: ${Jo(we("workspace",this.panelSizes.workspacePanelWidth,t.workspace))};`),i.join(" ")}storedPanelWidth(t){return t==="navigation"?this.panelSizes.navigationPanelWidth:this.panelSizes.workspacePanelWidth}}function Zt(e){return Vg[e]}function Qg(e,t,i){return e==="navigation"?i-t:t-i}function Jg(e,t,i,s,r=Zt(e)){return we(e,t+Qg(e,i,s),r)}function Zg(e,t,i,s={}){const r=s.constraints??Zt(e);if(i==="Home")return r.minWidth;if(i==="End")return r.maxWidth;const o=s.largeStep===!0?r.largeKeyboardStep:r.keyboardStep,n=sm(e,i,o);if(n!==void 0)return we(e,t+n,r)}function we(e,t,i=Zt(e)){return Number.isFinite(t)?Math.round(Math.min(Math.max(t,i.minWidth),i.maxWidth)):i.defaultWidth}function Xg(e=Pr()){try{const t=e?.getItem(Hs);if(t==null||t==="")return{};const i=JSON.parse(t);return em(i)}catch{return{}}}function Yg(e,t=Pr()){if(t!==void 0)try{if(e.navigationPanelWidth===void 0&&e.workspacePanelWidth===void 0){t.removeItem(Hs);return}const i={version:1};e.navigationPanelWidth!==void 0&&(i.navigationPanelWidth=we("navigation",e.navigationPanelWidth)),e.workspacePanelWidth!==void 0&&(i.workspacePanelWidth=we("workspace",e.workspacePanelWidth)),t.setItem(Hs,JSON.stringify(i))}catch{}}function em(e){if(!rm(e)||e.version!==1)return{};const t={},i=Qo(e.navigationPanelWidth),s=Qo(e.workspacePanelWidth);return i!==void 0&&(t.navigationPanelWidth=we("navigation",i)),s!==void 0&&(t.workspacePanelWidth=we("workspace",s)),t}function Qo(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function tm(e,t,i){return t==="navigation"?{...e,navigationPanelWidth:i}:{...e,workspacePanelWidth:i}}function im(e,t){return t==="navigation"?e.workspacePanelWidth===void 0?{}:{workspacePanelWidth:e.workspacePanelWidth}:e.navigationPanelWidth===void 0?{}:{navigationPanelWidth:e.navigationPanelWidth}}function sm(e,t,i){if(e==="navigation")return t==="ArrowRight"?i:t==="ArrowLeft"?-i:void 0;if(t==="ArrowLeft")return i;if(t==="ArrowRight")return-i}function Jo(e){return`${String(Math.round(e))}px`}function Pr(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function rm(e){return typeof e=="object"&&e!==null}function Zo(){const 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:om(e.get("tool")),view:nm(e.get("view"))}}function vs(e,t){const i=new URL(window.location.href);i.searchParams.delete("machine"),i.searchParams.delete("project"),i.searchParams.delete("workspace"),i.searchParams.delete("session"),i.searchParams.delete("tool"),i.searchParams.delete("view"),e.machineId!==void 0&&e.machineId!==""&&e.machineId!=="local"&&i.searchParams.set("machine",e.machineId),e.projectId!==void 0&&e.projectId!==""&&i.searchParams.set("project",e.projectId),e.workspaceId!==void 0&&e.workspaceId!==""&&i.searchParams.set("workspace",e.workspaceId),e.sessionId!==void 0&&e.sessionId!==""&&i.searchParams.set("session",e.sessionId),e.tool!==void 0&&i.searchParams.set("tool",e.tool),e.view!==void 0&&i.searchParams.set("view",e.view);const s=`${i.pathname}${i.search}${i.hash}`,r=`${window.location.pathname}${window.location.search}${window.location.hash}`;s!==r&&(t?.replace===!0?window.history.replaceState({},"",i):window.history.pushState({},"",i))}function om(e){return e==="files"?"core:workspace.files":e==="git"?"core:workspace.git":Ba(e)?e:void 0}function nm(e){return e==="chat"?"chat":e==="files"?"core:workspace.files":e==="git"?"core:workspace.git":Ba(e)?e:void 0}function Ba(e){return e!==null&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function Xo(){return am(new URLSearchParams(window.location.search).get("settings"))}function bs(e,t){const i=new URL(window.location.href);e===void 0?i.searchParams.delete("settings"):i.searchParams.set("settings",e);const s=`${i.pathname}${i.search}${i.hash}`,r=`${window.location.pathname}${window.location.search}${window.location.hash}`;s!==r&&window.history.pushState({},"",i)}function am(e){if(e==="general")return"general";if(e==="sessiond"||e==="sessions")return"sessiond";if(e==="plugins")return"plugins";if(e==="shortcuts"||e==="keyboard"||e==="keyboard-shortcuts")return"shortcuts"}function lm(e,t){return t===void 0?e:e.map(i=>dm(i,t))}function cm(e,t){const i=new Set(yr(e,t,{enabledOnly:!0}).filter(s=>s.active).map(s=>s.action.id));return lm(e,t).map(s=>s.shortcut!==void 0&&!i.has(s.id)?Ha(s):s)}function dm(e,t){if(!Object.hasOwn(t,e.id))return e;const i=t[e.id];return i===void 0?e:i===null?Ha(e):{...e,shortcut:i}}function Ha(e){const t={...e};return delete t.shortcut,t}function pm(e,t){const i=t.api??wt,s=t.pollIntervalMs??1e3,r=t.setTimeout??um(),o=t.clearTimeout??fm();return{async runCommand(n){const a=await i.runTerminalCommand(e,n);return n.open===!0&&t.openTerminal(n.workspace,{terminalId:a.terminalId}),{run:a,completed:hm(a,i,s,r,o)}},listCommandRuns:n=>i.listCommandRuns(n),getCommandRun:n=>i.getCommandRun(n),open:n=>{t.openTerminal(void 0,n)}}}function hm(e,t,i,s,r){return Yo(e)?Promise.resolve(e):new Promise((o,n)=>{let a,c=!1;const p=f=>{c||(c=!0,a!==void 0&&r(a),o(f))},u=f=>{c||(c=!0,a!==void 0&&r(a),n(f instanceof Error?f:new Error(String(f))))},h=()=>{t.getCommandRun(e.id).then(f=>{if(f!==void 0&&Yo(f)){p(f);return}a=s(h,i)}).catch(u)};a=s(h,i)})}function Yo(e){return e.status==="succeeded"||e.status==="failed"}function um(){return(e,t)=>globalThis.setTimeout(e,t)}function fm(){return e=>{globalThis.clearTimeout(e)}}function gm(e,t){return t[e.path]}function mm(e){if(e?.hasSessionActivity===!0)return"session";if(e?.hasTerminalActivity===!0)return"terminal"}function vm(e,t,i){return Ka(bm(e,t,i))}function qa(e){return Ka(Object.values(e??{}))}function Ka(e){if(e.some(t=>t.hasSessionActivity))return"session";if(e.some(t=>t.hasTerminalActivity))return"terminal"}function bm(e,t,i){const s=new Set(t.filter(o=>o.projectId===e.id).map(o=>o.path)),r=new Map;for(const o of s){const n=i[o];n!==void 0&&r.set(n.cwd,n)}for(const o of Object.values(i))(o.cwd===e.path||o.cwd.startsWith(`${e.path}/`))&&r.set(o.cwd,o);return[...r.values()]}const oi=0,wm=120;function Xt(e,t={}){if(typeof HTMLElement>"u"||typeof window>"u"||!(e instanceof HTMLElement))return"";const i=e.getBoundingClientRect(),s=t.constrainTo==="viewport"?Va():ym(e),r=window.innerWidth,o=window.innerHeight,n=Math.max(0,s.left),a=Math.min(r,s.right),c=Math.max(0,s.top),p=Math.min(o,s.bottom),u=Math.min(i.right,a),h=p-i.bottom-oi,f=i.top-c-oi;return[...h<wm&&f>h?[`bottom: ${gt(o-i.top+oi)};`,`max-height: ${gt(Math.max(0,f))};`]:[`top: ${gt(i.bottom+oi)};`,`max-height: ${gt(Math.max(0,h))};`],`right: ${gt(Math.max(0,r-u))};`,`max-width: ${gt(Math.max(0,u-n))};`].join(" ")}function ym(e){const t=e.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():Va()}function Va(){return{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function gt(e){return`${String(Math.round(e))}px`}function Ga(e,t="Active"){if(e!==void 0)return l`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`}function Zi(e,t="Active"){const i=Ga(e,t);if(i!==void 0)return l`<span class="action-activity">${i}</span>`}const xm=["a[href]","button","input","select","textarea","summary","[role='button']","[role='link']","[contenteditable='true']"].join(",");function Qa(e){return e.composedPath().some(t=>Sm(t,xm))}function Sm(e,t){if(typeof Element<"u"&&e instanceof Element)return e.matches(t);if(!("matches"in e))return!1;const{matches:i}=e;return typeof i=="function"&&i.call(e,t)===!0}function Xi(e,t){Qa(e)||t()}function Yi(e,t){return Qa(e)?!1:e.key==="Enter"||e.key===" "?(e.preventDefault(),t.activate(),!0):e.key==="ArrowUp"?it(e,()=>{en(e.currentTarget,-1)}):e.key==="ArrowDown"?it(e,()=>{en(e.currentTarget,1)}):e.key==="Home"?it(e,()=>{tn(e.currentTarget,0)}):e.key==="End"?it(e,()=>{tn(e.currentTarget,-1)}):e.key==="ArrowLeft"&&t.previousSection!==void 0?it(e,t.previousSection):e.key==="ArrowRight"&&t.nextSection!==void 0?it(e,t.nextSection):e.key==="Escape"&&t.cancel!==void 0?it(e,t.cancel):!1}function es(e,t={}){const i=e.querySelector(".action-row.selected")??e.querySelector(".action-row")??(t.fallbackSelector===void 0?void 0:e.querySelector(t.fallbackSelector));return i==null?!1:(i.focus(),i.scrollIntoView({block:"nearest"}),!0)}function it(e,t){return e.preventDefault(),e.stopPropagation?.(),t(),!0}function en(e,t){const i=Za(e),s=Xa(e);if(s===void 0||i.length===0)return;const r=i.indexOf(s);r<0||Ja(i,r+t)}function tn(e,t){const i=Za(e);i.length!==0&&Ja(i,t<0?i.length-1:t)}function Ja(e,t){const i=e[Math.min(Math.max(t,0),e.length-1)];i?.focus(),i?.scrollIntoView({block:"nearest"})}function Za(e){const t=Xa(e)?.getRootNode();return t===void 0||!km(t)?[]:Array.from(t.querySelectorAll(".action-row"))}function km(e){return typeof Document<"u"&&e instanceof Document||typeof DocumentFragment<"u"&&e instanceof DocumentFragment}function Xa(e){if(!(typeof HTMLElement>"u"||!(e instanceof HTMLElement)))return e.closest(".action-row")??void 0}var $m=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,he=(e,t,i,s)=>{for(var r=s>1?void 0:s?Pm(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&$m(t,i,r),r};let te=class extends M{constructor(){super(...arguments),this.machines=[],this.statuses={},this.activities={},this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuMachineId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("machines")&&this.openMenuMachineId!==void 0&&!this.machines.some(t=>t.id===this.openMenuMachineId)&&(this.openMenuMachineId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuMachineId=void 0)}async focusSelectedOrFirst(){return await this.updateComplete,es(this.renderRoot,{fallbackSelector:".section-toggle"})}render(){return l`
|
|
697
|
+
<section>
|
|
698
|
+
<h2>${this.renderHeading()}</h2>
|
|
699
|
+
${this.collapsed?null:l`
|
|
700
|
+
<div class="list-body">
|
|
701
|
+
${this.machines.map(e=>this.renderMachine(e))}
|
|
702
|
+
</div>
|
|
703
|
+
`}
|
|
704
|
+
</section>
|
|
705
|
+
`}renderMachine(e){const t=this.statuses[e.id]?.status??e.status??"unknown",i=t==="online"?"online":t==="offline"?"offline":t==="error"?"error":"unknown",s=Ya(e)&&this.onRemove!==void 0;return l`
|
|
706
|
+
<div
|
|
707
|
+
class=${`action-row machine-row ${this.selected?.id===e.id?"selected":""} ${s?"":"no-actions"}`}
|
|
708
|
+
tabindex="0"
|
|
709
|
+
title=${e.baseUrl??e.name}
|
|
710
|
+
@click=${r=>{Xi(r,()=>this.onSelect?.(e))}}
|
|
711
|
+
@keydown=${r=>{this.handleMachineKeydown(r,e)}}
|
|
712
|
+
>
|
|
713
|
+
<div class="action-main">
|
|
714
|
+
<span class="action-name machine-primary"><span class="machine-primary-label">${e.name}</span></span><small>${e.kind==="local"?"Local Pi Web":e.baseUrl??"Remote Pi Web"} · ${i}</small>
|
|
715
|
+
${this.renderActivity(e)}
|
|
716
|
+
</div>
|
|
717
|
+
${s?this.renderMachineMenu(e):null}
|
|
718
|
+
</div>
|
|
719
|
+
`}renderActivity(e){const t=this.statuses[e.id]?.status??e.status;if(t==="offline"||t==="error")return;const i=qa(this.activities[e.id]);return Zi(i,i==="terminal"?"Machine terminal active":"Machine active")}renderMachineMenu(e){const t=this.openMenuMachineId===e.id,i=Cm(e.id);return l`
|
|
720
|
+
<div class="action-menu">
|
|
721
|
+
<button
|
|
722
|
+
class="action-menu-toggle"
|
|
723
|
+
title="Machine actions"
|
|
724
|
+
aria-label=${`Actions for ${e.name}`}
|
|
725
|
+
aria-expanded=${String(t)}
|
|
726
|
+
aria-controls=${i}
|
|
727
|
+
@click=${s=>{s.stopPropagation(),this.toggleMenu(e.id,s.currentTarget)}}
|
|
728
|
+
>⋯</button>
|
|
729
|
+
${t?l`
|
|
730
|
+
<div class="action-menu-panel machine-menu-panel" id=${i} style=${this.menuStyle} @click=${s=>{s.stopPropagation()}}>
|
|
731
|
+
<button class="danger" title=${`Remove ${e.name}`} @click=${()=>{this.removeMachine(e)}}>Remove</button>
|
|
732
|
+
</div>
|
|
733
|
+
`:null}
|
|
734
|
+
</div>
|
|
735
|
+
`}renderHeading(){if(!this.collapsible)return"Machines";const e=this.selected?.name??"No machine selected",t=this.selected?.baseUrl??e;return l`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Machines</span>${this.collapsed?l`<small class="section-selected" title=${t}>${e}</small>`:null}</span><small class="section-count">${this.machines.length}</small></button>`}toggleMenu(e,t){if(this.openMenuMachineId===e){this.openMenuMachineId=void 0;return}this.menuStyle=Xt(t,{constrainTo:"viewport"}),this.openMenuMachineId=e}removeMachine(e){this.openMenuMachineId=void 0,this.onRemove?.(e)}handleMachineKeydown(e,t){if(e.key==="Escape"&&this.openMenuMachineId===t.id){e.preventDefault(),e.stopPropagation(),this.openMenuMachineId=void 0;return}Yi(e,{activate:()=>this.onSelect?.(t),nextSection:this.onFocusNextSection===void 0?void 0:()=>{this.onFocusNextSection?.()},cancel:this.onCancelKeyboardNavigation===void 0?void 0:()=>{this.onCancelKeyboardNavigation?.()}})}};te.styles=[Ji,O`
|
|
736
|
+
.machine-row.no-actions .action-main { border-radius: 8px; }
|
|
737
|
+
.machine-primary { display: flex; align-items: baseline; gap: 6px; }
|
|
738
|
+
.machine-primary-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
739
|
+
.machine-menu-panel button.danger { color: var(--pi-danger); }
|
|
740
|
+
.machine-menu-panel button.danger:hover, .machine-menu-panel button.danger:focus { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
741
|
+
`];he([d({attribute:!1})],te.prototype,"machines",2);he([d({attribute:!1})],te.prototype,"selected",2);he([d({attribute:!1})],te.prototype,"statuses",2);he([d({attribute:!1})],te.prototype,"activities",2);he([d({type:Boolean,reflect:!0})],te.prototype,"collapsible",2);he([d({type:Boolean,reflect:!0})],te.prototype,"collapsed",2);he([d({attribute:!1})],te.prototype,"onSelect",2);he([d({attribute:!1})],te.prototype,"onRemove",2);he([d({attribute:!1})],te.prototype,"onToggleCollapsed",2);he([d({attribute:!1})],te.prototype,"onFocusNextSection",2);he([d({attribute:!1})],te.prototype,"onCancelKeyboardNavigation",2);he([v()],te.prototype,"openMenuMachineId",2);he([v()],te.prototype,"menuStyle",2);te=he([D("machine-list")],te);function Ya(e){return e.kind==="remote"}function Cm(e){return`machine-menu-${e.replace(/[^a-zA-Z0-9_-]/g,"-")}`}var Rm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,ae=(e,t,i,s)=>{for(var r=s>1?void 0:s?Im(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Rm(t,i,r),r};let J=class extends M{constructor(){super(...arguments),this.projects=[],this.activities={},this.workspacesByProjectId={},this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuProjectId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("projects")&&this.openMenuProjectId!==void 0&&!this.projects.some(t=>t.id===this.openMenuProjectId)&&(this.openMenuProjectId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuProjectId=void 0)}async focusSelectedOrFirst(){return await this.updateComplete,es(this.renderRoot,{fallbackSelector:".section-toggle"})}render(){return l`
|
|
742
|
+
<section>
|
|
743
|
+
<h2>${this.renderHeading()}</h2>
|
|
744
|
+
${this.collapsed?null:l`
|
|
745
|
+
<div class="list-body">
|
|
746
|
+
${this.projects.map(e=>l`
|
|
747
|
+
<div
|
|
748
|
+
class=${`action-row ${this.selected?.id===e.id?"selected":""}`}
|
|
749
|
+
tabindex="0"
|
|
750
|
+
title=${e.path}
|
|
751
|
+
@click=${t=>{Xi(t,()=>this.onSelect?.(e))}}
|
|
752
|
+
@keydown=${t=>{this.handleProjectKeydown(t,e)}}
|
|
753
|
+
>
|
|
754
|
+
<div class="action-main">
|
|
755
|
+
<span class="action-name">${e.name}</span><small>${e.path}</small>
|
|
756
|
+
${this.renderActivity(e)}
|
|
757
|
+
</div>
|
|
758
|
+
<div class="action-menu">
|
|
759
|
+
<button class="action-menu-toggle" title="Project actions" aria-label=${`Actions for ${e.name}`} @click=${t=>{t.stopPropagation(),this.toggleMenu(e.id,t.currentTarget)}}>⋯</button>
|
|
760
|
+
${this.openMenuProjectId===e.id?l`
|
|
761
|
+
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
762
|
+
<button title="Close project" @click=${()=>{this.close(e)}}>Close</button>
|
|
763
|
+
</div>
|
|
764
|
+
`:null}
|
|
765
|
+
</div>
|
|
766
|
+
</div>
|
|
767
|
+
`)}
|
|
768
|
+
</div>
|
|
769
|
+
`}
|
|
770
|
+
</section>
|
|
771
|
+
`}handleProjectKeydown(e,t){Yi(e,{activate:()=>this.onSelect?.(t),previousSection:this.onFocusPreviousSection===void 0?void 0:()=>{this.onFocusPreviousSection?.()},nextSection:this.onFocusNextSection===void 0?void 0:()=>{this.onFocusNextSection?.()},cancel:this.onCancelKeyboardNavigation===void 0?void 0:()=>{this.onCancelKeyboardNavigation?.()}})}renderHeading(){if(!this.collapsible)return"Projects";const e=this.selected?.name??"No project selected",t=this.selected?.path??e;return l`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Projects</span>${this.collapsed?l`<small class="section-selected" title=${t}>${e}</small>`:null}</span><small class="section-count">${this.projects.length}</small></button>`}renderActivity(e){const t=vm(e,this.workspacesByProjectId[e.id]??[],this.activities);return Zi(t,t==="terminal"?"Project terminal active":"Project active")}toggleMenu(e,t){if(this.openMenuProjectId===e){this.openMenuProjectId=void 0;return}this.menuStyle=Xt(t,{constrainTo:"viewport"}),this.openMenuProjectId=e}close(e){this.openMenuProjectId=void 0,confirm(`Close ${e.name}?
|
|
772
|
+
|
|
773
|
+
This only removes it from PI WEB; it will not change the project folder.`)&&this.onClose?.(e)}};J.styles=Ji;ae([d({attribute:!1})],J.prototype,"projects",2);ae([d({attribute:!1})],J.prototype,"selected",2);ae([d({attribute:!1})],J.prototype,"activities",2);ae([d({attribute:!1})],J.prototype,"workspacesByProjectId",2);ae([d({type:Boolean,reflect:!0})],J.prototype,"collapsible",2);ae([d({type:Boolean,reflect:!0})],J.prototype,"collapsed",2);ae([d({attribute:!1})],J.prototype,"onSelect",2);ae([d({attribute:!1})],J.prototype,"onClose",2);ae([d({attribute:!1})],J.prototype,"onToggleCollapsed",2);ae([d({attribute:!1})],J.prototype,"onFocusPreviousSection",2);ae([d({attribute:!1})],J.prototype,"onFocusNextSection",2);ae([d({attribute:!1})],J.prototype,"onCancelKeyboardNavigation",2);ae([v()],J.prototype,"openMenuProjectId",2);ae([v()],J.prototype,"menuStyle",2);J=ae([D("project-list")],J);function sn(e=[]){return e.map((t,i)=>l`${i===0?null:l`<span class="workspace-label-separator">·</span>`}${Am(t)}`)}function Am(e){if(e.type==="render")return l`<span class="workspace-label-render">${e.render()}</span>`;if(e.type==="link"&&Mm(e.href)){const t=e.target??"_blank",i=t==="_blank"?"noopener noreferrer":void 0;return l`<a class="workspace-label-item workspace-label-link" href=${e.href} title=${e.title??e.text} target=${t} rel=${i??void 0}>${e.text}</a>`}return l`<span class="workspace-label-item" title=${e.title??e.text}>${e.text}</span>`}function Mm(e){const t=e.trim().toLowerCase();return t!==""&&!t.startsWith("javascript:")&&!t.startsWith("data:")}var Tm=Object.defineProperty,Em=Object.getOwnPropertyDescriptor,ie=(e,t,i,s)=>{for(var r=s>1?void 0:s?Em(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Tm(t,i,r),r};let K=class extends M{constructor(){super(...arguments),this.workspaces=[],this.collapsible=!1,this.collapsed=!1,this.workspaceLabelItems=()=>[],this.activities={},this.deletingWorkspaceIds=[],this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuWorkspaceId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("workspaces")&&this.openMenuWorkspaceId!==void 0&&!this.workspaces.some(t=>t.id===this.openMenuWorkspaceId)&&(this.openMenuWorkspaceId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuWorkspaceId=void 0),(e.has("selected")||e.has("workspaces")||e.has("collapsed"))&&!this.collapsed&&this.scrollSelectedIntoView()}async focusSelectedOrFirst(){return await this.updateComplete,es(this.renderRoot,{fallbackSelector:".section-toggle"})}render(){return l`
|
|
774
|
+
<section>
|
|
775
|
+
<h2>${this.renderHeading()}</h2>
|
|
776
|
+
${this.collapsed?null:l`
|
|
777
|
+
<div class="list-body">
|
|
778
|
+
${this.workspaces.map(e=>{const t=Dm(e),i=this.workspaceLabelItems(e);return l`
|
|
779
|
+
<div
|
|
780
|
+
class=${`action-row workspace-row ${this.selected?.id===e.id?"selected":""}`}
|
|
781
|
+
tabindex="0"
|
|
782
|
+
title=${t}
|
|
783
|
+
@click=${s=>{Xi(s,()=>this.onSelect?.(e))}}
|
|
784
|
+
@keydown=${s=>{this.handleWorkspaceKeydown(s,e)}}
|
|
785
|
+
>
|
|
786
|
+
<div class="action-main">
|
|
787
|
+
${this.renderWorkspaceMain(t,i,e)}
|
|
788
|
+
</div>
|
|
789
|
+
${this.renderWorkspaceMenu(t,i,e)}
|
|
790
|
+
</div>
|
|
791
|
+
`})}
|
|
792
|
+
</div>
|
|
793
|
+
`}
|
|
794
|
+
</section>
|
|
795
|
+
`}renderHeading(){if(!this.collapsible)return"Workspaces";const e=this.selected===void 0?"No workspace selected":`${this.selected.label}${this.selected.isMain?" · main":""} · ${this.selected.path}`,t=this.selected?.path??e;return l`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Workspaces</span>${this.collapsed?l`<small class="section-selected" title=${t}>${e}</small>`:null}</span><small class="section-count">${this.workspaces.length}</small></button>`}renderActivity(e){const t=mm(gm(e,this.activities));return Zi(t,t==="terminal"?"Workspace terminal active":"Workspace active")}renderWorkspaceMain(e,t,i){return l`
|
|
796
|
+
<span class="workspace-primary">
|
|
797
|
+
<span class="workspace-primary-label">${e}</span>
|
|
798
|
+
${this.isDeleting(i)?l`<span class="workspace-status">Deleting…</span>`:null}
|
|
799
|
+
</span>
|
|
800
|
+
${t.length===0?null:l`
|
|
801
|
+
<small class="workspace-secondary">
|
|
802
|
+
<span class="workspace-label">${sn(t)}</span>
|
|
803
|
+
</small>
|
|
804
|
+
`}
|
|
805
|
+
${this.renderActivity(i)}
|
|
806
|
+
`}renderWorkspaceMenu(e,t,i){const s=this.openMenuWorkspaceId===i.id,r=Om(i.id);return l`
|
|
807
|
+
<div class="action-menu">
|
|
808
|
+
<button
|
|
809
|
+
class="action-menu-toggle"
|
|
810
|
+
title="Workspace actions and details"
|
|
811
|
+
aria-label=${`Actions and details for ${e}`}
|
|
812
|
+
aria-expanded=${String(s)}
|
|
813
|
+
aria-controls=${r}
|
|
814
|
+
@click=${o=>{o.stopPropagation(),this.toggleMenu(i.id,o.currentTarget)}}
|
|
815
|
+
>⋯</button>
|
|
816
|
+
${s?l`
|
|
817
|
+
<div class="action-menu-panel workspace-menu-panel" id=${r} style=${this.menuStyle} @click=${o=>{o.stopPropagation()}}>
|
|
818
|
+
${this.renderWorkspaceActions(i)}
|
|
819
|
+
${this.renderWorkspaceDetails(e,t,i)}
|
|
820
|
+
</div>
|
|
821
|
+
`:null}
|
|
822
|
+
</div>
|
|
823
|
+
`}renderWorkspaceActions(e){if(!Wm(e))return;const t=this.isDeleting(e);return l`
|
|
824
|
+
<div class="workspace-menu-actions">
|
|
825
|
+
<button class="danger" title=${t?"Workspace deletion in progress":"Delete workspace"} ?disabled=${t} @click=${()=>{this.delete(e)}}>${t?"Deleting…":"Delete workspace"}</button>
|
|
826
|
+
</div>
|
|
827
|
+
`}renderWorkspaceDetails(e,t,i){return l`
|
|
828
|
+
<dl class="workspace-menu-details">
|
|
829
|
+
<div class="workspace-detail-row">
|
|
830
|
+
<dt>${i.branch===void 0?"Workspace":"Branch"}</dt>
|
|
831
|
+
<dd>${e}</dd>
|
|
832
|
+
</div>
|
|
833
|
+
<div class="workspace-detail-row">
|
|
834
|
+
<dt>Path</dt>
|
|
835
|
+
<dd title=${i.path}>${i.path}</dd>
|
|
836
|
+
</div>
|
|
837
|
+
${t.length===0?null:l`
|
|
838
|
+
<div class="workspace-detail-row">
|
|
839
|
+
<dt>Details</dt>
|
|
840
|
+
<dd><span class="workspace-label">${sn(t)}</span></dd>
|
|
841
|
+
</div>
|
|
842
|
+
`}
|
|
843
|
+
</dl>
|
|
844
|
+
`}delete(e){this.isDeleting(e)||(this.openMenuWorkspaceId=void 0,this.onDelete?.(e))}isDeleting(e){return this.deletingWorkspaceIds.includes(e.id)}toggleMenu(e,t){if(this.openMenuWorkspaceId===e){this.openMenuWorkspaceId=void 0;return}this.menuStyle=Xt(t,{constrainTo:"viewport"}),this.openMenuWorkspaceId=e}handleWorkspaceKeydown(e,t){if(e.key==="Escape"&&this.openMenuWorkspaceId===t.id){e.preventDefault(),e.stopPropagation(),this.openMenuWorkspaceId=void 0;return}Yi(e,{activate:()=>this.onSelect?.(t),previousSection:this.onFocusPreviousSection===void 0?void 0:()=>{this.onFocusPreviousSection?.()},nextSection:this.onFocusNextSection===void 0?void 0:()=>{this.onFocusNextSection?.()},cancel:this.onCancelKeyboardNavigation===void 0?void 0:()=>{this.onCancelKeyboardNavigation?.()}})}scrollSelectedIntoView(){this.renderRoot.querySelector(".action-row.selected")?.scrollIntoView({block:"nearest"})}};K.styles=Ji;ie([d({attribute:!1})],K.prototype,"workspaces",2);ie([d({attribute:!1})],K.prototype,"selected",2);ie([d({type:Boolean,reflect:!0})],K.prototype,"collapsible",2);ie([d({type:Boolean,reflect:!0})],K.prototype,"collapsed",2);ie([d({attribute:!1})],K.prototype,"workspaceLabelItems",2);ie([d({attribute:!1})],K.prototype,"activities",2);ie([d({attribute:!1})],K.prototype,"deletingWorkspaceIds",2);ie([d({attribute:!1})],K.prototype,"onSelect",2);ie([d({attribute:!1})],K.prototype,"onDelete",2);ie([d({attribute:!1})],K.prototype,"onToggleCollapsed",2);ie([d({attribute:!1})],K.prototype,"onFocusPreviousSection",2);ie([d({attribute:!1})],K.prototype,"onFocusNextSection",2);ie([d({attribute:!1})],K.prototype,"onCancelKeyboardNavigation",2);ie([v()],K.prototype,"openMenuWorkspaceId",2);ie([v()],K.prototype,"menuStyle",2);K=ie([D("workspace-list")],K);function Dm(e){return`${e.branch??e.label}${e.isMain?" · main":""}`}function Wm(e){return e.isGitWorktree&&!e.isMain}function Om(e){return`workspace-menu-${e.replace(/[^a-zA-Z0-9_-]/g,"-")}`}var jm=Object.defineProperty,_m=Object.getOwnPropertyDescriptor,A=(e,t,i,s)=>{for(var r=s>1?void 0:s?_m(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&jm(t,i,r),r};function Dt(e){return e.name!==void 0&&e.name!==""?e.name:e.firstMessage!==""?e.firstMessage:e.id.slice(0,8)}let R=class extends M{constructor(){super(...arguments),this.sessions=[],this.statuses={},this.activities={},this.sending={},this.canStart=!1,this.canDeleteArchived=!1,this.canReload=!1,this.canCleanup=!1,this.archivedDeleteUnavailableMessage="Update and restart Pi-Web on this machine to delete archived sessions.",this.cleanupUnavailableMessage="Update and restart Pi-Web on this machine to clean up sessions.",this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.archivedExpanded=!1,this.selectionScopes=new Set,this.selectedSessionIds=new Set,this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuSessionId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("sessions")&&(this.openMenuSessionId!==void 0&&!this.sessions.some(i=>i.id===this.openMenuSessionId)&&(this.openMenuSessionId=void 0),this.sessions.some(i=>i.archived===!0)||(this.archivedExpanded=!1),this.pruneSelectedSessionIds()),e.has("collapsed")&&this.collapsed&&(this.openMenuSessionId=void 0);const t=e.get("selected");if(e.has("selected")&&this.selected?.archived===!0&&(t?.id!==this.selected.id||t.archived!==!0)&&!this.archivedExpanded){this.archivedExpanded=!0,this.updateComplete.then(()=>{this.scrollSelectedIntoView()});return}(e.has("selected")||e.has("sessions")||e.has("collapsed"))&&!this.collapsed&&this.scrollSelectedIntoView()}async focusSelectedOrFirst(){return await this.updateComplete,es(this.renderRoot,{fallbackSelector:".section-toggle, h2 button:not([disabled])"})}render(){const e=Nm(this.sessions),t=new Set(e.map(o=>o.session.id)),i=e.map(o=>o.session).filter(o=>Wt(o)==="current"),s=el(this.sessions.filter(o=>o.archived===!0&&!t.has(o.id))),r=Lm(this.sessions);return l`
|
|
845
|
+
<section>
|
|
846
|
+
${this.renderHeading(e.length+s.length,i)}
|
|
847
|
+
${this.collapsed?null:l`
|
|
848
|
+
<div class="list-body">
|
|
849
|
+
${this.renderCurrentSelectionToolbar(i)}
|
|
850
|
+
${e.map(o=>this.renderSession(o,r.get(o.session.id)??0,"current"))}
|
|
851
|
+
${s.length>0?l`
|
|
852
|
+
${this.renderArchivedHeading(s.map(o=>o.session))}
|
|
853
|
+
${this.archivedExpanded?l`
|
|
854
|
+
${this.renderArchivedSelectionToolbar(s.map(o=>o.session))}
|
|
855
|
+
${s.map(o=>this.renderSession(o,r.get(o.session.id)??0,"archived"))}
|
|
856
|
+
`:null}
|
|
857
|
+
`:null}
|
|
858
|
+
</div>
|
|
859
|
+
`}
|
|
860
|
+
</section>
|
|
861
|
+
`}renderHeading(e,t){if(!this.collapsible)return l`
|
|
862
|
+
<h2>
|
|
863
|
+
Sessions
|
|
864
|
+
${this.renderCurrentSelectionButton(t)}
|
|
865
|
+
${this.renderCleanupButton()}
|
|
866
|
+
<button ?disabled=${!this.canStart} @click=${()=>this.onStart?.()}>+</button>
|
|
867
|
+
</h2>
|
|
868
|
+
`;const i=this.selected===void 0?"No session selected":Dt(this.selected),s=this.selected?.path??i;return l`
|
|
869
|
+
<h2>
|
|
870
|
+
<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Sessions</span>${this.collapsed?l`<small class="section-selected" dir="auto" title=${s}>${i}</small>`:null}</span></button>
|
|
871
|
+
${this.renderCurrentSelectionButton(t)}
|
|
872
|
+
<small class="section-count">${e}</small>
|
|
873
|
+
${this.renderCleanupButton()}
|
|
874
|
+
<button ?disabled=${!this.canStart} @click=${r=>{r.stopPropagation(),this.onStart?.()}}>+</button>
|
|
875
|
+
</h2>
|
|
876
|
+
`}renderCurrentSelectionButton(e){if(this.collapsed||e.length===0)return null;const t=this.selectionScopes.has("current");return l`<button class="bulk-select-entry ${t?"selected":""}" title=${t?"Close current session selection":"Select current sessions"} aria-label=${t?"Close current session selection":"Select current sessions"} aria-expanded=${String(t)} aria-pressed=${String(t)} @click=${i=>{i.stopPropagation(),this.toggleSelection("current",e)}}>☑</button>`}renderCleanupButton(){return l`<button class="cleanup-entry" title=${this.canCleanup?"Preview session cleanup":this.cleanupUnavailableMessage} @click=${e=>{e.stopPropagation(),this.onCleanup?.()}}>Clean up</button>`}renderArchivedHeading(e){const t=this.selectionScopes.has("archived");return l`
|
|
877
|
+
<h2 class="subheading">
|
|
878
|
+
<button class="section-toggle" aria-expanded=${String(this.archivedExpanded)} @click=${()=>{this.toggleArchived()}}><span>${this.archivedExpanded?"▾":"▸"} Archived</span></button>
|
|
879
|
+
${this.archivedExpanded?l`<button class="bulk-select-entry ${t?"selected":""}" title=${t?"Close archived session selection":"Select archived sessions"} aria-label=${t?"Close archived session selection":"Select archived sessions"} aria-expanded=${String(t)} aria-pressed=${String(t)} @click=${()=>{this.toggleSelection("archived",e)}}>☑</button>`:null}
|
|
880
|
+
<small class="section-count">${e.length}</small>
|
|
881
|
+
</h2>
|
|
882
|
+
`}renderCurrentSelectionToolbar(e){if(e.length===0||!this.selectionScopes.has("current"))return null;const t=this.selectedSessions("current"),i=t.filter(o=>!Y(o)),s=e.length>0&&e.every(o=>this.selectedSessionIds.has(o.id)),r=e.filter(o=>this.selectedSessionIds.has(o.id)).length;return l`
|
|
883
|
+
<div class="bulk-row selecting">
|
|
884
|
+
<button ?disabled=${e.length===0} @click=${()=>{this.toggleVisibleSelection(e,!s)}}>${s?"Clear visible":"Select visible"}</button>
|
|
885
|
+
<small>${t.length} selected${r!==t.length?l` · ${r} visible`:null}</small>
|
|
886
|
+
<button ?disabled=${i.length===0} @click=${()=>{this.archiveSelectedCurrent()}}>Archive selected</button>
|
|
887
|
+
<button @click=${()=>{this.clearSelection("current")}}>Clear</button>
|
|
888
|
+
<button @click=${()=>{this.closeSelection("current")}}>Done</button>
|
|
889
|
+
</div>
|
|
890
|
+
`}renderArchivedSelectionToolbar(e){if(e.length===0||!this.selectionScopes.has("archived"))return null;const t=this.selectedSessions("archived"),i=e.length>0&&e.every(r=>this.selectedSessionIds.has(r.id)),s=e.filter(r=>this.selectedSessionIds.has(r.id)).length;return l`
|
|
891
|
+
<div class="bulk-row selecting">
|
|
892
|
+
<button ?disabled=${e.length===0} @click=${()=>{this.toggleVisibleSelection(e,!i)}}>${i?"Clear visible":"Select visible"}</button>
|
|
893
|
+
<small>${t.length} selected${s!==t.length?l` · ${s} visible`:null}</small>
|
|
894
|
+
<button class="danger" title=${this.canDeleteArchived?"Permanently delete selected archived sessions":this.archivedDeleteUnavailableMessage} ?disabled=${t.length===0||!this.canDeleteArchived} @click=${()=>{this.confirmDeleteSelectedArchived()}}>Delete selected</button>
|
|
895
|
+
<button @click=${()=>{this.clearSelection("archived")}}>Clear</button>
|
|
896
|
+
<button @click=${()=>{this.closeSelection("archived")}}>Done</button>
|
|
897
|
+
${this.canDeleteArchived?null:l`<small class="capability-hint">${this.archivedDeleteUnavailableMessage}</small>`}
|
|
898
|
+
</div>
|
|
899
|
+
`}renderSession(e,t,i){const{session:s}=e,r=Math.min(e.depth,2),o=Wt(s)===i,n=this.selectionScopes.has(i),a=n&&o,c=a&&this.selectedSessionIds.has(s.id);return l`
|
|
900
|
+
<div
|
|
901
|
+
class="action-row ${this.selected?.id===s.id?"selected":""} ${c?"bulk-selected":""} ${s.archived===!0?"archived":""} ${n?"selecting":""}"
|
|
902
|
+
style=${`--depth:${String(r)}`}
|
|
903
|
+
tabindex="0"
|
|
904
|
+
title=${s.path}
|
|
905
|
+
@click=${p=>{Xi(p,()=>{this.activateSessionRow(s,i)})}}
|
|
906
|
+
@keydown=${p=>{this.handleSessionKeydown(p,s,i)}}
|
|
907
|
+
>
|
|
908
|
+
<div class="action-main ${n?"selecting":""}">
|
|
909
|
+
${a?l`<input class="session-checkbox" type="checkbox" aria-label=${`Select ${Dt(s)}`} .checked=${c} @click=${p=>{p.stopPropagation()}} @change=${()=>{this.toggleSelected(s.id)}}>`:null}
|
|
910
|
+
<span class="action-name" dir="auto">${e.depth>0?l`<span class="tree-marker">↳</span>`:null}${Dt(s)}${e.depth>2?l` <span class="badge">depth ${e.depth}</span>`:null}${e.hasMissingParent?l` <span class="badge">parent unavailable</span>`:null}</span><small>${this.renderSessionMetaPrefix(s)}${String(s.messageCount)} messages</small>
|
|
911
|
+
${this.renderActivity(s)}
|
|
912
|
+
</div>
|
|
913
|
+
<div class="action-menu">
|
|
914
|
+
<button class="action-menu-toggle" title="Session actions" @click=${p=>{p.stopPropagation(),this.toggleMenu(s.id,p.currentTarget)}}>⋯</button>
|
|
915
|
+
${this.openMenuSessionId===s.id?l`
|
|
916
|
+
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
917
|
+
${Y(s)?l`<button title="Delete browser-cached new session" @click=${()=>{this.openMenuSessionId=void 0,this.onDelete?.(s)}}>Delete</button>`:s.archived===!0?l`
|
|
918
|
+
<button title="Restore session" @click=${()=>{this.openMenuSessionId=void 0,this.onRestore?.(s)}}>Restore</button>
|
|
919
|
+
<button class="danger" title=${this.canDeleteArchived?"Permanently delete archived session":this.archivedDeleteUnavailableMessage} ?disabled=${!this.canDeleteArchived} @click=${()=>{this.openMenuSessionId=void 0,this.confirmDeleteArchived(s)}}>Delete archived session</button>
|
|
920
|
+
`:l`
|
|
921
|
+
<button title="Archive session" @click=${()=>{this.openMenuSessionId=void 0,this.onArchive?.(s)}}>Archive</button>
|
|
922
|
+
${t>0?l`<button title="Archive this session and its descendants" @click=${()=>{this.openMenuSessionId=void 0,this.confirmArchiveWithDescendants(s,t)}}>Archive with descendants (${t})</button>`:null}
|
|
923
|
+
${s.parentSessionPath!==void 0?l`<button title="Detach from parent" @click=${()=>{this.openMenuSessionId=void 0,this.onDetachParent?.(s)}}>Detach from parent</button>`:null}
|
|
924
|
+
${this.canReload?l`<button title=${Xe(this.statuses[s.id],this.activities[s.id])?"Stop current session activity before reloading":"Reload session from disk"} ?disabled=${Xe(this.statuses[s.id],this.activities[s.id])} @click=${()=>{this.openMenuSessionId=void 0,this.onReload?.(s)}}>Reload</button>`:null}
|
|
925
|
+
`}
|
|
926
|
+
</div>
|
|
927
|
+
`:null}
|
|
928
|
+
</div>
|
|
929
|
+
</div>
|
|
930
|
+
`}handleSessionKeydown(e,t,i){Yi(e,{activate:()=>{this.activateSessionRow(t,i)},previousSection:this.onFocusPreviousSection===void 0?void 0:()=>{this.onFocusPreviousSection?.()},nextSection:this.onFocusNextSection===void 0?void 0:()=>{this.onFocusNextSection?.()},cancel:this.onCancelKeyboardNavigation===void 0?void 0:()=>{this.onCancelKeyboardNavigation?.()}})}activateSessionRow(e,t){if(this.selectionScopes.has(t)&&Wt(e)===t){this.toggleSelected(e.id);return}this.onSelect?.(e)}confirmArchiveWithDescendants(e,t){const i=t===1?"descendant session":"descendant sessions";confirm(`Archive “${Dt(e)}” and ${String(t)} ${i}?`)&&this.onArchiveWithDescendants?.(e)}confirmDeleteArchived(e){this.canDeleteArchived&&confirm(`Permanently delete archived session “${Dt(e)}”? This cannot be undone.`)&&this.onDeleteArchived?.(e)}confirmDeleteSelectedArchived(){if(!this.canDeleteArchived)return;const e=this.selectedSessions("archived");if(e.length===0)return;const t=e.length===1?"archived session":"archived sessions";confirm(`Permanently delete ${String(e.length)} selected ${t}? This cannot be undone.`)&&(this.selectedSessionIds=ws(this.selectedSessionIds,e.map(i=>i.id)),this.onDeleteArchivedMany?.(e))}archiveSelectedCurrent(){const e=this.selectedSessions("current").filter(t=>!Y(t));this.selectedSessionIds=ws(this.selectedSessionIds,e.map(t=>t.id)),this.onArchiveMany?.(e)}toggleSelection(e,t){if(this.selectionScopes.has(e)){this.closeSelection(e);return}this.startSelection(e,t)}startSelection(e,t){this.selectionScopes=new Set([...this.selectionScopes,e]);const i=t.length===1?t[0]:void 0;i!==void 0&&(this.selectedSessionIds=new Set([...this.selectedSessionIds,i.id]))}closeSelection(e){this.selectionScopes=new Set([...this.selectionScopes].filter(t=>t!==e)),this.clearSelection(e)}clearSelection(e){const t=this.sessions.filter(i=>Wt(i)===e).map(i=>i.id);this.selectedSessionIds=ws(this.selectedSessionIds,t)}toggleSelected(e){const t=new Set(this.selectedSessionIds);t.has(e)?t.delete(e):t.add(e),this.selectedSessionIds=t}toggleVisibleSelection(e,t){const i=new Set(this.selectedSessionIds);for(const s of e)t?i.add(s.id):i.delete(s.id);this.selectedSessionIds=i}selectedSessions(e){return this.sessions.filter(t=>this.selectedSessionIds.has(t.id)&&Wt(t)===e)}pruneSelectedSessionIds(){const e=new Set(this.sessions.map(i=>i.id)),t=new Set([...this.selectedSessionIds].filter(i=>e.has(i)));t.size!==this.selectedSessionIds.size&&(this.selectedSessionIds=t),this.selectionScopes.has("archived")&&!this.sessions.some(i=>i.archived===!0)&&this.closeSelection("archived"),this.selectionScopes.has("current")&&!this.sessions.some(i=>i.archived!==!0)&&this.closeSelection("current")}toggleMenu(e,t){if(this.openMenuSessionId===e){this.openMenuSessionId=void 0;return}this.menuStyle=Xt(t,{constrainTo:"viewport"}),this.openMenuSessionId=e}toggleArchived(){this.archivedExpanded=!this.archivedExpanded,this.archivedExpanded||(this.openMenuSessionId=void 0,this.selectionScopes.has("archived")&&this.closeSelection("archived"),this.onArchivedCollapsed?.())}scrollSelectedIntoView(){this.renderRoot.querySelector(".action-row.selected")?.scrollIntoView({block:"nearest"})}renderSessionMetaPrefix(e){return Y(e)?"new · ":e.archived===!0?"read-only · ":""}renderActivity(e){const t=Fm(e,this.statuses[e.id],this.activities[e.id],this.sending[e.id]===!0);return Zi(t,t==="sending"?"Sending message":"Session active")}};R.styles=[Ji,O`
|
|
931
|
+
h2 { min-height: 30px; }
|
|
932
|
+
h2 > .section-count { flex: 0 0 auto; display: inline; color: var(--pi-muted); font-size: inherit; }
|
|
933
|
+
.bulk-select-entry { box-sizing: border-box; flex: 0 0 auto; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; font-size: 13px; line-height: 1; text-transform: none; }
|
|
934
|
+
.cleanup-entry { flex: 0 0 auto; padding: 5px 7px; font-size: 12px; text-transform: none; }
|
|
935
|
+
.bulk-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; }
|
|
936
|
+
.bulk-row button { padding: 5px 7px; font-size: 12px; }
|
|
937
|
+
.bulk-row small { display: inline; min-width: 0; color: var(--pi-muted); }
|
|
938
|
+
.action-name, .section-selected { text-align: start; unicode-bidi: plaintext; }
|
|
939
|
+
.bulk-row .capability-hint { flex: 1 0 100%; color: var(--pi-warning); }
|
|
940
|
+
.bulk-row.selecting { padding: 6px; border: 1px solid var(--pi-border-muted); border-radius: 8px; background: color-mix(in srgb, var(--pi-surface) 65%, transparent); }
|
|
941
|
+
button.danger, .action-menu-panel button.danger { color: var(--pi-danger); }
|
|
942
|
+
button.danger:hover, .action-menu-panel button.danger:hover { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
943
|
+
.action-row.bulk-selected .action-main { border-color: var(--pi-accent); box-shadow: inset 3px 0 0 var(--pi-accent); }
|
|
944
|
+
.action-main.selecting { padding-left: calc(32px + var(--depth, 0) * 16px); }
|
|
945
|
+
.session-checkbox { position: absolute; top: 9px; left: calc(8px + var(--depth, 0) * 16px); z-index: 2; margin: 0; }
|
|
946
|
+
`];A([d({attribute:!1})],R.prototype,"sessions",2);A([d({attribute:!1})],R.prototype,"statuses",2);A([d({attribute:!1})],R.prototype,"activities",2);A([d({attribute:!1})],R.prototype,"sending",2);A([d({attribute:!1})],R.prototype,"selected",2);A([d({type:Boolean})],R.prototype,"canStart",2);A([d({type:Boolean})],R.prototype,"canDeleteArchived",2);A([d({type:Boolean})],R.prototype,"canReload",2);A([d({type:Boolean})],R.prototype,"canCleanup",2);A([d({type:String})],R.prototype,"archivedDeleteUnavailableMessage",2);A([d({type:String})],R.prototype,"cleanupUnavailableMessage",2);A([d({type:Boolean,reflect:!0})],R.prototype,"collapsible",2);A([d({type:Boolean,reflect:!0})],R.prototype,"collapsed",2);A([d({attribute:!1})],R.prototype,"onSelect",2);A([d({attribute:!1})],R.prototype,"onStart",2);A([d({attribute:!1})],R.prototype,"onToggleCollapsed",2);A([d({attribute:!1})],R.prototype,"onArchivedCollapsed",2);A([d({attribute:!1})],R.prototype,"onFocusPreviousSection",2);A([d({attribute:!1})],R.prototype,"onFocusNextSection",2);A([d({attribute:!1})],R.prototype,"onCancelKeyboardNavigation",2);A([d({attribute:!1})],R.prototype,"onArchive",2);A([d({attribute:!1})],R.prototype,"onArchiveWithDescendants",2);A([d({attribute:!1})],R.prototype,"onArchiveMany",2);A([d({attribute:!1})],R.prototype,"onRestore",2);A([d({attribute:!1})],R.prototype,"onDelete",2);A([d({attribute:!1})],R.prototype,"onDeleteArchived",2);A([d({attribute:!1})],R.prototype,"onDeleteArchivedMany",2);A([d({attribute:!1})],R.prototype,"onDetachParent",2);A([d({attribute:!1})],R.prototype,"onReload",2);A([d({attribute:!1})],R.prototype,"onCleanup",2);A([v()],R.prototype,"openMenuSessionId",2);A([v()],R.prototype,"menuStyle",2);A([v()],R.prototype,"archivedExpanded",2);A([v()],R.prototype,"selectionScopes",2);A([v()],R.prototype,"selectedSessionIds",2);R=A([D("session-list")],R);function Wt(e){return e.archived===!0?"archived":"current"}function ws(e,t){const i=new Set(t);return new Set([...e].filter(s=>!i.has(s)))}function Lm(e){const t=new Map;for(const s of e){if(s.parentSessionPath===void 0)continue;const r=t.get(s.parentSessionPath)??[];r.push(s),t.set(s.parentSessionPath,r)}const i=(s,r)=>{if(r.has(s.path))return 0;const o=new Set(r);o.add(s.path);let n=0;for(const a of t.get(s.path)??[])o.has(a.path)||(a.archived!==!0&&(n+=1),n+=i(a,o));return n};return new Map(e.map(s=>[s.id,i(s,new Set)]))}function Fm(e,t,i,s){if(!(Y(e)||e.archived===!0))return s?"sending":Xe(t,i)?"session":void 0}function Nm(e){const t=new Map(e.map(s=>[s.path,s])),i=new Set;for(const s of e){if(s.archived===!0)continue;i.add(s.id);let r=s.parentSessionPath;const o=new Set([s.path]);for(;r!==void 0&&!o.has(r);){o.add(r);const n=t.get(r);if(n===void 0)break;i.add(n.id),r=n.parentSessionPath}}return el(e.filter(s=>i.has(s.id)))}function el(e){const t=new Map(e.map(n=>[n.path,n])),i=new Map,s=[];for(const n of e){const a=n.parentSessionPath,c=a===void 0?void 0:t.get(a);if(c===void 0){s.push(n);continue}const p=i.get(c.path)??[];p.push(n),i.set(c.path,p)}const r=[],o=(n,a,c)=>{if(c.has(n.path))return;const p=n.parentSessionPath;r.push({session:n,depth:a,hasMissingParent:p!==void 0&&!t.has(p)});const u=new Set(c);u.add(n.path);for(const h of i.get(n.path)??[])o(h,a+1,u)};for(const n of s)o(n,0,new Set);return r}var Um=Object.defineProperty,zm=Object.getOwnPropertyDescriptor,le=(e,t,i,s)=>{for(var r=s>1?void 0:s?zm(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Um(t,i,r),r};let Z=class extends M{constructor(){super(...arguments),this.canCleanup=!0,this.unavailableMessage="Update and restart Pi-Web on this machine to clean up sessions.",this.loading=!1,this.running=!1,this.error="",this.draft={...Ku},this.formError=""}willUpdate(e){e.has("preview")&&(this.selectedProjectCwds=this.preview?.projects.map(t=>t.cwd))}render(){const e=Lt(this.draft),t=this.selectedPreview(),i=No({canCleanup:this.canCleanup,draft:this.draft,preview:t,previewRequest:this.previewRequest,loading:this.loading,running:this.running}),s=i?"Run cleanup":t!==void 0&&!bi(t)?"Select at least one project to run cleanup":"Preview cleanup before running it";return l`
|
|
947
|
+
<div class="backdrop" @mousedown=${()=>{this.onClose?.()}}>
|
|
948
|
+
<section role="dialog" aria-modal="true" aria-label="Clean up sessions" @mousedown=${r=>{r.stopPropagation()}} @keydown=${r=>{this.handleKeyDown(r)}}>
|
|
949
|
+
<header>
|
|
950
|
+
<div>
|
|
951
|
+
<span class="eyebrow">Sessions</span>
|
|
952
|
+
<h1>Clean up sessions</h1>
|
|
953
|
+
</div>
|
|
954
|
+
<button class="close-button" title="Close cleanup" aria-label="Close cleanup" @click=${()=>{this.onClose?.()}}>×</button>
|
|
955
|
+
</header>
|
|
956
|
+
<div class="body">
|
|
957
|
+
<p class="intro">Preview manual cleanup for this machine before archiving idle sessions or permanently deleting old archived sessions.</p>
|
|
958
|
+
${this.canCleanup?this.renderForm(e.ok?"":e.error):this.renderUnavailable()}
|
|
959
|
+
${this.renderMessage()}
|
|
960
|
+
${this.preview===void 0?null:this.renderPreview(this.preview)}
|
|
961
|
+
${this.result===void 0?null:this.renderResult(this.result)}
|
|
962
|
+
</div>
|
|
963
|
+
<footer>
|
|
964
|
+
<button @click=${()=>{this.onClose?.()}}>${this.result===void 0?"Cancel":"Close"}</button>
|
|
965
|
+
<button ?disabled=${!this.canCleanup||this.loading||this.running} @click=${()=>{this.previewCleanup()}}>${this.loading?"Previewing…":"Preview"}</button>
|
|
966
|
+
<button class="danger" ?disabled=${!i} title=${s} @click=${()=>{this.runCleanup()}}>${this.running?"Running…":"Run cleanup"}</button>
|
|
967
|
+
</footer>
|
|
968
|
+
</section>
|
|
969
|
+
</div>
|
|
970
|
+
`}renderForm(e){const t=this.loading||this.running,i=Lt(this.draft),s=this.preview!==void 0&&i.ok&&St(i.request)!==St(this.previewRequest)&&bi(this.preview);return l`
|
|
971
|
+
<fieldset ?disabled=${t}>
|
|
972
|
+
<label class="toggle-row">
|
|
973
|
+
<input type="checkbox" .checked=${this.draft.archiveIdleEnabled} @change=${r=>{this.updateDraft({archiveIdleEnabled:ys(r)})}}>
|
|
974
|
+
<span>Archive non-archived sessions idle for more than</span>
|
|
975
|
+
<input class="days" type="number" min="0" step="1" inputmode="numeric" .value=${this.draft.archiveIdleDays} ?disabled=${t||!this.draft.archiveIdleEnabled} @input=${r=>{this.updateDraft({archiveIdleDays:rn(r)})}}>
|
|
976
|
+
<span>days</span>
|
|
977
|
+
</label>
|
|
978
|
+
<label class="toggle-row delete-row">
|
|
979
|
+
<input type="checkbox" .checked=${this.draft.deleteArchivedEnabled} @change=${r=>{this.updateDraft({deleteArchivedEnabled:ys(r)})}}>
|
|
980
|
+
<span>Delete archived sessions archived for more than</span>
|
|
981
|
+
<input class="days" type="number" min="0" step="1" inputmode="numeric" .value=${this.draft.deleteArchivedDays} ?disabled=${t||!this.draft.deleteArchivedEnabled} @input=${r=>{this.updateDraft({deleteArchivedDays:rn(r)})}}>
|
|
982
|
+
<span>days</span>
|
|
983
|
+
</label>
|
|
984
|
+
</fieldset>
|
|
985
|
+
<p class="warning"><strong>Deletion is permanent.</strong> Cleanup only deletes sessions that are already archived.</p>
|
|
986
|
+
${e===""?null:l`<div class="dialog-error" role="alert">${e}</div>`}
|
|
987
|
+
${s?l`<div class="hint" role="status">Thresholds changed. Preview again before running cleanup.</div>`:null}
|
|
988
|
+
`}renderUnavailable(){return l`<div class="unavailable" role="status">${this.unavailableMessage}</div>`}renderMessage(){const e=this.formError||this.error;return e===""?null:l`<div class="dialog-error" role="alert">${e}</div>`}renderPreview(e){const t=this.selectedProjectCwdsForPreview(),i=new Set(t),s=Uo(e,t);return l`
|
|
989
|
+
<section class="preview" aria-label="Cleanup preview">
|
|
990
|
+
<h2>Preview</h2>
|
|
991
|
+
${e.projects.length===0?l`<p class="empty">No sessions match these thresholds.</p>`:l`
|
|
992
|
+
${this.renderSelectionControls(e,t)}
|
|
993
|
+
<div class="table-scroll" tabindex="0" aria-label="Cleanup projects table">
|
|
994
|
+
<table>
|
|
995
|
+
<thead>
|
|
996
|
+
<tr><th>Clean up</th><th>Project/workspace path</th><th>Archive</th><th>Delete archived</th></tr>
|
|
997
|
+
</thead>
|
|
998
|
+
<tbody>
|
|
999
|
+
${e.projects.map(r=>this.renderProjectRow(r,i.has(r.cwd)))}
|
|
1000
|
+
</tbody>
|
|
1001
|
+
<tfoot>
|
|
1002
|
+
<tr><th colspan="2">Selected totals</th><td>${s.totals.archiveCount}</td><td>${s.totals.deleteCount}</td></tr>
|
|
1003
|
+
</tfoot>
|
|
1004
|
+
</table>
|
|
1005
|
+
</div>
|
|
1006
|
+
`}
|
|
1007
|
+
${e.skippedBusySessionIds===void 0||e.skippedBusySessionIds.length===0?null:l`<p class="hint">${e.skippedBusySessionIds.length} busy ${e.skippedBusySessionIds.length===1?"session was":"sessions were"} skipped.</p>`}
|
|
1008
|
+
</section>
|
|
1009
|
+
`}renderSelectionControls(e,t){const i=this.loading||this.running;return l`
|
|
1010
|
+
<div class="selection-controls" role="group" aria-label="Project selection">
|
|
1011
|
+
<span>${t.length} of ${e.projects.length} projects selected</span>
|
|
1012
|
+
<button ?disabled=${i||t.length===e.projects.length} @click=${()=>{this.selectAllProjects()}}>Select all</button>
|
|
1013
|
+
<button ?disabled=${i||t.length===0} @click=${()=>{this.deselectAllProjects()}}>Deselect all</button>
|
|
1014
|
+
</div>
|
|
1015
|
+
${t.length===0?l`<p class="hint" role="status">Select at least one project to run cleanup.</p>`:null}
|
|
1016
|
+
`}renderProjectRow(e,t){return l`
|
|
1017
|
+
<tr class=${t?"":"unselected"}>
|
|
1018
|
+
<td class="select-cell"><input type="checkbox" aria-label=${`Clean up ${e.cwd}`} .checked=${t} ?disabled=${this.running} @change=${i=>{this.setProjectSelected(e.cwd,ys(i))}}></td>
|
|
1019
|
+
<th title=${e.cwd} dir="auto">${e.cwd}</th>
|
|
1020
|
+
<td>${e.archiveCount}</td>
|
|
1021
|
+
<td>${e.deleteCount}</td>
|
|
1022
|
+
</tr>
|
|
1023
|
+
`}renderResult(e){return l`
|
|
1024
|
+
<section class="result" aria-label="Cleanup result">
|
|
1025
|
+
<h2>Cleanup complete</h2>
|
|
1026
|
+
<p>Archived ${e.archivedSessionIds.length} ${e.archivedSessionIds.length===1?"session":"sessions"}; permanently deleted ${e.deletedSessionIds.length} archived ${e.deletedSessionIds.length===1?"session":"sessions"}.</p>
|
|
1027
|
+
</section>
|
|
1028
|
+
`}updateDraft(e){this.draft={...this.draft,...e},this.formError=""}selectedPreview(){return this.preview===void 0?void 0:Uo(this.preview,this.selectedProjectCwdsForPreview())}selectedProjectCwdsForPreview(){return this.preview===void 0?[]:Ea(this.preview,this.selectedProjectCwds)}selectAllProjects(){this.selectedProjectCwds=this.preview?.projects.map(e=>e.cwd)??[],this.formError=""}deselectAllProjects(){this.selectedProjectCwds=[],this.formError=""}setProjectSelected(e,t){const i=this.preview;if(i===void 0)return;const s=new Set(this.selectedProjectCwdsForPreview());t?s.add(e):s.delete(e),this.selectedProjectCwds=i.projects.map(r=>r.cwd).filter(r=>s.has(r)),this.formError=""}previewCleanup(){const e=Lt(this.draft);if(!e.ok){this.formError=e.error;return}this.formError="",this.onPreview?.(e.request)}runCleanup(){const e=Lt(this.draft);if(!e.ok){this.formError=e.error;return}const t=this.selectedPreview(),i=this.selectedProjectCwdsForPreview();if(!No({canCleanup:this.canCleanup,draft:this.draft,preview:t,previewRequest:this.previewRequest})){this.formError=t!==void 0&&!bi(t)?"Select at least one project to run cleanup.":"Preview cleanup before running it.";return}t===void 0||!Vu(t,s=>confirm(s))||(this.formError="",this.onRun?.({...e.request,projectCwds:i}))}handleKeyDown(e){e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.onClose?.())}};Z.styles=O`
|
|
1029
|
+
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1030
|
+
.backdrop { box-sizing: border-box; width: 100%; height: 100dvh; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: var(--pi-overlay); overflow: hidden; }
|
|
1031
|
+
section[role="dialog"] { width: min(760px, 100%); max-height: min(760px, 100%); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border: 1px solid var(--pi-border); border-radius: 14px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
1032
|
+
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--pi-border); }
|
|
1033
|
+
footer { border-top: 1px solid var(--pi-border); border-bottom: 0; justify-content: end; }
|
|
1034
|
+
.body { min-height: 0; overflow: auto; display: grid; gap: 14px; padding: 16px; }
|
|
1035
|
+
.eyebrow { display: block; color: var(--pi-muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
|
1036
|
+
h1, h2, p { margin: 0; }
|
|
1037
|
+
h1 { font-size: 20px; line-height: 1.2; }
|
|
1038
|
+
h2 { font-size: 15px; }
|
|
1039
|
+
.intro, .hint, .empty { color: var(--pi-muted); }
|
|
1040
|
+
fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 10px; }
|
|
1041
|
+
.toggle-row { display: grid; grid-template-columns: auto minmax(0, max-content) 88px auto; align-items: center; gap: 8px; color: var(--pi-text); }
|
|
1042
|
+
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--pi-accent); }
|
|
1043
|
+
input.days { box-sizing: border-box; width: 88px; min-width: 0; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 8px 9px; font: inherit; }
|
|
1044
|
+
input.days:disabled { opacity: .55; }
|
|
1045
|
+
.warning, .unavailable, .dialog-error, .result { border: 1px solid var(--pi-border); border-radius: 10px; padding: 10px 12px; }
|
|
1046
|
+
.warning { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); color: var(--pi-text); }
|
|
1047
|
+
.unavailable { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); color: var(--pi-warning); }
|
|
1048
|
+
.dialog-error { border-color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); color: var(--pi-danger); }
|
|
1049
|
+
.result { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
1050
|
+
.preview { display: grid; gap: 10px; min-width: 0; }
|
|
1051
|
+
.selection-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
1052
|
+
.selection-controls span { color: var(--pi-muted); }
|
|
1053
|
+
.selection-controls button { padding: 5px 7px; font-size: 12px; }
|
|
1054
|
+
.table-scroll { max-width: 100%; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; border: 1px solid var(--pi-border); border-radius: 10px; }
|
|
1055
|
+
table { width: 100%; min-width: 620px; border-collapse: collapse; }
|
|
1056
|
+
th, td { border-bottom: 1px solid var(--pi-border-muted); padding: 8px 10px; text-align: right; }
|
|
1057
|
+
thead th:first-child, td.select-cell { width: 72px; text-align: center; }
|
|
1058
|
+
th:nth-child(2), td:nth-child(2) { text-align: left; }
|
|
1059
|
+
tbody tr.unselected { opacity: .58; }
|
|
1060
|
+
tbody th { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 500; }
|
|
1061
|
+
tfoot th, tfoot td { border-bottom: 0; font-weight: 700; }
|
|
1062
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; font: inherit; cursor: pointer; }
|
|
1063
|
+
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
1064
|
+
button.danger { color: var(--pi-danger); }
|
|
1065
|
+
button.danger:not(:disabled):hover { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
1066
|
+
.close-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--pi-muted); padding: 0; font-size: 24px; }
|
|
1067
|
+
.close-button:hover, .close-button:focus { color: var(--pi-text); background: var(--pi-surface-hover); }
|
|
1068
|
+
|
|
1069
|
+
@media (max-width: 680px) {
|
|
1070
|
+
.backdrop { padding: 0; place-items: stretch; }
|
|
1071
|
+
section[role="dialog"] { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
|
|
1072
|
+
.toggle-row { grid-template-columns: auto minmax(0, 1fr); }
|
|
1073
|
+
.toggle-row input.days { grid-column: 2; }
|
|
1074
|
+
.toggle-row span:last-child { grid-column: 2; }
|
|
1075
|
+
table { min-width: 560px; }
|
|
1076
|
+
thead th:first-child, td.select-cell { width: 58px; }
|
|
1077
|
+
}
|
|
1078
|
+
`;le([d({type:Boolean})],Z.prototype,"canCleanup",2);le([d({type:String})],Z.prototype,"unavailableMessage",2);le([d({attribute:!1})],Z.prototype,"preview",2);le([d({attribute:!1})],Z.prototype,"previewRequest",2);le([d({attribute:!1})],Z.prototype,"result",2);le([d({type:Boolean})],Z.prototype,"loading",2);le([d({type:Boolean})],Z.prototype,"running",2);le([d({type:String})],Z.prototype,"error",2);le([d({attribute:!1})],Z.prototype,"onPreview",2);le([d({attribute:!1})],Z.prototype,"onRun",2);le([d({attribute:!1})],Z.prototype,"onClose",2);le([v()],Z.prototype,"draft",2);le([v()],Z.prototype,"formError",2);le([v()],Z.prototype,"selectedProjectCwds",2);Z=le([D("session-cleanup-dialog")],Z);function ys(e){return e.target instanceof HTMLInputElement?e.target.checked:!1}function rn(e){return e.target instanceof HTMLInputElement?e.target.value:""}const Cr={CHILD:2,ELEMENT:6},Rr=e=>(...t)=>({_$litDirective$:e,values:t});let Ir=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}};const{I:Bm}=oc,on=e=>e,nn=()=>document.createComment(""),Ot=(e,t,i)=>{const s=e._$AA.parentNode,r=t===void 0?e._$AB:t._$AA;if(i===void 0){const o=s.insertBefore(nn(),r),n=s.insertBefore(nn(),r);i=new Bm(o,n,e,e.options)}else{const o=i._$AB.nextSibling,n=i._$AM,a=n!==e;if(a){let c;i._$AQ?.(e),i._$AM=e,i._$AP!==void 0&&(c=e._$AU)!==n._$AU&&i._$AP(c)}if(o!==r||a){let c=i._$AA;for(;c!==o;){const p=on(c).nextSibling;on(s).insertBefore(c,r),c=p}}}return i},st=(e,t,i=e)=>(e._$AI(t,i),e),Hm={},qm=(e,t=Hm)=>e._$AH=t,Km=e=>e._$AH,xs=e=>{e._$AR(),e._$AA.remove()};const an=(e,t,i)=>{const s=new Map;for(let r=t;r<=i;r++)s.set(e[r],r);return s},Vm=Rr(class extends Ir{constructor(e){if(super(e),e.type!==Cr.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let s;i===void 0?i=t:t!==void 0&&(s=t);const r=[],o=[];let n=0;for(const a of e)r[n]=s?s(a,n):n,o[n]=i(a,n),n++;return{values:o,keys:r}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const r=Km(e),{values:o,keys:n}=this.dt(t,i,s);if(!Array.isArray(r))return this.ut=n,o;const a=this.ut??=[],c=[];let p,u,h=0,f=r.length-1,b=0,P=o.length-1;for(;h<=f&&b<=P;)if(r[h]===null)h++;else if(r[f]===null)f--;else if(a[h]===n[b])c[b]=st(r[h],o[b]),h++,b++;else if(a[f]===n[P])c[P]=st(r[f],o[P]),f--,P--;else if(a[h]===n[P])c[P]=st(r[h],o[P]),Ot(e,c[P+1],r[h]),h++,P--;else if(a[f]===n[b])c[b]=st(r[f],o[b]),Ot(e,r[h],r[f]),f--,b++;else if(p===void 0&&(p=an(n,b,P),u=an(a,h,f)),p.has(a[h]))if(p.has(a[f])){const C=u.get(n[b]),G=C!==void 0?r[C]:null;if(G===null){const Ke=Ot(e,r[h]);st(Ke,o[b]),c[b]=Ke}else c[b]=st(G,o[b]),Ot(e,r[h],G),r[C]=null;b++}else xs(r[f]),f--;else xs(r[h]),h++;for(;b<=P;){const C=Ot(e,c[P+1]);st(C,o[b]),c[b++]=C}for(;h<=f;){const C=r[h++];C!==null&&xs(C)}return this.ut=n,qm(e,c),Ze}}),Gm="pi-web:chat-groups:",Qm={read(e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(ln(e));return t===null||t===""?void 0:Zm(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>"u")return;localStorage.setItem(ln(e),JSON.stringify(t))}catch{}}};class Jm{constructor(t=Qm){this.storage=t,this.sessionId="",this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(t){if(this.sessionId===t)return;this.sessionId=t;const i=t===""?void 0:this.storage.read(t);this.openGroupKeys=new Set(i?.open??[]),this.closedDefaultOpenGroupKeys=new Set(i?.closedDefaultOpen??[])}isOpen(t,i){return i?!this.closedDefaultOpenGroupKeys.has(t):this.openGroupKeys.has(t)}applyToggle(t,i,s){const r=this.isOpen(t,s),o=new Set(this.openGroupKeys),n=new Set(this.closedDefaultOpenGroupKeys);return s?(o.delete(t),i?n.delete(t):n.add(t)):(n.delete(t),i?o.add(t):o.delete(t)),(s?!n.has(t):o.has(t))===r&&cn(o,this.openGroupKeys)&&cn(n,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=o,this.closedDefaultOpenGroupKeys=n,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==""&&this.storage.write(this.sessionId,this.snapshot())}}function ln(e){return`${Gm}${e}`}function Zm(e){if(Array.isArray(e))return{open:Ss(e),closedDefaultOpen:[]};if(Xm(e))return{open:Array.isArray(e.open)?Ss(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?Ss(e.closedDefaultOpen):[]}}function Ss(e){return e.filter(t=>typeof t=="string")}function cn(e,t){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}function Xm(e){return typeof e=="object"&&e!==null}function Ym(e,t=0){const i=[];let s=[],r=0;const o=(a,c)=>{s.length||(r=c),s.push(a)},n=()=>{s.length&&(i.push({kind:"group",messages:s,startIndex:r,endIndex:r+s.length-1}),s=[])};return e.forEach((a,c)=>{const p=a.parts.filter(b=>dn(a,b)),u=a.parts.filter(b=>!dn(a,b)),h=t+c,f={...a.source===void 0?{}:{source:a.source},...a.meta===void 0?{}:{meta:a.meta}};if(u.length&&o({role:a.role,parts:u,...f},h),p.length){n();const b=p.every(P=>P.type==="skillRead")?"skill":a.role;i.push({kind:"message",message:{role:b,parts:p,...f},index:h})}}),n(),i}function ev(e){if(e.every(s=>s.source==="compaction"))return`${String(e.length)} history compaction ${e.length===1?"summary":"summaries"}`;if(e.every(s=>s.source==="branch_summary"))return`${String(e.length)} branch ${e.length===1?"summary":"summaries"}`;const t=e.reduce((s,r)=>(s[r.role]=(s[r.role]??0)+1,s),{}),i=Object.entries(t).map(([s,r])=>`${String(r)} ${s}`).join(" · ");return`${String(e.length)} ${e.length===1?"event":"events"}${i!==""?` · ${i}`:""}`}function dn(e,t){return e.source==="compaction"||e.source==="branch_summary"?!1:t.type==="skillInvocation"||t.type==="skillRead"?!0:t.type==="text"&&(e.role==="user"||e.role==="assistant"||e.role==="system"||e.role==="bash")}const tv=30;function iv(e,t){const i=rv(av(e,t)),s={distanceFromBottom:e.scrollHeight-e.scrollTop};return i===void 0?s:{...s,markerId:i.id,markerOffset:i.offset}}function sv(e,t,i){if(i!==void 0&&t.markerOffset!==void 0){const s=i.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=ov(s,t.markerOffset);return}e.scrollTop=nv(e.scrollHeight,t.distanceFromBottom)}function rv(e){let t,i=Number.NEGATIVE_INFINITY,s,r=Number.POSITIVE_INFINITY;for(const o of e)o.offset<=0&&o.offset>=i?(t=o,i=o.offset):o.offset>0&&o.offset<r&&(s=o,r=o.offset);return t??s}function ov(e,t){return e-t}function nv(e,t){return Math.max(0,e-t)}function av(e,t){const i=e.getBoundingClientRect().top;return t.flatMap(s=>{const r=s.dataset.markerId;return r===void 0?[]:[{id:r,offset:s.getBoundingClientRect().top-i}]})}const lv=600,cv=1;function dv(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:pv(e)||hv(e)}function pv(e){return e.scrollTop<(e.topThreshold??Math.max(lv,e.clientHeight))}function hv(e){return e.scrollHeight<=e.clientHeight+cv}const uv="pi-web:chat-scroll:",fv=180,gv=48,mv=2,vv={getItem(e){return typeof localStorage>"u"?null:localStorage.getItem(e)},setItem(e,t){typeof localStorage>"u"||localStorage.setItem(e,t)},removeItem(e){typeof localStorage>"u"||localStorage.removeItem(e)}},bv={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}};class wv{constructor(t=vv,i=bv){this.storage=t,this.scheduler=i}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(t,i,s=fv){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,i(t)},s)}savePosition(t,i,s,r=mv){if(t===""||i===void 0||!$s(i))return"skipped";try{if(il(i,r)){const a={mode:"bottom"};return this.storage.setItem(ks(t),JSON.stringify(a)),"saved"}const o=Sv(i,s);if(o===void 0)return"skipped";const n=xv(i,o);return this.storage.setItem(ks(t),JSON.stringify(n)),"saved"}catch{return"skipped"}}restorePosition(t,i,s,r){const o=this.readPosition(t);return o===void 0?this.scrollToBottom(i):this.restoreExplicitPosition(o,i,s,r)}restoreExplicitPosition(t,i,s,r){if(t.mode==="bottom")return this.scrollToBottom(i);if(i===void 0||!$s(i))return{status:"skipped"};const o=kv(s,t.anchorId);if(o===void 0)return r?.fallbackToBottom===!1?{status:"missing",position:t}:this.scrollToBottom(i);const n=i.getBoundingClientRect().top,a=o.getBoundingClientRect().top-n;return i.scrollTop+=a-t.offset,{status:"restored"}}readPosition(t){if(t!=="")try{const i=this.storage.getItem(ks(t));if(i===null||i==="")return;const s=JSON.parse(i);return yv(s)?s:void 0}catch{return}}scrollToBottom(t){return t===void 0||!$s(t)?{status:"skipped"}:(t.scrollTop=t.scrollHeight,{status:"bottom"})}}function ks(e){return`${uv}${e}`}function yv(e){return typeof e!="object"||e===null||!("mode"in e)?!1:e.mode==="bottom"?!0:e.mode==="anchor"&&"anchorId"in e&&typeof e.anchorId=="string"&&e.anchorId!==""&&"offset"in e&&typeof e.offset=="number"}function $s(e){return e.clientHeight>0&&e.scrollHeight>0}function tl(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function il(e,t=gv){return tl(e)<t}function xv(e,t){const i=e.getBoundingClientRect().top;return{mode:"anchor",anchorId:Ar(t)??"",offset:t.getBoundingClientRect().top-i}}function Sv(e,t){const i=e.getBoundingClientRect();let s,r=Number.NEGATIVE_INFINITY,o,n=Number.POSITIVE_INFINITY;for(const a of t){if(Ar(a)===void 0)continue;const c=a.getBoundingClientRect();if(c.bottom<=c.top||c.bottom<i.top||c.top>i.bottom)continue;const p=c.top-i.top;p<=0&&p>=r?(s=a,r=p):p>0&&p<n&&(o=a,n=p)}return s??o}function pn(e,t){const i=e.getBoundingClientRect();return t.find(s=>{const r=s.getBoundingClientRect();return r.bottom>=i.top&&r.top<=i.bottom})}function kv(e,t){return e.find(i=>Ar(i)===t)}function Ar(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==""?e.dataset.scrollAnchorId:void 0}var $v=Object.defineProperty,Pv=Object.getOwnPropertyDescriptor,Mr=(e,t,i,s)=>{for(var r=s>1?void 0:s?Pv(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&$v(t,i,r),r};let Kt=class extends M{constructor(){super(...arguments),this.positionPercent=0,this.loadedPercent=100}render(){const e=hn(this.positionPercent),t=hn(this.loadedPercent),i=`Message position: about ${String(Math.round(e))}% through conversation. ${String(Math.round(t))}% of messages loaded.`;return l`
|
|
1079
|
+
<div
|
|
1080
|
+
class="meter"
|
|
1081
|
+
style=${`--position:${e.toFixed(2)}%;`}
|
|
1082
|
+
role="meter"
|
|
1083
|
+
aria-label=${i}
|
|
1084
|
+
aria-valuemin="0"
|
|
1085
|
+
aria-valuemax="100"
|
|
1086
|
+
aria-valuenow=${String(Math.round(e))}
|
|
1087
|
+
title=${i}
|
|
1088
|
+
>
|
|
1089
|
+
<div class="track" aria-hidden="true">
|
|
1090
|
+
<div class="progress"></div>
|
|
1091
|
+
<div class="marker"></div>
|
|
1092
|
+
</div>
|
|
1093
|
+
</div>
|
|
1094
|
+
`}};Kt.styles=O`
|
|
1095
|
+
:host { position: absolute; top: -4px; left: 16px; right: 16px; z-index: 6; display: block; height: 12px; opacity: .58; transition: opacity .15s ease; }
|
|
1096
|
+
:host(:hover), :host(:focus-within) { opacity: .92; }
|
|
1097
|
+
.meter { height: 100%; }
|
|
1098
|
+
.track { position: relative; height: 4px; margin-top: 4px; border-radius: 999px; background: color-mix(in srgb, var(--pi-border-muted) 34%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--pi-bg) 55%, transparent); }
|
|
1099
|
+
.progress { position: absolute; left: 0; width: var(--position); top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--pi-accent) 42%, var(--pi-border-muted)); }
|
|
1100
|
+
.marker { position: absolute; left: var(--position); top: 50%; width: 10px; height: 10px; border: 2px solid var(--pi-bg); border-radius: 50%; background: var(--pi-accent); box-shadow: 0 2px 8px var(--pi-shadow); transform: translate(-50%, -50%); }
|
|
1101
|
+
`;Mr([d({type:Number})],Kt.prototype,"positionPercent",2);Mr([d({type:Number})],Kt.prototype,"loadedPercent",2);Kt=Mr([D("conversation-meter")],Kt);function hn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}class qs extends Ir{constructor(t){if(super(t),this.it=U,t.type!==Cr.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===U||t==null)return this._t=void 0,this.it=t;if(t===Ze)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const i=[t];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}}qs.directiveName="unsafeHTML",qs.resultType=1;const Cv=Rr(qs);function Tr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pt=Tr();function sl(e){pt=e}var rt={exec:()=>null};function mt(e){let t=[];return i=>{let s=Math.max(0,Math.min(3,i-1)),r=t[s];return r||(r=e(s),t[s]=r),r}}function T(e,t=""){let i=typeof e=="string"?e:e.source,s={replace:(r,o)=>{let n=typeof o=="string"?o:o.source;return n=n.replace(ee.caret,"$1"),i=i.replace(r,n),s},getRegex:()=>new RegExp(i,t)};return s}var Rv=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),ee={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:mt(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:mt(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:mt(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:mt(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:mt(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:mt(e=>new RegExp(`^ {0,${e}}>`))},Iv=/^(?:[ \t]*(?:\n|$))+/,Av=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Mv=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Tv=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Er=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,rl=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ol=T(rl).replace(/bull/g,Er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ev=T(rl).replace(/bull/g,Er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Dr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Dv=/^[^\n]+/,Wr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Wv=T(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Wr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ov=T(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Er).getRegex(),ts="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Or=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,jv=T("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Or).replace("tag",ts).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),nl=T(Dr).replace("hr",Yt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ts).getRegex(),_v=T(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",nl).getRegex(),jr={blockquote:_v,code:Av,def:Wv,fences:Mv,heading:Tv,hr:Yt,html:jv,lheading:ol,list:Ov,newline:Iv,paragraph:nl,table:rt,text:Dv},un=T("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ts).getRegex(),Lv={...jr,lheading:Ev,table:un,paragraph:T(Dr).replace("hr",Yt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",un).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ts).getRegex()},Fv={...jr,html:T(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Or).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:rt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:T(Dr).replace("hr",Yt).replace("heading",` *#{1,6} *[^
|
|
1102
|
+
]`).replace("lheading",ol).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Nv=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Uv=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,al=/^( {2,}|\\)\n(?!\s*$)/,zv=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ct=/[\p{P}\p{S}]/u,is=/[\s\p{P}\p{S}]/u,_r=/[^\s\p{P}\p{S}]/u,Bv=T(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,is).getRegex(),ll=/(?!~)[\p{P}\p{S}]/u,Hv=/(?!~)[\s\p{P}\p{S}]/u,qv=/(?:[^\s\p{P}\p{S}]|~)/u,Kv=T(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Rv?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),cl=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Vv=T(cl,"u").replace(/punct/g,Ct).getRegex(),Gv=T(cl,"u").replace(/punct/g,ll).getRegex(),dl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Qv=T(dl,"gu").replace(/notPunctSpace/g,_r).replace(/punctSpace/g,is).replace(/punct/g,Ct).getRegex(),Jv=T(dl,"gu").replace(/notPunctSpace/g,qv).replace(/punctSpace/g,Hv).replace(/punct/g,ll).getRegex(),Zv=T("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_r).replace(/punctSpace/g,is).replace(/punct/g,Ct).getRegex(),Xv=T(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ct).getRegex(),Yv="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",eb=T(Yv,"gu").replace(/notPunctSpace/g,_r).replace(/punctSpace/g,is).replace(/punct/g,Ct).getRegex(),tb=T(/\\(punct)/,"gu").replace(/punct/g,Ct).getRegex(),ib=T(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),sb=T(Or).replace("(?:-->|$)","-->").getRegex(),rb=T("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",sb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_i=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ob=T(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",_i).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),pl=T(/^!?\[(label)\]\[(ref)\]/).replace("label",_i).replace("ref",Wr).getRegex(),hl=T(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wr).getRegex(),nb=T("reflink|nolink(?!\\()","g").replace("reflink",pl).replace("nolink",hl).getRegex(),fn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Lr={_backpedal:rt,anyPunctuation:tb,autolink:ib,blockSkip:Kv,br:al,code:Uv,del:rt,delLDelim:rt,delRDelim:rt,emStrongLDelim:Vv,emStrongRDelimAst:Qv,emStrongRDelimUnd:Zv,escape:Nv,link:ob,nolink:hl,punctuation:Bv,reflink:pl,reflinkSearch:nb,tag:rb,text:zv,url:rt},ab={...Lr,link:T(/^!?\[(label)\]\((.*?)\)/).replace("label",_i).getRegex(),reflink:T(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_i).getRegex()},Ks={...Lr,emStrongRDelimAst:Jv,emStrongLDelim:Gv,delLDelim:Xv,delRDelim:eb,url:T(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",fn).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:T(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",fn).getRegex()},lb={...Ks,br:T(al).replace("{2,}","*").getRegex(),text:T(Ks.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ni={normal:jr,gfm:Lv,pedantic:Fv},jt={normal:Lr,gfm:Ks,breaks:lb,pedantic:ab},cb={"&":"&","<":"<",">":">",'"':""","'":"'"},gn=e=>cb[e];function We(e,t){if(t){if(ee.escapeTest.test(e))return e.replace(ee.escapeReplace,gn)}else if(ee.escapeTestNoEncode.test(e))return e.replace(ee.escapeReplaceNoEncode,gn);return e}function mn(e){try{e=encodeURI(e).replace(ee.percentDecode,"%")}catch{return null}return e}function vn(e,t){let i=e.replace(ee.findPipe,(o,n,a)=>{let c=!1,p=n;for(;--p>=0&&a[p]==="\\";)c=!c;return c?"|":" |"}),s=i.split(ee.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(ee.slashPipe,"|");return s}function Ve(e,t,i){let s=e.length;if(s===0)return"";let r=0;for(;r<s&&e.charAt(s-r-1)===t;)r++;return e.slice(0,s-r)}function bn(e){let t=e.split(`
|
|
1103
|
+
`),i=t.length-1;for(;i>=0&&ee.blankLine.test(t[i]);)i--;return t.length-i<=2?e:t.slice(0,i+1).join(`
|
|
1104
|
+
`)}function db(e,t){if(e.indexOf(t[1])===-1)return-1;let i=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])i++;else if(e[s]===t[1]&&(i--,i<0))return s;return i>0?-2:-1}function pb(e,t=0){let i=t,s="";for(let r of e)if(r===" "){let o=4-i%4;s+=" ".repeat(o),i+=o}else s+=r,i++;return s}function wn(e,t,i,s,r){let o=t.href,n=t.title||null,a=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let c={type:e[0].charAt(0)==="!"?"image":"link",raw:i,href:o,title:n,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,c}function hb(e,t,i){let s=e.match(i.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(`
|
|
1105
|
+
`).map(o=>{let n=o.match(i.other.beginningSpace);if(n===null)return o;let[a]=n;return a.length>=r.length?o.slice(r.length):o}).join(`
|
|
1106
|
+
`)}var Li=class{options;rules;lexer;constructor(e){this.options=e||pt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let i=this.options.pedantic?t[0]:bn(t[0]),s=i.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:i,codeBlockStyle:"indented",text:s}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let i=t[0],s=hb(i,t[3]||"",this.rules);return{type:"code",raw:i,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let i=t[2].trim();if(this.rules.other.endingHash.test(i)){let s=Ve(i,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(i=s.trim())}return{type:"heading",raw:Ve(t[0],`
|
|
1107
|
+
`),depth:t[1].length,text:i,tokens:this.lexer.inline(i)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ve(t[0],`
|
|
1108
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let i=Ve(t[0],`
|
|
1109
|
+
`).split(`
|
|
1110
|
+
`),s="",r="",o=[];for(;i.length>0;){let n=!1,a=[],c;for(c=0;c<i.length;c++)if(this.rules.other.blockquoteStart.test(i[c]))a.push(i[c]),n=!0;else if(!n)a.push(i[c]);else break;i=i.slice(c);let p=a.join(`
|
|
1111
|
+
`),u=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
1112
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
1113
|
+
${p}`:p,r=r?`${r}
|
|
1114
|
+
${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,o,!0),this.lexer.state.top=h,i.length===0)break;let f=o.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let b=f,P=b.raw+`
|
|
1115
|
+
`+i.join(`
|
|
1116
|
+
`),C=this.blockquote(P);o[o.length-1]=C,s=s.substring(0,s.length-b.raw.length)+C.raw,r=r.substring(0,r.length-b.text.length)+C.text;break}else if(f?.type==="list"){let b=f,P=b.raw+`
|
|
1117
|
+
`+i.join(`
|
|
1118
|
+
`),C=this.list(P);o[o.length-1]=C,s=s.substring(0,s.length-f.raw.length)+C.raw,r=r.substring(0,r.length-b.raw.length)+C.raw,i=P.substring(o.at(-1).raw.length).split(`
|
|
1119
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim(),s=i.length>1,r={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let o=this.rules.other.listItemRegex(i),n=!1;for(;e;){let c=!1,p="",u="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let h=pb(t[2].split(`
|
|
1120
|
+
`,1)[0],t[1].length),f=e.split(`
|
|
1121
|
+
`,1)[0],b=!h.trim(),P=0;if(this.options.pedantic?(P=2,u=h.trimStart()):b?P=t[1].length+1:(P=h.search(this.rules.other.nonSpaceChar),P=P>4?1:P,u=h.slice(P),P+=t[1].length),b&&this.rules.other.blankLine.test(f)&&(p+=f+`
|
|
1122
|
+
`,e=e.substring(f.length+1),c=!0),!c){let C=this.rules.other.nextBulletRegex(P),G=this.rules.other.hrRegex(P),Ke=this.rules.other.fencesBeginRegex(P),zr=this.rules.other.headingBeginRegex(P),Cl=this.rules.other.htmlBeginRegex(P),Rl=this.rules.other.blockquoteBeginRegex(P);for(;e;){let ns=e.split(`
|
|
1123
|
+
`,1)[0],Rt;if(f=ns,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),Rt=f):Rt=f.replace(this.rules.other.tabCharGlobal," "),Ke.test(f)||zr.test(f)||Cl.test(f)||Rl.test(f)||C.test(f)||G.test(f))break;if(Rt.search(this.rules.other.nonSpaceChar)>=P||!f.trim())u+=`
|
|
1124
|
+
`+Rt.slice(P);else{if(b||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Ke.test(h)||zr.test(h)||G.test(h))break;u+=`
|
|
1125
|
+
`+f}b=!f.trim(),p+=ns+`
|
|
1126
|
+
`,e=e.substring(ns.length+1),h=Rt.slice(P)}}r.loose||(n?r.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(n=!0)),r.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=p}let a=r.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let c of r.items){this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]);let p=c.tokens[0];if(c.task&&(p?.type==="text"||p?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),p.raw=p.raw.replace(this.rules.other.listReplaceTask,""),p.text=p.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(c.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};c.checked=h.checked,r.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=h.raw+c.tokens[0].raw,c.tokens[0].text=h.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(h)):c.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):c.tokens.unshift(h)}}else c.task&&(c.task=!1);if(!r.loose){let u=c.tokens.filter(f=>f.type==="space"),h=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));r.loose=h}}if(r.loose)for(let c of r.items){c.loose=!0;for(let p of c.tokens)p.type==="text"&&(p.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let i=bn(t[0]);return{type:"html",block:!0,raw:i,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:i}}}def(e){let t=this.rules.block.def.exec(e);if(t){let i=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:i,raw:Ve(t[0],`
|
|
1127
|
+
`),href:s,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let i=vn(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
1128
|
+
`):[],o={type:"table",raw:Ve(t[0],`
|
|
1129
|
+
`),header:[],align:[],rows:[]};if(i.length===s.length){for(let n of s)this.rules.other.tableAlignRight.test(n)?o.align.push("right"):this.rules.other.tableAlignCenter.test(n)?o.align.push("center"):this.rules.other.tableAlignLeft.test(n)?o.align.push("left"):o.align.push(null);for(let n=0;n<i.length;n++)o.header.push({text:i[n],tokens:this.lexer.inline(i[n]),header:!0,align:o.align[n]});for(let n of r)o.rows.push(vn(n,o.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let i=t[1].trim();return{type:"heading",raw:Ve(t[0],`
|
|
1130
|
+
`),depth:t[2].charAt(0)==="="?1:2,text:i,tokens:this.lexer.inline(i)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let i=t[1].charAt(t[1].length-1)===`
|
|
1131
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:i,tokens:this.lexer.inline(i)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let i=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;let o=Ve(i.slice(0,-1),"\\");if((i.length-o.length)%2===0)return}else{let o=db(t[2],"()");if(o===-2)return;if(o>-1){let n=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(i)?s=s.slice(1):s=s.slice(1,-1)),wn(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){let s=(i[2]||i[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let o=i[0].charAt(0);return{type:"text",raw:o,text:o}}return wn(i,r,i[0],this.lexer,this.rules)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&i.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!i||this.rules.inline.punctuation.exec(i))){let r=[...s[0]].length-1,o,n,a=r,c=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+r);(s=p.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(n=[...o].length,s[3]||s[4]){a+=n;continue}else if((s[5]||s[6])&&r%3&&!((r+n)%3)){c+=n;continue}if(a-=n,a>0)continue;n=Math.min(n,n+a+c);let u=[...s[0]][0].length,h=e.slice(0,r+s.index+u+n);if(Math.min(r,n)%2){let b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}let f=h.slice(2,-2);return{type:"strong",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let i=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(i),r=this.rules.other.startingSpaceChar.test(i)&&this.rules.other.endingSpaceChar.test(i);return s&&r&&(i=i.substring(1,i.length-1)),{type:"codespan",raw:t[0],text:i}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,i=""){let s=this.rules.inline.delLDelim.exec(e);if(s&&(!s[1]||!i||this.rules.inline.punctuation.exec(i))){let r=[...s[0]].length-1,o,n,a=r,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*e.length+r);(s=c.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(n=[...o].length,n!==r))continue;if(s[3]||s[4]){a+=n;continue}if(a-=n,a>0)continue;n=Math.min(n,n+a);let p=[...s[0]][0].length,u=e.slice(0,r+s.index+p+n),h=u.slice(r,-r);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let i,s;return t[2]==="@"?(i=t[1],s="mailto:"+i):(i=t[1],s=i),{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let i=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:i}}}},Ie=class Vs{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pt,this.options.tokenizer=this.options.tokenizer||new Li,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let i={other:ee,block:ni.normal,inline:jt.normal};this.options.pedantic?(i.block=ni.pedantic,i.inline=jt.pedantic):this.options.gfm&&(i.block=ni.gfm,this.options.breaks?i.inline=jt.breaks:i.inline=jt.gfm),this.tokenizer.rules=i}static get rules(){return{block:ni,inline:jt}}static lex(t,i){return new Vs(i).lex(t)}static lexInline(t,i){return new Vs(i).inlineTokens(t)}lex(t){t=t.replace(ee.carriageReturn,`
|
|
1132
|
+
`),this.blockTokens(t,this.tokens);for(let i=0;i<this.inlineQueue.length;i++){let s=this.inlineQueue[i];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,i=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(ee.tabCharGlobal," ").replace(ee.spaceLine,""));let r=1/0;for(;t;){if(t.length<r)r=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(a=>(o=a.call({lexer:this},t,i))?(t=t.substring(o.raw.length),i.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let a=i.at(-1);o.raw.length===1&&a!==void 0?a.raw+=`
|
|
1133
|
+
`:i.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let a=i.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
1134
|
+
`)?"":`
|
|
1135
|
+
`)+o.raw,a.text+=`
|
|
1136
|
+
`+o.text,this.inlineQueue.at(-1).src=a.text):i.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let a=i.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
1137
|
+
`)?"":`
|
|
1138
|
+
`)+o.raw,a.text+=`
|
|
1139
|
+
`+o.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},i.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),i.push(o);continue}let n=t;if(this.options.extensions?.startBlock){let a=1/0,c=t.slice(1),p;this.options.extensions.startBlock.forEach(u=>{p=u.call({lexer:this},c),typeof p=="number"&&p>=0&&(a=Math.min(a,p))}),a<1/0&&a>=0&&(n=t.substring(0,a+1))}if(this.state.top&&(o=this.tokenizer.paragraph(n))){let a=i.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
1140
|
+
`)?"":`
|
|
1141
|
+
`)+o.raw,a.text+=`
|
|
1142
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):i.push(o),s=n.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let a=i.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
1143
|
+
`)?"":`
|
|
1144
|
+
`)+o.raw,a.text+=`
|
|
1145
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):i.push(o);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,i}inline(t,i=[]){return this.inlineQueue.push({src:t,tokens:i}),i}inlineTokens(t,i=[]){this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let p=Object.keys(this.tokens.links);if(p.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)p.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)o=r[2]?r[2].length:0,s=s.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let n=!1,a="",c=1/0;for(;t;){if(t.length<c)c=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}n||(a=""),n=!1;let p;if(this.options.extensions?.inline?.some(h=>(p=h.call({lexer:this},t,i))?(t=t.substring(p.raw.length),i.push(p),!0):!1))continue;if(p=this.tokenizer.escape(t)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.tag(t)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.link(t)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(p.raw.length);let h=i.at(-1);p.type==="text"&&h?.type==="text"?(h.raw+=p.raw,h.text+=p.text):i.push(p);continue}if(p=this.tokenizer.emStrong(t,s,a)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.codespan(t)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.br(t)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.del(t,s,a)){t=t.substring(p.raw.length),i.push(p);continue}if(p=this.tokenizer.autolink(t)){t=t.substring(p.raw.length),i.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(t))){t=t.substring(p.raw.length),i.push(p);continue}let u=t;if(this.options.extensions?.startInline){let h=1/0,f=t.slice(1),b;this.options.extensions.startInline.forEach(P=>{b=P.call({lexer:this},f),typeof b=="number"&&b>=0&&(h=Math.min(h,b))}),h<1/0&&h>=0&&(u=t.substring(0,h+1))}if(p=this.tokenizer.inlineText(u)){t=t.substring(p.raw.length),p.raw.slice(-1)!=="_"&&(a=p.raw.slice(-1)),n=!0;let h=i.at(-1);h?.type==="text"?(h.raw+=p.raw,h.text+=p.text):i.push(p);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return i}infiniteLoopError(t){let i="Infinite loop on byte: "+t;if(this.options.silent)console.error(i);else throw new Error(i)}},Fi=class{options;parser;constructor(e){this.options=e||pt}space(e){return""}code({text:e,lang:t,escaped:i}){let s=(t||"").match(ee.notSpaceStart)?.[0],r=e.replace(ee.endingNewline,"")+`
|
|
1146
|
+
`;return s?'<pre><code class="language-'+We(s)+'">'+(i?r:We(r,!0))+`</code></pre>
|
|
1147
|
+
`:"<pre><code>"+(i?r:We(r,!0))+`</code></pre>
|
|
1148
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
1149
|
+
${this.parser.parse(e)}</blockquote>
|
|
1150
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
1151
|
+
`}hr(e){return`<hr>
|
|
1152
|
+
`}list(e){let t=e.ordered,i=e.start,s="";for(let n=0;n<e.items.length;n++){let a=e.items[n];s+=this.listitem(a)}let r=t?"ol":"ul",o=t&&i!==1?' start="'+i+'"':"";return"<"+r+o+`>
|
|
1153
|
+
`+s+"</"+r+`>
|
|
1154
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
1155
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
1156
|
+
`}table(e){let t="",i="";for(let r=0;r<e.header.length;r++)i+=this.tablecell(e.header[r]);t+=this.tablerow({text:i});let s="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];i="";for(let n=0;n<o.length;n++)i+=this.tablecell(o[n]);s+=this.tablerow({text:i})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
1157
|
+
<thead>
|
|
1158
|
+
`+t+`</thead>
|
|
1159
|
+
`+s+`</table>
|
|
1160
|
+
`}tablerow({text:e}){return`<tr>
|
|
1161
|
+
${e}</tr>
|
|
1162
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),i=e.header?"th":"td";return(e.align?`<${i} align="${e.align}">`:`<${i}>`)+t+`</${i}>
|
|
1163
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${We(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:i}){let s=this.parser.parseInline(i),r=mn(e);if(r===null)return s;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+We(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:i,tokens:s}){s&&(i=this.parser.parseInline(s,this.parser.textRenderer));let r=mn(e);if(r===null)return We(i);e=r;let o=`<img src="${e}" alt="${We(i)}"`;return t&&(o+=` title="${We(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:We(e.text)}},Fr=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ae=class Gs{options;renderer;textRenderer;constructor(t){this.options=t||pt,this.options.renderer=this.options.renderer||new Fi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Fr}static parse(t,i){return new Gs(i).parse(t)}static parseInline(t,i){return new Gs(i).parseInline(t)}parse(t){this.renderer.parser=this;let i="";for(let s=0;s<t.length;s++){let r=t[s];if(this.options.extensions?.renderers?.[r.type]){let n=r,a=this.options.extensions.renderers[n.type].call({parser:this},n);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(n.type)){i+=a||"";continue}}let o=r;switch(o.type){case"space":{i+=this.renderer.space(o);break}case"hr":{i+=this.renderer.hr(o);break}case"heading":{i+=this.renderer.heading(o);break}case"code":{i+=this.renderer.code(o);break}case"table":{i+=this.renderer.table(o);break}case"blockquote":{i+=this.renderer.blockquote(o);break}case"list":{i+=this.renderer.list(o);break}case"checkbox":{i+=this.renderer.checkbox(o);break}case"html":{i+=this.renderer.html(o);break}case"def":{i+=this.renderer.def(o);break}case"paragraph":{i+=this.renderer.paragraph(o);break}case"text":{i+=this.renderer.text(o);break}default:{let n='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return i}parseInline(t,i=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=a||"";continue}}let n=o;switch(n.type){case"escape":{s+=i.text(n);break}case"html":{s+=i.html(n);break}case"link":{s+=i.link(n);break}case"image":{s+=i.image(n);break}case"checkbox":{s+=i.checkbox(n);break}case"strong":{s+=i.strong(n);break}case"em":{s+=i.em(n);break}case"codespan":{s+=i.codespan(n);break}case"br":{s+=i.br(n);break}case"del":{s+=i.del(n);break}case"text":{s+=i.text(n);break}default:{let a='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}},Ft=class{options;block;constructor(e){this.options=e||pt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ie.lex:Ie.lexInline}provideParser(e=this.block){return e?Ae.parse:Ae.parseInline}},ub=class{defaults=Tr();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ae;Renderer=Fi;TextRenderer=Fr;Lexer=Ie;Tokenizer=Li;Hooks=Ft;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(let s of e)switch(i=i.concat(t.call(this,s)),s.type){case"table":{let r=s;for(let o of r.header)i=i.concat(this.walkTokens(o.tokens,t));for(let o of r.rows)for(let n of o)i=i.concat(this.walkTokens(n.tokens,t));break}case"list":{let r=s;i=i.concat(this.walkTokens(r.items,t));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let n=r[o].flat(1/0);i=i.concat(this.walkTokens(n,t))}):r.tokens&&(i=i.concat(this.walkTokens(r.tokens,t)))}}return i}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(i=>{let s={...i};if(s.async=this.defaults.async||s.async||!1,i.extensions&&(i.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...n){let a=r.renderer.apply(this,n);return a===!1&&(a=o.apply(this,n)),a}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),i.renderer){let r=this.defaults.renderer||new Fi(this.defaults);for(let o in i.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let n=o,a=i.renderer[n],c=r[n];r[n]=(...p)=>{let u=a.apply(r,p);return u===!1&&(u=c.apply(r,p)),u||""}}s.renderer=r}if(i.tokenizer){let r=this.defaults.tokenizer||new Li(this.defaults);for(let o in i.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let n=o,a=i.tokenizer[n],c=r[n];r[n]=(...p)=>{let u=a.apply(r,p);return u===!1&&(u=c.apply(r,p)),u}}s.tokenizer=r}if(i.hooks){let r=this.defaults.hooks||new Ft;for(let o in i.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let n=o,a=i.hooks[n],c=r[n];Ft.passThroughHooks.has(o)?r[n]=p=>{if(this.defaults.async&&Ft.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await a.call(r,p);return c.call(r,h)})();let u=a.call(r,p);return c.call(r,u)}:r[n]=(...p)=>{if(this.defaults.async)return(async()=>{let h=await a.apply(r,p);return h===!1&&(h=await c.apply(r,p)),h})();let u=a.apply(r,p);return u===!1&&(u=c.apply(r,p)),u}}s.hooks=r}if(i.walkTokens){let r=this.defaults.walkTokens,o=i.walkTokens;s.walkTokens=function(n){let a=[];return a.push(o.call(this,n)),r&&(a=a.concat(r.call(this,n))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ie.lex(e,t??this.defaults)}parser(e,t){return Ae.parse(e,t??this.defaults)}parseMarkdown(e){return(t,i)=>{let s={...i},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let n=r.hooks?await r.hooks.preprocess(t):t,a=await(r.hooks?await r.hooks.provideLexer(e):e?Ie.lex:Ie.lexInline)(n,r),c=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(c,r.walkTokens));let p=await(r.hooks?await r.hooks.provideParser(e):e?Ae.parse:Ae.parseInline)(c,r);return r.hooks?await r.hooks.postprocess(p):p})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let n=(r.hooks?r.hooks.provideLexer(e):e?Ie.lex:Ie.lexInline)(t,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let a=(r.hooks?r.hooks.provideParser(e):e?Ae.parse:Ae.parseInline)(n,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(n){return o(n)}}}onError(e,t){return i=>{if(i.message+=`
|
|
1164
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+We(i.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(i);throw i}}},ct=new ub;function W(e,t){return ct.parse(e,t)}W.options=W.setOptions=function(e){return ct.setOptions(e),W.defaults=ct.defaults,sl(W.defaults),W};W.getDefaults=Tr;W.defaults=pt;W.use=function(...e){return ct.use(...e),W.defaults=ct.defaults,sl(W.defaults),W};W.walkTokens=function(e,t){return ct.walkTokens(e,t)};W.parseInline=ct.parseInline;W.Parser=Ae;W.parser=Ae.parse;W.Renderer=Fi;W.TextRenderer=Fr;W.Lexer=Ie;W.lexer=Ie.lex;W.Tokenizer=Li;W.Hooks=Ft;W.parse=W;W.options;W.setOptions;W.use;W.walkTokens;W.parseInline;Ae.parse;Ie.lex;const ul=new W.Renderer;ul.html=({text:e})=>mb(e);const fb=300,_t=new Map;function gb(e){const t=_t.get(e);if(t!==void 0)return t;const i=W.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:ul}),s=vb(i);if(_t.set(e,s),_t.size>fb){const r=_t.keys().next().value;r!==void 0&&_t.delete(r)}return s}function mb(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function vb(e){const t=document.createElement("template");return t.innerHTML=e,t.content.querySelectorAll("script, style, iframe, object, embed").forEach(i=>{i.remove()}),t.content.querySelectorAll("*").forEach(i=>{for(const s of[...i.attributes]){const r=s.name.toLowerCase();r.startsWith("on")&&i.removeAttribute(s.name),(r==="href"||r==="src")&&!bb(s.value)&&i.removeAttribute(s.name)}i.tagName==="A"&&(i.setAttribute("target","_blank"),i.setAttribute("rel","noreferrer noopener"))}),t.innerHTML}function bb(e){if(e.startsWith("#")||e.startsWith("/"))return!0;try{return["http:","https:","mailto:"].includes(new URL(e).protocol)}catch{return!1}}var wb=Object.defineProperty,yb=Object.getOwnPropertyDescriptor,fl=(e,t,i,s)=>{for(var r=s>1?void 0:s?yb(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&wb(t,i,r),r};let Ni=class extends M{constructor(){super(...arguments),this.text="",this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;const t=e.target.closest(".code-copy-button");if(!(t instanceof HTMLButtonElement))return;const i=t.closest(".code-block-wrapper");if(!(i instanceof HTMLElement))return;const s=i.querySelector("pre code");s instanceof HTMLElement&&this.copyCode(s.textContent,t)}}render(){return l`<div class="formatted" dir="auto" @click=${this.onFormattedClick}>${Cv(gb(this.text))}</div>`}updated(){this.enhanceCodeBlocks()}enhanceCodeBlocks(){this.renderRoot.querySelectorAll("pre").forEach(e=>{if(!(e instanceof HTMLPreElement)||e.parentElement?.classList.contains("code-block-wrapper")===!0||!(e.querySelector("code")instanceof HTMLElement))return;const i=document.createElement("div");i.className="code-block-wrapper";const s=document.createElement("button");s.type="button",s.className="code-copy-button",s.title="Copy code block",s.setAttribute("aria-label","Copy code block");const r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.textContent="⧉",s.append(r),e.before(i),i.append(e,s)})}async copyCode(e,t){const i=await xb(e);this.setCopyButtonState(t,i?"copied":"failed"),window.setTimeout(()=>{this.setCopyButtonState(t,"idle")},1200)}setCopyButtonState(e,t){const i=e.querySelector("span");i!==null&&(i.textContent=t==="copied"?"✓":"⧉");const s=t==="copied"?"Copied code block":t==="failed"?"Failed to copy code block":"Copy code block";e.title=s,e.setAttribute("aria-label",s)}};Ni.styles=Af;fl([d()],Ni.prototype,"text",2);Ni=fl([D("formatted-text")],Ni);async function xb(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}var Sb=Object.defineProperty,kb=Object.getOwnPropertyDescriptor,ei=(e,t,i,s)=>{for(var r=s>1?void 0:s?kb(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Sb(t,i,r),r};const yn=180;let dt=class extends M{constructor(){super(...arguments),this.showFullDiff=!1,this.copied=!1,this.diffOpen=!0}render(){const e=this.execution;if(e===void 0)return null;const t=e.toolName==="edit",i=$b(e.args),s=Pb(e.details),r=e.preview,o=s??r?.diff,n=o===void 0?void 0:Cb(o),a=s!==void 0&&r?.diff!==void 0&&s!==r.diff,c=e.status==="error"?e.resultText:r?.error,p=o===void 0?e.resultText:void 0;return l`
|
|
1165
|
+
<section class=${`tool-card ${e.status}`}>
|
|
1166
|
+
<div class="tool-header">
|
|
1167
|
+
<div class="tool-title">
|
|
1168
|
+
<span class="status-icon" aria-hidden="true">${Ib(e.status)}</span>
|
|
1169
|
+
<strong>${e.toolName}</strong>
|
|
1170
|
+
${i===void 0?l`<span class="summary">${e.summary}</span>`:l`<span class="path">${i}</span>`}
|
|
1171
|
+
</div>
|
|
1172
|
+
<div class="tool-meta">
|
|
1173
|
+
${xn(e)===void 0?null:l`<span>${xn(e)}</span>`}
|
|
1174
|
+
${n===void 0?null:l`<span class="diff-stats"><b class="added">+${n.added}</b><span>/</span><b class="removed">-${n.removed}</b></span>`}
|
|
1175
|
+
<span class="status-label">${Ab(e.status)}</span>
|
|
1176
|
+
</div>
|
|
1177
|
+
</div>
|
|
1178
|
+
|
|
1179
|
+
${a?l`<p class="notice">Applied diff differs from the preview.</p>`:null}
|
|
1180
|
+
${c===void 0||c===""?null:l`<pre class="error-text">${c}</pre>`}
|
|
1181
|
+
${o===void 0?this.renderTextBody(p,e.status==="error"):this.renderDiffBody(o,s===void 0?"Preview diff":"Applied diff")}
|
|
1182
|
+
${!t&&o===void 0&&(p===void 0||p==="")?l`<p class="muted">${e.summary}</p>`:null}
|
|
1183
|
+
</section>
|
|
1184
|
+
`}renderTextBody(e,t){return e===void 0||e===""?null:l`
|
|
1185
|
+
<details class="text-body" ?open=${t}>
|
|
1186
|
+
<summary>Result</summary>
|
|
1187
|
+
<pre>${e}</pre>
|
|
1188
|
+
</details>
|
|
1189
|
+
`}renderDiffBody(e,t){const i=e.split(`
|
|
1190
|
+
`),s=!this.showFullDiff&&i.length>yn,r=s?i.slice(0,yn):i;return l`
|
|
1191
|
+
<details class="diff-details" ?open=${this.diffOpen} @toggle=${o=>{this.onDiffToggle(o)}}>
|
|
1192
|
+
<summary>
|
|
1193
|
+
<span>${t}</span>
|
|
1194
|
+
<small>${String(i.length)} ${i.length===1?"line":"lines"}</small>
|
|
1195
|
+
</summary>
|
|
1196
|
+
<div class="diff-toolbar">
|
|
1197
|
+
<span>${s?`Showing ${String(r.length)} of ${String(i.length)} lines`:"Full diff"}</span>
|
|
1198
|
+
<button type="button" @click=${()=>{this.copyDiff(e)}}>${this.copied?"Copied":"Copy diff"}</button>
|
|
1199
|
+
</div>
|
|
1200
|
+
<pre class="diff" aria-label=${t}><code class="diff-content">${r.map(o=>l`<span class=${Rb(o)}>${o}</span>`)}</code></pre>
|
|
1201
|
+
${s?l`
|
|
1202
|
+
<button class="show-more" type="button" @click=${()=>{this.showFullDiff=!0}}>
|
|
1203
|
+
Show all ${String(i.length)} diff lines
|
|
1204
|
+
</button>
|
|
1205
|
+
`:null}
|
|
1206
|
+
</details>
|
|
1207
|
+
`}onDiffToggle(e){const t=e.currentTarget;t instanceof HTMLDetailsElement&&(this.diffOpen=t.open)}async copyDiff(e){try{await navigator.clipboard.writeText(e),this.copied=!0,window.setTimeout(()=>{this.copied=!1},1200)}catch{this.copied=!1}}};dt.styles=O`
|
|
1208
|
+
:host { display: block; width: 100%; max-width: 100%; min-width: 0; color: var(--pi-text); }
|
|
1209
|
+
.tool-card { display: grid; gap: 8px; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); padding: 9px; color: var(--pi-text); }
|
|
1210
|
+
.tool-card.running, .tool-card.pending { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); }
|
|
1211
|
+
.tool-card.success { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
1212
|
+
.tool-card.error { border-color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); }
|
|
1213
|
+
.tool-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
|
|
1214
|
+
.tool-title { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; }
|
|
1215
|
+
.status-icon { flex: 0 0 auto; color: var(--pi-muted); }
|
|
1216
|
+
strong { color: var(--pi-text); }
|
|
1217
|
+
.path, .summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pi-accent); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1218
|
+
.summary { color: var(--pi-muted); font-family: inherit; }
|
|
1219
|
+
.tool-meta { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 8px; color: var(--pi-muted); font-size: 12px; }
|
|
1220
|
+
.diff-stats { display: inline-flex; gap: 3px; }
|
|
1221
|
+
.added, .diff .added { color: var(--pi-success); }
|
|
1222
|
+
.removed, .diff .removed { color: var(--pi-danger); }
|
|
1223
|
+
.status-label { text-transform: uppercase; letter-spacing: .04em; color: var(--pi-muted); }
|
|
1224
|
+
.notice { margin: 0; color: var(--pi-warning); }
|
|
1225
|
+
.muted { margin: 0; color: var(--pi-muted); }
|
|
1226
|
+
.error-text { margin: 0; border: 1px solid var(--pi-danger); border-radius: 7px; background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); color: var(--pi-danger); padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1227
|
+
.text-body { border-top: 1px solid var(--pi-border-muted); padding-top: 6px; }
|
|
1228
|
+
.text-body pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--pi-text); }
|
|
1229
|
+
.diff-details { min-width: 0; max-width: 100%; border-top: 1px solid var(--pi-border-muted); padding-top: 6px; }
|
|
1230
|
+
.diff-details > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; color: var(--pi-muted); cursor: pointer; }
|
|
1231
|
+
.diff-details > summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1232
|
+
.diff-details > summary small { flex: 0 0 auto; color: var(--pi-dim); }
|
|
1233
|
+
.diff-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; margin-top: 8px; color: var(--pi-muted); font-size: 12px; }
|
|
1234
|
+
.diff-toolbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1235
|
+
button { border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-text); padding: 3px 7px; font: 12px system-ui, sans-serif; cursor: pointer; }
|
|
1236
|
+
button:hover, button:focus { border-color: var(--pi-accent); }
|
|
1237
|
+
.diff { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; margin: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; border: 1px solid var(--pi-border-muted); border-radius: 7px; background: var(--pi-bg); padding: 8px 0; color: var(--pi-muted); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
|
|
1238
|
+
.diff-content { display: block; width: max-content; min-width: 100%; }
|
|
1239
|
+
.diff span { display: block; min-height: 1.45em; padding: 0 8px; white-space: pre; }
|
|
1240
|
+
.diff .context { color: var(--pi-muted); }
|
|
1241
|
+
.diff .hunk { color: var(--pi-accent); }
|
|
1242
|
+
.diff .file { color: var(--pi-dim); }
|
|
1243
|
+
.diff .meta { color: var(--pi-dim); }
|
|
1244
|
+
.diff .added { background: color-mix(in srgb, var(--pi-success) 12%, transparent); }
|
|
1245
|
+
.diff .removed { background: color-mix(in srgb, var(--pi-danger) 12%, transparent); }
|
|
1246
|
+
.show-more { justify-self: start; }
|
|
1247
|
+
`;ei([d({attribute:!1})],dt.prototype,"execution",2);ei([v()],dt.prototype,"showFullDiff",2);ei([v()],dt.prototype,"copied",2);ei([v()],dt.prototype,"diffOpen",2);dt=ei([D("tool-execution-view")],dt);function $b(e){return Qs(e,"path")??Qs(e,"file_path")}function xn(e){if(e.toolName!=="edit")return;const t=yi(e.args,"edits");if(Array.isArray(t))return`${String(t.length)} edit${t.length===1?"":"s"}`;if(typeof yi(e.args,"oldText")=="string"&&typeof yi(e.args,"newText")=="string")return"1 edit"}function Pb(e){return Qs(e,"diff")}function Cb(e){let t=0,i=0;for(const s of e.split(`
|
|
1248
|
+
`))gl(s)?t++:ml(s)&&i++;return{added:t,removed:i}}function Rb(e){return gl(e)?"added":ml(e)?"removed":e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")?"file":e.startsWith("diff ")||e.startsWith("index ")?"meta":"context"}function gl(e){return e.startsWith("+")&&!e.startsWith("+++")}function ml(e){return e.startsWith("-")&&!e.startsWith("---")}function Ib(e){return e==="success"?"✓":e==="error"?"✖":e==="running"?"●":"○"}function Ab(e){return e==="success"?"done":e==="error"?"failed":e==="running"?"running":"pending"}function Mb(e){return typeof e=="object"&&e!==null}function yi(e,t){return Mb(e)?e[t]:void 0}function Qs(e,t){const i=yi(e,t);return typeof i=="string"?i:void 0}var Tb=Object.defineProperty,Eb=Object.getOwnPropertyDescriptor,H=(e,t,i,s)=>{for(var r=s>1?void 0:s?Eb(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Tb(t,i,r),r};const Db=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),Wb=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}),Ps=["You opened this chat while the assistant was already replying. The complete answer will appear shortly.","We joined mid-sentence. Holding the curtain until the full reply is ready.","The assistant started before this tab arrived. We’ll show the full answer when it lands.","Catching the reply in one piece — no spoilers, no half-answers.","The tokens are still assembling themselves. Full answer incoming.","We arrived fashionably late to this response. The complete version will appear soon."];function Sn(){return Ps[Math.floor(Math.random()*Ps.length)]??Ps[0]}function kn(e){return xi(e,0,100)}function xi(e,t,i){return Number.isFinite(e)?Math.min(i,Math.max(t,e)):t}let N=class extends M{constructor(){super(...arguments),this.messages=[],this.sessionId="",this.messageStart=0,this.messageEnd=0,this.messageTotal=0,this.hasMore=!1,this.loadingMore=!1,this.isReceivingPartialStream=!1,this.isSendingPrompt=!1,this.isCompacting=!1,this.pendingMessageCount=0,this.pinnedToBottom=!0,this.disclosures=new Jm,this.scrollController=new wv,this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.groupedMessagesStart=0,this.groupedMessagesCache=[],this.messageMetaCache=new WeakMap,this.messageCopyTextCache=new WeakMap,this.lastScrollTop=0,this.lastClientHeight=0,this.prependRestoreToken=0,this.loadMoreRequested=!1,this.onViewportResize=()=>{this.pinnedToBottom?this.scrollToBottom():this.lastClientHeight=this.chat?.clientHeight??0},this.onPageHide=()=>{this.saveScrollPosition()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onViewportResize),window.addEventListener("pagehide",this.onPageHide),window.visualViewport?.addEventListener("resize",this.onViewportResize)}firstUpdated(){this.lastClientHeight=this.chat?.clientHeight??0}disconnectedCallback(){this.saveScrollPosition(),this.scrollController.dispose(),this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.loadMoreCheckFrame!==void 0&&cancelAnimationFrame(this.loadMoreCheckFrame),this.scrollToBottomFrame!==void 0&&cancelAnimationFrame(this.scrollToBottomFrame),this.conversationRailFrame!==void 0&&cancelAnimationFrame(this.conversationRailFrame),window.removeEventListener("resize",this.onViewportResize),window.removeEventListener("pagehide",this.onPageHide),window.visualViewport?.removeEventListener("resize",this.onViewportResize),super.disconnectedCallback()}savePreviousSessionScrollPosition(e){typeof e!="string"||e===""||e===this.sessionId||this.saveScrollPosition(e)}prepareSessionUiState(){this.disclosures.syncSession(this.sessionId),this.scrollController.clearScheduledSave(),this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0,this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&(cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=void 0)}willUpdate(e){e.has("sessionId")&&(this.savePreviousSessionScrollPosition(e.get("sessionId")),this.prepareSessionUiState()),(e.has("isReceivingPartialStream")||e.has("sessionId")&&this.isReceivingPartialStream)&&this.syncPartialStreamNoticeBody(),e.has("messages")&&(this.pinnedToBottom=this.pinnedToBottom&&(this.didChatHeightChange()||this.isNearBottom()))}update(e){const t=this.isPrependingMessages(e)?this.capturePrependScrollAnchor():void 0;super.update(e),t!==void 0&&this.restorePrependScrollAnchor(t)}updated(e){e.has("loadingMore")&&!this.loadingMore&&(this.loadMoreRequested=!1),e.has("hasMore")&&!this.hasMore&&(this.loadMoreRequested=!1),e.has("sessionId")&&this.restoreScrollPosition(),!e.has("sessionId")&&e.has("messages")&&this.pinnedToBottom&&this.scrollToBottom(),(e.has("messages")||e.has("messageStart")||e.has("messageTotal")||e.has("hasMore")||e.has("loadingMore"))&&this.scheduleConversationRailUpdate(),(e.has("messages")||e.has("messageStart")||e.has("hasMore")||e.has("loadingMore"))&&this.continuePendingScrollRestore(),(e.has("messages")||e.has("hasMore")||e.has("loadingMore"))&&this.requestLoadMoreIfNeeded()}render(){const e=this.groupedMessages();return l`
|
|
1249
|
+
<div class="chat-wrap">
|
|
1250
|
+
${this.renderConversationRail()}
|
|
1251
|
+
<div class="chat" @scroll=${()=>{this.onScroll()}} @wheel=${t=>{this.onWheel(t)}} @touchstart=${t=>{this.onTouchStart(t)}} @touchmove=${t=>{this.onTouchMove(t)}}>
|
|
1252
|
+
${this.renderHistoryBoundary()}
|
|
1253
|
+
${Vm(e,t=>t.kind==="message"?this.messageAnchorKey(t.index):this.groupRenderKey(t.startIndex),(t,i)=>t.kind==="message"?this.renderMessage(t.message,t.index):this.renderMessageGroup(t.messages,t.startIndex,t.endIndex,this.isLiveTailGroup(e,i)))}
|
|
1254
|
+
${this.renderQueuedMessages()}
|
|
1255
|
+
${this.renderSessionActivity()}
|
|
1256
|
+
</div>
|
|
1257
|
+
${this.renderActivityDock()}
|
|
1258
|
+
</div>
|
|
1259
|
+
`}groupedMessages(){return this.groupedMessagesInput===this.messages&&this.groupedMessagesStart===this.messageStart?this.groupedMessagesCache:(this.groupedMessagesInput=this.messages,this.groupedMessagesStart=this.messageStart,this.groupedMessagesCache=Ym(this.messages,this.messageStart),this.groupedMessagesCache)}isLiveTailGroup(e,t){return t===e.length-1&&this.isSessionLive()}isSessionLive(){return this.isSendingPrompt||this.status?.isStreaming===!0||this.status?.isCompacting===!0||this.status?.isBashRunning===!0||this.activity?.phase==="active"}renderActivityDock(){if(this.isSendingPrompt)return l`
|
|
1260
|
+
<div class="activity-dock active" aria-live="polite">
|
|
1261
|
+
<span class="dot"></span>
|
|
1262
|
+
<span class="activity-text">Sending your message…</span>
|
|
1263
|
+
</div>
|
|
1264
|
+
`;const e=this.activityState();if(e===void 0)return null;const t=e!=="idle"||this.activity?.phase==="active";return l`
|
|
1265
|
+
<div class=${t?"activity-dock active":"activity-dock"} aria-live="polite">
|
|
1266
|
+
<span class="dot"></span>
|
|
1267
|
+
<span class="activity-text">${this.activityText(e)}</span>
|
|
1268
|
+
</div>
|
|
1269
|
+
`}renderQueuedMessages(){const e=this.status?.queuedMessages??[];return e.length===0?null:l`
|
|
1270
|
+
<aside class="queued-messages" aria-live="polite">
|
|
1271
|
+
<div class="queued-header">
|
|
1272
|
+
<strong>Queued messages</strong>
|
|
1273
|
+
<small>${e.length} pending · Stop clears the queue</small>
|
|
1274
|
+
</div>
|
|
1275
|
+
${e.map((t,i)=>l`
|
|
1276
|
+
<div class="queued-message">
|
|
1277
|
+
<span class="queued-kind">${t.kind==="steer"?"Steer":"Follow-up"} ${String(i+1)}</span>
|
|
1278
|
+
<formatted-text .text=${t.text}></formatted-text>
|
|
1279
|
+
</div>
|
|
1280
|
+
`)}
|
|
1281
|
+
</aside>
|
|
1282
|
+
`}renderSessionActivity(){return this.isReceivingPartialStream?l`
|
|
1283
|
+
<aside class="session-activity receiving" aria-live="polite">
|
|
1284
|
+
<strong>Catching up…</strong>
|
|
1285
|
+
<span>${this.currentPartialStreamNoticeBody()}</span>
|
|
1286
|
+
</aside>
|
|
1287
|
+
`:this.isCompacting?l`
|
|
1288
|
+
<aside class="session-activity compacting" aria-live="polite">
|
|
1289
|
+
<strong>Compacting history…</strong>
|
|
1290
|
+
<span>The agent is summarizing earlier context. New prompts will be queued until compaction finishes.</span>
|
|
1291
|
+
${this.pendingMessageCount>0?l`<small>${this.pendingMessageCount} queued ${this.pendingMessageCount===1?"message":"messages"}</small>`:null}
|
|
1292
|
+
</aside>
|
|
1293
|
+
`:null}syncPartialStreamNoticeBody(){this.partialStreamNoticeBody=this.isReceivingPartialStream?Sn():void 0}currentPartialStreamNoticeBody(){return this.partialStreamNoticeBody??=Sn(),this.partialStreamNoticeBody}activityState(){const e=this.status;return e===void 0?this.activity?.label:e.isCompacting?"compacting":e.isBashRunning?"bash":e.isStreaming?"running":e.pendingMessageCount>0?"queued":"idle"}activityText(e){const t=this.activity;return t===void 0||e!=="idle"&&t.phase==="idle"?e:t.detail!==void 0&&t.detail!==""?`${t.label}: ${t.detail}`:t.label}renderConversationRail(){if(!this.messages.length||this.messageTotal<=0)return null;const e=this.conversationDisplayTotal(),t=this.conversationPositionPercent(e),i=this.hasMore?kn(this.messages.length/e*100):100;return l`<conversation-meter .positionPercent=${t} .loadedPercent=${i}></conversation-meter>`}conversationDisplayTotal(){return!this.hasMore&&this.messageStart===0?Math.max(1,this.messages.length):Math.max(1,this.messageTotal,this.messageStart+this.messages.length)}conversationPositionPercent(e=this.conversationDisplayTotal()){if(e<=1)return 100;const t=this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,i=xi(this.currentConversationIndex??t,0,e-1);return kn(i/(e-1)*100)}renderHistoryBoundary(){const e=this.historyRangeLabel();return this.loadingMore?l`<div class="history-boundary"><span>Loading earlier messages…</span>${e}</div>`:this.hasMore?l`
|
|
1294
|
+
<div class="history-boundary">
|
|
1295
|
+
<button type="button" class="history-load-button" ?disabled=${this.loadMoreRequested} @click=${()=>{this.requestLoadMore()}}>Load earlier messages</button>
|
|
1296
|
+
<span>Scroll up to load earlier messages</span>
|
|
1297
|
+
${e}
|
|
1298
|
+
</div>
|
|
1299
|
+
`:this.messages.length?l`<div class="history-boundary"><span>Beginning of session</span>${e}</div>`:null}historyRangeLabel(){if(!this.messages.length||this.messageTotal<=0)return null;const e=this.messageStart+1,t=this.loadedRawMessageEnd(),i=Math.max(this.messageTotal,t);return l`<small>Showing messages ${e}–${t} of ${i}</small>`}loadedRawMessageEnd(){return Math.max(this.messageEnd,this.messageStart+this.messages.length)}renderMessage(e,t){const i=this.isToolExecutionOnlyMessage(e);return l`
|
|
1300
|
+
${this.renderScrollMarker(this.messageScrollMarkerId(t))}
|
|
1301
|
+
<article class=${i?"msg tool-execution-shell":`msg ${e.role}`} data-index=${t} data-scroll-anchor-id=${this.messageAnchorKey(t)}>
|
|
1302
|
+
${i?null:this.renderMessageHeader(e,String(t))}
|
|
1303
|
+
${e.parts.map(s=>this.renderPart(s,e))}
|
|
1304
|
+
</article>
|
|
1305
|
+
`}isToolExecutionOnlyMessage(e){return e.role==="tool"&&e.parts.length>0&&e.parts.every(t=>t.type==="toolExecution")}renderMessageGroup(e,t,i,s){const r=this.groupDisclosureKey(t,i,s),o=this.disclosures.isOpen(r,s);return l`
|
|
1306
|
+
${this.renderScrollMarker(this.groupScrollMarkerId(i))}
|
|
1307
|
+
<details class=${s?"msg event-group live":"msg event-group"} data-index=${t} data-scroll-anchor-id=${this.groupAnchorKey(t)} ?open=${o} @toggle=${n=>{this.onGroupToggle(r,n,s)}}>
|
|
1308
|
+
<summary>
|
|
1309
|
+
<b class="label">${s?"live events":"events"}</b>
|
|
1310
|
+
<span>${ev(e)}</span>
|
|
1311
|
+
</summary>
|
|
1312
|
+
<div class="group-body">
|
|
1313
|
+
${e.map((n,a)=>{const c=this.isToolExecutionOnlyMessage(n);return l`
|
|
1314
|
+
<section class=${c?"group-msg tool-execution-shell":`group-msg ${n.role}`} data-index=${t+a} data-scroll-anchor-id=${this.eventAnchorKey(t+a)}>
|
|
1315
|
+
${c?null:this.renderMessageHeader(n,`${String(t)}:${String(a)}`)}
|
|
1316
|
+
${n.parts.map(p=>this.renderPart(p,n))}
|
|
1317
|
+
</section>
|
|
1318
|
+
`})}
|
|
1319
|
+
</div>
|
|
1320
|
+
</details>
|
|
1321
|
+
`}renderScrollMarker(e){return l`<span class="scroll-marker" data-marker-id=${e} aria-hidden="true"></span>`}renderMessageHeader(e,t){const i=this.messageMetaLabel(e),s=this.expandedMetaKey===t;return l`
|
|
1322
|
+
<div class="msg-header">
|
|
1323
|
+
<b class="label">${e.role}</b>
|
|
1324
|
+
<div class="msg-header-trailing">
|
|
1325
|
+
${this.renderMessageActions(e,t)}
|
|
1326
|
+
<span class=${s?"msg-meta expanded":"msg-meta"} role="button" tabindex="0" title=${i.full} aria-label=${i.full} aria-expanded=${String(s)} @click=${()=>{this.expandedMetaKey=s?void 0:t}} @keydown=${r=>{this.onMetaKeydown(r,t,s)}}>${i.short}</span>
|
|
1327
|
+
</div>
|
|
1328
|
+
</div>
|
|
1329
|
+
`}renderMessageActions(e,t){if(!this.isCopyableMessage(e))return null;const i=this.copiedMessageKey===t;return l`
|
|
1330
|
+
<div class="msg-actions" aria-label="Message actions">
|
|
1331
|
+
<button type="button" class="msg-action" title=${i?"Copied":"Copy message"} aria-label=${`${i?"Copied":"Copy"} ${e.role} message`} @click=${s=>{this.copyMessage(e,t,s)}}>
|
|
1332
|
+
<span aria-hidden="true">${i?"✓":"⧉"}</span>
|
|
1333
|
+
</button>
|
|
1334
|
+
</div>
|
|
1335
|
+
`}onMetaKeydown(e,t,i){e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.expandedMetaKey=i?void 0:t)}isCopyableMessage(e){return(e.role==="user"||e.role==="assistant")&&this.messageCopyText(e)!==""}messageCopyText(e){const t=this.messageCopyTextCache.get(e);if(t!==void 0)return t;const i=e.parts.filter(s=>s.type==="text").map(s=>s.text.trim()).filter(s=>s!=="").join(`
|
|
1336
|
+
|
|
1337
|
+
`);return this.messageCopyTextCache.set(e,i),i}async copyMessage(e,t,i){i.stopPropagation(),await this.writeClipboard(this.messageCopyText(e))&&(this.copiedMessageKey=t,window.setTimeout(()=>{this.copiedMessageKey===t&&(this.copiedMessageKey=void 0)},1200))}async writeClipboard(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}messageMetaLabel(e){const t=this.messageMetaCache.get(e);if(t!==void 0)return t;const i=e.meta?.timestamp,s=this.modelLabel(e);if(i===void 0&&s===void 0){const c={short:"no info",full:"No Pi message metadata available"};return this.messageMetaCache.set(e,c),c}const r=i===void 0?void 0:this.formatTimestamp(i),o=[r?.short,s].filter(c=>c!==void 0&&c!==""),n=[r?.full,s===void 0?void 0:`Model: ${s}`].filter(c=>c!==void 0&&c!==""),a={short:o.join(" · "),full:n.join(" · ")};return this.messageMetaCache.set(e,a),a}formatTimestamp(e){const t=new Date(e);if(Number.isFinite(t.getTime()))return{short:Db.format(t),full:Wb.format(t)}}modelLabel(e){const t=e.meta?.model;if(t===void 0)return;const i=t.responseId??t.id;return i===void 0||i===""?t.provider:t.provider!==void 0&&t.provider!==""?`${t.provider}/${i}`:i}renderPart(e,t){return e.type==="text"&&t?.role==="bash"?l`<pre class="part shell-output">${e.text}</pre>`:e.type==="text"?l`<formatted-text class="part" .text=${e.text}></formatted-text>`:e.type==="thinking"?l`<details class="part"><summary>thinking</summary><formatted-text .text=${e.text}></formatted-text></details>`:e.type==="skillInvocation"?l`
|
|
1338
|
+
<details class="part skill-invocation">
|
|
1339
|
+
<summary><b>[skill]</b> ${e.name}</summary>
|
|
1340
|
+
<small>${e.location}</small>
|
|
1341
|
+
<formatted-text .text=${e.content}></formatted-text>
|
|
1342
|
+
</details>
|
|
1343
|
+
`:e.type==="skillRead"?l`
|
|
1344
|
+
<div class="part skill-read">
|
|
1345
|
+
<strong>Loaded ${e.name}</strong>
|
|
1346
|
+
<small>read ${e.path}</small>
|
|
1347
|
+
</div>
|
|
1348
|
+
`:e.type==="image"?l`<img class="part chat-image" src=${`data:${e.mimeType};base64,${e.data}`} alt="attached image" loading="lazy" />`:e.type==="toolCall"?l`<div class="part tool-line">▶ ${e.toolName}<span class="summary">${e.summary}</span></div>`:e.type==="toolExecution"?l`<tool-execution-view class="part" .execution=${e}></tool-execution-view>`:e.type==="toolResult"?l`
|
|
1349
|
+
<details class="part" ?open=${e.isError}>
|
|
1350
|
+
<summary>${e.isError?"✖":"✓"} ${e.toolName} result</summary>
|
|
1351
|
+
<formatted-text .text=${e.text}></formatted-text>
|
|
1352
|
+
</details>
|
|
1353
|
+
`:null}onGroupToggle(e,t,i){const s=t.currentTarget;s instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,s.open,i)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){const t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){const e=this.chat;if(!e)return;const t=this.didChatHeightChange(),i=this.pinnedToBottom,s=e.scrollTop<this.lastScrollTop;if(t&&i){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:s?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){const e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){const t=e.get("messageStart");return typeof t=="number"&&this.messageStart<t}requestLoadMoreIfNeeded(){this.loadMoreCheckFrame===void 0&&(this.loadMoreCheckFrame=requestAnimationFrame(()=>{if(this.loadMoreCheckFrame=void 0,this.suppressLoadMoreRequests)return;const e=this.chat;e&&dv({hasMore:this.hasMore,loadingMore:this.loadingMore||this.loadMoreRequested,canRequest:this.onLoadMore!==void 0,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})&&this.requestLoadMore()}))}requestLoadMore(){this.loadMoreRequested||!this.hasMore||this.loadingMore||this.onLoadMore===void 0||(this.loadMoreRequested=!0,this.onLoadMore())}isNearBottom(){const e=this.chat;return e?il(e):!0}isAtBottom(){const e=this.chat;return e?tl(e)<2:!0}canScrollUp(){const e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;const e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}restoreScrollPosition(){const e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{const t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){const e=this.pendingScrollRestoreSessionId,t=this.pendingScrollRestorePosition;e===void 0||t===void 0||e!==this.sessionId||this.restoreScrollFrame!==void 0||(this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{const i=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,i)})}))}handleScrollRestoreResult(e,t){if(this.syncScrollMetrics(),t.status!=="missing"){this.updatePinnedToBottomAfterRestore(t.status),(t.status==="restored"||t.status==="bottom")&&this.cancelPrependRestore(),this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0;return}this.pinnedToBottom=!1,this.pendingScrollRestoreSessionId=e,this.pendingScrollRestorePosition=t.position;const i=this.chat;i===void 0||!this.hasMore||this.loadingMore||(i.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore&&!this.isReceivingPartialStream}updatePinnedToBottomAfterRestore(e){e==="bottom"?this.pinnedToBottom=!0:e==="restored"&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){const e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){const e=this.chat;if(e)return iv(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;const t=this.prependRestoreToken+1;this.prependRestoreToken=t;let i=0;const s=()=>{const r=this.chat;if(!(!r||t!==this.prependRestoreToken)){if(sv(r,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=r.scrollTop,i+=1,i<tv){requestAnimationFrame(s);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};s()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){const e=this.sessionId;this.scrollController.scheduleSave(e,t=>{this.sessionId===t&&this.saveScrollPosition(t)})}scheduleConversationRailUpdate(){this.conversationRailFrame===void 0&&(this.conversationRailFrame=requestAnimationFrame(()=>{this.conversationRailFrame=void 0,this.updateConversationRailPosition()}))}updateConversationRailPosition(){if(!this.messages.length||this.messageTotal<=0){this.currentConversationIndex=void 0;return}const e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),i=Number(t?.dataset.index);if(Number.isFinite(i)){this.currentConversationIndex=xi(i,0,Math.max(0,e-1));return}this.currentConversationIndex=xi(this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,0,Math.max(0,e-1))}scrollMarkers(){return Array.from(this.renderRoot.querySelectorAll(".scroll-marker"))}scrollMarkerAt(e){return this.scrollMarkers().find(t=>t.dataset.markerId===e)}firstVisibleArticle(){const e=this.chat;if(e===void 0)return;const t=Array.from(this.renderRoot.querySelectorAll("article.msg"));return pn(e,t)??pn(e,this.articles())}articles(){return Array.from(this.renderRoot.querySelectorAll("article.msg, details.msg"))}scrollAnchorElements(){return Array.from(this.renderRoot.querySelectorAll("[data-scroll-anchor-id]"))}withSuppressedScrollSave(e){this.suppressScrollSave=!0,e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.suppressScrollSave=!1})})}groupDisclosureKey(e,t,i){return i?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return`m:${String(e)}`}groupRenderKey(e){return`g:${String(e)}`}groupAnchorKey(e){return`g:${String(e)}`}eventAnchorKey(e){return`e:${String(e)}`}messageScrollMarkerId(e){return`m:${String(e)}`}groupScrollMarkerId(e){return`g:${String(e)}`}};N.styles=If;H([d({attribute:!1})],N.prototype,"messages",2);H([d()],N.prototype,"sessionId",2);H([d({type:Number})],N.prototype,"messageStart",2);H([d({type:Number})],N.prototype,"messageEnd",2);H([d({type:Number})],N.prototype,"messageTotal",2);H([d({type:Boolean})],N.prototype,"hasMore",2);H([d({type:Boolean})],N.prototype,"loadingMore",2);H([d({type:Boolean})],N.prototype,"isReceivingPartialStream",2);H([d({type:Boolean})],N.prototype,"isSendingPrompt",2);H([d({type:Boolean})],N.prototype,"isCompacting",2);H([d({type:Number})],N.prototype,"pendingMessageCount",2);H([d({attribute:!1})],N.prototype,"status",2);H([d({attribute:!1})],N.prototype,"activity",2);H([d({attribute:!1})],N.prototype,"onLoadMore",2);H([z(".chat")],N.prototype,"chat",2);H([v()],N.prototype,"pinnedToBottom",2);H([v()],N.prototype,"expandedMetaKey",2);H([v()],N.prototype,"copiedMessageKey",2);H([v()],N.prototype,"currentConversationIndex",2);H([v()],N.prototype,"loadMoreRequested",2);N=H([D("chat-view")],N);const Ob=["image/jpeg","image/png","image/gif","image/webp"],jb=new Set(Ob);function Nr(e){return typeof e=="string"&&jb.has(e)}function _b(e){switch(e){case"image/jpeg":return"jpg";case"image/png":return"png";case"image/gif":return"gif";case"image/webp":return"webp";default:return"bin"}}const Lb="application/octet-stream",Fb="Failed to read an attachment.";async function Nb(e,t){const i=[];let s;for(const r of e)try{const o=await t(r);i.push(zb(r,o))}catch{s=Fb}return{attachments:i,...s===void 0?{}:{error:s}}}function Js(e){return e.kind==="image"&&Nr(e.mimeType)}function Zs(e){return e.every(t=>Js(t))}function Ub(e,t){return Zs(t)?e:"folder"}function zb(e,t){return Nr(e.type)?{kind:"image",name:$n(e),mimeType:e.type,data:t,size:e.size}:{kind:"file",name:$n(e),mimeType:Bb(e),data:t,size:e.size}}function Bb(e){const t=e.type.trim();return t===""?Lb:t}function $n(e){return e.name!==""?e.name:Nr(e.type)?`pasted-image.${_b(e.type)}`:"pasted-file.bin"}const vl="pi-web:attachment-delivery";function bl(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Hb(e=bl()){try{return e?.getItem(vl)==="folder"?"folder":"inline"}catch{return"inline"}}function qb(e,t=bl()){try{t?.setItem(vl,e)}catch{}}const Kb="(pointer: coarse), (max-width: 760px)",wl="pi-web.promptEnterPreference";function ss(){return typeof window<"u"&&"matchMedia"in window?window.matchMedia(Kb):void 0}function Vb(e){return e==="send"||e==="newline"?e:"auto"}function rs(e=yl()){if(e===void 0)return"auto";try{return Vb(e.getItem(wl))}catch{return"auto"}}function Gb(e,t=yl()){if(t!==void 0)try{t.setItem(wl,e)}catch{}}function Qb(e=ss(),t=rs()){return t==="send"?!0:t==="newline"?!1:e?.matches!==!0}function Jb(e,t,i=ss()){return e?i?.matches===!0?t:!0:!1}function Zb(e,t=ss(),i=rs()){const s=Qb(t,i);return e?!s:s}function yl(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Xb(){return be`
|
|
1354
|
+
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1355
|
+
<path d="M20 11.5 12.5 19a4 4 0 0 1-5.66-5.66l7.07-7.07a2.5 2.5 0 0 1 3.54 3.54l-7.07 7.07a1 1 0 0 1-1.42-1.42l6.37-6.36"></path>
|
|
1356
|
+
</svg>
|
|
1357
|
+
`}function xl(){return be`
|
|
1358
|
+
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1359
|
+
<path d="M21 3 13.5 21l-2-8.5L3 10.5Z"></path>
|
|
1360
|
+
<path d="M21 3 11.5 12.5"></path>
|
|
1361
|
+
</svg>
|
|
1362
|
+
`}function Yb(){return be`
|
|
1363
|
+
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1364
|
+
<path d="M4 7h11"></path>
|
|
1365
|
+
<path d="M4 12h7"></path>
|
|
1366
|
+
<path d="M4 17h7"></path>
|
|
1367
|
+
<path d="m15 14 5 3-5 3z"></path>
|
|
1368
|
+
</svg>
|
|
1369
|
+
`}function ew(){return xl()}function tw(){return be`
|
|
1370
|
+
<svg class="prompt-action-icon prompt-action-icon-filled" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1371
|
+
<rect x="6.5" y="6.5" width="11" height="11" rx="2"></rect>
|
|
1372
|
+
</svg>
|
|
1373
|
+
`}function iw(e){const t=Math.max(e.total,1),i=t>1?1.2:0,s=3,n=(21-s-i*(t-1))/t,a=Array.from({length:t},(c,p)=>{const u=s+p*(n+i),h=4+(p+1)/t*12,f=20-h,b=p<e.filled;return be`<rect class=${b?"gauge-bar gauge-bar-active":"gauge-bar"} x=${u} y=${f} width=${n} height=${h} rx="1"></rect>`});return be`
|
|
1374
|
+
<svg class="prompt-thinking-gauge" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1375
|
+
${a}
|
|
1376
|
+
</svg>
|
|
1377
|
+
`}const sw=["off","minimal","low","medium","high","xhigh"];function Xs(e){return e===void 0||e===""?"off":e}function rw(e,t){const i=t.length>=2?t:sw,s=i.length-1,r=Xs(e),o=i.indexOf(r),n=o<=0?0:Math.min(o,s);return{total:s,filled:n}}class ow extends Ir{constructor(t){super(t),this.wasSelected=!1,this.isElementPart=t.type===Cr.ELEMENT}update(t,[i,s]){if(!this.isElementPart)throw new Error("scrollWhenSelected must be used on an element");if(i&&(!this.wasSelected||s!==this.previousKey)){const r="element"in t?t.element:void 0;requestAnimationFrame(()=>{r instanceof HTMLElement&&r.scrollIntoView({block:"nearest"})})}this.wasSelected=i,this.previousKey=s}render(t,i){}}const Ur=Rr(ow);var nw=Object.defineProperty,aw=Object.getOwnPropertyDescriptor,os=(e,t,i,s)=>{for(var r=s>1?void 0:s?aw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&nw(t,i,r),r};let kt=class extends M{constructor(){super(...arguments),this.items=[],this.selectedIndex=0}render(){return this.items.length?l`
|
|
1378
|
+
<div class="menu">
|
|
1379
|
+
${this.items.map((e,t)=>l`
|
|
1380
|
+
<button class=${t===this.selectedIndex?"selected":""} ${Ur(t===this.selectedIndex,e)} @mousedown=${i=>{i.preventDefault(),this.onPick?.(e)}}>
|
|
1381
|
+
<strong>${e.insertText}</strong>
|
|
1382
|
+
<span>${e.detail}</span>
|
|
1383
|
+
${e.description!==void 0&&e.description!==""?l`<small>${e.description}</small>`:null}
|
|
1384
|
+
</button>
|
|
1385
|
+
`)}
|
|
1386
|
+
</div>
|
|
1387
|
+
`:null}};kt.styles=Tf;os([d({attribute:!1})],kt.prototype,"items",2);os([d({type:Number})],kt.prototype,"selectedIndex",2);os([d({attribute:!1})],kt.prototype,"onPick",2);kt=os([D("autocomplete-menu")],kt);var lw=Object.defineProperty,cw=Object.getOwnPropertyDescriptor,L=(e,t,i,s)=>{for(var r=s>1?void 0:s?cw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&lw(t,i,r),r};let _=class extends M{constructor(){super(...arguments),this.disabled=!1,this.machineId="local",this.workspaceScopedFileSuggestions=!1,this.canSteer=!1,this.isCompacting=!1,this.canStop=!1,this.sending=!1,this.availableThinkingLevels=[],this.draft="",this.completions=[],this.selectedIndex=0,this.attachments=[],this.attachmentDelivery=Hb(),this.attachmentError=void 0,this.attachmentSeq=0,this.requestVersion=0,this.editableCompartment=new Br,this.readOnlyCompartment=new Br,this.mobilePromptEnterMedia=ss(),this.explicitShiftKeyActive=!1}willUpdate(e){if(!e.has("sessionId")&&!e.has("machineId"))return;const t=e.has("sessionId")?e.get("sessionId"):this.sessionId,i=e.has("machineId")?e.get("machineId"):this.machineId,s=ai(i,t);s!==void 0&&Mi(s,this.draft);const r=ai(this.machineId,this.sessionId);this.draft=r!==void 0?ua(r):"",this.completions=[],this.selectedIndex=0}firstUpdated(){this.createEditor()}updated(e){e.has("disabled")&&this.updateEditorDisabledState(),(e.has("draft")||e.has("sessionId")||e.has("machineId"))&&this.syncEditorDoc()}disconnectedCallback(){this.editor?.destroy(),this.editor=void 0,super.disconnectedCallback()}render(){const e=vr(this.draft),t=e.kind==="shell",i=this.canSteer||this.isCompacting,s=this.disabled||this.sending;return l`
|
|
1388
|
+
<footer class=${t?"shell-mode":""} @paste=${r=>{this.handlePaste(r)}} @dragover=${r=>{this.handleDragOver(r)}} @drop=${r=>{this.handleDrop(r)}}>
|
|
1389
|
+
<div class="editor-wrap">
|
|
1390
|
+
<div class=${`markdown-editor${this.disabled?" markdown-editor-disabled":""}`} aria-label="Message pi" aria-disabled=${this.disabled?"true":"false"}></div>
|
|
1391
|
+
<input class="attachment-input" type="file" multiple hidden @change=${r=>{this.handleFileInput(r)}} />
|
|
1392
|
+
<button class="editor-attach icon-button" ?disabled=${s} title="Attach files" aria-label="Attach files" @click=${()=>{this.attachmentInput?.click()}}>${Xb()}</button>
|
|
1393
|
+
${t?l`<div class="mode-hint">Shell command${e.excludeFromContext?" · excluded from context":""}</div>`:null}
|
|
1394
|
+
${this.isCompacting&&!t?l`<div class="mode-hint">Compacting history · message will be queued</div>`:null}
|
|
1395
|
+
${this.renderAttachments()}
|
|
1396
|
+
<autocomplete-menu .items=${this.completions} .selectedIndex=${this.selectedIndex} .onPick=${r=>{this.pick(r)}}></autocomplete-menu>
|
|
1397
|
+
</div>
|
|
1398
|
+
<div class="actions">
|
|
1399
|
+
${this.renderCompactStatus()}
|
|
1400
|
+
<button class="icon-button send-button" ?disabled=${s} title=${i?"Queue until the current activity finishes":"Send message"} aria-label=${i?"Queue message":"Send message"} @click=${()=>{this.send("followUp")}}>${i?Yb():xl()}</button>
|
|
1401
|
+
${this.canSteer&&!this.isCompacting?l`<button class="icon-button steer-button" ?disabled=${s} title="Steer the current response before the next model call" aria-label="Steer current response" @click=${()=>{this.send("steer")}}>${ew()}</button>`:null}
|
|
1402
|
+
<button class="icon-button stop-button" ?disabled=${this.disabled||!this.canStop} title=${this.canStop?"Stop current work and clear queued messages":"Nothing running"} aria-label="Stop current work" @click=${()=>this.onStop?.()}>${tw()}</button>
|
|
1403
|
+
</div>
|
|
1404
|
+
</footer>
|
|
1405
|
+
`}focusInput(){this.editor?.focus()}get view(){return this.editor}renderCompactStatus(){const e=this.status;if(e===void 0)return null;const t=e.model?.id??"no model",i=e.model?.provider!==void 0&&e.model.provider!==""?`${e.model.provider}/`:"";return l`
|
|
1406
|
+
<div class="compact-status" aria-label="Session status">
|
|
1407
|
+
<button class="select-model" title="Select model" @click=${()=>this.onSelectModel?.()}>${i}${t}</button>
|
|
1408
|
+
<button class="select-thinking icon-button" title=${`Thinking level: ${Xs(e.thinkingLevel)}`} aria-label=${`Thinking level: ${Xs(e.thinkingLevel)}`} @click=${()=>this.onSelectThinking?.()}>${iw(rw(e.thinkingLevel,this.availableThinkingLevels))}</button>
|
|
1409
|
+
</div>
|
|
1410
|
+
`}renderAttachments(){if(this.attachments.length===0&&this.attachmentError===void 0)return null;const e=Zs(this.attachments),t=this.effectiveAttachmentDelivery();return l`
|
|
1411
|
+
<div class="attachments" aria-label="Pending attachments">
|
|
1412
|
+
${this.attachments.map(i=>l`
|
|
1413
|
+
<div class=${`attachment-chip ${Js(i)?"attachment-chip-image":"attachment-chip-file"}`} title=${i.name}>
|
|
1414
|
+
${this.renderAttachmentPreview(i)}
|
|
1415
|
+
<button type="button" class="attachment-remove" title="Remove attachment" aria-label=${`Remove ${i.name}`} @click=${()=>{this.removeAttachment(i.id)}}>×</button>
|
|
1416
|
+
</div>
|
|
1417
|
+
`)}
|
|
1418
|
+
${this.attachments.length>0?l`
|
|
1419
|
+
<label class="attachment-delivery" title=${e?"How attachments are delivered to the agent":"General files are saved and mentioned from the workspace"}>
|
|
1420
|
+
<select .value=${t} @change=${i=>{this.changeDelivery(i)}}>
|
|
1421
|
+
<option value="inline" ?disabled=${!e}>Attach to message${e?"":" (images only)"}</option>
|
|
1422
|
+
<option value="folder">Save to .pi-web/attachments</option>
|
|
1423
|
+
</select>
|
|
1424
|
+
</label>
|
|
1425
|
+
`:null}
|
|
1426
|
+
${this.attachmentError!==void 0?l`<div class="attachment-error">${this.attachmentError}</div>`:null}
|
|
1427
|
+
</div>
|
|
1428
|
+
`}renderAttachmentPreview(e){return Js(e)?l`<img src=${`data:${e.mimeType};base64,${e.data}`} alt=${e.name} />`:l`
|
|
1429
|
+
<div class="attachment-file-preview" aria-hidden="true">${fw(e.name)}</div>
|
|
1430
|
+
<span class="attachment-file-name">${e.name}</span>
|
|
1431
|
+
`}changeDelivery(e){if(!(e.target instanceof HTMLSelectElement))return;const t=e.target.value==="folder"?"folder":"inline";if(t==="inline"&&!Zs(this.attachments)){e.target.value="folder";return}this.attachmentDelivery=t,qb(this.attachmentDelivery)}removeAttachment(e){this.attachments=this.attachments.filter(t=>t.id!==e)}async handlePaste(e){const t=Pn(e.clipboardData);t.length!==0&&(e.preventDefault(),await this.addAttachmentFiles(t))}handleDragOver(e){e.dataTransfer!==null&&hw(e.dataTransfer)&&e.preventDefault()}async handleDrop(e){const t=Pn(e.dataTransfer);t.length!==0&&(e.preventDefault(),await this.addAttachmentFiles(t))}async handleFileInput(e){if(!(e.target instanceof HTMLInputElement)||e.target.files===null)return;const t=Array.from(e.target.files);e.target.value="",await this.addAttachmentFiles(t)}async addAttachmentFiles(e){this.attachmentError=void 0;const{attachments:t,error:i}=await Nb(e,gw);t.length>0&&(this.attachments=[...this.attachments,...t.map(s=>({id:`attachment-${String(++this.attachmentSeq)}`,...s}))]),i!==void 0&&(this.attachmentError=i)}currentAttachments(){return this.attachments.map(e=>uw(e))}effectiveAttachmentDelivery(){return Ub(this.attachmentDelivery,this.attachments)}createEditor(){!this.editorHost||this.editor!==void 0||(this.editor=new et({parent:this.editorHost,state:as.create({doc:this.draft,extensions:[Il(),Ll(),Al(),Ml.of(" "),Tl(El,{fallback:!0}),et.lineWrapping,et.contentAttributes.of(e=>bw(e.state.sliceDoc(0,e.state.selection.main.head))),et.domEventHandlers({keyup:e=>this.handleEditorKeyUp(e),blur:()=>this.resetEditorModifierState()}),Dl("Message pi... Use / for commands, @ for tracked files, @ space for all files"),this.editableCompartment.of(et.editable.of(!this.disabled)),this.readOnlyCompartment.of(as.readOnly.of(this.disabled)),et.updateListener.of(e=>{e.docChanged&&this.updateDraft(e.state.doc.toString())}),Wl.of([{any:(e,t)=>this.handleEditorKeyDown(t,e)},{key:"ArrowDown",run:()=>this.moveCompletion(1)},{key:"ArrowUp",run:()=>this.moveCompletion(-1)},{key:"Escape",run:()=>this.closeCompletions()},{key:"Tab",run:e=>this.handleEditorTab(e)},{key:"Shift-Tab",run:e=>Hr.shift?.(e)??!1},{key:"Backspace",run:e=>Fl(e)},...Ol,...jl])]})}))}syncEditorDoc(){const e=this.editor;if(!e)return;const t=e.state.doc.toString();t!==this.draft&&e.dispatch({changes:{from:0,to:t.length,insert:this.draft},selection:qr.cursor(this.draft.length)})}updateEditorDisabledState(){this.editor?.dispatch({effects:[this.editableCompartment.reconfigure(et.editable.of(!this.disabled)),this.readOnlyCompartment.reconfigure(as.readOnly.of(this.disabled))]})}updateDraft(e){this.draft=e;const t=ai(this.machineId,this.sessionId);t!==void 0&&Mi(t,this.draft),this.refreshCompletions()}async refreshCompletions(){const e=this.currentTrigger(),t=++this.requestVersion;if(this.selectedIndex=0,e===void 0){this.completions=[];return}if(e.kind==="command"&&this.sessionId!==void 0&&this.sessionId!==""&&this.cwd!==void 0&&this.cwd!==""){const i=await B.commands({id:this.sessionId,cwd:this.cwd},this.machineId).catch(dw);if(t!==this.requestVersion)return;this.completions=i.filter(s=>s.name.toLowerCase().includes(e.query.toLowerCase())).slice(0,12).map(s=>({kind:"command",replaceFrom:e.from,replaceTo:e.to,insertText:`/${s.name}`,detail:s.source,...s.description===void 0?{}:{description:s.description}}))}else if(e.kind==="file"&&this.cwd!==void 0&&this.cwd!==""){const i=await B.files(this.cwd,e.query,{scope:e.fileScope,machineId:this.machineId,projectId:this.projectId,workspaceId:this.workspaceId,workspaceScoped:this.workspaceScopedFileSuggestions}).catch(pw);if(t!==this.requestVersion)return;this.completions=i.slice(0,12).map(s=>{const r=ya(s.path,e.quoted===!0,s.path.endsWith("/")?e.allPrefix:void 0);return{kind:"file",replaceFrom:e.from,replaceTo:e.to,insertText:r,detail:s.kind,...s.path.endsWith("/")&&r.endsWith('"')?{cursorOffset:r.length-1}:{}}})}}currentTrigger(){return wa(this.draft,this.editor?.state.selection.main.head??this.draft.length)}moveCompletion(e){return this.completions.length?(this.selectedIndex=(this.selectedIndex+e+this.completions.length)%this.completions.length,!0):!1}closeCompletions(){return this.completions.length?(this.completions=[],!0):!1}handleEditorKeyDown(e,t){if(e.key==="Shift")return this.explicitShiftKeyActive=!0,!1;if(e.key!=="Enter")return this.explicitShiftKeyActive=!1,!1;if(e.defaultPrevented||e.isComposing||t.composing)return!1;const i=Jb(e.shiftKey,this.explicitShiftKeyActive,this.mobilePromptEnterMedia);return this.explicitShiftKeyActive=!1,this.handleEditorEnter(t,i)}handleEditorKeyUp(e){return e.key==="Shift"&&(this.explicitShiftKeyActive=!1),!1}resetEditorModifierState(){return this.explicitShiftKeyActive=!1,!1}handleEditorEnter(e,t){if(!t&&this.completions.length){const i=this.completions[this.selectedIndex];return i!==void 0&&this.pick(i),!0}return Zb(t,this.mobilePromptEnterMedia,rs())?(this.send(this.canSteer||this.isCompacting?"followUp":void 0),!0):Nl(e)||_l(e)}handleEditorTab(e){if(this.completions.length){const i=this.completions[this.selectedIndex];return i!==void 0&&this.pick(i),!0}return this.currentTrigger()?.kind==="file"?(this.refreshCompletions(),!0):Hr.run?.(e)??!1}pick(e){const t=this.editor;if(!t)return;const i=e.kind==="file"&&(e.insertText.endsWith("/")||e.cursorOffset!==void 0)?"":" ",s=e.replaceFrom+(e.cursorOffset??e.insertText.length)+i.length,r=e.insertText.endsWith('"')&&this.draft.slice(e.replaceTo).startsWith('"')?e.replaceTo+1:e.replaceTo;t.dispatch({changes:{from:e.replaceFrom,to:r,insert:`${e.insertText}${i}`},selection:qr.cursor(s),scrollIntoView:!0}),this.completions=[]}send(e){if(this.disabled||this.sending)return;const t=this.draft.trim(),i=this.attachments;if(t===""&&i.length===0)return;const s=this.canSteer||this.isCompacting?e:void 0,r=i.length>0?this.currentAttachments():void 0,o=this.effectiveAttachmentDelivery();this.resetComposer(),this.onSend?.(t,s,r,r===void 0?void 0:o)}resetComposer(){this.draft="";const e=ai(this.machineId,this.sessionId);e!==void 0&&mr(e),this.completions=[],this.attachments=[],this.attachmentError=void 0}};_.styles=Df;L([d({type:Boolean})],_.prototype,"disabled",2);L([d()],_.prototype,"sessionId",2);L([d()],_.prototype,"cwd",2);L([d()],_.prototype,"machineId",2);L([d()],_.prototype,"projectId",2);L([d()],_.prototype,"workspaceId",2);L([d({type:Boolean})],_.prototype,"workspaceScopedFileSuggestions",2);L([d({type:Boolean})],_.prototype,"canSteer",2);L([d({type:Boolean})],_.prototype,"isCompacting",2);L([d({type:Boolean})],_.prototype,"canStop",2);L([d({attribute:!1})],_.prototype,"status",2);L([d({type:Boolean})],_.prototype,"sending",2);L([d({attribute:!1})],_.prototype,"onSend",2);L([d({attribute:!1})],_.prototype,"onStop",2);L([d({attribute:!1})],_.prototype,"onSelectModel",2);L([d({attribute:!1})],_.prototype,"onSelectThinking",2);L([d({attribute:!1})],_.prototype,"availableThinkingLevels",2);L([z(".markdown-editor")],_.prototype,"editorHost",2);L([z(".attachment-input")],_.prototype,"attachmentInput",2);L([v()],_.prototype,"draft",2);L([v()],_.prototype,"completions",2);L([v()],_.prototype,"selectedIndex",2);L([v()],_.prototype,"attachments",2);L([v()],_.prototype,"attachmentDelivery",2);L([v()],_.prototype,"attachmentError",2);_=L([D("prompt-editor")],_);function ai(e,t){if(!(typeof e!="string"||e==="")&&!(typeof t!="string"||t===""))return pa(e,t)}function dw(){return[]}function pw(){return[]}function Pn(e){return e===null?[]:Array.from(e.files)}function hw(e){const t=Array.from(e.items);return t.length>0?t.some(i=>i.kind==="file"):Array.from(e.types).includes("Files")}function uw(e){return e.kind==="image"?{kind:"image",mimeType:e.mimeType,data:e.data,name:e.name}:{kind:"file",mimeType:e.mimeType,data:e.data,name:e.name}}function fw(e){const t=e.trim(),i=t.lastIndexOf(".");return i>=0&&i<t.length-1?t.slice(i+1,i+5).toUpperCase():"FILE"}function gw(e){return new Promise((t,i)=>{const s=new FileReader;s.onerror=()=>{i(s.error??new Error("Failed to read file"))},s.onload=()=>{const r=s.result;if(typeof r!="string"){i(new Error("Unexpected file reader result"));return}const o=r.indexOf(",");t(o===-1?r:r.slice(o+1))},s.readAsDataURL(e)})}const mw={spellcheck:"true",autocorrect:"on",autocapitalize:"sentences",writingsuggestions:"true",dir:"auto"},vw={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",dir:"auto"};function bw(e){return vr(e).kind==="normal"?mw:vw}function li(e){return Number.isFinite(e)?e<1e3?Math.round(e).toString():e<1e4?`${(e/1e3).toFixed(1)}k`:e<1e6?`${String(Math.round(e/1e3))}k`:e<1e7?`${(e/1e6).toFixed(1)}M`:`${String(Math.round(e/1e6))}M`:"0"}function ww(e){return!Number.isFinite(e)||e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}var yw=Object.defineProperty,xw=Object.getOwnPropertyDescriptor,Sl=(e,t,i,s)=>{for(var r=s>1?void 0:s?xw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&yw(t,i,r),r};let Ui=class extends M{render(){const e=this.status;if(e===void 0)return l`<div class="bar muted">No session status yet</div>`;const t=e.contextUsage,i=t?t.percent==null?`context ${li(t.contextWindow)}`:`${t.percent.toFixed(1)}%/${li(t.contextWindow)}`:"context unknown",s=e.tokens;return l`
|
|
1432
|
+
<div class="bar">
|
|
1433
|
+
<span>↑${li(s.input)}</span>
|
|
1434
|
+
<span>↓${li(s.output)}</span>
|
|
1435
|
+
<span class="context">${i}</span>
|
|
1436
|
+
<span>${ww(e.cost)}</span>
|
|
1437
|
+
${e.pendingMessageCount>0?l`<span>${String(e.pendingMessageCount)} queued</span>`:null}
|
|
1438
|
+
</div>
|
|
1439
|
+
`}};Ui.styles=Mf;Sl([d({attribute:!1})],Ui.prototype,"status",2);Ui=Sl([D("status-bar")],Ui);var Sw=Object.defineProperty,kw=Object.getOwnPropertyDescriptor,He=(e,t,i,s)=>{for(var r=s>1?void 0:s?kw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Sw(t,i,r),r};let Te=class extends M{constructor(){super(...arguments),this.title="Select",this.searchable=!1,this.options=[],this.selectedIndex=0,this.query=""}render(){const e=this.filteredOptions();return l`
|
|
1440
|
+
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
1441
|
+
<section @mousedown=${t=>{t.stopPropagation()}}>
|
|
1442
|
+
<header>
|
|
1443
|
+
<strong>${this.title}</strong>
|
|
1444
|
+
<button @click=${()=>this.onCancel?.()}>×</button>
|
|
1445
|
+
</header>
|
|
1446
|
+
${this.searchable?l`<input placeholder="Search" .value=${this.query} @input=${t=>{this.handleSearchInput(t)}} @keydown=${t=>{this.handleKeyDown(t)}}>`:null}
|
|
1447
|
+
<div class="options" @keydown=${t=>{this.handleKeyDown(t)}} tabindex="0">
|
|
1448
|
+
${e.map((t,i)=>l`
|
|
1449
|
+
<button class=${i===this.selectedIndex?"selected":""} ${Ur(i===this.selectedIndex,t.value)} @click=${()=>this.onPick?.(t.value)}>
|
|
1450
|
+
<span>${t.label}</span>
|
|
1451
|
+
${t.description!==void 0&&t.description!==""?l`<small>${t.description}</small>`:null}
|
|
1452
|
+
</button>
|
|
1453
|
+
`)}
|
|
1454
|
+
${e.length===0?l`<div class="empty">No matching options</div>`:null}
|
|
1455
|
+
</div>
|
|
1456
|
+
</section>
|
|
1457
|
+
</div>
|
|
1458
|
+
`}firstUpdated(){this.selectInitialValue(),this.renderRoot.querySelector(this.searchable?"input":".options")?.focus()}selectInitialValue(){if(this.selectedValue===void 0)return;const e=this.filteredOptions().findIndex(t=>t.value===this.selectedValue);e>=0&&(this.selectedIndex=e)}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(){const e=this.query.trim().toLowerCase();return e===""?this.options:this.options.filter(t=>`${t.label} ${t.description??""} ${t.value}`.toLowerCase().includes(e))}handleKeyDown(e){const t=this.filteredOptions();if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="ArrowDown")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key==="Enter"){e.preventDefault();const i=t[this.selectedIndex];i&&this.onPick?.(i.value)}}};Te.styles=La;He([d()],Te.prototype,"title",2);He([d({type:Boolean})],Te.prototype,"searchable",2);He([d({attribute:!1})],Te.prototype,"options",2);He([d({attribute:!1})],Te.prototype,"selectedValue",2);He([d({attribute:!1})],Te.prototype,"onPick",2);He([d({attribute:!1})],Te.prototype,"onCancel",2);He([v()],Te.prototype,"selectedIndex",2);He([v()],Te.prototype,"query",2);Te=He([D("command-picker")],Te);var $w=Object.defineProperty,Pw=Object.getOwnPropertyDescriptor,ht=(e,t,i,s)=>{for(var r=s>1?void 0:s?Pw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&$w(t,i,r),r};let Ue=class extends M{constructor(){super(...arguments),this.actions=[],this.queryText="",this.selectedIndex=0}render(){const e=this.filteredActions();return l`
|
|
1459
|
+
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
1460
|
+
<section @mousedown=${t=>{t.stopPropagation()}} @keydown=${t=>{this.handleKeyDown(t)}}>
|
|
1461
|
+
<header>
|
|
1462
|
+
<input
|
|
1463
|
+
.value=${this.queryText}
|
|
1464
|
+
placeholder="Search actions..."
|
|
1465
|
+
@input=${t=>{t.target instanceof HTMLInputElement&&(this.queryText=t.target.value,this.selectedIndex=0)}}
|
|
1466
|
+
>
|
|
1467
|
+
<button title="Close" @click=${()=>this.onCancel?.()}>×</button>
|
|
1468
|
+
</header>
|
|
1469
|
+
<div class="options">
|
|
1470
|
+
${e.length===0?l`<div class="empty">No actions found.</div>`:e.map((t,i)=>l`
|
|
1471
|
+
<button class=${`${i===this.selectedIndex?"selected":""} ${t.enabled===!1?"disabled":""}`} ?disabled=${t.enabled===!1} title=${t.disabledReason??t.title} ${Ur(i===this.selectedIndex,t.id)} @click=${()=>{this.run(t)}}>
|
|
1472
|
+
<span class="main">
|
|
1473
|
+
<strong>${t.title}</strong>
|
|
1474
|
+
${t.description!==void 0&&t.description!==""?l`<small>${t.description}</small>`:null}
|
|
1475
|
+
${t.enabled===!1&&t.disabledReason!==void 0?l`<small class="disabled-reason">${t.disabledReason}</small>`:null}
|
|
1476
|
+
</span>
|
|
1477
|
+
${t.shortcut!==void 0?l`<kbd>${vi(t.shortcut)}</kbd>`:null}
|
|
1478
|
+
${t.group!==void 0&&t.group!==""?l`<small class="group">${t.group}</small>`:null}
|
|
1479
|
+
</button>
|
|
1480
|
+
`)}
|
|
1481
|
+
</div>
|
|
1482
|
+
</section>
|
|
1483
|
+
</div>
|
|
1484
|
+
`}firstUpdated(){this.input?.focus()}updated(e){if(!e.has("actions")&&!e.has("queryText"))return;const t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){return Cw(this.actions,this.queryText)}handleKeyDown(e){const t=this.filteredActions();if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="ArrowDown")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key==="Enter"){e.preventDefault();const i=t[this.selectedIndex];i!==void 0&&this.run(i)}}run(e){e.enabled!==!1&&this.onRun?.(e)}};Ue.styles=Ef;ht([d({attribute:!1})],Ue.prototype,"actions",2);ht([d({attribute:!1})],Ue.prototype,"onRun",2);ht([d({attribute:!1})],Ue.prototype,"onCancel",2);ht([z("input")],Ue.prototype,"input",2);ht([v()],Ue.prototype,"queryText",2);ht([v()],Ue.prototype,"selectedIndex",2);Ue=ht([D("action-palette")],Ue);function Cw(e,t){const i=t.trim().toLowerCase();return e.filter(s=>s.enabled!==!1||s.disabledReason!==void 0).filter(s=>i===""?!0:[s.title,s.description??"",s.disabledReason??"",s.group??"",s.shortcut??""].join(" ").toLowerCase().includes(i))}var Rw=Object.defineProperty,Iw=Object.getOwnPropertyDescriptor,$e=(e,t,i,s)=>{for(var r=s>1?void 0:s?Iw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Rw(t,i,r),r};let ce=class extends M{render(){const e=this.state;return e===void 0?null:l`
|
|
1485
|
+
<div class="backdrop" @mousedown=${()=>{this.cancel()}}>
|
|
1486
|
+
<section @mousedown=${t=>{t.stopPropagation()}} @keydown=${t=>{this.handleKeyDown(t)}}>
|
|
1487
|
+
<header>
|
|
1488
|
+
<strong>${this.dialogTitle(e)}</strong>
|
|
1489
|
+
<button title="Close" @click=${()=>{this.cancel()}}>×</button>
|
|
1490
|
+
</header>
|
|
1491
|
+
${this.renderBody(e)}
|
|
1492
|
+
</section>
|
|
1493
|
+
</div>
|
|
1494
|
+
`}updated(){this.focusInputIfNeeded()}dialogTitle(e){switch(e.step){case"method":return"Configure provider authentication";case"providers":return e.authType===void 0?"Select provider authentication":e.authType==="oauth"?"Select subscription provider":"Select API key provider";case"apiKey":return`API key for ${e.provider.name}`;case"oauth":return`Login to ${e.flow.providerName}`;case"logout":return"Remove stored provider authentication"}}renderBody(e){switch(e.step){case"method":return l`
|
|
1495
|
+
<div class="options">
|
|
1496
|
+
<button @click=${()=>{this.onChooseMethod?.("oauth")}}><span>Use a subscription</span><small>ChatGPT Plus/Pro, Claude Pro/Max, or GitHub Copilot</small></button>
|
|
1497
|
+
<button @click=${()=>{this.onChooseMethod?.("api_key")}}><span>Use an API key</span><small>Store an API key in pi auth.json</small></button>
|
|
1498
|
+
</div>
|
|
1499
|
+
`;case"providers":return l`<div class="options">${e.providers.length===0?l`<div class="empty">No providers available.</div>`:e.providers.map(t=>this.renderProviderButton(t))}</div>`;case"apiKey":return l`
|
|
1500
|
+
<div class="form">
|
|
1501
|
+
<p>Enter the API key for <strong>${e.provider.name}</strong>. It will be stored by pi in <code>auth.json</code>.</p>
|
|
1502
|
+
<input type="password" autocomplete="off" placeholder="API key" .value=${e.value} @input=${t=>{t.target instanceof HTMLInputElement&&this.onApiKeyInput?.(t.target.value)}}>
|
|
1503
|
+
${e.error!==void 0&&e.error!==""?l`<div class="error-text">${e.error}</div>`:null}
|
|
1504
|
+
<div class="actions"><button @click=${()=>{this.cancel()}}>Cancel</button><button class="primary" ?disabled=${e.saving===!0} @click=${()=>{this.onSaveApiKey?.()}}>${e.saving===!0?"Saving…":"Save API key"}</button></div>
|
|
1505
|
+
</div>
|
|
1506
|
+
`;case"oauth":return this.renderOAuth(e);case"logout":return l`<div class="options">${e.providers.length===0?l`<div class="empty">No stored credentials. Environment variables and models.json settings are unchanged.</div>`:e.providers.map(t=>l`
|
|
1507
|
+
<button @click=${()=>{this.onLogoutProvider?.(t.id)}}><span>${t.name}</span><small>${t.id} · ${Cn(t.authType)}</small></button>
|
|
1508
|
+
`)}</div>`}}renderProviderButton(e){return l`
|
|
1509
|
+
<button @click=${()=>{this.onSelectProvider?.(e.id,e.authType)}}>
|
|
1510
|
+
<span>${e.name}${e.status.source!==void 0?l` <em>${Mw(e)}</em>`:null}</span>
|
|
1511
|
+
<small>${e.id} · ${Cn(e.authType)}</small>
|
|
1512
|
+
</button>
|
|
1513
|
+
`}renderOAuth(e){const t=e.flow,i=t.prompt,s=t.select;return l`
|
|
1514
|
+
<div class="form">
|
|
1515
|
+
${t.auth!==void 0?l`
|
|
1516
|
+
<p>Open this authorization link:</p>
|
|
1517
|
+
<p><a href=${t.auth.url} target="_blank" rel="noreferrer">${t.auth.url}</a></p>
|
|
1518
|
+
${t.auth.instructions!==void 0?l`<p class="warning">${t.auth.instructions}</p>`:null}
|
|
1519
|
+
`:l`<p>Starting login flow…</p>`}
|
|
1520
|
+
${t.progress.length>0?l`<ul class="progress">${t.progress.map(r=>l`<li>${r}</li>`)}</ul>`:null}
|
|
1521
|
+
${i!==void 0?l`
|
|
1522
|
+
<label>${i.message}</label>
|
|
1523
|
+
<input .value=${e.inputValue??""} placeholder=${i.placeholder??""} @input=${r=>{r.target instanceof HTMLInputElement&&this.onOAuthInput?.(r.target.value)}}>
|
|
1524
|
+
<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button><button class="primary" ?disabled=${e.responding===!0} @click=${()=>{this.onOAuthRespond?.()}}>Submit</button></div>
|
|
1525
|
+
`:null}
|
|
1526
|
+
${s!==void 0?l`
|
|
1527
|
+
<p>${s.message}</p>
|
|
1528
|
+
<div class="inline-options">${s.options.map(r=>l`<button @click=${()=>{this.onOAuthRespond?.(r.value)}}>${r.label}</button>`)}</div>
|
|
1529
|
+
`:null}
|
|
1530
|
+
${e.error!==void 0&&e.error!==""?l`<div class="error-text">${e.error}</div>`:null}
|
|
1531
|
+
${t.status==="error"||t.status==="cancelled"?l`<div class="error-text">${t.error??t.status}</div><div class="actions"><button @click=${()=>{this.cancel()}}>Close</button></div>`:null}
|
|
1532
|
+
${i===void 0&&s===void 0&&t.status==="running"?l`<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button></div>`:null}
|
|
1533
|
+
</div>
|
|
1534
|
+
`}focusInputIfNeeded(){const e=Aw(this.state);if(e===void 0){this.lastFocusedInputKey=void 0;return}e!==this.lastFocusedInputKey&&(this.lastFocusedInputKey=e,this.input?.focus())}handleKeyDown(e){if(e.key==="Escape"){e.preventDefault(),this.cancel();return}if(e.key!=="Enter")return;const t=this.state;t?.step==="apiKey"?(e.preventDefault(),this.onSaveApiKey?.()):t?.step==="oauth"&&t.flow.prompt!==void 0&&(e.preventDefault(),this.onOAuthRespond?.())}cancel(){this.state?.step==="oauth"?this.onOAuthCancel?.():this.onCancel?.()}};ce.styles=[La,O`
|
|
1535
|
+
.form { display: grid; gap: 12px; padding: 14px; overflow: auto; }
|
|
1536
|
+
.form p { margin: 0; color: var(--pi-text-secondary); overflow-wrap: anywhere; }
|
|
1537
|
+
.form a { color: var(--pi-accent); overflow-wrap: anywhere; }
|
|
1538
|
+
.form code { border: 1px solid var(--pi-border); border-radius: 4px; background: var(--pi-surface); padding: 1px 4px; }
|
|
1539
|
+
label { color: var(--pi-muted); }
|
|
1540
|
+
.actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1541
|
+
.actions button, .inline-options button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; }
|
|
1542
|
+
.actions button.primary { border-color: var(--pi-success-border); background: var(--pi-success-surface); color: var(--pi-success); }
|
|
1543
|
+
.actions button:disabled { opacity: .6; cursor: wait; }
|
|
1544
|
+
.warning { color: var(--pi-warning); }
|
|
1545
|
+
.error-text { color: var(--pi-danger); }
|
|
1546
|
+
.progress { margin: 0; padding-left: 18px; color: var(--pi-muted); }
|
|
1547
|
+
.inline-options { display: grid; gap: 8px; }
|
|
1548
|
+
em { color: var(--pi-success); font-style: normal; font-size: 12px; }
|
|
1549
|
+
`];$e([d({attribute:!1})],ce.prototype,"state",2);$e([d({attribute:!1})],ce.prototype,"onChooseMethod",2);$e([d({attribute:!1})],ce.prototype,"onSelectProvider",2);$e([d({attribute:!1})],ce.prototype,"onApiKeyInput",2);$e([d({attribute:!1})],ce.prototype,"onSaveApiKey",2);$e([d({attribute:!1})],ce.prototype,"onLogoutProvider",2);$e([d({attribute:!1})],ce.prototype,"onOAuthInput",2);$e([d({attribute:!1})],ce.prototype,"onOAuthRespond",2);$e([d({attribute:!1})],ce.prototype,"onOAuthCancel",2);$e([d({attribute:!1})],ce.prototype,"onCancel",2);$e([z("input")],ce.prototype,"input",2);ce=$e([D("auth-dialog")],ce);function Cn(e){return e==="oauth"?"subscription":"API key"}function Aw(e){if(e?.step==="apiKey")return`api-key:${e.provider.authType}:${e.provider.id}`;if(e?.step==="oauth"&&e.flow.prompt!==void 0)return`oauth:${e.flow.flowId}:${e.flow.prompt.requestId}`}function Mw(e){if(e.status.source===void 0)return"";switch(e.status.source){case"stored":return"✓ configured";case"environment":return`✓ env${e.status.label===void 0?"":`: ${e.status.label}`}`;case"runtime":return"✓ runtime";case"fallback":return"✓ custom key";case"models_json_key":return"✓ models.json key";case"models_json_command":return"✓ models.json command";default:return""}}var Tw=Object.defineProperty,Ew=Object.getOwnPropertyDescriptor,_e=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ew(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Tw(t,i,r),r};let xe=class extends M{constructor(){super(...arguments),this.machineId="local",this.path="",this.createMissing=!0,this.suggestions=[],this.selected=0,this.loading=!1,this.requestId=0}connectedCallback(){super.connectedCallback(),this.loadSuggestions()}firstUpdated(){this.pathInput?.focus()}async loadSuggestions(){const e=++this.requestId;this.loading=!0;try{const t=await B.projectDirectories(this.path,this.machineId);if(e!==this.requestId)return;this.suggestions=t,this.selected=Math.min(this.selected,Math.max(0,t.length-1))}catch{e===this.requestId&&(this.suggestions=[])}finally{e===this.requestId&&(this.loading=!1)}}setPath(e){this.path=e,this.selected=0,this.loadSuggestions()}pick(e){this.setPath(e.path)}submit(){this.path.trim()!==""&&this.onSubmit?.(this.path,this.createMissing)}onPathInput(e){e.target instanceof HTMLInputElement&&this.setPath(e.target.value)}onCreateMissingChange(e){e.target instanceof HTMLInputElement&&(this.createMissing=e.target.checked)}onKeyDown(e){if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="Enter")e.preventDefault(),this.submit();else if(e.key==="ArrowDown")e.preventDefault(),this.selected=Math.min(this.selected+1,Math.max(0,this.suggestions.length-1));else if(e.key==="ArrowUp")e.preventDefault(),this.selected=Math.max(0,this.selected-1);else if(e.key==="Tab"){const t=this.suggestions[this.selected];if(t===void 0)return;e.preventDefault(),this.pick(t)}}render(){return l`
|
|
1550
|
+
<div class="backdrop" @click=${()=>this.onCancel?.()}>
|
|
1551
|
+
<section @click=${e=>{e.stopPropagation()}}>
|
|
1552
|
+
<header>
|
|
1553
|
+
<strong>Add project</strong>
|
|
1554
|
+
<button @click=${()=>{this.onCancel?.()}} aria-label="Close">×</button>
|
|
1555
|
+
</header>
|
|
1556
|
+
<div class="body">
|
|
1557
|
+
<label>
|
|
1558
|
+
Project folder
|
|
1559
|
+
<input .value=${this.path} @input=${e=>{this.onPathInput(e)}} @keydown=${e=>{this.onKeyDown(e)}} placeholder="/path/to/project or ~/code/project" autofocus />
|
|
1560
|
+
</label>
|
|
1561
|
+
<div class="suggestions">
|
|
1562
|
+
${this.loading?l`<div class="hint">Loading folders…</div>`:null}
|
|
1563
|
+
${this.suggestions.map((e,t)=>l`
|
|
1564
|
+
<button class=${t===this.selected?"selected":""} @click=${()=>{this.pick(e)}}>
|
|
1565
|
+
${e.path}
|
|
1566
|
+
</button>
|
|
1567
|
+
`)}
|
|
1568
|
+
${!this.loading&&this.suggestions.length===0?l`<div class="hint">No matching folders. Enter a new path to create it.</div>`:null}
|
|
1569
|
+
</div>
|
|
1570
|
+
<label class="check">
|
|
1571
|
+
<input type="checkbox" .checked=${this.createMissing} @change=${e=>{this.onCreateMissingChange(e)}} />
|
|
1572
|
+
Create the folder if it does not exist
|
|
1573
|
+
</label>
|
|
1574
|
+
</div>
|
|
1575
|
+
<footer>
|
|
1576
|
+
<button @click=${()=>{this.onCancel?.()}}>Cancel</button>
|
|
1577
|
+
<button class="primary" ?disabled=${this.path.trim()===""} @click=${()=>{this.submit()}}>Add project</button>
|
|
1578
|
+
</footer>
|
|
1579
|
+
</section>
|
|
1580
|
+
</div>
|
|
1581
|
+
`}};xe.styles=O`
|
|
1582
|
+
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1583
|
+
.backdrop { display: grid; place-items: start center; width: 100%; height: 100%; padding-top: min(12vh, 90px); box-sizing: border-box; background: var(--pi-overlay); }
|
|
1584
|
+
section { width: min(720px, calc(100vw - 40px)); max-height: min(700px, calc(100vh - 40px)); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
1585
|
+
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
1586
|
+
footer { border-top: 1px solid var(--pi-border); border-bottom: 0; justify-content: end; }
|
|
1587
|
+
.body { display: grid; gap: 12px; padding: 12px; min-height: 0; }
|
|
1588
|
+
label { display: grid; gap: 6px; color: var(--pi-muted); }
|
|
1589
|
+
input[type="text"], input:not([type]) { box-sizing: border-box; width: 100%; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 9px; font: 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1590
|
+
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; color: var(--pi-text); }
|
|
1591
|
+
.suggestions { min-height: 90px; max-height: 320px; overflow: auto; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); }
|
|
1592
|
+
.suggestions button { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-bottom: 1px solid var(--pi-border); border-radius: 0; background: transparent; color: var(--pi-text); padding: 8px 10px; text-align: left; font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1593
|
+
.suggestions button.selected, .suggestions button:hover { background: var(--pi-selection-bg); }
|
|
1594
|
+
.hint { padding: 12px; color: var(--pi-muted); }
|
|
1595
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1596
|
+
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
1597
|
+
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
1598
|
+
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
1599
|
+
`;_e([d({attribute:!1})],xe.prototype,"onSubmit",2);_e([d({attribute:!1})],xe.prototype,"onCancel",2);_e([d()],xe.prototype,"machineId",2);_e([v()],xe.prototype,"path",2);_e([v()],xe.prototype,"createMissing",2);_e([v()],xe.prototype,"suggestions",2);_e([v()],xe.prototype,"selected",2);_e([v()],xe.prototype,"loading",2);_e([z("input")],xe.prototype,"pathInput",2);xe=_e([D("project-dialog")],xe);var Dw=Object.defineProperty,Ww=Object.getOwnPropertyDescriptor,Le=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ww(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Dw(t,i,r),r};let Se=class extends M{constructor(){super(...arguments),this.error="",this.url="",this.name="",this.token="",this.submitting=!1,this.nameEdited=!1,this.previousSuggestedName=""}firstUpdated(){this.urlInput?.focus()}handleUrlInput(e){if(!(e.target instanceof HTMLInputElement))return;const t=e.target.value,i=Ow(t);(!this.nameEdited||this.name.trim()===""||this.name===this.previousSuggestedName)&&(this.name=i),this.previousSuggestedName=i,this.url=t}handleNameInput(e){e.target instanceof HTMLInputElement&&(this.nameEdited=!0,this.name=e.target.value)}handleTokenInput(e){e.target instanceof HTMLInputElement&&(this.token=e.target.value)}handleKeyDown(e){if(e.key==="Escape"){e.preventDefault(),this.onCancel?.();return}e.key==="Enter"&&e.target instanceof HTMLInputElement&&e.target.name==="baseUrl"&&Cs(this.url)===void 0&&(e.preventDefault(),this.updateComplete.then(()=>{this.nameInput?.focus(),this.nameInput?.select()}))}handleSubmit(e){e.preventDefault(),this.submit()}async submit(){const e=this.validInput();if(!(e===void 0||this.submitting)){this.submitting=!0;try{await this.onSubmit?.(e)}finally{this.isConnected&&(this.submitting=!1)}}}validInput(){const e=this.url.trim(),t=this.name.trim();if(e===""||t===""||Cs(e)!==void 0)return;const i=this.token.trim();return{name:t,baseUrl:e,...i===""?{}:{token:i}}}render(){const e=this.url.trim()!=="",t=e?Cs(this.url):void 0,i=this.validInput()!==void 0&&!this.submitting;return l`
|
|
1600
|
+
<div class="backdrop" @click=${()=>this.onCancel?.()}>
|
|
1601
|
+
<section @click=${s=>{s.stopPropagation()}}>
|
|
1602
|
+
<form @submit=${s=>{this.handleSubmit(s)}} @keydown=${s=>{this.handleKeyDown(s)}}>
|
|
1603
|
+
<header>
|
|
1604
|
+
<strong>Add machine</strong>
|
|
1605
|
+
<button type="button" @click=${()=>{this.onCancel?.()}} aria-label="Close">×</button>
|
|
1606
|
+
</header>
|
|
1607
|
+
<div class="body">
|
|
1608
|
+
${this.error===""?null:l`<div class="dialog-error" role="alert">${this.error}</div>`}
|
|
1609
|
+
<label>
|
|
1610
|
+
Remote PI WEB URL
|
|
1611
|
+
<input name="baseUrl" type="url" .value=${this.url} @input=${s=>{this.handleUrlInput(s)}} placeholder="http://dev-box.local:8504" autocomplete="url" inputmode="url" autofocus />
|
|
1612
|
+
</label>
|
|
1613
|
+
<small class=${t===void 0?"hint":"field-error"}>${t??"Enter the reachable base URL first, including http:// or https://."}</small>
|
|
1614
|
+
${e?l`
|
|
1615
|
+
<label>
|
|
1616
|
+
Machine name
|
|
1617
|
+
<input name="name" type="text" .value=${this.name} @input=${s=>{this.handleNameInput(s)}} placeholder=${this.previousSuggestedName||"Dev Box"} autocomplete="off" />
|
|
1618
|
+
</label>
|
|
1619
|
+
<small class="hint">Suggested from the URL. Edit it to use a friendlier sidebar label.</small>
|
|
1620
|
+
<label>
|
|
1621
|
+
Bearer token <span class="optional">optional</span>
|
|
1622
|
+
<input name="token" type="password" .value=${this.token} @input=${s=>{this.handleTokenInput(s)}} placeholder="Leave blank if the remote machine does not require one" autocomplete="off" />
|
|
1623
|
+
</label>
|
|
1624
|
+
<small class="hint">Paste only the token value; PI WEB sends it as an Authorization: Bearer header.</small>
|
|
1625
|
+
`:l`<p class="hint intro">After you enter a URL, PI WEB will suggest a machine name and let you add an optional bearer token.</p>`}
|
|
1626
|
+
</div>
|
|
1627
|
+
<footer>
|
|
1628
|
+
<button type="button" @click=${()=>{this.onCancel?.()}}>Cancel</button>
|
|
1629
|
+
<button class="primary" type="submit" ?disabled=${!i}>${this.submitting?"Adding…":"Add machine"}</button>
|
|
1630
|
+
</footer>
|
|
1631
|
+
</form>
|
|
1632
|
+
</section>
|
|
1633
|
+
</div>
|
|
1634
|
+
`}};Se.styles=O`
|
|
1635
|
+
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1636
|
+
.backdrop { display: grid; place-items: start center; width: 100%; height: 100%; padding-top: min(12vh, 90px); box-sizing: border-box; background: var(--pi-overlay); }
|
|
1637
|
+
section { width: min(560px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 40px)); border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
1638
|
+
form { display: flex; flex-direction: column; max-height: inherit; min-height: 0; }
|
|
1639
|
+
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
1640
|
+
footer { border-top: 1px solid var(--pi-border); border-bottom: 0; justify-content: end; }
|
|
1641
|
+
.body { display: grid; gap: 8px; padding: 12px; min-height: 0; overflow: auto; }
|
|
1642
|
+
label { display: grid; gap: 6px; color: var(--pi-muted); }
|
|
1643
|
+
input { box-sizing: border-box; width: 100%; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 9px; font: 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1644
|
+
input:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 1px; }
|
|
1645
|
+
.hint { color: var(--pi-muted); }
|
|
1646
|
+
.intro { margin: 4px 0 0; line-height: 1.4; }
|
|
1647
|
+
.optional { color: var(--pi-muted); font-weight: 400; }
|
|
1648
|
+
.field-error { color: var(--pi-danger); }
|
|
1649
|
+
.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; }
|
|
1650
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1651
|
+
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
1652
|
+
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
1653
|
+
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
1654
|
+
`;Le([d({attribute:!1})],Se.prototype,"onSubmit",2);Le([d({attribute:!1})],Se.prototype,"onCancel",2);Le([d()],Se.prototype,"error",2);Le([v()],Se.prototype,"url",2);Le([v()],Se.prototype,"name",2);Le([v()],Se.prototype,"token",2);Le([v()],Se.prototype,"submitting",2);Le([z("input[name='baseUrl']")],Se.prototype,"urlInput",2);Le([z("input[name='name']")],Se.prototype,"nameInput",2);Se=Le([D("machine-dialog")],Se);function Ow(e){const t=e.trim();if(t==="")return"";const i=Rn(t)??Rn(`http://${t.replace(/^\/+/u,"")}`);return i!==void 0&&i.hostname!==""?i.hostname.replace(/^\[(.*)\]$/u,"$1"):jw(t)}function Cs(e){const t=e.trim();if(t==="")return"Remote PI WEB URL is required.";let i;try{i=new URL(t)}catch{return"Enter a valid URL including http:// or https://."}if(i.protocol!=="http:"&&i.protocol!=="https:")return"Use an http:// or https:// URL.";if(i.username!==""||i.password!=="")return"Do not include credentials in the machine URL.";if(i.search!==""||i.hash!=="")return"Do not include a query string or fragment."}function Rn(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t:void 0}catch{return}}function jw(e){const t=e.replace(/^[a-z][a-z\d+.-]*:\/\//iu,""),s=t.slice(t.lastIndexOf("@")+1).split(/[/?#]/u)[0]??"";return s.startsWith("[")&&s.includes("]")?s.slice(1,s.indexOf("]")):s.replace(/:\d+$/u,"")}function _w(){return{host:"",port:"",allowedHostsMode:"list",allowedHostsText:"",allowedPathsText:""}}function Lw(e){return{host:e.host??"",port:e.port===void 0?"":String(e.port),allowedHostsMode:e.allowedHosts===!0?"all":"list",allowedHostsText:Array.isArray(e.allowedHosts)?e.allowedHosts.join(`
|
|
1655
|
+
`):"",allowedPathsText:e.pathAccess?.allowedPaths?.join(`
|
|
1656
|
+
`)??""}}function Fw(e,t={}){const i={...t.shortcuts===void 0?{}:{shortcuts:t.shortcuts},...t.plugins===void 0?{}:{plugins:t.plugins},...t.uploads===void 0?{}:{uploads:t.uploads},...t.maxUploadBytes===void 0?{}:{maxUploadBytes:t.maxUploadBytes},...t.spawnSessions===void 0?{}:{spawnSessions:t.spawnSessions},...t.subsessions===void 0?{}:{subsessions:t.subsessions}},s=e.host.trim(),r=e.port.trim();if(s!==""&&(i.host=s),r!==""){const n=Number(r);if(!Number.isInteger(n)||n<1||n>65535)throw new Error("Port must be an integer from 1 to 65535.");i.port=n}i.allowedHosts=e.allowedHostsMode==="all"?!0:Nw(e.allowedHostsText);const o=Uw(e.allowedPathsText);return o.length>0&&(i.pathAccess={allowedPaths:o}),i}function Nw(e){return e.split(/[\n,]/u).map(t=>t.trim()).filter(t=>t!=="")}function Uw(e){const t=e.split(`
|
|
1657
|
+
`).map(s=>s.trim()).filter(s=>s!==""),i=t.find(s=>!zw(s));if(i!==void 0)throw new Error(`Allowed external paths must be absolute paths or start with ~: ${i}`);return t}function zw(e){return e==="~"||e.startsWith("~/")||e.startsWith("~\\")||e.startsWith("/")||e.startsWith("\\")||/^[A-Za-z]:[\\/]/u.test(e)}var Bw=Object.defineProperty,Hw=Object.getOwnPropertyDescriptor,Fe=(e,t,i,s)=>{for(var r=s>1?void 0:s?Hw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Bw(t,i,r),r};let ke=class extends M{constructor(){super(...arguments),this.loading=!1,this.saving=!1,this.error="",this.savedMessage="",this.draft=_w(),this.localError=""}willUpdate(e){e.has("configResponse")&&this.configResponse!==void 0&&(this.draft=Lw(this.configResponse.config),this.localError="")}render(){const e=this.configResponse;return l`
|
|
1658
|
+
<div class="section-heading">
|
|
1659
|
+
<div>
|
|
1660
|
+
<h2>General configuration</h2>
|
|
1661
|
+
<p>Update the JSON config file PI WEB is using. Host and port changes are saved immediately, but require the web service to restart before the running server binds to the new address.</p>
|
|
1662
|
+
</div>
|
|
1663
|
+
<button class="secondary" ?disabled=${this.loading} @click=${()=>{this.onReload?.()}}>Reload</button>
|
|
1664
|
+
</div>
|
|
1665
|
+
${this.renderMessages()}
|
|
1666
|
+
${e===void 0&&this.loading?l`<div class="loading-card">Loading configuration…</div>`:l`
|
|
1667
|
+
<div class="config-path-card">
|
|
1668
|
+
<span>Config file</span>
|
|
1669
|
+
<code>${e?.path??"Unknown"}</code>
|
|
1670
|
+
<small>${e?.exists===!0?"Existing file":"This file will be created on save"}</small>
|
|
1671
|
+
</div>
|
|
1672
|
+
<form class="config-form" @submit=${t=>{this.saveConfig(t)}}>
|
|
1673
|
+
<label class="field">
|
|
1674
|
+
<span class="field-heading">
|
|
1675
|
+
<span>Host</span>
|
|
1676
|
+
${this.renderOverrideBadge("host")}
|
|
1677
|
+
</span>
|
|
1678
|
+
<input .value=${this.draft.host} placeholder="127.0.0.1" autocomplete="off" spellcheck="false" @input=${t=>{this.updateDraft({host:In(t)})}}>
|
|
1679
|
+
<small>Address the web server should bind to. Leave empty to use PI WEB's default.</small>
|
|
1680
|
+
</label>
|
|
1681
|
+
|
|
1682
|
+
<label class="field">
|
|
1683
|
+
<span class="field-heading">
|
|
1684
|
+
<span>Port</span>
|
|
1685
|
+
${this.renderOverrideBadge("port")}
|
|
1686
|
+
</span>
|
|
1687
|
+
<input .value=${this.draft.port} inputmode="numeric" pattern="[0-9]*" placeholder="8504" autocomplete="off" @input=${t=>{this.updateDraft({port:In(t)})}}>
|
|
1688
|
+
<small>TCP port from 1 to 65535. Leave empty to use PI WEB's default.</small>
|
|
1689
|
+
</label>
|
|
1690
|
+
|
|
1691
|
+
<div class="field">
|
|
1692
|
+
<span class="field-heading">
|
|
1693
|
+
<span>Allowed hosts</span>
|
|
1694
|
+
${this.renderOverrideBadge("allowedHosts")}
|
|
1695
|
+
</span>
|
|
1696
|
+
<select .value=${this.draft.allowedHostsMode} @change=${t=>{this.updateDraft({allowedHostsMode:Vw(t)==="all"?"all":"list"})}}>
|
|
1697
|
+
<option value="list">Only listed hosts</option>
|
|
1698
|
+
<option value="all">Allow every host</option>
|
|
1699
|
+
</select>
|
|
1700
|
+
<textarea .value=${this.draft.allowedHostsText} ?disabled=${this.draft.allowedHostsMode==="all"} rows="4" placeholder="example.local 192.168.1.20" spellcheck="false" @input=${t=>{this.updateDraft({allowedHostsText:An(t)})}}></textarea>
|
|
1701
|
+
<small>Enter one host per line, or choose “Allow every host” to write <code>true</code>.</small>
|
|
1702
|
+
</div>
|
|
1703
|
+
|
|
1704
|
+
<label class="field">
|
|
1705
|
+
<span class="field-heading">
|
|
1706
|
+
<span>External filesystem roots</span>
|
|
1707
|
+
</span>
|
|
1708
|
+
<textarea .value=${this.draft.allowedPathsText} rows="4" placeholder="~/SDKs /opt/reference" spellcheck="false" @input=${t=>{this.updateDraft({allowedPathsText:An(t)})}}></textarea>
|
|
1709
|
+
<small>Global allowlist for absolute <code>@</code> completions and file explorer reads outside a workspace. Enter one absolute path, Windows absolute path, or <code>~</code>-prefixed path per line. Leave empty to deny external paths by default.</small>
|
|
1710
|
+
</label>
|
|
1711
|
+
|
|
1712
|
+
${this.renderEffectiveConfig()}
|
|
1713
|
+
|
|
1714
|
+
<footer class="form-actions">
|
|
1715
|
+
<button class="primary" ?disabled=${this.loading||this.saving}>${this.saving?"Saving…":"Save config"}</button>
|
|
1716
|
+
</footer>
|
|
1717
|
+
</form>
|
|
1718
|
+
`}
|
|
1719
|
+
`}renderMessages(){const e=this.localError||this.error;return e!==""?l`<div class="message error-message">${e}</div>`:this.savedMessage!==""?l`<div class="message success-message">${this.savedMessage}</div>`:null}renderOverrideBadge(e){return this.configResponse?.envOverrides[e]!==!0?null:l`<span class="override-badge">environment override</span>`}renderEffectiveConfig(){const e=this.configResponse?.effectiveConfig??{};return l`
|
|
1720
|
+
<section class="effective-card" aria-label="Effective configuration summary">
|
|
1721
|
+
<h3>Effective after environment overrides</h3>
|
|
1722
|
+
<dl>
|
|
1723
|
+
<div><dt>Host</dt><dd>${e.host??l`<span class="muted">127.0.0.1 default</span>`}</dd></div>
|
|
1724
|
+
<div><dt>Port</dt><dd>${e.port??l`<span class="muted">8504 default</span>`}</dd></div>
|
|
1725
|
+
<div><dt>Allowed hosts</dt><dd>${qw(e.allowedHosts)}</dd></div>
|
|
1726
|
+
<div><dt>External roots</dt><dd>${Kw(e.pathAccess?.allowedPaths)}</dd></div>
|
|
1727
|
+
</dl>
|
|
1728
|
+
</section>
|
|
1729
|
+
`}async saveConfig(e){e.preventDefault(),this.localError="";try{await this.onSave?.(Fw(this.draft,this.configResponse?.config??{}))}catch(t){this.localError=Gw(t)}}updateDraft(e){this.draft={...this.draft,...e},this.localError=""}};ke.styles=O`
|
|
1730
|
+
:host { display: block; }
|
|
1731
|
+
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
|
1732
|
+
.section-heading > div { display: grid; gap: 6px; min-width: 0; }
|
|
1733
|
+
h2, h3, p { margin: 0; }
|
|
1734
|
+
h2 { font-size: 17px; line-height: 1.25; }
|
|
1735
|
+
h3 { font-size: 13px; line-height: 1.3; }
|
|
1736
|
+
p { color: var(--pi-muted); line-height: 1.45; }
|
|
1737
|
+
button, input, select, textarea { font: inherit; }
|
|
1738
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1739
|
+
button:disabled { opacity: .55; cursor: not-allowed; }
|
|
1740
|
+
.secondary { flex: 0 0 auto; }
|
|
1741
|
+
.message, .loading-card, .config-path-card, .effective-card { border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); padding: 12px; }
|
|
1742
|
+
.message { margin-bottom: 12px; }
|
|
1743
|
+
.error-message { border-color: var(--pi-danger); color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-surface)); }
|
|
1744
|
+
.success-message { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-surface); }
|
|
1745
|
+
.loading-card { color: var(--pi-muted); }
|
|
1746
|
+
.config-path-card { display: grid; gap: 5px; margin-bottom: 14px; }
|
|
1747
|
+
.config-path-card span, .field-heading, dt { color: var(--pi-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
|
|
1748
|
+
code { border: 1px solid var(--pi-border-muted); border-radius: 5px; background: var(--pi-bg); padding: 1px 4px; color: var(--pi-text); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
|
|
1749
|
+
.config-path-card small, .field small { color: var(--pi-muted); }
|
|
1750
|
+
.config-form { display: grid; gap: 14px; }
|
|
1751
|
+
.field { display: grid; gap: 7px; }
|
|
1752
|
+
.field-heading { display: flex; align-items: center; gap: 8px; }
|
|
1753
|
+
input, select, textarea { box-sizing: border-box; width: 100%; min-width: 0; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 9px 10px; outline: none; }
|
|
1754
|
+
input:focus, select:focus, textarea:focus { border-color: var(--pi-accent); box-shadow: 0 0 0 1px var(--pi-accent-border); }
|
|
1755
|
+
textarea { resize: vertical; min-height: 94px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1756
|
+
textarea:disabled { opacity: .55; }
|
|
1757
|
+
.override-badge { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); background: var(--pi-warning-surface); padding: 2px 7px; font-size: 11px; font-weight: 600; text-transform: none; }
|
|
1758
|
+
.effective-card { display: grid; gap: 10px; }
|
|
1759
|
+
.effective-card dl { display: grid; gap: 8px; margin: 0; }
|
|
1760
|
+
.effective-card dl > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: baseline; }
|
|
1761
|
+
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
|
|
1762
|
+
.muted { color: var(--pi-muted); }
|
|
1763
|
+
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }
|
|
1764
|
+
.primary { border-color: var(--pi-accent); background: var(--pi-selection-bg); color: var(--pi-text-bright); }
|
|
1765
|
+
|
|
1766
|
+
@media (max-width: 760px) {
|
|
1767
|
+
.section-heading { display: grid; gap: 12px; }
|
|
1768
|
+
.section-heading .secondary { justify-self: start; }
|
|
1769
|
+
.effective-card dl > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
|
1770
|
+
}
|
|
1771
|
+
`;Fe([d({attribute:!1})],ke.prototype,"configResponse",2);Fe([d({type:Boolean})],ke.prototype,"loading",2);Fe([d({type:Boolean})],ke.prototype,"saving",2);Fe([d()],ke.prototype,"error",2);Fe([d()],ke.prototype,"savedMessage",2);Fe([d({attribute:!1})],ke.prototype,"onReload",2);Fe([d({attribute:!1})],ke.prototype,"onSave",2);Fe([v()],ke.prototype,"draft",2);Fe([v()],ke.prototype,"localError",2);ke=Fe([D("settings-general-panel")],ke);function qw(e){return e===!0?"Any host":Array.isArray(e)?e.length===0?l`<span class="muted">None listed</span>`:e.join(", "):l`<span class="muted">Unset</span>`}function Kw(e){return e===void 0||e.length===0?l`<span class="muted">External paths denied</span>`:e.join(", ")}function In(e){return e.target instanceof HTMLInputElement?e.target.value:""}function Vw(e){return e.target instanceof HTMLSelectElement?e.target.value:""}function An(e){return e.target instanceof HTMLTextAreaElement?e.target.value:""}function Gw(e){return e instanceof Error?e.message:String(e)}var Qw=Object.defineProperty,Jw=Object.getOwnPropertyDescriptor,Ye=(e,t,i,s)=>{for(var r=s>1?void 0:s?Jw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Qw(t,i,r),r};let je=class extends M{constructor(){super(...arguments),this.loading=!1,this.saving=!1,this.error="",this.savedMessage=""}render(){const e=this.configResponse,t=e?.envOverrides.spawnSessions===!0,i=e?.effectiveConfig.spawnSessions!==!1,s=e?.envOverrides.subsessions===!0,r=e?.effectiveConfig.subsessions===!0&&i;return l`
|
|
1772
|
+
<div class="section-heading">
|
|
1773
|
+
<div>
|
|
1774
|
+
<h2>Session daemon</h2>
|
|
1775
|
+
<p>These settings affect the long-lived session runtime. Changes are saved to the config file immediately but only take effect after the session daemon restarts.</p>
|
|
1776
|
+
</div>
|
|
1777
|
+
<button class="secondary" ?disabled=${this.loading} @click=${()=>{this.onReload?.()}}>Reload</button>
|
|
1778
|
+
</div>
|
|
1779
|
+
${this.renderMessages()}
|
|
1780
|
+
<div class="restart-note" role="note">Restart required: run <code>pi-web restart</code> (or restart the session daemon service) after changing these settings.</div>
|
|
1781
|
+
${e===void 0&&this.loading?l`<div class="loading-card">Loading configuration…</div>`:l`
|
|
1782
|
+
<div class="config-path-card">
|
|
1783
|
+
<span>Config file</span>
|
|
1784
|
+
<code>${e?.path??"Unknown"}</code>
|
|
1785
|
+
</div>
|
|
1786
|
+
<div class="field">
|
|
1787
|
+
<span class="field-heading">
|
|
1788
|
+
<span>Allow agents to start sessions</span>
|
|
1789
|
+
${t?l`<span class="override-badge">environment override</span>`:null}
|
|
1790
|
+
</span>
|
|
1791
|
+
<label class="toggle">
|
|
1792
|
+
<input
|
|
1793
|
+
type="checkbox"
|
|
1794
|
+
.checked=${i}
|
|
1795
|
+
?disabled=${this.loading||this.saving||t}
|
|
1796
|
+
@change=${o=>{this.toggleSpawnSessions(o)}}
|
|
1797
|
+
>
|
|
1798
|
+
<span>Enable the <code>spawn_session</code> tool</span>
|
|
1799
|
+
</label>
|
|
1800
|
+
<small>When enabled, LLMs can start new sessions, constrained to a workspace (any worktree) of the same registered project so every spawned session stays visible here. On by default.</small>
|
|
1801
|
+
</div>
|
|
1802
|
+
<div class="field">
|
|
1803
|
+
<span class="field-heading">
|
|
1804
|
+
<span>Allow agents to start tracked subsessions</span>
|
|
1805
|
+
<span class="beta-badge">beta</span>
|
|
1806
|
+
${s?l`<span class="override-badge">environment override</span>`:null}
|
|
1807
|
+
</span>
|
|
1808
|
+
<label class="toggle">
|
|
1809
|
+
<input
|
|
1810
|
+
type="checkbox"
|
|
1811
|
+
.checked=${r}
|
|
1812
|
+
?disabled=${this.loading||this.saving||s||!i}
|
|
1813
|
+
@change=${o=>{this.toggleSubsessions(o)}}
|
|
1814
|
+
>
|
|
1815
|
+
<span>Enable the <code>spawn_subsession</code> tools</span>
|
|
1816
|
+
</label>
|
|
1817
|
+
<small>Beta: agents can start child sessions they stay attached to (<code>spawn_subsession</code>, <code>list_subsessions</code>, <code>check_subsession</code>, <code>read_subsession</code>) and are notified when a child finishes. Requires "Allow agents to start sessions". Off by default.</small>
|
|
1818
|
+
</div>
|
|
1819
|
+
<section class="effective-card" aria-label="Effective configuration summary">
|
|
1820
|
+
<h3>Effective after environment overrides</h3>
|
|
1821
|
+
<dl>
|
|
1822
|
+
<div><dt>Spawn sessions</dt><dd>${i?"Enabled":l`<span class="muted">Disabled</span>`}</dd></div>
|
|
1823
|
+
<div><dt>Subsessions</dt><dd>${r?"Enabled":l`<span class="muted">Disabled</span>`}</dd></div>
|
|
1824
|
+
</dl>
|
|
1825
|
+
</section>
|
|
1826
|
+
`}
|
|
1827
|
+
`}renderMessages(){return this.error!==""?l`<div class="message error-message">${this.error}</div>`:this.savedMessage!==""?l`<div class="message success-message">${this.savedMessage}</div>`:null}async toggleSpawnSessions(e){const t=e.target instanceof HTMLInputElement&&e.target.checked,i=this.configResponse?.config??{};await this.onSave?.({...i,spawnSessions:t})}async toggleSubsessions(e){const t=e.target instanceof HTMLInputElement&&e.target.checked,i=this.configResponse?.config??{};await this.onSave?.({...i,subsessions:t})}};je.styles=O`
|
|
1828
|
+
:host { display: block; }
|
|
1829
|
+
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
|
1830
|
+
.section-heading > div { display: grid; gap: 6px; min-width: 0; }
|
|
1831
|
+
h2, h3, p { margin: 0; }
|
|
1832
|
+
h2 { font-size: 17px; line-height: 1.25; }
|
|
1833
|
+
h3 { font-size: 13px; line-height: 1.3; }
|
|
1834
|
+
p { color: var(--pi-muted); line-height: 1.45; }
|
|
1835
|
+
button, input { font: inherit; }
|
|
1836
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1837
|
+
button:disabled { opacity: .55; cursor: not-allowed; }
|
|
1838
|
+
.secondary { flex: 0 0 auto; }
|
|
1839
|
+
.message, .loading-card, .config-path-card, .effective-card, .restart-note { border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); padding: 12px; }
|
|
1840
|
+
.message { margin-bottom: 12px; }
|
|
1841
|
+
.error-message { border-color: var(--pi-danger); color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-surface)); }
|
|
1842
|
+
.success-message { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-surface); }
|
|
1843
|
+
.loading-card { color: var(--pi-muted); }
|
|
1844
|
+
.restart-note { margin-bottom: 14px; border-color: var(--pi-warning-border); color: var(--pi-warning); background: var(--pi-warning-surface); line-height: 1.45; }
|
|
1845
|
+
.config-path-card { display: grid; gap: 5px; margin-bottom: 14px; }
|
|
1846
|
+
.config-path-card span, .field-heading, dt { color: var(--pi-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
|
|
1847
|
+
code { border: 1px solid var(--pi-border-muted); border-radius: 5px; background: var(--pi-bg); padding: 1px 4px; color: var(--pi-text); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
|
|
1848
|
+
.field { display: grid; gap: 7px; margin-bottom: 14px; }
|
|
1849
|
+
.field small { color: var(--pi-muted); line-height: 1.45; }
|
|
1850
|
+
.field-heading { display: flex; align-items: center; gap: 8px; }
|
|
1851
|
+
.toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
|
|
1852
|
+
.toggle input { width: 16px; height: 16px; }
|
|
1853
|
+
.toggle input:disabled { cursor: not-allowed; }
|
|
1854
|
+
.override-badge { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); background: var(--pi-warning-surface); padding: 2px 7px; font-size: 11px; font-weight: 600; text-transform: none; }
|
|
1855
|
+
.beta-badge { border: 1px solid var(--pi-border); border-radius: 999px; color: var(--pi-muted); background: var(--pi-bg); padding: 2px 7px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
|
|
1856
|
+
.effective-card { display: grid; gap: 10px; }
|
|
1857
|
+
.effective-card dl { display: grid; gap: 8px; margin: 0; }
|
|
1858
|
+
.effective-card dl > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: baseline; }
|
|
1859
|
+
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
|
|
1860
|
+
.muted { color: var(--pi-muted); }
|
|
1861
|
+
|
|
1862
|
+
@media (max-width: 760px) {
|
|
1863
|
+
.section-heading { display: grid; gap: 12px; }
|
|
1864
|
+
.section-heading .secondary { justify-self: start; }
|
|
1865
|
+
.effective-card dl > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
|
1866
|
+
}
|
|
1867
|
+
`;Ye([d({attribute:!1})],je.prototype,"configResponse",2);Ye([d({type:Boolean})],je.prototype,"loading",2);Ye([d({type:Boolean})],je.prototype,"saving",2);Ye([d()],je.prototype,"error",2);Ye([d()],je.prototype,"savedMessage",2);Ye([d({attribute:!1})],je.prototype,"onReload",2);Ye([d({attribute:!1})],je.prototype,"onSave",2);je=Ye([D("settings-sessiond-panel")],je);var Zw=Object.defineProperty,Xw=Object.getOwnPropertyDescriptor,qe=(e,t,i,s)=>{for(var r=s>1?void 0:s?Xw(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Zw(t,i,r),r};let Ee=class extends M{constructor(){super(...arguments),this.loading=!1,this.saving=!1,this.error="",this.savedMessage=""}render(){const e=this.pluginsResponse?.plugins??[];return l`
|
|
1868
|
+
<div class="section-heading">
|
|
1869
|
+
<div>
|
|
1870
|
+
<h2>Plugins</h2>
|
|
1871
|
+
<p>Enable or disable discovered PI WEB plugins. Changes apply after reloading the browser tab; already-loaded plugin code is not unloaded from the current page.</p>
|
|
1872
|
+
</div>
|
|
1873
|
+
<button class="secondary" ?disabled=${this.loading} @click=${()=>{this.onReload?.()}}>Reload</button>
|
|
1874
|
+
</div>
|
|
1875
|
+
${this.renderMessages()}
|
|
1876
|
+
<div class="plugin-note">Config key: <code>plugins</code>. Plugins are enabled unless their entry sets <code>enabled</code> to <code>false</code>.</div>
|
|
1877
|
+
${this.loading&&e.length===0?l`<div class="loading-card">Loading plugins…</div>`:e.length===0?l`<div class="loading-card">No external or bundled plugins discovered.</div>`:l`
|
|
1878
|
+
<div class="plugin-list">
|
|
1879
|
+
${e.map(t=>this.renderPlugin(t))}
|
|
1880
|
+
</div>
|
|
1881
|
+
`}
|
|
1882
|
+
`}renderMessages(){return this.error!==""?l`<div class="message error-message">${this.error}</div>`:this.savedMessage!==""?l`<div class="message success-message">${this.savedMessage} Reload the browser tab to apply plugin changes.</div>`:null}renderPlugin(e){const t=this.configResponse?.config.plugins?.[e.id],i=t?.enabled===!1?"Config disabled":t?.enabled===!0?"Config enabled":"Default enabled";return l`
|
|
1883
|
+
<article class=${`plugin-card${e.enabled?"":" disabled"}`}>
|
|
1884
|
+
<div class="plugin-main">
|
|
1885
|
+
<strong>${e.id}</strong>
|
|
1886
|
+
<small>${e.source} · ${e.scope}${e.machineSpecific?" · machine-specific":""}</small>
|
|
1887
|
+
<small>${i}</small>
|
|
1888
|
+
</div>
|
|
1889
|
+
<label class="toggle">
|
|
1890
|
+
<input type="checkbox" .checked=${e.enabled} ?disabled=${this.saving} @change=${s=>{this.togglePlugin(e,s)}}>
|
|
1891
|
+
<span>${e.enabled?"Enabled":"Disabled"}</span>
|
|
1892
|
+
</label>
|
|
1893
|
+
</article>
|
|
1894
|
+
`}async togglePlugin(e,t){const i=t.target instanceof HTMLInputElement?t.target.checked:e.enabled;await this.onTogglePlugin?.(e.id,i)}};Ee.styles=O`
|
|
1895
|
+
:host { display: block; }
|
|
1896
|
+
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
|
1897
|
+
.section-heading > div { display: grid; gap: 6px; min-width: 0; }
|
|
1898
|
+
h2, p { margin: 0; }
|
|
1899
|
+
h2 { font-size: 17px; line-height: 1.25; }
|
|
1900
|
+
p { color: var(--pi-muted); line-height: 1.45; }
|
|
1901
|
+
button, input { font: inherit; }
|
|
1902
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1903
|
+
button:disabled, input:disabled { opacity: .55; cursor: not-allowed; }
|
|
1904
|
+
.secondary { flex: 0 0 auto; }
|
|
1905
|
+
.message, .loading-card, .plugin-note, .plugin-card { border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); padding: 12px; }
|
|
1906
|
+
.message { margin-bottom: 12px; }
|
|
1907
|
+
.error-message { border-color: var(--pi-danger); color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-surface)); }
|
|
1908
|
+
.success-message { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-surface); }
|
|
1909
|
+
.loading-card, .plugin-note { color: var(--pi-muted); }
|
|
1910
|
+
.plugin-note { margin-bottom: 14px; }
|
|
1911
|
+
code { border: 1px solid var(--pi-border-muted); border-radius: 5px; background: var(--pi-bg); padding: 1px 4px; color: var(--pi-text); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
|
|
1912
|
+
.plugin-list { display: grid; gap: 10px; }
|
|
1913
|
+
.plugin-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
|
|
1914
|
+
.plugin-card.disabled { opacity: .75; }
|
|
1915
|
+
.plugin-main { min-width: 0; display: grid; gap: 3px; }
|
|
1916
|
+
.plugin-main strong, .plugin-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1917
|
+
.plugin-main small { color: var(--pi-muted); }
|
|
1918
|
+
.toggle { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
|
|
1919
|
+
.toggle input { width: 18px; height: 18px; accent-color: var(--pi-accent); }
|
|
1920
|
+
|
|
1921
|
+
@media (max-width: 760px) {
|
|
1922
|
+
.section-heading { display: grid; gap: 12px; }
|
|
1923
|
+
.section-heading .secondary { justify-self: start; }
|
|
1924
|
+
.plugin-card { grid-template-columns: minmax(0, 1fr); align-items: start; }
|
|
1925
|
+
.toggle { justify-self: start; }
|
|
1926
|
+
}
|
|
1927
|
+
`;qe([d({attribute:!1})],Ee.prototype,"pluginsResponse",2);qe([d({attribute:!1})],Ee.prototype,"configResponse",2);qe([d({type:Boolean})],Ee.prototype,"loading",2);qe([d({type:Boolean})],Ee.prototype,"saving",2);qe([d()],Ee.prototype,"error",2);qe([d()],Ee.prototype,"savedMessage",2);qe([d({attribute:!1})],Ee.prototype,"onReload",2);qe([d({attribute:!1})],Ee.prototype,"onTogglePlugin",2);Ee=qe([D("settings-plugins-panel")],Ee);var Yw=Object.defineProperty,ey=Object.getOwnPropertyDescriptor,ge=(e,t,i,s)=>{for(var r=s>1?void 0:s?ey(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Yw(t,i,r),r};const Mn={capture:!0},ty=[{value:"auto",label:"Auto/default",description:"Desktop-like Enter sends; mobile, coarse pointer, or narrow screens insert a new line."},{value:"send",label:"Enter sends message",description:"Enter sends the chat message; Shift+Enter adds a new line when supported."},{value:"newline",label:"Enter inserts new line",description:"Enter adds a line break; Shift+Enter sends the chat message when supported."}];let re=class extends M{constructor(){super(...arguments),this.actions=[],this.loading=!1,this.saving=!1,this.error="",this.savedMessage="",this.drafts={},this.localError="",this.promptEnterPreference=rs(),this.recordingListenerActive=!1,this.onRecordKeyDown=e=>{const t=this.recording;if(t===void 0)return;if(e.preventDefault(),e.stopPropagation(),e.key==="Escape"){this.stopRecording();return}const i=Ia(e);if(i===void 0){this.localError="Press a letter, number, punctuation, function, or navigation key. Press Esc to cancel recording.";return}if(t.tokens.length===0&&!qt(i)){this.localError="Start shortcuts with Ctrl/⌘ or Alt so normal typing is not captured.";return}const s=[...t.tokens,i];this.localError="",this.drafts={[t.actionId]:s.join(" ")},this.recording={actionId:t.actionId,tokens:s},this.armRecordingTimer()}}willUpdate(e){e.has("configResponse")&&this.configResponse!==void 0&&(this.drafts={},this.localError="",this.stopRecording())}disconnectedCallback(){this.stopRecording(),super.disconnectedCallback()}render(){const e=oy(this.actions),t=this.shortcutResolutions();return l`
|
|
1928
|
+
<div class="section-heading">
|
|
1929
|
+
<div>
|
|
1930
|
+
<h2>Keyboard shortcuts</h2>
|
|
1931
|
+
<p>Edit app shortcuts by action. Type a shortcut such as <code>mod+k</code> or <code>mod+g p</code>, record one from the keyboard, disable it with None, or reset it to the default. When shortcuts conflict, custom shortcuts win before defaults; ties are resolved by action id, and shorter shortcuts shadow longer sequences with the same prefix.</p>
|
|
1932
|
+
</div>
|
|
1933
|
+
<button class="secondary" ?disabled=${this.loading} @click=${()=>{this.onReload?.()}}>Reload</button>
|
|
1934
|
+
</div>
|
|
1935
|
+
${this.renderMessages()}
|
|
1936
|
+
${this.renderPromptEnterPreferenceCard()}
|
|
1937
|
+
${this.configResponse===void 0&&this.loading?l`<div class="loading-card">Loading shortcuts…</div>`:l`
|
|
1938
|
+
<div class="config-path-card">
|
|
1939
|
+
<span>Config file</span>
|
|
1940
|
+
<code>${this.configResponse?.path??"Unknown"}</code>
|
|
1941
|
+
<small>Shortcut overrides are saved under <code>shortcuts</code>. A value of <code>null</code> disables the action shortcut.</small>
|
|
1942
|
+
</div>
|
|
1943
|
+
${e.length===0?l`<div class="loading-card">No actions registered.</div>`:e.map(i=>l`
|
|
1944
|
+
<section class="shortcut-group">
|
|
1945
|
+
<h3>${i.name}</h3>
|
|
1946
|
+
<div class="shortcut-list">
|
|
1947
|
+
${i.actions.map(s=>this.renderShortcutRow(s,t.get(s.id)))}
|
|
1948
|
+
</div>
|
|
1949
|
+
</section>
|
|
1950
|
+
`)}
|
|
1951
|
+
`}
|
|
1952
|
+
`}renderMessages(){const e=this.localError||this.error;return e!==""?l`<div class="message error-message">${e}</div>`:this.savedMessage!==""?l`<div class="message success-message">${this.savedMessage}</div>`:null}renderPromptEnterPreferenceCard(){return l`
|
|
1953
|
+
<section class="prompt-enter-card" aria-labelledby="prompt-enter-preference-title">
|
|
1954
|
+
<div class="prompt-enter-copy">
|
|
1955
|
+
<span class="card-eyebrow">Chat composer</span>
|
|
1956
|
+
<h3 id="prompt-enter-preference-title">Enter key behavior</h3>
|
|
1957
|
+
<p>Choose what Enter does in this browser. Shift+Enter does the opposite when supported; automatic touch-keyboard capitalization is ignored to avoid accidental sends.</p>
|
|
1958
|
+
</div>
|
|
1959
|
+
<div class="prompt-enter-options" role="radiogroup" aria-label="Enter and Shift Enter behavior in the chat composer">
|
|
1960
|
+
${ty.map(e=>l`
|
|
1961
|
+
<label class="prompt-enter-option">
|
|
1962
|
+
<input
|
|
1963
|
+
type="radio"
|
|
1964
|
+
name="prompt-enter-preference"
|
|
1965
|
+
.value=${e.value}
|
|
1966
|
+
.checked=${this.promptEnterPreference===e.value}
|
|
1967
|
+
@change=${()=>{this.updatePromptEnterPreference(e.value)}}
|
|
1968
|
+
>
|
|
1969
|
+
<span>
|
|
1970
|
+
<strong>${e.label}</strong>
|
|
1971
|
+
<small>${e.description}</small>
|
|
1972
|
+
</span>
|
|
1973
|
+
</label>
|
|
1974
|
+
`)}
|
|
1975
|
+
</div>
|
|
1976
|
+
</section>
|
|
1977
|
+
`}updatePromptEnterPreference(e){this.promptEnterPreference=e,Gb(e)}renderShortcutRow(e,t){const i=this.configResponse?.config.shortcuts,s=zi(e.id,i),r=cy(e,i),o=this.shortcutInputText(e),n=o.trim()===""?void 0:fs(o),a=n?.ok===!0?n.shortcut:ly(e,i),c=s!==void 0,p=this.drafts[e.id]!==void 0,u=p&&o.trim()!==""?"custom":r,h=this.recordingHint(e.id),f=ry(t);return l`
|
|
1978
|
+
<article class=${iy(t)}>
|
|
1979
|
+
<div class="shortcut-main">
|
|
1980
|
+
<strong>${e.title}</strong>
|
|
1981
|
+
${e.description!==void 0&&e.description!==""?l`<small>${e.description}</small>`:null}
|
|
1982
|
+
<small class="shortcut-id">${e.id}</small>
|
|
1983
|
+
<small>${e.shortcut!==void 0&&e.shortcut!==""?l`Default: <kbd>${vi(e.shortcut)}</kbd>`:"No default shortcut"}</small>
|
|
1984
|
+
</div>
|
|
1985
|
+
<div class="shortcut-editor">
|
|
1986
|
+
<div class="shortcut-status">
|
|
1987
|
+
${a!==void 0&&a!==""?l`<kbd>${vi(a)}</kbd>`:l`<span class="unassigned">${r==="disabled"?"Disabled":"Unassigned"}</span>`}
|
|
1988
|
+
<small class=${u}>${dy(u)}${p?" · Unsaved":""}</small>
|
|
1989
|
+
${f===void 0?null:l`<small class=${sy(t)}>${f}</small>`}
|
|
1990
|
+
</div>
|
|
1991
|
+
<label class="shortcut-input-label">
|
|
1992
|
+
<span>Shortcut</span>
|
|
1993
|
+
<input
|
|
1994
|
+
class="shortcut-input"
|
|
1995
|
+
data-action-id=${e.id}
|
|
1996
|
+
.value=${o}
|
|
1997
|
+
placeholder=${e.shortcut??"mod+k"}
|
|
1998
|
+
autocomplete="off"
|
|
1999
|
+
autocapitalize="off"
|
|
2000
|
+
spellcheck="false"
|
|
2001
|
+
?disabled=${this.saving}
|
|
2002
|
+
@input=${b=>{this.updateDraft(e.id,py(b))}}
|
|
2003
|
+
>
|
|
2004
|
+
</label>
|
|
2005
|
+
${h!==""?l`<small class="recording-hint">${h}</small>`:null}
|
|
2006
|
+
<div class="shortcut-actions">
|
|
2007
|
+
<button class="primary" ?disabled=${this.loading||this.saving||!p||o.trim()===""} @click=${()=>{this.saveShortcut(e)}}>Save</button>
|
|
2008
|
+
<button ?disabled=${this.loading||this.saving} @click=${()=>{this.toggleRecording(e.id)}}>${this.recording?.actionId===e.id?"Cancel recording":"Record"}</button>
|
|
2009
|
+
<button ?disabled=${this.loading||this.saving||s===null} @click=${()=>{this.setShortcutNone(e.id)}}>None</button>
|
|
2010
|
+
<button ?disabled=${this.loading||this.saving||!c} @click=${()=>{this.resetShortcut(e.id)}}>Reset</button>
|
|
2011
|
+
</div>
|
|
2012
|
+
</div>
|
|
2013
|
+
</article>
|
|
2014
|
+
`}shortcutInputText(e){const t=this.drafts[e.id];if(t!==void 0)return t;const i=zi(e.id,this.configResponse?.config.shortcuts);return i===null?"":i??e.shortcut??""}recordingHint(e){const t=this.recording;return t?.actionId!==e?"":t.tokens.length===0?"Recording: press Ctrl/⌘ or Alt with a key. Press Esc to cancel.":`Recording: ${vi(t.tokens.join(" "))}. Press another key to add a sequence, or wait to finish.`}updateDraft(e,t){this.drafts={[e]:t},this.localError=""}async saveShortcut(e){this.stopRecording();const t=this.shortcutInputText(e).trim(),i=fs(t);if(!i.ok){this.localError=i.message;return}this.localError="",await this.saveShortcutPreference(e.id,i.shortcut)}async setShortcutNone(e){this.stopRecording(),this.localError="",await this.saveShortcutPreference(e,null)}async resetShortcut(e){this.stopRecording(),this.localError="",await this.saveShortcutPreference(e,void 0)}async saveShortcutPreference(e,t){const i={...this.configResponse?.config??{}},s=i.shortcuts??{},r=t===void 0?ay(s,e):{...s,[e]:t};Object.keys(r).length===0?delete i.shortcuts:i.shortcuts=r,await this.onSave?.(i)}shortcutResolutions(){return new Map(yr(this.actions,this.previewShortcutConfig(),{enabledOnly:!0}).map(e=>[e.action.id,e]))}previewShortcutConfig(){const e={...this.configResponse?.config.shortcuts??{}};for(const[t,i]of Object.entries(this.drafts)){const s=i.trim();if(s==="")continue;const r=fs(s);r.ok&&(e[t]=r.shortcut)}return Object.keys(e).length===0?void 0:e}async toggleRecording(e){if(this.recording?.actionId===e){this.stopRecording();return}this.stopRecording(),this.localError="",this.recording={actionId:e,tokens:[]},this.ensureRecordingListener(),await this.updateComplete,this.focusShortcutInput(e)}focusShortcutInput(e){for(const t of this.renderRoot.querySelectorAll(".shortcut-input"))if(t.dataset.actionId===e){t.focus(),t.select();return}}armRecordingTimer(){this.clearRecordingTimer(),this.recordingTimer=window.setTimeout(()=>{this.recordingTimer=void 0,this.stopRecording()},Ca)}stopRecording(){this.clearRecordingTimer(),this.removeRecordingListener(),this.recording=void 0}clearRecordingTimer(){this.recordingTimer!==void 0&&(window.clearTimeout(this.recordingTimer),this.recordingTimer=void 0)}ensureRecordingListener(){this.recordingListenerActive||(window.addEventListener("keydown",this.onRecordKeyDown,Mn),this.recordingListenerActive=!0)}removeRecordingListener(){this.recordingListenerActive&&(window.removeEventListener("keydown",this.onRecordKeyDown,Mn),this.recordingListenerActive=!1)}};re.styles=O`
|
|
2015
|
+
:host { display: block; }
|
|
2016
|
+
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
|
2017
|
+
.section-heading > div { display: grid; gap: 6px; min-width: 0; }
|
|
2018
|
+
h2, h3, p { margin: 0; }
|
|
2019
|
+
h2 { font-size: 17px; line-height: 1.25; }
|
|
2020
|
+
h3 { font-size: 13px; line-height: 1.3; }
|
|
2021
|
+
p { color: var(--pi-muted); line-height: 1.45; }
|
|
2022
|
+
button, input { font: inherit; }
|
|
2023
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
2024
|
+
button:disabled, input:disabled { opacity: .55; cursor: not-allowed; }
|
|
2025
|
+
.primary { border-color: var(--pi-accent); background: var(--pi-selection-bg); color: var(--pi-text-bright); }
|
|
2026
|
+
.secondary { flex: 0 0 auto; }
|
|
2027
|
+
.message, .loading-card, .config-path-card, .prompt-enter-card { border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); padding: 12px; }
|
|
2028
|
+
.message { margin-bottom: 12px; }
|
|
2029
|
+
.error-message { border-color: var(--pi-danger); color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-surface)); }
|
|
2030
|
+
.success-message { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-surface); }
|
|
2031
|
+
.loading-card, .config-path-card { color: var(--pi-muted); }
|
|
2032
|
+
.config-path-card { display: grid; gap: 5px; margin-bottom: 14px; }
|
|
2033
|
+
.config-path-card span, .card-eyebrow { color: var(--pi-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
|
|
2034
|
+
.prompt-enter-card { display: grid; grid-template-columns: minmax(0, .85fr) minmax(260px, 1fr); gap: 12px; align-items: start; margin-bottom: 14px; }
|
|
2035
|
+
.prompt-enter-copy { display: grid; gap: 5px; min-width: 0; }
|
|
2036
|
+
.prompt-enter-copy p, .prompt-enter-option small { font-size: 12px; }
|
|
2037
|
+
.prompt-enter-options { display: grid; gap: 7px; }
|
|
2038
|
+
.prompt-enter-option { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; color: var(--pi-text); }
|
|
2039
|
+
.prompt-enter-option input { box-sizing: border-box; width: 14px; min-width: 14px; height: 14px; margin: 3px 0 0; padding: 0; border: 0; background: transparent; accent-color: var(--pi-accent); font-family: inherit; }
|
|
2040
|
+
.prompt-enter-option input:focus { border-color: transparent; box-shadow: none; outline: 2px solid var(--pi-accent-border); outline-offset: 2px; }
|
|
2041
|
+
.prompt-enter-option span { display: grid; gap: 2px; }
|
|
2042
|
+
.prompt-enter-option small { color: var(--pi-muted); line-height: 1.35; }
|
|
2043
|
+
code { border: 1px solid var(--pi-border-muted); border-radius: 5px; background: var(--pi-bg); padding: 1px 4px; color: var(--pi-text); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
|
|
2044
|
+
.shortcut-group { margin: 0 0 16px; }
|
|
2045
|
+
.shortcut-group h3 { margin: 0 0 8px; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
2046
|
+
.shortcut-list { border: 1px solid var(--pi-border); border-radius: 10px; overflow: hidden; }
|
|
2047
|
+
.shortcut-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 48%); gap: 14px; align-items: start; padding: 12px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-surface); }
|
|
2048
|
+
.shortcut-row.shadowed { background: color-mix(in srgb, var(--pi-warning) 5%, var(--pi-surface)); }
|
|
2049
|
+
.shortcut-row.shadowing { background: color-mix(in srgb, var(--pi-accent) 5%, var(--pi-surface)); }
|
|
2050
|
+
.shortcut-row:last-child { border-bottom: 0; }
|
|
2051
|
+
.shortcut-main { min-width: 0; display: grid; gap: 4px; }
|
|
2052
|
+
.shortcut-main strong, .shortcut-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2053
|
+
.shortcut-main small { color: var(--pi-muted); }
|
|
2054
|
+
.shortcut-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
2055
|
+
.shortcut-editor { min-width: 0; display: grid; gap: 8px; }
|
|
2056
|
+
.shortcut-status { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
|
|
2057
|
+
.shortcut-status small { color: var(--pi-muted); font-size: 11px; }
|
|
2058
|
+
.shortcut-status small.custom { color: var(--pi-accent); }
|
|
2059
|
+
.shortcut-status small.disabled { color: var(--pi-warning); }
|
|
2060
|
+
.shortcut-status small.conflict { border: 1px solid currentColor; border-radius: 999px; padding: 2px 7px; }
|
|
2061
|
+
.shortcut-status small.conflict.shadowing { color: var(--pi-accent); }
|
|
2062
|
+
.shortcut-status small.conflict.shadowed { color: var(--pi-warning); }
|
|
2063
|
+
.shortcut-input-label { min-width: 0; display: grid; gap: 5px; }
|
|
2064
|
+
.shortcut-input-label span { color: var(--pi-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
|
|
2065
|
+
input { box-sizing: border-box; width: 100%; min-width: 0; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 8px 9px; outline: none; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
2066
|
+
input:focus { border-color: var(--pi-accent); box-shadow: 0 0 0 1px var(--pi-accent-border); }
|
|
2067
|
+
.shortcut-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
|
|
2068
|
+
kbd { border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-bg); color: var(--pi-text-secondary); padding: 3px 7px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
|
|
2069
|
+
.unassigned { color: var(--pi-muted); font-size: 12px; }
|
|
2070
|
+
.recording-hint { color: var(--pi-accent); font-size: 12px; }
|
|
2071
|
+
|
|
2072
|
+
@media (max-width: 760px) {
|
|
2073
|
+
.section-heading { display: grid; gap: 12px; }
|
|
2074
|
+
.section-heading .secondary { justify-self: start; }
|
|
2075
|
+
.prompt-enter-card { grid-template-columns: minmax(0, 1fr); }
|
|
2076
|
+
.shortcut-row { grid-template-columns: minmax(0, 1fr); align-items: start; }
|
|
2077
|
+
.shortcut-status, .shortcut-actions { justify-content: flex-start; }
|
|
2078
|
+
}
|
|
2079
|
+
`;ge([d({attribute:!1})],re.prototype,"actions",2);ge([d({attribute:!1})],re.prototype,"configResponse",2);ge([d({type:Boolean})],re.prototype,"loading",2);ge([d({type:Boolean})],re.prototype,"saving",2);ge([d()],re.prototype,"error",2);ge([d()],re.prototype,"savedMessage",2);ge([d({attribute:!1})],re.prototype,"onReload",2);ge([d({attribute:!1})],re.prototype,"onSave",2);ge([v()],re.prototype,"drafts",2);ge([v()],re.prototype,"localError",2);ge([v()],re.prototype,"promptEnterPreference",2);ge([v()],re.prototype,"recording",2);re=ge([D("settings-shortcuts-panel")],re);function iy(e){return e?.active===!1?"shortcut-row shadowed":e?.active===!0&&e.shadows.length>0?"shortcut-row shadowing":"shortcut-row"}function sy(e){return e?.active===!1?"conflict shadowed":"conflict shadowing"}function ry(e){if(e===void 0)return;if(!e.active)return`Shadowed by ${e.shadowedBy?.action.title??"another action"}`;const t=e.shadows.length;if(t===0)return;const i=e.shadows.slice(0,2).map(r=>r.action.title).join(", "),s=t>2?`, +${String(t-2)} more`:"";return`Shadows ${String(t)} ${t===1?"action":"actions"}: ${i}${s}`}function oy(e){const t=new Map;for(const i of[...e].sort(ny)){const s=i.group??"Other";t.set(s,[...t.get(s)??[],i])}return[...t.entries()].map(([i,s])=>({name:i,actions:s}))}function ny(e,t){return(e.group??"Other").localeCompare(t.group??"Other")||e.title.localeCompare(t.title)}function zi(e,t){if(!(t===void 0||!Object.hasOwn(t,e)))return t[e]}function ay(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}function ly(e,t){const i=zi(e.id,t);if(i!==null)return i??e.shortcut}function cy(e,t){const i=zi(e.id,t);return i===null?"disabled":i!==void 0?"custom":e.shortcut===void 0||e.shortcut===""?"unassigned":"default"}function dy(e){switch(e){case"default":return"Default";case"custom":return"Custom";case"disabled":return"Disabled";case"unassigned":return"No default"}}function py(e){return e.target instanceof HTMLInputElement?e.target.value:""}var hy=Object.defineProperty,uy=Object.getOwnPropertyDescriptor,Pe=(e,t,i,s)=>{for(var r=s>1?void 0:s?uy(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&hy(t,i,r),r};let de=class extends M{constructor(){super(...arguments),this.section="general",this.actions=[],this.loading=!0,this.saving=!1,this.error="",this.savedMessage=""}connectedCallback(){super.connectedCallback(),this.loadConfig()}disconnectedCallback(){this.savedMessageTimer!==void 0&&window.clearTimeout(this.savedMessageTimer),this.savedMessageTimer=void 0,super.disconnectedCallback()}render(){return l`
|
|
2080
|
+
<div class="backdrop" @mousedown=${()=>this.onClose?.()}>
|
|
2081
|
+
<section class="settings-shell" role="dialog" aria-modal="true" aria-label="PI WEB settings" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
2082
|
+
<header class="settings-header">
|
|
2083
|
+
<div>
|
|
2084
|
+
<span class="eyebrow">Settings</span>
|
|
2085
|
+
<h1>PI WEB</h1>
|
|
2086
|
+
</div>
|
|
2087
|
+
<button class="close-button" title="Close settings" aria-label="Close settings" @click=${()=>this.onClose?.()}>×</button>
|
|
2088
|
+
</header>
|
|
2089
|
+
<div class="settings-body">
|
|
2090
|
+
<nav class="settings-nav" aria-label="Settings sections">
|
|
2091
|
+
${this.renderNavButton("general","General","Server config")}
|
|
2092
|
+
${this.renderNavButton("sessiond","Session daemon","Runtime settings")}
|
|
2093
|
+
${this.renderNavButton("plugins","Plugins","Enable and disable")}
|
|
2094
|
+
${this.renderNavButton("shortcuts","Keyboard","Shortcuts")}
|
|
2095
|
+
</nav>
|
|
2096
|
+
<main class="settings-content">
|
|
2097
|
+
${this.renderActiveSection()}
|
|
2098
|
+
</main>
|
|
2099
|
+
</div>
|
|
2100
|
+
</section>
|
|
2101
|
+
</div>
|
|
2102
|
+
`}renderActiveSection(){return this.section==="sessiond"?l`
|
|
2103
|
+
<settings-sessiond-panel
|
|
2104
|
+
.configResponse=${this.configResponse}
|
|
2105
|
+
.loading=${this.loading}
|
|
2106
|
+
.saving=${this.saving}
|
|
2107
|
+
.error=${this.error}
|
|
2108
|
+
.savedMessage=${this.savedMessage}
|
|
2109
|
+
.onReload=${()=>this.loadConfig()}
|
|
2110
|
+
.onSave=${e=>this.saveConfig(e)}
|
|
2111
|
+
></settings-sessiond-panel>
|
|
2112
|
+
`:this.section==="shortcuts"?l`
|
|
2113
|
+
<settings-shortcuts-panel
|
|
2114
|
+
.actions=${this.actions}
|
|
2115
|
+
.configResponse=${this.configResponse}
|
|
2116
|
+
.loading=${this.loading}
|
|
2117
|
+
.saving=${this.saving}
|
|
2118
|
+
.error=${this.error}
|
|
2119
|
+
.savedMessage=${this.savedMessage}
|
|
2120
|
+
.onReload=${()=>this.loadConfig()}
|
|
2121
|
+
.onSave=${e=>this.saveConfig(e)}
|
|
2122
|
+
></settings-shortcuts-panel>
|
|
2123
|
+
`:this.section==="plugins"?l`
|
|
2124
|
+
<settings-plugins-panel
|
|
2125
|
+
.configResponse=${this.configResponse}
|
|
2126
|
+
.pluginsResponse=${this.pluginsResponse}
|
|
2127
|
+
.loading=${this.loading}
|
|
2128
|
+
.saving=${this.saving}
|
|
2129
|
+
.error=${this.error}
|
|
2130
|
+
.savedMessage=${this.savedMessage}
|
|
2131
|
+
.onReload=${()=>this.loadConfig()}
|
|
2132
|
+
.onTogglePlugin=${(e,t)=>this.togglePlugin(e,t)}
|
|
2133
|
+
></settings-plugins-panel>
|
|
2134
|
+
`:l`
|
|
2135
|
+
<settings-general-panel
|
|
2136
|
+
.configResponse=${this.configResponse}
|
|
2137
|
+
.loading=${this.loading}
|
|
2138
|
+
.saving=${this.saving}
|
|
2139
|
+
.error=${this.error}
|
|
2140
|
+
.savedMessage=${this.savedMessage}
|
|
2141
|
+
.onReload=${()=>this.loadConfig()}
|
|
2142
|
+
.onSave=${e=>this.saveConfig(e)}
|
|
2143
|
+
></settings-general-panel>
|
|
2144
|
+
`}renderNavButton(e,t,i){const s=this.section===e;return l`
|
|
2145
|
+
<button class=${s?"selected":""} aria-current=${s?"page":"false"} @click=${()=>{this.navigate(e)}}>
|
|
2146
|
+
<strong>${t}</strong>
|
|
2147
|
+
<small>${i}</small>
|
|
2148
|
+
</button>
|
|
2149
|
+
`}navigate(e){this.onNavigate?.(e)}async loadConfig(){this.loading=!0,this.error="";try{const[e,t]=await Promise.all([Ci.config(),_s.plugins()]);this.configResponse=e,this.pluginsResponse=t}catch(e){this.error=`Failed to load settings: ${Rs(e)}`}finally{this.loading=!1}}async togglePlugin(e,t){const i=this.configResponse?.config??{},s=i.plugins??{},r=s[e]??{};await this.saveConfig({...i,plugins:{...s,[e]:{...r,enabled:t}}}),await this.refreshPlugins()}async saveConfig(e){if(!this.saving){this.saving=!0,this.error="",this.savedMessage="";try{const t=await Ci.saveConfig(e);this.configResponse=t,this.onConfigSaved?.(t.effectiveConfig),this.showSavedMessage()}catch(t){this.error=`Failed to save config: ${Rs(t)}`}finally{this.saving=!1}}}async refreshPlugins(){try{this.pluginsResponse=await _s.plugins()}catch(e){this.error=`Failed to refresh plugins: ${Rs(e)}`}}showSavedMessage(){this.savedMessage="Config saved.",this.savedMessageTimer!==void 0&&window.clearTimeout(this.savedMessageTimer),this.savedMessageTimer=window.setTimeout(()=>{this.savedMessage==="Config saved."&&(this.savedMessage=""),this.savedMessageTimer=void 0},3e3)}handleKeyDown(e){e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this.onClose?.())}};de.styles=O`
|
|
2150
|
+
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
2151
|
+
.backdrop { box-sizing: border-box; width: 100%; height: 100dvh; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: var(--pi-overlay); overflow: hidden; }
|
|
2152
|
+
.settings-shell { width: min(980px, 100%); max-height: min(760px, 100%); min-height: min(620px, 100%); display: grid; grid-template-rows: auto minmax(0, 1fr); border: 1px solid var(--pi-border); border-radius: 14px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
2153
|
+
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--pi-border); }
|
|
2154
|
+
.eyebrow { display: block; color: var(--pi-muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
|
2155
|
+
h1 { margin: 0; font-size: 20px; line-height: 1.2; }
|
|
2156
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; font: inherit; cursor: pointer; }
|
|
2157
|
+
.close-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--pi-muted); padding: 0; font-size: 24px; }
|
|
2158
|
+
.close-button:hover, .close-button:focus { color: var(--pi-text); background: var(--pi-surface-hover); }
|
|
2159
|
+
.settings-body { min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
|
|
2160
|
+
.settings-nav { min-height: 0; padding: 10px; border-right: 1px solid var(--pi-border); background: var(--pi-surface); overflow: auto; }
|
|
2161
|
+
.settings-nav button { display: grid; gap: 2px; width: 100%; margin: 0 0 6px; text-align: left; border-color: transparent; background: transparent; }
|
|
2162
|
+
.settings-nav button:hover, .settings-nav button:focus { background: var(--pi-surface-hover); }
|
|
2163
|
+
.settings-nav button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
2164
|
+
.settings-nav small { color: var(--pi-muted); }
|
|
2165
|
+
.settings-content { min-width: 0; min-height: 0; overflow: auto; padding: 18px; }
|
|
2166
|
+
|
|
2167
|
+
@media (max-width: 760px) {
|
|
2168
|
+
.backdrop { padding: 0; place-items: stretch; }
|
|
2169
|
+
.settings-shell { width: 100%; height: 100dvh; max-height: none; min-height: 0; border: 0; border-radius: 0; }
|
|
2170
|
+
.settings-header { padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
|
|
2171
|
+
.settings-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
|
2172
|
+
.settings-nav { display: flex; gap: 8px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--pi-border); overflow-x: auto; overflow-y: hidden; }
|
|
2173
|
+
.settings-nav button { flex: 0 0 auto; width: auto; min-width: 128px; margin: 0; }
|
|
2174
|
+
.settings-content { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
|
|
2175
|
+
}
|
|
2176
|
+
`;Pe([d({attribute:!1})],de.prototype,"section",2);Pe([d({attribute:!1})],de.prototype,"actions",2);Pe([d({attribute:!1})],de.prototype,"onNavigate",2);Pe([d({attribute:!1})],de.prototype,"onClose",2);Pe([d({attribute:!1})],de.prototype,"onConfigSaved",2);Pe([v()],de.prototype,"configResponse",2);Pe([v()],de.prototype,"pluginsResponse",2);Pe([v()],de.prototype,"loading",2);Pe([v()],de.prototype,"saving",2);Pe([v()],de.prototype,"error",2);Pe([v()],de.prototype,"savedMessage",2);de=Pe([D("settings-dialog")],de);function Rs(e){return e instanceof Error?e.message:String(e)}var fy=Object.defineProperty,gy=Object.getOwnPropertyDescriptor,De=(e,t,i,s)=>{for(var r=s>1?void 0:s?gy(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&fy(t,i,r),r};let fe=class extends M{constructor(){super(...arguments),this.tool="core:workspace.files",this.panels=[],this.hideToolTabs=!1,this.onSelectTool=()=>{},this.workspaceHeaderCanScrollLeft=!1,this.workspaceHeaderCanScrollRight=!1,this.onWorkspaceHeaderScroll=()=>{this.updateWorkspaceHeaderScrollState()}}firstUpdated(){this.observeWorkspaceHeaderStrip(),this.updateWorkspaceHeaderScrollState()}updated(){this.observeWorkspaceHeaderStrip(),this.updateWorkspaceHeaderScrollState()}disconnectedCallback(){this.workspaceHeaderResizeObserver?.disconnect(),this.workspaceHeaderResizeObserver=void 0,this.observedWorkspaceHeaderStrip=void 0,super.disconnectedCallback()}render(){if(this.workspace===void 0)return this.renderEmptyState(this.emptyState??{title:"Select a workspace",body:"Choose a workspace to inspect files, Git, or terminals."});const t=this.panelContext;if(t===void 0)return this.renderEmptyState({title:"Workspace tools unavailable",body:"Try selecting the workspace again."});const i=this.panels,s=i.find(r=>r.id===this.tool)??i[0];return l`
|
|
2177
|
+
${this.hideToolTabs?null:l`
|
|
2178
|
+
<header>
|
|
2179
|
+
<div class=${this.workspaceHeaderFrameClass()}>
|
|
2180
|
+
<div class="workspace-header-strip" @scroll=${this.onWorkspaceHeaderScroll}>
|
|
2181
|
+
<div class="tabs">
|
|
2182
|
+
${i.map(r=>{const o=s?.id===r.id,n=r.badge?.(t),a=this.panelTabAriaLabel(r,n);return l`
|
|
2183
|
+
<button class=${this.panelTabClass(r,o)} title=${a} aria-label=${a} aria-pressed=${String(o)} @click=${()=>{this.onSelectTool(r.id)}}>
|
|
2184
|
+
${this.renderPanelTabContent(r,n)}
|
|
2185
|
+
</button>
|
|
2186
|
+
`})}
|
|
2187
|
+
</div>
|
|
2188
|
+
</div>
|
|
2189
|
+
</div>
|
|
2190
|
+
</header>
|
|
2191
|
+
`}
|
|
2192
|
+
${s===void 0?this.renderEmptyState({title:"No workspace tools available",body:"No tools are available for this workspace."}):l`
|
|
2193
|
+
<div class="panel-content">
|
|
2194
|
+
${s.render(t)}
|
|
2195
|
+
</div>
|
|
2196
|
+
`}
|
|
2197
|
+
`}panelTabClass(e,t){return[...e.icon===void 0?[]:["icon-tab"],...t?["selected"]:[]].join(" ")}panelTabAriaLabel(e,t){if(typeof t!="string"&&typeof t!="number")return e.title;const i=String(t).trim();return i===""?e.title:`${e.title}, ${i}`}renderPanelTabContent(e,t){return l`
|
|
2198
|
+
${e.icon===void 0?null:l`<span class="tab-custom-icon" aria-hidden="true">${e.icon}</span>`}
|
|
2199
|
+
<span class="tab-label">${e.title}</span>
|
|
2200
|
+
${this.isEmptyBadge(t)?null:l`<span class="tab-badge">${t}</span>`}
|
|
2201
|
+
`}isEmptyBadge(e){return e===void 0||e===""}renderEmptyState(e){return l`
|
|
2202
|
+
<section class="empty-state" role="status">
|
|
2203
|
+
<h2>${e.title}</h2>
|
|
2204
|
+
${e.body===void 0?null:l`<p>${e.body}</p>`}
|
|
2205
|
+
</section>
|
|
2206
|
+
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${this.workspaceHeaderCanScrollLeft?" can-scroll-left":""}${this.workspaceHeaderCanScrollRight?" can-scroll-right":""}`}observeWorkspaceHeaderStrip(){const e=this.workspaceHeaderStripElement();this.observedWorkspaceHeaderStrip!==e&&(this.workspaceHeaderResizeObserver?.disconnect(),this.observedWorkspaceHeaderStrip=e,this.workspaceHeaderResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.workspaceHeaderResizeObserver=new ResizeObserver(()=>{this.updateWorkspaceHeaderScrollState()}),this.workspaceHeaderResizeObserver.observe(e)))}updateWorkspaceHeaderScrollState(){const e=this.workspaceHeaderStripElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),i=e!==void 0&&e.scrollLeft>1,s=e!==void 0&&t-e.scrollLeft>1;this.workspaceHeaderCanScrollLeft!==i&&(this.workspaceHeaderCanScrollLeft=i),this.workspaceHeaderCanScrollRight!==s&&(this.workspaceHeaderCanScrollRight=s)}workspaceHeaderStripElement(){const e=this.workspaceHeaderStrip;return e instanceof HTMLElement?e:void 0}};fe.styles=_a;De([d({attribute:!1})],fe.prototype,"workspace",2);De([d({attribute:!1})],fe.prototype,"panelContext",2);De([d({attribute:!1})],fe.prototype,"emptyState",2);De([d()],fe.prototype,"tool",2);De([d({attribute:!1})],fe.prototype,"panels",2);De([d({type:Boolean})],fe.prototype,"hideToolTabs",2);De([d({attribute:!1})],fe.prototype,"onSelectTool",2);De([z(".workspace-header-strip")],fe.prototype,"workspaceHeaderStrip",2);De([v()],fe.prototype,"workspaceHeaderCanScrollLeft",2);De([v()],fe.prototype,"workspaceHeaderCanScrollRight",2);fe=De([D("workspace-panel")],fe);var my=Object.defineProperty,vy=Object.getOwnPropertyDescriptor,Ce=(e,t,i,s)=>{for(var r=s>1?void 0:s?vy(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&my(t,i,r),r};let pe=class extends M{constructor(){super(...arguments),this.machines=[],this.canScrollLeft=!1,this.canScrollRight=!1,this.onContextScroll=()=>{this.updateScrollState()}}disconnectedCallback(){this.contextItemsResizeObserver?.disconnect(),this.contextItemsResizeObserver=void 0,this.observedContextItems=void 0,super.disconnectedCallback()}firstUpdated(){this.observeContextItems(),this.updateScrollState()}updated(){this.observeContextItems(),this.updateScrollState()}render(){const e=by(this.machines),t=wy(this.machine),i=xy(this.project),s=ky(this.workspace),r=Py(this.session);return l`
|
|
2207
|
+
<nav class=${this.contextBarClass()} aria-label="Current location">
|
|
2208
|
+
<span class="context-bar-label">Location</span>
|
|
2209
|
+
<ol class="context-items" @scroll=${this.onContextScroll}>
|
|
2210
|
+
${e?l`
|
|
2211
|
+
<li class="context-item">
|
|
2212
|
+
<button type="button" class=${this.machine===void 0?"context-chip empty":"context-chip"} title=${yy(this.machine)} aria-label=${`Machine: ${t}. Open machine selection.`} @click=${()=>{this.onOpenSection?.("machines")}}>
|
|
2213
|
+
<span class="context-kind">Machine</span>
|
|
2214
|
+
<span class="context-value">${t}</span>
|
|
2215
|
+
</button>
|
|
2216
|
+
</li>
|
|
2217
|
+
`:null}
|
|
2218
|
+
<li class="context-item">
|
|
2219
|
+
<button type="button" class=${this.project===void 0?"context-chip empty":"context-chip"} title=${Sy(this.project)} aria-label=${`Project: ${i}. Open project selection.`} @click=${()=>{this.onOpenSection?.("projects")}}>
|
|
2220
|
+
<span class="context-kind">Project</span>
|
|
2221
|
+
<span class="context-value">${i}</span>
|
|
2222
|
+
</button>
|
|
2223
|
+
</li>
|
|
2224
|
+
<li class="context-item">
|
|
2225
|
+
<button type="button" class=${this.workspace===void 0?"context-chip empty":"context-chip"} title=${$y(this.workspace)} aria-label=${`Workspace: ${s}. Open workspace selection.`} @click=${()=>{this.onOpenSection?.("workspaces")}}>
|
|
2226
|
+
<span class="context-kind">Workspace</span>
|
|
2227
|
+
<span class="context-value">${s}</span>
|
|
2228
|
+
</button>
|
|
2229
|
+
</li>
|
|
2230
|
+
<li class="context-item">
|
|
2231
|
+
<button type="button" class=${this.session===void 0?"context-chip empty":"context-chip"} title=${Cy(this.session)} aria-label=${`Session: ${r}. Open session selection.`} @click=${()=>{this.onOpenSection?.("sessions")}}>
|
|
2232
|
+
<span class="context-kind">Session</span>
|
|
2233
|
+
<span class="context-value">${r}</span>
|
|
2234
|
+
</button>
|
|
2235
|
+
</li>
|
|
2236
|
+
</ol>
|
|
2237
|
+
${this.hasContextActions()?l`<div class="context-actions">${this.renderActionsButton()}${this.refreshControl}</div>`:null}
|
|
2238
|
+
</nav>
|
|
2239
|
+
`}renderActionsButton(){return this.onShowActions===void 0?null:l`
|
|
2240
|
+
<button type="button" class="context-action-button" title="Show Actions" aria-label="Show Actions" @click=${e=>{e.stopPropagation(),this.onShowActions?.()}}>
|
|
2241
|
+
<svg class="context-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2242
|
+
<path d="M13 2 4 14h7l-1 8 10-13h-7V2Z"></path>
|
|
2243
|
+
</svg>
|
|
2244
|
+
</button>
|
|
2245
|
+
`}contextBarClass(){const e=["context-bar"];return this.hasContextActions()&&e.push("has-context-actions"),this.refreshControl!==void 0&&this.onShowActions!==void 0&&e.push("has-context-actions-double"),this.canScrollLeft&&e.push("can-scroll-left"),this.canScrollRight&&e.push("can-scroll-right"),e.join(" ")}hasContextActions(){return this.refreshControl!==void 0||this.onShowActions!==void 0}observeContextItems(){const e=this.contextItemsElement();this.observedContextItems!==e&&(this.contextItemsResizeObserver?.disconnect(),this.observedContextItems=e,this.contextItemsResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.contextItemsResizeObserver=new ResizeObserver(()=>{this.updateScrollState()}),this.contextItemsResizeObserver.observe(e)))}updateScrollState(){const e=this.contextItemsElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),i=e!==void 0&&e.scrollLeft>1,s=e!==void 0&&t-e.scrollLeft>1;this.canScrollLeft!==i&&(this.canScrollLeft=i),this.canScrollRight!==s&&(this.canScrollRight=s)}contextItemsElement(){const e=this.contextItems;return e instanceof HTMLElement?e:void 0}};pe.styles=O`
|
|
2246
|
+
/* Keep the refresh menu in this shadow tree above the following mobile tab strip. */
|
|
2247
|
+
:host { position: relative; z-index: 20; flex: 0 0 auto; min-width: 0; }
|
|
2248
|
+
.context-bar { position: relative; flex: 0 0 auto; min-width: 0; display: flex; align-items: center; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
2249
|
+
.context-bar::before, .context-bar::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
2250
|
+
.context-bar::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
2251
|
+
.context-bar::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
2252
|
+
.context-bar.can-scroll-left::before, .context-bar.can-scroll-right::after { opacity: 1; }
|
|
2253
|
+
.context-bar-label { display: none; }
|
|
2254
|
+
.context-items { flex: 1 1 auto; min-width: 0; display: flex; align-items: stretch; gap: 5px; margin: 0; padding: 0 8px; list-style: none; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-padding-inline: 8px; scrollbar-width: thin; }
|
|
2255
|
+
.context-bar.has-context-actions .context-items { padding-right: 58px; scroll-padding-inline: 8px 58px; }
|
|
2256
|
+
.context-bar.has-context-actions-double .context-items { padding-right: 102px; scroll-padding-inline: 8px 102px; }
|
|
2257
|
+
.context-item { flex: 0 0 auto; min-width: 0; display: flex; }
|
|
2258
|
+
.context-actions { position: absolute; top: 6px; right: 0; bottom: 6px; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 0 8px; background: var(--pi-bg); pointer-events: none; }
|
|
2259
|
+
.context-actions::before { content: ""; position: absolute; top: 0; bottom: 0; left: -24px; z-index: 0; width: 24px; background: linear-gradient(90deg, transparent, var(--pi-bg)); pointer-events: none; }
|
|
2260
|
+
app-refresh-control, .context-action-button { position: relative; z-index: 1; pointer-events: auto; }
|
|
2261
|
+
.context-action-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 0; line-height: 1; }
|
|
2262
|
+
.context-action-button:hover, .context-action-button:focus-visible { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
2263
|
+
.context-action-icon { width: 18px; height: 18px; fill: currentColor; pointer-events: none; }
|
|
2264
|
+
.context-chip { flex: 0 0 auto; min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 4px 8px; font: inherit; text-align: left; }
|
|
2265
|
+
.context-chip:hover { background: var(--pi-surface-hover); }
|
|
2266
|
+
.context-chip:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; }
|
|
2267
|
+
.context-chip.empty { border-style: dashed; color: var(--pi-muted); }
|
|
2268
|
+
.context-kind { display: none; }
|
|
2269
|
+
.context-value { min-width: 0; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
2270
|
+
button { cursor: pointer; }
|
|
2271
|
+
`;Ce([d({attribute:!1})],pe.prototype,"machines",2);Ce([d({attribute:!1})],pe.prototype,"machine",2);Ce([d({attribute:!1})],pe.prototype,"project",2);Ce([d({attribute:!1})],pe.prototype,"workspace",2);Ce([d({attribute:!1})],pe.prototype,"session",2);Ce([d({attribute:!1})],pe.prototype,"refreshControl",2);Ce([d({attribute:!1})],pe.prototype,"onOpenSection",2);Ce([d({attribute:!1})],pe.prototype,"onShowActions",2);Ce([z(".context-items")],pe.prototype,"contextItems",2);Ce([v()],pe.prototype,"canScrollLeft",2);Ce([v()],pe.prototype,"canScrollRight",2);pe=Ce([D("app-context-bar")],pe);function by(e){return e.length>1}function wy(e){return e===void 0?"No machine":`${e.name}${e.kind==="remote"?" · remote":""}`}function yy(e){return e===void 0?"No machine selected":e.baseUrl??e.name}function xy(e){return e?.name??"No project"}function Sy(e){return e===void 0?"No project selected":`${e.name} — ${e.path}`}function ky(e){return e===void 0?"No workspace":`${e.label}${e.isMain?" · main":""} · ${e.path}`}function $y(e){return e===void 0?"No workspace selected":`${e.label}${e.isMain?" · main":""} — ${e.path}`}function Py(e){const t=e?.name?.trim(),i=e?.firstMessage.trim();return t!==void 0&&t!==""?t:i!==void 0&&i!==""?i:e?.id.slice(0,8)??"No session"}function Cy(e){return e===void 0?"No session selected":e.path}var Ry=Object.defineProperty,Iy=Object.getOwnPropertyDescriptor,ut=(e,t,i,s)=>{for(var r=s>1?void 0:s?Iy(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Ry(t,i,r),r};let ze=class extends M{constructor(){super(...arguments),this.tabs=[],this.selectedView="chat",this.canScrollLeft=!1,this.canScrollRight=!1,this.onMobileTabsScroll=()=>{this.updateScrollState()}}disconnectedCallback(){this.mobileTabsResizeObserver?.disconnect(),this.mobileTabsResizeObserver=void 0,this.observedMobileTabs=void 0,super.disconnectedCallback()}firstUpdated(){this.observeMobileTabs(),this.updateScrollState()}updated(){this.observeMobileTabs(),this.updateScrollState()}render(){const e=this.fallbackLabels();return l`
|
|
2272
|
+
<div class=${this.frameClass()}>
|
|
2273
|
+
<div class="mobile-tabs" @scroll=${this.onMobileTabsScroll}>
|
|
2274
|
+
${this.tabs.map(t=>{const i=this.selectedView===t.id;return l`
|
|
2275
|
+
<button class=${this.tabClass(t)} title=${t.label} aria-label=${this.tabAriaLabel(t)} aria-pressed=${String(i)} @click=${()=>{this.onSelect?.(t.id)}}>
|
|
2276
|
+
${this.renderTabMark(t,e)}
|
|
2277
|
+
<span class="tab-label">${t.label}</span>
|
|
2278
|
+
${this.isEmptyBadge(t.badge)?null:l`<span class="tab-badge">${t.badge}</span>`}
|
|
2279
|
+
</button>
|
|
2280
|
+
`})}
|
|
2281
|
+
</div>
|
|
2282
|
+
</div>
|
|
2283
|
+
`}frameClass(){return`mobile-tabs-frame${this.canScrollLeft?" can-scroll-left":""}${this.canScrollRight?" can-scroll-right":""}`}tabClass(e){return[...e.className===void 0?[]:[e.className],...this.selectedView===e.id?["selected"]:[]].join(" ")}tabAriaLabel(e){if(typeof e.badge!="string"&&typeof e.badge!="number")return e.label;const t=String(e.badge).trim();return t===""?e.label:`${e.label}, ${t}`}isEmptyBadge(e){return e===void 0||e===""}renderTabMark(e,t){return e.icon===void 0?l`<span class="tab-fallback" aria-hidden="true">${t.get(e.id)??this.initialsLabel(e.label)}</span>`:$f(e.icon)}fallbackLabels(){const e=this.tabs.filter(s=>s.icon===void 0),t=new Map;for(const s of e){const r=this.initialsLabel(s.label);t.set(r,(t.get(r)??0)+1)}const i=new Map;for(const s of e){const r=this.initialsLabel(s.label);i.set(s.id,(t.get(r)??0)>1?this.fullFallbackLabel(s.label):r)}return i}initialsLabel(e){const i=(e.match(/[\p{L}\p{N}]+/gu)??[]).map(s=>Array.from(s)[0]??"").join("").toLocaleUpperCase();return i===""?"?":i}fullFallbackLabel(e){const t=e.trim();return t===""?"?":t}observeMobileTabs(){const e=this.mobileTabsElement();this.observedMobileTabs!==e&&(this.mobileTabsResizeObserver?.disconnect(),this.observedMobileTabs=e,this.mobileTabsResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.mobileTabsResizeObserver=new ResizeObserver(()=>{this.updateScrollState()}),this.mobileTabsResizeObserver.observe(e)))}updateScrollState(){const e=this.mobileTabsElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),i=e!==void 0&&e.scrollLeft>1,s=e!==void 0&&t-e.scrollLeft>1;this.canScrollLeft!==i&&(this.canScrollLeft=i),this.canScrollRight!==s&&(this.canScrollRight=s)}mobileTabsElement(){const e=this.mobileTabs;return e instanceof HTMLElement?e:void 0}};ze.styles=O`
|
|
2284
|
+
:host { flex: 0 0 auto; min-width: 0; }
|
|
2285
|
+
.mobile-tabs-frame { position: relative; display: flex; flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
2286
|
+
.mobile-tabs-frame::before, .mobile-tabs-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
2287
|
+
.mobile-tabs-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
2288
|
+
.mobile-tabs-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
2289
|
+
.mobile-tabs-frame.can-scroll-left::before, .mobile-tabs-frame.can-scroll-right::after { opacity: 1; }
|
|
2290
|
+
.mobile-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
2291
|
+
.mobile-tabs button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
|
|
2292
|
+
.mobile-tabs .navigation-tab { display: none; }
|
|
2293
|
+
.mobile-tabs button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
2294
|
+
.tab-icon { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
2295
|
+
.tab-custom-icon { flex: 0 0 auto; width: 18px; height: 18px; display: inline-grid; place-items: center; color: currentColor; pointer-events: none; }
|
|
2296
|
+
.tab-custom-icon svg { width: 18px; height: 18px; pointer-events: none; }
|
|
2297
|
+
.tab-fallback { display: none; font-weight: 650; letter-spacing: .01em; pointer-events: none; }
|
|
2298
|
+
.tab-label { min-width: 0; }
|
|
2299
|
+
.tab-badge { flex: 0 0 auto; display: inline-block; min-width: 14px; margin-left: 0; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
2300
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
2301
|
+
@media (max-width: 760px) {
|
|
2302
|
+
.mobile-tabs { gap: 4px; padding: 6px 8px; }
|
|
2303
|
+
.mobile-tabs button { min-width: 40px; height: 36px; justify-content: center; gap: 4px; padding: 0 8px; }
|
|
2304
|
+
.mobile-tabs .navigation-tab { display: inline-flex; }
|
|
2305
|
+
.tab-fallback { display: inline-block; }
|
|
2306
|
+
.tab-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
2307
|
+
.tab-badge { min-width: 13px; padding: 0 4px; font-size: 10px; line-height: 13px; }
|
|
2308
|
+
}
|
|
2309
|
+
`;ut([d({attribute:!1})],ze.prototype,"tabs",2);ut([d({attribute:!1})],ze.prototype,"selectedView",2);ut([d({attribute:!1})],ze.prototype,"onSelect",2);ut([z(".mobile-tabs")],ze.prototype,"mobileTabs",2);ut([v()],ze.prototype,"canScrollLeft",2);ut([v()],ze.prototype,"canScrollRight",2);ze=ut([D("app-mobile-main-tabs")],ze);var Ay=Object.defineProperty,My=Object.getOwnPropertyDescriptor,me=(e,t,i,s)=>{for(var r=s>1?void 0:s?My(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Ay(t,i,r),r};let oe=class extends M{constructor(){super(...arguments),this.machines=[],this.statuses={},this.activities={},this.open=!1,this.menuStyle="",this.actionMenuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.open=!1,this.openActionsMachineId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("machines")&&this.open&&this.selectedMachine()===void 0&&(this.open=!1),e.has("machines")&&this.openActionsMachineId!==void 0&&!this.machines.some(t=>t.id===this.openActionsMachineId)&&(this.openActionsMachineId=void 0)}async focusSelectedOrFirst(){const e=this.switcherButton();return e===null?!1:await this.openMenuAndFocusOption(e)}render(){const e=this.selectedMachine();if(e===void 0)return null;const t=Is(e,this.statuses),i=e.name;return l`
|
|
2310
|
+
<div class="machine-switcher">
|
|
2311
|
+
<button
|
|
2312
|
+
type="button"
|
|
2313
|
+
class="machine-switcher-button"
|
|
2314
|
+
title=${En(e)}
|
|
2315
|
+
aria-label=${`Machine: ${i}. Switch machine.`}
|
|
2316
|
+
aria-expanded=${String(this.open)}
|
|
2317
|
+
@click=${s=>{this.toggleMenu(s.currentTarget)}}
|
|
2318
|
+
@keydown=${s=>{this.handleSwitcherButtonKeydown(s)}}
|
|
2319
|
+
>
|
|
2320
|
+
${this.renderActivity(e)}
|
|
2321
|
+
<span class="machine-switcher-text">
|
|
2322
|
+
<span class="machine-switcher-kicker">Machine</span>
|
|
2323
|
+
<span class="machine-switcher-label">${i}</span>
|
|
2324
|
+
</span>
|
|
2325
|
+
<span class=${`machine-status ${t}`}>${Tn(t)}</span>
|
|
2326
|
+
<span class="machine-chevron" aria-hidden="true">▾</span>
|
|
2327
|
+
</button>
|
|
2328
|
+
${this.open?l`
|
|
2329
|
+
<div class="machine-switcher-menu" style=${this.menuStyle} @click=${s=>{s.stopPropagation()}}>
|
|
2330
|
+
${this.machines.map(s=>this.renderMachineOption(s))}
|
|
2331
|
+
</div>
|
|
2332
|
+
`:null}
|
|
2333
|
+
</div>
|
|
2334
|
+
`}renderMachineOption(e){const t=this.selected?.id===e.id,i=Is(e,this.statuses),s=Ya(e)&&this.onRemove!==void 0,r=this.openActionsMachineId===e.id;return l`
|
|
2335
|
+
<div class=${`machine-option ${t?"selected":""} ${s?"":"no-actions"}`}>
|
|
2336
|
+
<button
|
|
2337
|
+
type="button"
|
|
2338
|
+
class="machine-option-main"
|
|
2339
|
+
title=${En(e)}
|
|
2340
|
+
data-machine-id=${e.id}
|
|
2341
|
+
@click=${()=>{this.select(e)}}
|
|
2342
|
+
@keydown=${o=>{this.handleMachineOptionKeydown(o)}}
|
|
2343
|
+
>
|
|
2344
|
+
<span class="machine-option-name">${this.renderActivity(e)}<span>${e.name}</span></span>
|
|
2345
|
+
<small>${e.kind==="local"?"Local Pi Web":e.baseUrl??"Remote Pi Web"} · ${Tn(i)}</small>
|
|
2346
|
+
</button>
|
|
2347
|
+
${s?l`
|
|
2348
|
+
<div class="machine-option-actions">
|
|
2349
|
+
<button
|
|
2350
|
+
type="button"
|
|
2351
|
+
class="machine-option-actions-toggle"
|
|
2352
|
+
title="Machine actions"
|
|
2353
|
+
aria-label=${`Actions for ${e.name}`}
|
|
2354
|
+
aria-expanded=${String(r)}
|
|
2355
|
+
@click=${o=>{o.stopPropagation(),this.toggleActionsMenu(e.id,o.currentTarget)}}
|
|
2356
|
+
>⋯</button>
|
|
2357
|
+
${r?l`
|
|
2358
|
+
<div class="machine-option-actions-panel" style=${this.actionMenuStyle} @click=${o=>{o.stopPropagation()}}>
|
|
2359
|
+
<button class="danger" title=${`Remove ${e.name}`} @click=${()=>{this.removeMachine(e)}}>Remove</button>
|
|
2360
|
+
</div>
|
|
2361
|
+
`:null}
|
|
2362
|
+
</div>
|
|
2363
|
+
`:null}
|
|
2364
|
+
</div>
|
|
2365
|
+
`}renderActivity(e){const t=Is(e,this.statuses);if(t==="offline"||t==="error")return;const i=qa(this.activities[e.id]);return Ga(i,i==="terminal"?"Machine terminal active":"Machine active")}selectedMachine(){return this.selected??this.machines.find(e=>e.id==="local")??this.machines[0]}switcherButton(){return this.renderRoot.querySelector(".machine-switcher-button")}handleSwitcherButtonKeydown(e){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation(),this.openMenuAndFocusOption(e.currentTarget);return}if(e.key==="ArrowRight"&&this.onFocusNextSection!==void 0){e.preventDefault(),e.stopPropagation(),this.onFocusNextSection();return}e.key==="Escape"&&this.onCancelKeyboardNavigation!==void 0&&(e.preventDefault(),e.stopPropagation(),this.onCancelKeyboardNavigation())}handleMachineOptionKeydown(e){if(e.key==="ArrowUp"){this.focusRelativeMachineOption(e.currentTarget,-1,e);return}if(e.key==="ArrowDown"){this.focusRelativeMachineOption(e.currentTarget,1,e);return}if(e.key==="Home"){this.focusIndexedMachineOption(0,e);return}if(e.key==="End"){this.focusIndexedMachineOption(-1,e);return}if(e.key==="ArrowRight"&&this.onFocusNextSection!==void 0){e.preventDefault(),e.stopPropagation(),this.open=!1,this.onFocusNextSection();return}(e.key==="ArrowLeft"||e.key==="Escape")&&(e.preventDefault(),e.stopPropagation(),this.open=!1,this.updateComplete.then(()=>{this.focusSwitcherButton()}))}toggleMenu(e){this.menuStyle=Dn(e),this.open=!this.open,this.openActionsMachineId=void 0}focusSwitcherButton(){const e=this.switcherButton();return e===null?!1:(e.focus(),!0)}async openMenuAndFocusOption(e){return this.menuStyle=Dn(e),this.open=!0,this.openActionsMachineId=void 0,await this.updateComplete,this.focusSelectedMachineOption()}focusSelectedMachineOption(){const e=this.renderRoot.querySelector(".machine-option.selected .machine-option-main"),t=this.machineOptionButtons()[0],i=e??t;return i===void 0?!1:(i.focus(),i.scrollIntoView({block:"nearest"}),!0)}focusRelativeMachineOption(e,t,i){i.preventDefault(),i.stopPropagation();const s=this.machineOptionButtons();if(s.length===0||!(e instanceof HTMLElement))return;const r=s.indexOf(e);r<0||this.focusMachineOptionAt(r+t)}focusIndexedMachineOption(e,t){t.preventDefault(),t.stopPropagation(),this.focusMachineOptionAt(e<0?this.machineOptionButtons().length-1:e)}focusMachineOptionAt(e){const t=this.machineOptionButtons(),i=t[Math.min(Math.max(e,0),t.length-1)];i?.focus(),i?.scrollIntoView({block:"nearest"})}machineOptionButtons(){return Array.from(this.renderRoot.querySelectorAll(".machine-option-main"))}toggleActionsMenu(e,t){if(this.openActionsMachineId===e){this.openActionsMachineId=void 0;return}this.actionMenuStyle=Xt(t,{constrainTo:"viewport"}),this.openActionsMachineId=e}select(e){this.open=!1,this.openActionsMachineId=void 0,this.onSelect?.(e)}removeMachine(e){this.open=!1,this.openActionsMachineId=void 0,this.onRemove?.(e)}};oe.styles=O`
|
|
2366
|
+
:host { min-width: 0; display: block; }
|
|
2367
|
+
.machine-switcher { min-width: 0; }
|
|
2368
|
+
.machine-switcher-button { box-sizing: border-box; width: 100%; min-width: 0; display: flex; align-items: center; gap: 6px; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 8px; cursor: pointer; text-align: left; }
|
|
2369
|
+
.machine-switcher-button:hover, .machine-switcher-button:focus-visible { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
2370
|
+
.machine-switcher-text { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; }
|
|
2371
|
+
.machine-switcher-kicker { color: var(--pi-muted); font-size: 10px; line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
|
|
2372
|
+
.machine-switcher-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; line-height: 1.2; }
|
|
2373
|
+
.machine-status { flex: 0 0 auto; color: var(--pi-muted); font-size: 11px; }
|
|
2374
|
+
.machine-status.online { color: var(--pi-success); }
|
|
2375
|
+
.machine-status.offline, .machine-status.error { color: var(--pi-danger); }
|
|
2376
|
+
.machine-chevron { flex: 0 0 auto; color: var(--pi-muted); font-size: 11px; }
|
|
2377
|
+
.activity-indicator { flex: 0 0 auto; display: inline-block; width: 7px; height: 7px; background: var(--pi-success); animation: pulse 1s ease-in-out infinite; }
|
|
2378
|
+
.activity-indicator.session { border-radius: 50%; background: var(--pi-success); }
|
|
2379
|
+
.activity-indicator.terminal { border-radius: 2px; background: var(--pi-accent); }
|
|
2380
|
+
.activity-indicator.sending { border-radius: 50%; background: var(--pi-warning); }
|
|
2381
|
+
.machine-switcher-menu { position: fixed; z-index: 10000; box-sizing: border-box; min-width: min(280px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); }
|
|
2382
|
+
.machine-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px; align-items: stretch; margin: 2px 0; }
|
|
2383
|
+
.machine-option.no-actions { grid-template-columns: minmax(0, 1fr); }
|
|
2384
|
+
.machine-option-main, .machine-option-actions-toggle, .machine-option-actions-panel button { border: 0; border-radius: 7px; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
2385
|
+
.machine-option-main { min-width: 0; display: grid; gap: 2px; padding: 7px 8px; text-align: left; }
|
|
2386
|
+
.machine-option-name { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
|
|
2387
|
+
.machine-option-name span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2388
|
+
.machine-option-main small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pi-muted); }
|
|
2389
|
+
.machine-option-actions { position: relative; align-self: stretch; }
|
|
2390
|
+
.machine-option-actions-toggle { display: grid; place-items: center; height: 100%; min-width: 32px; padding: 0; color: var(--pi-muted); }
|
|
2391
|
+
.machine-option-actions-panel { position: fixed; z-index: 10001; box-sizing: border-box; min-width: min(120px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); }
|
|
2392
|
+
.machine-option-actions-panel button { display: block; width: 100%; padding: 7px 9px; text-align: left; white-space: nowrap; }
|
|
2393
|
+
.machine-option-actions-panel button.danger { color: var(--pi-danger); }
|
|
2394
|
+
.machine-option-main:hover, .machine-option-main:focus-visible, .machine-option-actions-toggle:hover, .machine-option-actions-toggle:focus-visible, .machine-option.selected .machine-option-main { background: var(--pi-selection-bg); }
|
|
2395
|
+
.machine-option-actions-panel button:hover, .machine-option-actions-panel button:focus-visible { background: var(--pi-selection-bg); }
|
|
2396
|
+
.machine-option-actions-panel button.danger:hover, .machine-option-actions-panel button.danger:focus-visible { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
2397
|
+
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
|
|
2398
|
+
`;me([d({attribute:!1})],oe.prototype,"machines",2);me([d({attribute:!1})],oe.prototype,"selected",2);me([d({attribute:!1})],oe.prototype,"statuses",2);me([d({attribute:!1})],oe.prototype,"activities",2);me([d({attribute:!1})],oe.prototype,"onSelect",2);me([d({attribute:!1})],oe.prototype,"onRemove",2);me([d({attribute:!1})],oe.prototype,"onFocusNextSection",2);me([d({attribute:!1})],oe.prototype,"onCancelKeyboardNavigation",2);me([v()],oe.prototype,"open",2);me([v()],oe.prototype,"menuStyle",2);me([v()],oe.prototype,"openActionsMachineId",2);me([v()],oe.prototype,"actionMenuStyle",2);oe=me([D("machine-switcher")],oe);function Is(e,t){return t[e.id]?.status??e.status??"unknown"}function Tn(e){return e==="online"?"online":e==="offline"?"offline":e==="error"?"error":"unknown"}function En(e){return e.baseUrl??e.name}function Dn(e){if(typeof HTMLElement>"u"||typeof window>"u"||!(e instanceof HTMLElement))return"";const t=e.getBoundingClientRect(),i=8,s=Math.min(280,Math.max(0,window.innerWidth-i*2)),r=Math.min(Math.max(i,t.left),Math.max(i,window.innerWidth-i-s)),o=Math.max(0,window.innerHeight-t.bottom-i);return[`top: ${ci(t.bottom)};`,`left: ${ci(r)};`,`width: ${ci(s)};`,`max-height: ${ci(o)};`].join(" ")}function ci(e){return`${String(Math.round(e))}px`}var Ty=Object.defineProperty,Ey=Object.getOwnPropertyDescriptor,k=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ey(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Ty(t,i,r),r};let S=class extends M{constructor(){super(...arguments),this.machines=[],this.machineStatuses={},this.machineActivities={},this.projects=[],this.workspaces=[],this.sessions=[],this.workspaceActivities={},this.sessionActivities={},this.sessionStatuses={},this.sendingPrompts={},this.workspacesByProjectId={},this.deletingWorkspaceIds=[],this.workspaceLabelItems=()=>[],this.collapsible=!1,this.compact=!1,this.machinesCollapsed=!1,this.projectsCollapsed=!1,this.workspacesCollapsed=!1,this.sessionsCollapsed=!1,this.canStartSession=!1,this.canDeleteArchivedSessions=!1,this.canReloadSessions=!1,this.canCleanupSessions=!1,this.archivedDeleteUnavailableMessage="Update and restart Pi-Web on this machine to delete archived sessions.",this.cleanupUnavailableMessage="Update and restart Pi-Web on this machine to clean up sessions."}async focusSection(e){switch(await this.updateComplete,e){case"machines":return await this.focusNavigableSection(this.compact?this.machineList:this.machineSwitcher);case"projects":return await this.focusNavigableSection(this.projectList);case"workspaces":return await this.focusNavigableSection(this.workspaceList);case"sessions":return await this.focusNavigableSection(this.sessionList)}}render(){return l`
|
|
2399
|
+
<header>
|
|
2400
|
+
<strong>PI WEB</strong>
|
|
2401
|
+
${Bi(this.machines)?l`
|
|
2402
|
+
<machine-switcher
|
|
2403
|
+
.machines=${this.machines}
|
|
2404
|
+
.selected=${this.selectedMachine}
|
|
2405
|
+
.statuses=${this.machineStatuses}
|
|
2406
|
+
.activities=${this.machineActivities}
|
|
2407
|
+
.onSelect=${e=>this.onSelectMachine?.(e)}
|
|
2408
|
+
.onRemove=${e=>this.onRemoveMachine?.(e)}
|
|
2409
|
+
.onFocusNextSection=${()=>{this.focusNextFrom("machines")}}
|
|
2410
|
+
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
2411
|
+
></machine-switcher>
|
|
2412
|
+
`:null}
|
|
2413
|
+
<div class="header-actions">
|
|
2414
|
+
${this.refreshControl}
|
|
2415
|
+
<button title="Show Actions" aria-label="Show Actions" @click=${()=>{this.onShowActions?.()}}>Actions</button>
|
|
2416
|
+
</div>
|
|
2417
|
+
</header>
|
|
2418
|
+
${this.compact&&Bi(this.machines)?l`
|
|
2419
|
+
<machine-list
|
|
2420
|
+
.machines=${this.machines}
|
|
2421
|
+
.selected=${this.selectedMachine}
|
|
2422
|
+
.statuses=${this.machineStatuses}
|
|
2423
|
+
.activities=${this.machineActivities}
|
|
2424
|
+
.collapsible=${this.collapsible}
|
|
2425
|
+
.collapsed=${this.machinesCollapsed}
|
|
2426
|
+
.onToggleCollapsed=${()=>{this.onToggleMachines?.()}}
|
|
2427
|
+
.onSelect=${e=>this.onSelectMachine?.(e)}
|
|
2428
|
+
.onRemove=${e=>this.onRemoveMachine?.(e)}
|
|
2429
|
+
.onFocusNextSection=${()=>{this.focusNextFrom("machines")}}
|
|
2430
|
+
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
2431
|
+
></machine-list>
|
|
2432
|
+
`:null}
|
|
2433
|
+
<project-list
|
|
2434
|
+
.projects=${this.projects}
|
|
2435
|
+
.selected=${this.selectedProject}
|
|
2436
|
+
.activities=${this.workspaceActivities}
|
|
2437
|
+
.workspacesByProjectId=${this.workspacesByProjectId}
|
|
2438
|
+
.collapsible=${this.collapsible}
|
|
2439
|
+
.collapsed=${this.projectsCollapsed}
|
|
2440
|
+
.onToggleCollapsed=${()=>{this.onToggleProjects?.()}}
|
|
2441
|
+
.onSelect=${e=>this.onSelectProject?.(e)}
|
|
2442
|
+
.onClose=${e=>this.onCloseProject?.(e)}
|
|
2443
|
+
.onFocusPreviousSection=${()=>{this.focusPreviousFrom("projects")}}
|
|
2444
|
+
.onFocusNextSection=${()=>{this.focusNextFrom("projects")}}
|
|
2445
|
+
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
2446
|
+
></project-list>
|
|
2447
|
+
<workspace-list
|
|
2448
|
+
.workspaces=${this.workspaces}
|
|
2449
|
+
.selected=${this.selectedWorkspace}
|
|
2450
|
+
.activities=${this.workspaceActivities}
|
|
2451
|
+
.deletingWorkspaceIds=${this.deletingWorkspaceIds}
|
|
2452
|
+
.collapsible=${this.collapsible}
|
|
2453
|
+
.collapsed=${this.workspacesCollapsed}
|
|
2454
|
+
.workspaceLabelItems=${this.workspaceLabelItems}
|
|
2455
|
+
.onToggleCollapsed=${()=>{this.onToggleWorkspaces?.()}}
|
|
2456
|
+
.onSelect=${e=>this.onSelectWorkspace?.(e)}
|
|
2457
|
+
.onDelete=${e=>this.onDeleteWorkspace?.(e)}
|
|
2458
|
+
.onFocusPreviousSection=${()=>{this.focusPreviousFrom("workspaces")}}
|
|
2459
|
+
.onFocusNextSection=${()=>{this.focusNextFrom("workspaces")}}
|
|
2460
|
+
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
2461
|
+
></workspace-list>
|
|
2462
|
+
<session-list
|
|
2463
|
+
.sessions=${this.sessions}
|
|
2464
|
+
.statuses=${this.sessionStatuses}
|
|
2465
|
+
.activities=${this.sessionActivities}
|
|
2466
|
+
.sending=${this.sendingPrompts}
|
|
2467
|
+
.selected=${this.selectedSession}
|
|
2468
|
+
.canStart=${this.canStartSession}
|
|
2469
|
+
.canDeleteArchived=${this.canDeleteArchivedSessions}
|
|
2470
|
+
.canReload=${this.canReloadSessions}
|
|
2471
|
+
.canCleanup=${this.canCleanupSessions}
|
|
2472
|
+
.archivedDeleteUnavailableMessage=${this.archivedDeleteUnavailableMessage}
|
|
2473
|
+
.cleanupUnavailableMessage=${this.cleanupUnavailableMessage}
|
|
2474
|
+
.collapsible=${this.collapsible}
|
|
2475
|
+
.collapsed=${this.sessionsCollapsed}
|
|
2476
|
+
.onToggleCollapsed=${()=>{this.onToggleSessions?.()}}
|
|
2477
|
+
.onArchivedCollapsed=${()=>this.onArchivedCollapsed?.()}
|
|
2478
|
+
.onStart=${()=>this.onStartSession?.()}
|
|
2479
|
+
.onSelect=${e=>this.onSelectSession?.(e)}
|
|
2480
|
+
.onArchive=${e=>this.onArchiveSession?.(e)}
|
|
2481
|
+
.onArchiveWithDescendants=${e=>this.onArchiveSessionWithDescendants?.(e)}
|
|
2482
|
+
.onArchiveMany=${e=>this.onArchiveSessions?.(e)}
|
|
2483
|
+
.onRestore=${e=>this.onRestoreSession?.(e)}
|
|
2484
|
+
.onDelete=${e=>this.onDeleteCachedNewSession?.(e)}
|
|
2485
|
+
.onDeleteArchived=${e=>this.onDeleteArchivedSession?.(e)}
|
|
2486
|
+
.onDeleteArchivedMany=${e=>this.onDeleteArchivedSessions?.(e)}
|
|
2487
|
+
.onDetachParent=${e=>this.onDetachParentSession?.(e)}
|
|
2488
|
+
.onReload=${e=>this.onReloadSession?.(e)}
|
|
2489
|
+
.onCleanup=${()=>this.onCleanupSessions?.()}
|
|
2490
|
+
.onFocusPreviousSection=${()=>{this.focusPreviousFrom("sessions")}}
|
|
2491
|
+
.onFocusNextSection=${()=>{this.focusNextFrom("sessions")}}
|
|
2492
|
+
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
2493
|
+
></session-list>
|
|
2494
|
+
`}async focusNavigableSection(e){return e===void 0?!1:await e.focusSelectedOrFirst()}focusPreviousFrom(e){const t=Dy(e,this.machines);t!==void 0&&this.onFocusNavigationTarget?.(t)}focusNextFrom(e){this.onFocusNavigationTarget?.(Wy(e,this.machines))}cancelKeyboardNavigation(){this.onCancelKeyboardNavigation?.()}};S.styles=O`
|
|
2495
|
+
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
2496
|
+
:host([compact]) { flex: 1 1 auto; }
|
|
2497
|
+
header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
2498
|
+
header strong { flex: 0 0 auto; }
|
|
2499
|
+
machine-switcher { flex: 1 1 auto; min-width: 0; }
|
|
2500
|
+
:host([compact]) header { display: none; }
|
|
2501
|
+
.header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
|
|
2502
|
+
machine-list, project-list, workspace-list { flex: 0 0 auto; max-height: 26%; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--pi-border-muted); }
|
|
2503
|
+
session-list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
2504
|
+
machine-list[collapsed],
|
|
2505
|
+
project-list[collapsed],
|
|
2506
|
+
workspace-list[collapsed],
|
|
2507
|
+
session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
2508
|
+
:host([compact]) machine-list,
|
|
2509
|
+
:host([compact]) project-list,
|
|
2510
|
+
:host([compact]) workspace-list,
|
|
2511
|
+
:host([compact]) session-list { flex: 1 1 auto; max-height: none; min-height: 0; overflow: hidden; }
|
|
2512
|
+
:host([compact]) machine-list[collapsed],
|
|
2513
|
+
:host([compact]) project-list[collapsed],
|
|
2514
|
+
:host([compact]) workspace-list[collapsed],
|
|
2515
|
+
:host([compact]) session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
2516
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
2517
|
+
`;k([d({attribute:!1})],S.prototype,"machines",2);k([d({attribute:!1})],S.prototype,"selectedMachine",2);k([d({attribute:!1})],S.prototype,"machineStatuses",2);k([d({attribute:!1})],S.prototype,"machineActivities",2);k([d({attribute:!1})],S.prototype,"projects",2);k([d({attribute:!1})],S.prototype,"selectedProject",2);k([d({attribute:!1})],S.prototype,"workspaces",2);k([d({attribute:!1})],S.prototype,"selectedWorkspace",2);k([d({attribute:!1})],S.prototype,"sessions",2);k([d({attribute:!1})],S.prototype,"selectedSession",2);k([d({attribute:!1})],S.prototype,"workspaceActivities",2);k([d({attribute:!1})],S.prototype,"sessionActivities",2);k([d({attribute:!1})],S.prototype,"sessionStatuses",2);k([d({attribute:!1})],S.prototype,"sendingPrompts",2);k([d({attribute:!1})],S.prototype,"workspacesByProjectId",2);k([d({attribute:!1})],S.prototype,"deletingWorkspaceIds",2);k([d({attribute:!1})],S.prototype,"workspaceLabelItems",2);k([d({attribute:!1})],S.prototype,"refreshControl",2);k([d({type:Boolean,reflect:!0})],S.prototype,"collapsible",2);k([d({type:Boolean,reflect:!0})],S.prototype,"compact",2);k([d({type:Boolean})],S.prototype,"machinesCollapsed",2);k([d({type:Boolean})],S.prototype,"projectsCollapsed",2);k([d({type:Boolean})],S.prototype,"workspacesCollapsed",2);k([d({type:Boolean})],S.prototype,"sessionsCollapsed",2);k([d({type:Boolean})],S.prototype,"canStartSession",2);k([d({type:Boolean})],S.prototype,"canDeleteArchivedSessions",2);k([d({type:Boolean})],S.prototype,"canReloadSessions",2);k([d({type:Boolean})],S.prototype,"canCleanupSessions",2);k([d({type:String})],S.prototype,"archivedDeleteUnavailableMessage",2);k([d({type:String})],S.prototype,"cleanupUnavailableMessage",2);k([d({attribute:!1})],S.prototype,"onShowActions",2);k([d({attribute:!1})],S.prototype,"onToggleMachines",2);k([d({attribute:!1})],S.prototype,"onToggleProjects",2);k([d({attribute:!1})],S.prototype,"onToggleWorkspaces",2);k([d({attribute:!1})],S.prototype,"onToggleSessions",2);k([d({attribute:!1})],S.prototype,"onSelectProject",2);k([d({attribute:!1})],S.prototype,"onCloseProject",2);k([d({attribute:!1})],S.prototype,"onSelectWorkspace",2);k([d({attribute:!1})],S.prototype,"onDeleteWorkspace",2);k([d({attribute:!1})],S.prototype,"onStartSession",2);k([d({attribute:!1})],S.prototype,"onSelectSession",2);k([d({attribute:!1})],S.prototype,"onArchiveSession",2);k([d({attribute:!1})],S.prototype,"onArchiveSessionWithDescendants",2);k([d({attribute:!1})],S.prototype,"onArchiveSessions",2);k([d({attribute:!1})],S.prototype,"onRestoreSession",2);k([d({attribute:!1})],S.prototype,"onDeleteCachedNewSession",2);k([d({attribute:!1})],S.prototype,"onDeleteArchivedSession",2);k([d({attribute:!1})],S.prototype,"onDeleteArchivedSessions",2);k([d({attribute:!1})],S.prototype,"onDetachParentSession",2);k([d({attribute:!1})],S.prototype,"onReloadSession",2);k([d({attribute:!1})],S.prototype,"onCleanupSessions",2);k([d({attribute:!1})],S.prototype,"onArchivedCollapsed",2);k([d({attribute:!1})],S.prototype,"onSelectMachine",2);k([d({attribute:!1})],S.prototype,"onRemoveMachine",2);k([d({attribute:!1})],S.prototype,"onFocusNavigationTarget",2);k([d({attribute:!1})],S.prototype,"onCancelKeyboardNavigation",2);k([z("machine-list")],S.prototype,"machineList",2);k([z("machine-switcher")],S.prototype,"machineSwitcher",2);k([z("project-list")],S.prototype,"projectList",2);k([z("workspace-list")],S.prototype,"workspaceList",2);k([z("session-list")],S.prototype,"sessionList",2);S=k([D("app-navigation-panel")],S);function Bi(e){return e.length>1}function Dy(e,t){const i=kl(t);return i[i.indexOf(e)-1]}function Wy(e,t){const i=kl(t);return i[i.indexOf(e)+1]??"chat"}function kl(e){return ji.filter(t=>t!=="machines"||Bi(e))}var Oy=Object.defineProperty,jy=Object.getOwnPropertyDescriptor,se=(e,t,i,s)=>{for(var r=s>1?void 0:s?jy(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Oy(t,i,r),r};const _y=new Set(["ArrowLeft","ArrowRight","Home","End"]),Ly=420,Fy=4;let V=class extends M{constructor(){super(...arguments),this.side="navigation",this.collapsed=!1,this.resizable=!1,this.controls="",this.resizeLabel="Resize panel",this.expandLabel="Expand panel",this.collapseLabel="Collapse panel",this.lastTapAt=0}disconnectedCallback(){this.finishActiveResize(),super.disconnectedCallback()}render(){const e=this.collapsed?this.expandLabel:this.collapseLabel;return l`
|
|
2518
|
+
${this.renderResizeHandle()}
|
|
2519
|
+
<button
|
|
2520
|
+
type="button"
|
|
2521
|
+
class="edge-button"
|
|
2522
|
+
title=${e}
|
|
2523
|
+
aria-label=${e}
|
|
2524
|
+
aria-controls=${this.controls}
|
|
2525
|
+
aria-expanded=${String(!this.collapsed)}
|
|
2526
|
+
@click=${()=>{this.onToggle?.()}}
|
|
2527
|
+
>${this.renderIcon()}</button>
|
|
2528
|
+
`}renderResizeHandle(){if(!this.resizable)return U;const e=this.resizeConstraints();return l`
|
|
2529
|
+
<div
|
|
2530
|
+
class="resize-handle"
|
|
2531
|
+
role="separator"
|
|
2532
|
+
tabindex="0"
|
|
2533
|
+
aria-label=${this.resizeLabel}
|
|
2534
|
+
title=${`${this.resizeLabel}. Double-click or double-tap to reset.`}
|
|
2535
|
+
aria-controls=${this.controls}
|
|
2536
|
+
aria-orientation="vertical"
|
|
2537
|
+
aria-valuemin=${String(e.minWidth)}
|
|
2538
|
+
aria-valuemax=${String(e.maxWidth)}
|
|
2539
|
+
aria-valuenow=${this.resizeAriaValueNow()}
|
|
2540
|
+
@pointerdown=${t=>{this.onResizePointerDown(t)}}
|
|
2541
|
+
@pointermove=${t=>{this.onResizePointerMove(t)}}
|
|
2542
|
+
@pointerup=${t=>{this.onResizePointerUp(t)}}
|
|
2543
|
+
@pointercancel=${t=>{this.onResizePointerCancel(t)}}
|
|
2544
|
+
@dblclick=${t=>{this.onResizeDoubleClick(t)}}
|
|
2545
|
+
@keydown=${t=>{this.onResizeKeyDown(t)}}
|
|
2546
|
+
></div>
|
|
2547
|
+
`}resizeAriaValueNow(){return this.panelWidth===void 0?U:String(Math.round(this.panelWidth))}renderIcon(){const t=this.iconDirection()==="left"?"M15 18l-6-6 6-6":"M9 18l6-6-6-6";return l`<svg class="edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${t}/></svg>`}iconDirection(){return this.side==="navigation"?this.collapsed?"right":"left":this.collapsed?"left":"right"}onResizePointerDown(e){if(!this.resizable||e.button!==0)return;const t=e.currentTarget;if(!(t instanceof HTMLElement))return;const i=this.resizeStartWidth();i!==void 0&&(e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),this.activeResize={pointerId:e.pointerId,startClientX:e.clientX,startWidth:i,handle:t,moved:!1},this.toggleAttribute("resizing",!0))}onResizePointerMove(e){const t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),!(Math.abs(e.clientX-t.startClientX)<=Fy)&&(t.moved=!0,this.commitPanelWidth(Jg(this.side,t.startWidth,t.startClientX,e.clientX,this.resizeConstraints()))))}onResizePointerUp(e){const t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),this.finishActiveResize(),t.moved||this.registerTapForReset())}onResizePointerCancel(e){this.activeResize?.pointerId===e.pointerId&&this.finishActiveResize()}onResizeDoubleClick(e){e.preventDefault(),e.stopPropagation(),this.resetPanelSize()}onResizeKeyDown(e){if(!this.resizable||!_y.has(e.key))return;const t=this.resizeStartWidth();if(t===void 0)return;const i=Zg(this.side,t,e.key,{largeStep:e.shiftKey,constraints:this.resizeConstraints()});i!==void 0&&(e.preventDefault(),e.stopPropagation(),this.commitPanelWidth(i),this.onResizeEnd?.())}registerTapForReset(){const e=Date.now();if(e-this.lastTapAt<=Ly){this.lastTapAt=0,this.resetPanelSize();return}this.lastTapAt=e}resetPanelSize(){this.finishActiveResize(),this.onReset?.()}resizeStartWidth(){const e=this.onResizeStart?.()??this.panelWidth;if(e!==void 0)return we(this.side,e,this.resizeConstraints())}commitPanelWidth(e){this.onResize?.(we(this.side,e,this.resizeConstraints()))}finishActiveResize(){const e=this.activeResize;if(e!==void 0){try{e.handle.releasePointerCapture(e.pointerId)}catch{}this.activeResize=void 0,this.toggleAttribute("resizing",!1),this.onResizeEnd?.()}}resizeConstraints(){const e=Zt(this.side);return{...e,minWidth:this.minWidth??e.minWidth,maxWidth:this.maxWidth??e.maxWidth}}};V.styles=O`
|
|
2548
|
+
:host { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
|
2549
|
+
:host([side="navigation"]) { grid-column: 2; }
|
|
2550
|
+
:host([side="workspace"]) { grid-column: 4; }
|
|
2551
|
+
.resize-handle { position: absolute; inset: 0 -6px; z-index: 0; cursor: col-resize; touch-action: none; outline: none; }
|
|
2552
|
+
.resize-handle::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; transform: translateX(-50%); background: transparent; transition: width .12s ease, background .12s ease, opacity .12s ease; }
|
|
2553
|
+
.resize-handle:hover::after, .resize-handle:focus-visible::after, :host([resizing]) .resize-handle::after { width: 3px; background: var(--pi-accent); opacity: .72; }
|
|
2554
|
+
.edge-button { position: relative; z-index: 1; box-sizing: border-box; display: grid; place-items: center; width: 18px; height: 48px; padding: 0; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-bg); color: var(--pi-muted); opacity: .75; cursor: pointer; }
|
|
2555
|
+
.edge-button:hover, .edge-button:focus-visible { color: var(--pi-text); background: var(--pi-surface-hover); opacity: 1; }
|
|
2556
|
+
:host([side="navigation"][collapsed]) .edge-button { transform: translateX(calc(50% - .5px)); }
|
|
2557
|
+
:host([side="workspace"][collapsed]) .edge-button { transform: translateX(calc(-50% + .5px)); }
|
|
2558
|
+
.edge-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
2559
|
+
@media (max-width: 1180px) {
|
|
2560
|
+
:host([side="navigation"]) { grid-row: 1 / 3; }
|
|
2561
|
+
:host([side="workspace"]) { display: none; }
|
|
2562
|
+
}
|
|
2563
|
+
@media (max-width: 760px) {
|
|
2564
|
+
:host([side="navigation"]) { display: none; }
|
|
2565
|
+
}
|
|
2566
|
+
`;se([d({reflect:!0})],V.prototype,"side",2);se([d({type:Boolean,reflect:!0})],V.prototype,"collapsed",2);se([d({type:Boolean})],V.prototype,"resizable",2);se([d({type:Number})],V.prototype,"panelWidth",2);se([d({type:Number})],V.prototype,"minWidth",2);se([d({type:Number})],V.prototype,"maxWidth",2);se([d()],V.prototype,"controls",2);se([d()],V.prototype,"resizeLabel",2);se([d()],V.prototype,"expandLabel",2);se([d()],V.prototype,"collapseLabel",2);se([d({attribute:!1})],V.prototype,"onToggle",2);se([d({attribute:!1})],V.prototype,"onResizeStart",2);se([d({attribute:!1})],V.prototype,"onResize",2);se([d({attribute:!1})],V.prototype,"onResizeEnd",2);se([d({attribute:!1})],V.prototype,"onReset",2);V=se([D("app-panel-edge-control")],V);var Ny=Object.defineProperty,Uy=Object.getOwnPropertyDescriptor,$l=(e,t,i,s)=>{for(var r=s>1?void 0:s?Uy(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Ny(t,i,r),r};let Hi=class extends M{constructor(){super(...arguments),this.onReloadClick=e=>{e.stopPropagation(),this.onReload?.()}}render(){const e="Full page reload";return l`
|
|
2567
|
+
<button
|
|
2568
|
+
class="app-refresh-button"
|
|
2569
|
+
title=${e}
|
|
2570
|
+
aria-label=${e}
|
|
2571
|
+
@click=${this.onReloadClick}
|
|
2572
|
+
>${this.renderRefreshIcon()}</button>
|
|
2573
|
+
`}renderRefreshIcon(){return l`
|
|
2574
|
+
<svg class="app-refresh-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2575
|
+
<path d="M20 6v5h-5"></path>
|
|
2576
|
+
<path d="M4 18v-5h5"></path>
|
|
2577
|
+
<path d="M18.2 9A7 7 0 0 0 6.1 6.8L4 9"></path>
|
|
2578
|
+
<path d="M5.8 15a7 7 0 0 0 12.1 2.2L20 15"></path>
|
|
2579
|
+
</svg>
|
|
2580
|
+
`}};Hi.styles=O`
|
|
2581
|
+
:host { position: relative; z-index: 1; display: flex; align-items: center; pointer-events: auto; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
|
|
2582
|
+
:host, :host * { -webkit-user-select: none; user-select: none; }
|
|
2583
|
+
.app-refresh-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 0; line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-touch-callout: none; }
|
|
2584
|
+
.app-refresh-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
2585
|
+
`;$l([d({attribute:!1})],Hi.prototype,"onReload",2);Hi=$l([D("app-refresh-control")],Hi);var zy=Object.defineProperty,By=Object.getOwnPropertyDescriptor,ve=(e,t,i,s)=>{for(var r=s>1?void 0:s?By(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&zy(t,i,r),r};const Hy=900*1e3,qy=750,Ys=[1e3,3e3,8e3,15e3,3e4],Wn={capture:!0},As="auto:on",On="auto:off",di="theme:",Ms=Vt("core:workspace.files"),Ts=Vt("core:workspace.git"),pi=Vt("core:workspace.terminal"),Ky=320,Vy=2,Gy="(min-width: 1181px)";let ne=class extends M{constructor(){super(...arguments),this.state=hp(),this.sessions=new lu(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new iu),this.activity=new up(()=>this.state,e=>{this.setState(e)}),this.auth=new mp(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new Su(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new yu),this.projects=new Mp(()=>this.state,e=>{this.setState(e)},this.workspaces),this.machines=new Ap(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.files=new $p(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new Ip(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new Ou,this.realtime=new Ao,this.machineActivitySockets=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new Cu,this.terminalSelection=new Du,this.appShell=new Og(this),this.panelCollapse=new Kg(this),this.panelResize=new Gg(this),this.navigationSections=new Bg(this,()=>this.state,()=>this.appShell.isMobileNavigationLayout),this.systemLightThemeMedia=typeof window<"u"&&"matchMedia"in window?window.matchMedia("(prefers-color-scheme: light)"):void 0,this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.machineNavigationRestoreSeq=0,this.navigationSelectionSeq=0,this.routeRestoreSeq=0,this.routeRestoreDepth=0,this.remoteRouteRestoreAttempt=0,this.remoteRouteRestoreInProgress=!1,this.plugins=Qy(),this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=ef()??Zu,this.activeThemeId=Sr,this.isRefreshingApp=!1,this.settingsSection=Xo(),this.shortcutConfig={},this.workspaceUploadDefaultFolder=uo(void 0),this.onPopState=()=>{this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)})},this.onPageShow=()=>{this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onFocus=()=>{this.appShell.repairViewportPosition(),this.sessions.refreshSelectedSession(),this.schedulePiWebStatusRefresh(),this.refreshMachineActivities(),this.refreshWorkspaceDeletionRuns(),this.retryPendingRemoteRouteRestoreSoon()},this.onVisibilityChange=()=>{document.visibilityState==="visible"&&(this.appShell.repairViewportPosition(),this.sessions.refreshSelectedSession(),this.schedulePiWebStatusRefresh(),this.refreshMachineActivities(),this.refreshWorkspaceDeletionRuns(),this.retryPendingRemoteRouteRestoreSoon())},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onKeyDown=e=>{this.settingsSection===void 0&&this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())}}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute("pwa-display-mode",this.appShell.isPwaDisplayMode)}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this.onPopState),window.addEventListener("pageshow",this.onPageShow),window.addEventListener("focus",this.onFocus),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("keydown",this.onKeyDown,Wn),this.systemLightThemeMedia?.addEventListener("change",this.onSystemLightThemeChange),this.applyPreferredTheme(!1),this.connectRealtime(),this.piWebStatusTimer=window.setInterval(()=>{this.schedulePiWebStatusRefresh()},Hy),this.refreshWorkspaceActivity(),this.loadClientConfig(),this.ensureGatewayPluginsLoaded(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebStatusRefresh()})}disconnectedCallback(){window.removeEventListener("popstate",this.onPopState),window.removeEventListener("pageshow",this.onPageShow),window.removeEventListener("focus",this.onFocus),document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("keydown",this.onKeyDown,Wn),this.systemLightThemeMedia?.removeEventListener("change",this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.git.dispose(),this.piWebStatusTimer!==void 0&&window.clearInterval(this.piWebStatusTimer),this.piWebStatusTimer=void 0,this.clearScheduledPiWebStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.clearPendingRemoteRouteRestore(),super.disconnectedCallback()}setState(e){if(!Xy(this.state,e))return;const t=this.state;this.state={...this.state,...e},this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),this.handleMachineChange(t,this.state),Jy(t,this.state)&&this.syncMachineActivitySubscriptions()}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();const e=Zo();await this.machines.loadMachines(e.machineId);const t=this.routeForSelectedMachine(e),i=this.state.machineStatuses[t.machineId??"local"];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,i)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}schedulePiWebStatusRefresh(e=qy){this.clearScheduledPiWebStatusRefresh(),this.piWebStatusDeferredTimer=window.setTimeout(()=>{this.piWebStatusDeferredTimer=void 0,this.refreshPiWebStatus()},e)}clearScheduledPiWebStatusRefresh(){this.piWebStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebStatusDeferredTimer),this.piWebStatusDeferredTimer=void 0)}async refreshPiWebStatus(){const e=g(this.state);try{const t=await ra.piWebStatus(e);g(this.state)===e&&this.setState({piWebStatus:t})}catch(t){g(this.state)===e&&this.setState({piWebStatus:void 0}),console.warn(`Failed to refresh PI WEB status for ${e}`,t)}}async refreshWorkspaceActivity(e=g(this.state)){try{await this.activity.refresh(e)}catch(t){console.warn(`Failed to refresh workspace activity for ${e}`,t)}}async refreshMachineActivities(){const e=this.state.machines.length===0?[g(this.state)]:this.state.machines.filter(t=>Pl(t,this.state.machineStatuses[t.id])).map(t=>t.id);await Promise.all(e.map(t=>this.refreshWorkspaceActivity(t)))}async loadClientConfig(){try{this.applyClientConfig((await Ci.config()).effectiveConfig)}catch(e){console.warn("Failed to load PI WEB config",e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=uo(e)}async refreshAppData(){if(!this.isRefreshingApp){this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.loadClientConfig(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface()]),this.schedulePiWebStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){const e=this.state.selectedWorkspace,t=this.state.mainView!=="chat"&&this.state.mainView!=="navigation"?this.state.mainView:this.state.workspaceTool;t==="core:workspace.files"?await this.files.refreshFiles():t==="core:workspace.git"?await this.git.refreshGit():t==="core:workspace.terminal"&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(Zo(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,i=this.readWorkspaceRouteSurface(e),s){const r=g(this.state),o=e.projectId===void 0||e.projectId===""?Ln():i,n=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=o.selectedTerminalId;try{await this.restoreRouteMachine(e,!1);const a=this.loadPluginsForSelectedMachine();if(e.tool?.startsWith("machine.")===!0&&await a,!this.isCurrentRouteRestore(n))return;if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:s??e.view??this.defaultRouteView(),selectedFilePath:o.selectedFilePath,selectedDiffPath:o.selectedDiffPath,selectedTerminalId:o.selectedTerminalId}),e.projectId===void 0||e.projectId===""){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(e)){o.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(o.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,o.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl();return}const c=this.state.projects.find(p=>p.id===e.projectId);if(!c){this.setState({selectedFilePath:void 0,selectedDiffPath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(c,{workspaceId:e.workspaceId,sessionId:e.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(n))return;this.setState({selectedFilePath:o.selectedFilePath,selectedDiffPath:o.selectedDiffPath,selectedTerminalId:o.selectedTerminalId}),o.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(o.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,o.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),g(this.state)!==r&&this.schedulePiWebStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===""?Ln():{selectedFilePath:ps(Ms,"file"),selectedDiffPath:ps(Ts,"diff"),selectedTerminalId:ps(pi,"terminal")}}routeForSelectedMachine(e){const t=this.state.selectedMachine?.id??"local";return(e.machineId??"local")===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){vs(e,{replace:!0}),Re(Ms,"file",void 0,{replace:!0}),Re(Ts,"diff",void 0,{replace:!0}),Re(pi,"terminal",void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??"local"]){const i=e.machineId??"local",s=this.state.selectedMachine;return i==="local"||s?.id!==i||s.kind!=="remote"||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===""?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=e0(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;const e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{const t=e.machineId??"local",i=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(i?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==""){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=Ys.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){const i=e.machineId??"local",s=this.state.machines.find(a=>a.id===i)?.name??this.state.selectedMachine?.name??"Remote machine",o=this.state.machineStatuses[i]?.error??(this.state.error===""?void 0:this.state.error),n=t.exhausted===!0?`${s} is still unavailable.`:`${s} is unavailable; reconnecting…`;this.setState({error:`${n}${o===void 0?"":` ${o}`}`})}pendingRemoteRouteRestoreStillCurrent(e){const t=e.machineId??"local";return t!=="local"&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(i=>i.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){const i=e.machineId??"local";if(this.state.selectedMachine?.id===i)return;const s=this.state.machines.find(r=>r.id===i);s!==void 0&&await this.machines.selectMachine(s,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??"local")===(this.state.selectedMachine?.id??"local")&&e.workspaceId!==void 0&&e.workspaceId!==""&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e==="core:workspace.files"&&await this.files.refreshFiles(),e==="core:workspace.files"&&t!==void 0&&await this.files.restoreFile(t),e==="core:workspace.git"&&await this.git.refreshGit()}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await Ds(),t()&&(this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()))))}shouldAutoFocusPrompt(){return this.appShell.shouldAutoFocusPrompt()}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(){return this.appShell.defaultRouteView()}updateUrl(e){this.rememberCurrentMachineNavigation(),vs({machineId:this.state.selectedMachine?.id,projectId:this.state.selectedProject?.id,workspaceId:this.state.selectedWorkspace?.id,sessionId:this.state.selectedSession?.id,tool:this.state.workspaceTool,view:this.state.mainView==="navigation"?void 0:this.state.mainView},e),this.syncWorkspaceRouteSurfaceToUrl()}rememberCurrentMachineNavigation(){this.machineNavigation.remember(Do(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(Do(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){vs(Wo(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){Re(Ms,"file",e.selectedFilePath,{replace:!0}),Re(Ts,"diff",e.selectedDiffPath,{replace:!0}),Re(pi,"terminal",e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();const i=++this.machineNavigationRestoreSeq,s=this.machineNavigation.latest(e.id)??Ru(e.id);if(await this.restoreRouteFor(Wo(s),!1,s.surface,s.view),!(i!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(s)){this.machineNavigation.remember(s),this.writeMachineNavigationSnapshotToUrl(s);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==""}openWorkspaceTool(e){e==="core:workspace.terminal"&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e),this.git.updatePolling()}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool("core:workspace.terminal")}terminalCommandRunsForOrigin(e,t=g(this.state)){const i=Fn(t,e),s=this.terminalCommandRunRuntimes.get(i);if(s!==void 0)return s;const r=pm(e,{api:{runTerminalCommand:(o,n)=>wt.runTerminalCommand(o,n,t),listCommandRuns:o=>wt.listCommandRuns(o,t),getCommandRun:o=>wt.getCommandRun(o,t)},openTerminal:(o,n)=>{this.openRuntimeTerminal(t,o,n)}});return this.terminalCommandRunRuntimes.set(i,r),r}async openRuntimeTerminal(e,t,i){if((g(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:"core:workspace.terminal",view:"core:workspace.terminal"},!1,{selectedTerminalId:i?.terminalId},"core:workspace.terminal"),g(this.state)!==e)){this.setState({error:"Machine not found for terminal command run"});return}this.openTerminal(i)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){const t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){Re(pi,"terminal",e,t)}terminalWorkspaceKey(e){return`${g(this.state)}:${e.path}`}selectMainView(e){if(e!=="navigation"&&e!=="chat"){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}openSettings(e="general"){this.settingsSection=e,bs(e)}closeSettings(){this.settingsSection=void 0,bs(void 0)}navigateSettings(e){this.settingsSection=e,bs(e)}restoreSettingsRoute(){this.settingsSection=Xo()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();const i=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));this.setState({activeTerminalCount:0,selectedTerminalId:i}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(i,{replace:!0})),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling())}connectRealtime(){this.realtime.connect(e=>{this.handleRealtimeEvent(e)},()=>{const e=this.state.selectedWorkspace;e!==void 0&&this.refreshActiveTerminals(e),this.refreshWorkspaceActivity()},g(this.state))}syncMachineActivitySubscriptions(){const e=this.machineActivitySubscriptionIds();for(const[t,i]of this.machineActivitySockets.entries())e.has(t)||(i.close(),this.machineActivitySockets.delete(t));for(const t of e){if(this.machineActivitySockets.has(t))continue;const i=new Ao;i.connect(s=>{this.handleMachineActivityEvent(t,s)},()=>{this.refreshWorkspaceActivity(t)},t),this.machineActivitySockets.set(t,i)}}closeMachineActivitySockets(){for(const e of this.machineActivitySockets.values())e.close();this.machineActivitySockets.clear()}machineActivitySubscriptionIds(){const e=g(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(t=>Zy(t,this.state.machineStatuses[t.id])).map(t=>t.id))}handleMachineActivityEvent(e,t){t.type==="workspace.activity"&&this.activity.applyWorkspaceActivity(t.activity,e)}handleRealtimeEvent(e){e.type==="workspace.activity"?this.activity.applyWorkspaceActivity(e.activity):Yy(e)?(this.applyTerminalEvent(e),e.type==="terminal.exited"&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(e)}applyTerminalEvent(e){const t=this.state.selectedWorkspace;t===void 0||(e.type==="terminal.closed"?e.cwd:e.terminal.cwd)!==t.path||(e.type==="terminal.created"&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type==="terminal.closed"?e.terminalId:e.terminal.id),e.type==="terminal.closed"&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){const t=g(this.state);try{const i=await wt.terminals(e.projectId,e.id,t);if(g(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(const s of i)s.exited||this.activeTerminalIds.add(s.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(i){this.setState({error:String(i)})}}handleActivityTransition(e,t){const i=_n(e),s=_n(t);i&&!s&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){if((e.selectedMachine?.id??"local")===(t.selectedMachine?.id??"local"))return;(this.pendingRemoteRouteRestore?.machineId??"local")!==(t.selectedMachine?.id??"local")&&this.clearPendingRemoteRouteRestore(),this.sessions.clearActiveSession(),this.realtime.close(),this.connectRealtime(),this.activeTerminalIds.clear(),this.sessionCleanupDialog=void 0,this.setState({piWebStatus:void 0}),this.git.updatePolling(),this.loadPluginsForSelectedMachine()}refreshSelectedWorkspaceTool(e){e==="core:workspace.files"&&this.files.refreshFiles(),e==="core:workspace.git"&&this.git.refreshGit()}renderWorkspacePanel(){const e=this.state.selectedWorkspace,t=e===void 0?void 0:this.createWorkspacePanelContext(e),i=e===void 0?this.workspacePanelEmptyState():void 0;return l`
|
|
2586
|
+
<workspace-panel
|
|
2587
|
+
id="workspace-panel"
|
|
2588
|
+
.workspace=${e}
|
|
2589
|
+
.panelContext=${t}
|
|
2590
|
+
.emptyState=${i}
|
|
2591
|
+
.tool=${this.state.workspaceTool}
|
|
2592
|
+
.panels=${this.visibleWorkspacePanels()}
|
|
2593
|
+
.onSelectTool=${s=>{this.openWorkspaceTool(s)}}
|
|
2594
|
+
></workspace-panel>
|
|
2595
|
+
`}renderNavigationPanelEdgeControl(){const e=this.resizablePanelConstraints("navigation");return l`
|
|
2596
|
+
<app-panel-edge-control
|
|
2597
|
+
side="navigation"
|
|
2598
|
+
controls="navigation-panel"
|
|
2599
|
+
resizeLabel="Resize navigation panel"
|
|
2600
|
+
expandLabel="Expand navigation panel"
|
|
2601
|
+
collapseLabel="Collapse navigation panel"
|
|
2602
|
+
.collapsed=${this.panelCollapse.navigationPanelCollapsed}
|
|
2603
|
+
.resizable=${!this.appShell.isMobileNavigationLayout}
|
|
2604
|
+
.panelWidth=${this.panelResize.panelWidth("navigation")}
|
|
2605
|
+
.minWidth=${e.minWidth}
|
|
2606
|
+
.maxWidth=${e.maxWidth}
|
|
2607
|
+
.onToggle=${()=>{this.panelCollapse.toggleNavigationPanel()}}
|
|
2608
|
+
.onResizeStart=${()=>this.startPanelResize("navigation")}
|
|
2609
|
+
.onResize=${t=>{this.panelResize.resizePanel("navigation",t,{persist:!1})}}
|
|
2610
|
+
.onResizeEnd=${()=>{this.panelResize.persistPanelSizes()}}
|
|
2611
|
+
.onReset=${()=>{this.resetResizablePanel("navigation")}}
|
|
2612
|
+
></app-panel-edge-control>
|
|
2613
|
+
`}renderWorkspacePanelEdgeControl(){const e=this.resizablePanelConstraints("workspace");return l`
|
|
2614
|
+
<app-panel-edge-control
|
|
2615
|
+
side="workspace"
|
|
2616
|
+
controls="workspace-panel"
|
|
2617
|
+
resizeLabel="Resize workspace panel"
|
|
2618
|
+
expandLabel="Expand workspace panel"
|
|
2619
|
+
collapseLabel="Collapse workspace panel"
|
|
2620
|
+
.collapsed=${this.panelCollapse.workspacePanelCollapsed}
|
|
2621
|
+
.resizable=${!this.appShell.isMobileNavigationLayout}
|
|
2622
|
+
.panelWidth=${this.panelResize.panelWidth("workspace")}
|
|
2623
|
+
.minWidth=${e.minWidth}
|
|
2624
|
+
.maxWidth=${e.maxWidth}
|
|
2625
|
+
.onToggle=${()=>{this.panelCollapse.toggleWorkspacePanel()}}
|
|
2626
|
+
.onResizeStart=${()=>this.startPanelResize("workspace")}
|
|
2627
|
+
.onResize=${t=>{this.panelResize.resizePanel("workspace",t,{persist:!1})}}
|
|
2628
|
+
.onResizeEnd=${()=>{this.panelResize.persistPanelSizes()}}
|
|
2629
|
+
.onReset=${()=>{this.resetResizablePanel("workspace")}}
|
|
2630
|
+
></app-panel-edge-control>
|
|
2631
|
+
`}startPanelResize(e){return e==="navigation"?this.panelCollapse.expandNavigationPanel():this.panelCollapse.expandWorkspacePanel(),this.measuredPanelWidth(e)??this.panelResize.panelWidth(e)}resizablePanelConstraints(e){const t=this.panelResize.constraints(e);return{...t,maxWidth:this.resizablePanelMaxWidth(e,t)}}resizablePanelMaxWidth(e,t){const i=this.getBoundingClientRect().width||(typeof window>"u"?0:window.innerWidth);if(i<=0)return t.maxWidth;const s=this.oppositeResizablePanelWidth(e),r=Math.floor(i-s-Vy-Ky);return Math.max(t.minWidth,Math.min(t.maxWidth,r))}oppositeResizablePanelWidth(e){const t=e==="navigation"?"workspace":"navigation";return this.isResizablePanelCollapsedOrStacked(t)?0:this.measuredPanelWidth(t)??this.panelResize.panelWidth(t)}isResizablePanelCollapsedOrStacked(e){return e==="navigation"?this.panelCollapse.navigationPanelCollapsed:this.panelCollapse.workspacePanelCollapsed||!this.isDesktopSideBySideLayout()}isDesktopSideBySideLayout(){return typeof window>"u"||!("matchMedia"in window)?!0:window.matchMedia(Gy).matches}measuredPanelWidth(e){const i=(e==="navigation"?this.navigationPanelFrame:this.workspacePanelFrame)?.getBoundingClientRect().width;return i===void 0||i<=0?void 0:i}resetResizablePanel(e){this.panelResize.resetPanel(e)}resetResizablePanels(){this.panelResize.resetPanels()}canDeleteArchivedSessions(){const e=this.selectedMachineRuntime();return e?.ok===!0&&nt(e,Qe.sessionsDeleteArchived)}canReloadSessions(){const e=this.selectedMachineRuntime();return e?.ok===!0&&nt(e,Qe.sessionsReload)}canCleanupSessions(){const e=this.selectedMachineRuntime();return e?.ok===!0&&nt(e,Qe.sessionsCleanup)}supportsWorkspaceFileSuggestions(e=g(this.state)){if(e==="local")return!0;const t=this.state.machineRuntimes[e];return t?.ok===!0&&nt(t,Qe.workspaceFileSuggestions)}archivedDeleteUnavailableMessage(){return`Update and restart Pi-Web on ${this.state.selectedMachine?.name??"this machine"} to delete archived sessions.`}sessionCleanupUnavailableMessage(){return Qu(this.state.selectedMachine?.name)}selectedMachineRuntime(){return this.state.machineRuntimes[g(this.state)]}openSessionCleanupDialog(){this.sessionCleanupDialog={error:""}}closeSessionCleanupDialog(){this.sessionCleanupDialog=void 0}async previewSessionCleanup(e){if(!this.canCleanupSessions()){this.sessionCleanupDialog={...this.sessionCleanupDialog??{},error:this.sessionCleanupUnavailableMessage(),preview:void 0,previewRequest:void 0,result:void 0,loading:!1};return}const t=g(this.state);this.sessionCleanupDialog={...this.sessionCleanupDialog??{},loading:!0,error:"",preview:void 0,previewRequest:void 0,result:void 0};try{const i=await Ls.cleanupPreview(e,t);if(g(this.state)!==t)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,preview:i,previewRequest:e,result:void 0,loading:!1,error:""}}catch(i){g(this.state)===t&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,loading:!1,error:`Failed to preview cleanup: ${Es(i)}`})}}async runSessionCleanup(e){const t=this.sessionCleanupDialog;if(t?.preview===void 0||St(t.previewRequest)!==St(e)){this.sessionCleanupDialog={...t??{},error:"Preview cleanup before running it."};return}if(!this.canCleanupSessions()){this.sessionCleanupDialog={...t,error:this.sessionCleanupUnavailableMessage(),running:!1};return}const i=g(this.state);this.sessionCleanupDialog={...t,running:!0,error:""};try{const s=await Ls.cleanup(e,i);if(g(this.state)!==i)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,preview:s,previewRequest:e,result:s,running:!1,error:""},await this.sessions.applySessionCleanupResult(s,i)}catch(s){g(this.state)===i&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,running:!1,error:`Failed to run cleanup: ${Es(s)}`})}}renderNavigationPanel(){return l`
|
|
2632
|
+
<app-navigation-panel
|
|
2633
|
+
.machines=${this.state.machines}
|
|
2634
|
+
.selectedMachine=${this.state.selectedMachine}
|
|
2635
|
+
.machineStatuses=${this.state.machineStatuses}
|
|
2636
|
+
.machineActivities=${this.state.machineActivities}
|
|
2637
|
+
.machinesCollapsed=${this.navigationSections.isCollapsed("machines")}
|
|
2638
|
+
.onToggleMachines=${()=>{this.navigationSections.toggle("machines")}}
|
|
2639
|
+
.onSelectMachine=${e=>this.selectNavigationItem("machines","projects",()=>this.selectMachineWithMemory(e))}
|
|
2640
|
+
.onRemoveMachine=${e=>{this.removeMachine(e)}}
|
|
2641
|
+
.projects=${this.state.projects}
|
|
2642
|
+
.selectedProject=${this.state.selectedProject}
|
|
2643
|
+
.workspaceActivities=${this.state.workspaceActivities}
|
|
2644
|
+
.workspacesByProjectId=${this.state.workspacesByProjectId}
|
|
2645
|
+
.workspaces=${this.state.workspaces}
|
|
2646
|
+
.selectedWorkspace=${this.state.selectedWorkspace}
|
|
2647
|
+
.deletingWorkspaceIds=${gf(this.state.workspaceDeletionRuns)}
|
|
2648
|
+
.sessions=${this.state.sessions}
|
|
2649
|
+
.sessionStatuses=${this.state.sessionStatuses}
|
|
2650
|
+
.sessionActivities=${this.state.sessionActivities}
|
|
2651
|
+
.sendingPrompts=${this.state.sendingPrompts}
|
|
2652
|
+
.selectedSession=${this.state.selectedSession}
|
|
2653
|
+
.canStartSession=${!!this.state.selectedWorkspace}
|
|
2654
|
+
.canDeleteArchivedSessions=${this.canDeleteArchivedSessions()}
|
|
2655
|
+
.canReloadSessions=${this.canReloadSessions()}
|
|
2656
|
+
.canCleanupSessions=${this.canCleanupSessions()}
|
|
2657
|
+
.archivedDeleteUnavailableMessage=${this.archivedDeleteUnavailableMessage()}
|
|
2658
|
+
.cleanupUnavailableMessage=${this.sessionCleanupUnavailableMessage()}
|
|
2659
|
+
.collapsible=${!0}
|
|
2660
|
+
.compact=${this.appShell.isMobileNavigationLayout}
|
|
2661
|
+
.projectsCollapsed=${this.navigationSections.isCollapsed("projects")}
|
|
2662
|
+
.workspacesCollapsed=${this.navigationSections.isCollapsed("workspaces")}
|
|
2663
|
+
.sessionsCollapsed=${this.navigationSections.isCollapsed("sessions")}
|
|
2664
|
+
.workspaceLabelItems=${e=>this.workspaceLabelItems(e)}
|
|
2665
|
+
.refreshControl=${this.appShell.shouldShowAppRefreshInHeader()?this.renderAppRefresh():void 0}
|
|
2666
|
+
.onShowActions=${()=>{this.setState({actionPaletteOpen:!0})}}
|
|
2667
|
+
.onToggleProjects=${()=>{this.navigationSections.toggle("projects")}}
|
|
2668
|
+
.onToggleWorkspaces=${()=>{this.navigationSections.toggle("workspaces")}}
|
|
2669
|
+
.onToggleSessions=${()=>{this.navigationSections.toggle("sessions")}}
|
|
2670
|
+
.onSelectProject=${e=>this.selectNavigationItem("projects","workspaces",()=>this.workspaces.selectProject(e))}
|
|
2671
|
+
.onCloseProject=${e=>this.projects.closeProject(e.id)}
|
|
2672
|
+
.onSelectWorkspace=${e=>this.selectNavigationItem("workspaces","sessions",()=>this.workspaces.selectWorkspace(e))}
|
|
2673
|
+
.onDeleteWorkspace=${e=>{this.deleteWorkspace(e)}}
|
|
2674
|
+
.onArchivedCollapsed=${()=>{this.sessions.clearSelectionAfterArchivedCollapse()}}
|
|
2675
|
+
.onStartSession=${()=>this.selectNavigationItem("sessions","chat",()=>this.sessions.startSession())}
|
|
2676
|
+
.onSelectSession=${e=>this.selectNavigationItem("sessions","chat",()=>this.sessions.selectSession(e))}
|
|
2677
|
+
.onArchiveSession=${e=>this.sessions.archiveSession(e)}
|
|
2678
|
+
.onArchiveSessionWithDescendants=${e=>this.sessions.archiveSessionWithDescendants(e)}
|
|
2679
|
+
.onArchiveSessions=${e=>this.sessions.archiveSessions(e)}
|
|
2680
|
+
.onRestoreSession=${e=>this.selectNavigationItem("sessions","chat",()=>this.sessions.restoreSession(e))}
|
|
2681
|
+
.onDeleteCachedNewSession=${e=>this.sessions.deleteCachedNewSession(e)}
|
|
2682
|
+
.onDeleteArchivedSession=${e=>this.sessions.deleteArchivedSessions([e])}
|
|
2683
|
+
.onDeleteArchivedSessions=${e=>this.sessions.deleteArchivedSessions(e)}
|
|
2684
|
+
.onDetachParentSession=${e=>this.sessions.detachParent(e)}
|
|
2685
|
+
.onReloadSession=${e=>this.sessions.reloadSession(e)}
|
|
2686
|
+
.onCleanupSessions=${()=>{this.openSessionCleanupDialog()}}
|
|
2687
|
+
.onFocusNavigationTarget=${e=>{this.focusNavigationTarget(e)}}
|
|
2688
|
+
.onCancelKeyboardNavigation=${()=>{this.focusChatComposer()}}
|
|
2689
|
+
></app-navigation-panel>
|
|
2690
|
+
`}openNavigationSection(e){this.navigationSections.open(e,()=>{this.selectMainView("navigation")})}async selectNavigationItem(e,t,i){const s=++this.navigationSelectionSeq,r=()=>s===this.navigationSelectionSeq;await this.withChatScrollTransition(async()=>{this.navigationSections.advanceAfterSelection(e),await i()},r),r()&&await this.focusNavigationTarget(t)}async focusNavigationTarget(e){if(e==="chat"){await this.focusChatComposer();return}await this.focusNavigationSection(e)}async focusNavigationSection(e){if(e==="machines"&&!Bi(this.state.machines)){await this.focusNavigationSection("projects");return}this.panelCollapse.expandNavigationPanel(),this.appShell.isMobileNavigationLayout&&this.selectMainView("navigation"),this.navigationSections.expand(e),await this.updateComplete,await Ds(),await this.navigationPanel?.focusSection(e)}async focusChatComposer(){this.state.mainView!=="chat"&&this.selectMainView("chat"),await this.updateComplete,await Ds(),this.promptEditor?.focusInput()}visibleWorkspacePanels(){const e=this.state.selectedWorkspace;if(e===void 0)return[];const t=this.createWorkspacePanelContext(e);return this.plugins.getWorkspacePanels().filter(i=>i.visible?.(t)??!0)}workspacePanelEmptyState(){const e=this.state.selectedProject;return this.state.isLoadingProjects?{title:"Loading projects…",body:"Looking for projects you have added to PI WEB."}:e===void 0?this.state.projects.length===0?{title:"No projects yet",body:"Use Actions → Add Project to add a folder. Workspace tools will appear here after you choose a workspace."}:{title:"Select a project",body:"Choose a project from the sidebar, then select a workspace to inspect files, Git, or terminals."}:this.state.isLoadingWorkspaces?{title:"Loading workspaces…",body:`Preparing workspace tools for ${e.name}.`}:this.state.workspaces.length===0?{title:"No workspaces found",body:`${e.name} does not have any available workspaces. Try selecting the project again or re-adding it.`}:{title:"Select a workspace",body:`Choose a workspace in ${e.name} to inspect files, Git, or terminals.`}}sessionEmptyMessage(){return this.state.isLoadingProjects?"Loading projects…":this.state.selectedWorkspace!==void 0?"Select or start a session.":this.state.selectedProject!==void 0?"Select a workspace to start a session.":this.state.projects.length===0?"Add a project to start a session.":"Select a project and workspace to start a session."}mobilePanelBadge(e){const t=this.state.selectedWorkspace;if(t!==void 0)return e.badge?.(this.createWorkspacePanelContext(t))}mobilePanelIcon(e){switch(e.id){case"core:workspace.files":return"files";case"core:workspace.git":return"git";case"core:workspace.terminal":return"terminal";default:return}}workspaceLabelItems(e){return this.plugins.getWorkspaceLabelItems(this.createWorkspaceLabelContext(e))}createWorkspaceLabelContext(e){const t=jn(this.state);return{machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,t.id),host:this.createWorkspaceHost()}}createWorkspaceFiles(e,t){return{readFile:i=>bt.workspaceFile(e.projectId,e.id,i,t),writeFile:async(i,s,r)=>{const o=await bt.writeWorkspaceFile(e.projectId,e.id,i,s,r,t);return this.files.refreshFiles(),o},deleteFile:async i=>{const s=await bt.deleteWorkspaceFile(e.projectId,e.id,i,t);return this.files.refreshFiles(),s},moveFile:async(i,s,r)=>{const o=await bt.moveWorkspaceFile(e.projectId,e.id,i,s,r,t);return this.files.refreshFiles(),o}}}createWorkspaceHost(){return{requestRender:()=>{this.requestUpdate()}}}createWorkspacePanelContext(e){const t=jn(this.state),i=t.id,s=r=>{const o=this.terminalCommandRunsForOrigin(r,i);return kg({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,i),prompt:this.createPromptEditor(),terminal:{open:n=>{this.openRuntimeTerminal(i,e,n)},runCommand:n=>o.runCommand({...n,workspace:e})},openTerminal:n=>{this.openRuntimeTerminal(i,e,n)},host:this.createWorkspaceHost(),piWebUnstable:{terminalCommandRuns:o},fileTree:this.state.fileTree,expandedDirs:this.state.expandedDirs,selectedFilePath:this.state.selectedFilePath,selectedFileContent:this.state.selectedFileContent,fileTreeStale:this.state.fileTreeStale,gitStatus:this.state.gitStatus,selectedDiffPath:this.state.selectedDiffPath,selectedDiff:this.state.selectedDiff,selectedStagedDiff:this.state.selectedStagedDiff,gitStale:this.state.gitStale,activeTerminalCount:this.state.activeTerminalCount,selectedTerminalId:this.state.selectedTerminalId,terminalAutoStart:this.terminalAutoStartWorkspaceId===e.id,workspaceUploadDefaultFolder:Xd(e.effectiveConfig,this.workspaceUploadDefaultFolder),onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:n=>{this.files.expandDir(n)},onSelectFile:n=>{this.files.selectFile(n)},onStartWorkspaceUpload:(n,a)=>this.files.startWorkspaceUpload(n,a),onCancelWorkspaceUpload:n=>{this.files.cancelWorkspaceUpload(n)},onClearWorkspaceUpload:n=>{this.files.clearWorkspaceUpload(n)},onRefreshGit:()=>{this.git.refreshGit()},onSelectDiff:n=>{this.git.selectDiff(n)},onSelectTerminal:(n,a)=>{this.selectTerminal(n,a)}},s)};return s("core")}getActions(){return cm(this.getDefaultActions(),this.shortcutConfig)}getDefaultActions(){return[...this.plugins.getActions(this.createPluginRuntimeContext()),...this.sessionActions(),...this.navigationFocusActions(),...this.panelLayoutActions()]}sessionActions(){return[{id:"app.sessions.cleanup",title:"Clean Up Sessions",description:"Preview and manually clean up idle or archived sessions on the selected machine",group:"Sessions",...this.canCleanupSessions()?{}:{enabled:!1,disabledReason:this.sessionCleanupUnavailableMessage()},run:()=>{this.openSessionCleanupDialog()}}]}panelLayoutActions(){return[{id:"app.layout.reset-navigation-panel-size",title:"Reset Navigation Panel Size",description:"Restore the navigation panel to its default width",group:"View",run:()=>{this.resetResizablePanel("navigation")}},{id:"app.layout.reset-workspace-panel-size",title:"Reset Workspace Panel Size",description:"Restore the workspace panel to its default width",group:"View",run:()=>{this.resetResizablePanel("workspace")}},{id:"app.layout.reset-panel-sizes",title:"Reset Panel Sizes",description:"Restore all side panels to their default widths",group:"View",run:()=>{this.resetResizablePanels()}}]}navigationFocusActions(){return[{id:"app.navigation.focus-machines",title:"Focus Machines",description:"Move keyboard focus to the machine selector",shortcut:"mod+g m",group:"Navigation",run:()=>this.focusNavigationSection("machines")},{id:"app.navigation.focus-projects",title:"Focus Projects",description:"Move keyboard focus to the projects list",shortcut:"mod+g p",group:"Navigation",run:()=>this.focusNavigationSection("projects")},{id:"app.navigation.focus-workspaces",title:"Focus Workspaces",description:"Move keyboard focus to the workspaces list",shortcut:"mod+g w",group:"Navigation",run:()=>this.focusNavigationSection("workspaces")},{id:"app.navigation.focus-sessions",title:"Focus Sessions",description:"Move keyboard focus to the sessions list",shortcut:"mod+g s",group:"Navigation",run:()=>this.focusNavigationSection("sessions")}]}ensureGatewayPluginsLoaded(){return this.gatewayPluginLoadPromise??=this.loadExternalPlugins(),this.gatewayPluginLoadPromise}async loadExternalPlugins(){await this.registerExternalPlugins("PI WEB plugins",()=>Vo())}async loadPluginsForSelectedMachine(){const e=this.state.selectedMachine;e?.kind==="remote"&&await this.loadPluginsForMachine(e)}async loadPluginsForMachine(e){if(await this.ensureGatewayPluginsLoaded(),e.kind!=="remote"||this.loadedMachinePluginIds.has(e.id))return;const t=this.machinePluginLoadPromises.get(e.id);if(t!==void 0)return t;const i=this.registerExternalPlugins(`PI WEB plugins from ${e.name}`,()=>Vo(`/api/machines/${encodeURIComponent(e.id)}/pi-web-plugins/manifest.json`,{machineId:e.id,shouldLoadPlugin:s=>this.plugins.shouldLoadRemotePlugin(s.id,s.machineSpecific)})).then(s=>{s&&this.loadedMachinePluginIds.add(e.id)}).finally(()=>{this.machinePluginLoadPromises.delete(e.id)});this.machinePluginLoadPromises.set(e.id,i),await i}async registerExternalPlugins(e,t){try{const i=await t();for(const s of i)try{this.plugins.register(s)}catch(r){console.warn(`Failed to register PI WEB plugin ${s.id}`,r)}return this.applyPreferredTheme(!1),this.requestUpdate(),!0}catch(i){return console.warn(`Failed to load ${e}`,i),!1}}createPromptEditor(){return{insertText:e=>{const t=this.promptEditor?.view;if(!t)return;t.hasFocus||t.focus();const i=t.state.selection.main;t.dispatch({changes:{from:i.from,to:i.to,insert:e},selection:{anchor:i.from+e.length}})},getText:()=>this.promptEditor?.view?.state.doc.toString()??"",getSelection:()=>{const e=this.promptEditor?.view;if(!e)return null;const t=e.state.selection.main;return t.empty?null:{start:t.from,end:t.to,text:e.state.sliceDoc(t.from,t.to)}}}}createPluginRuntimeContext(){const e=t=>Sg({state:this.state,prompt:this.createPromptEditor(),piWebUnstable:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t),openSettings:i=>{this.openSettings(i)}},openActionPalette:()=>{this.setState({actionPaletteOpen:!0})},focusPrompt:()=>{this.focusChatComposer()},addProject:()=>{this.setState({projectDialogOpen:!0})},addMachine:()=>{this.openMachineDialog()},refreshSelectedMachine:async()=>{await Promise.all([this.machines.refreshMachineHealth(),this.machines.refreshMachineRuntime()])},removeSelectedMachine:()=>this.removeMachine(),openSelectedMachine:()=>{this.openSelectedMachine()},configureAuth:()=>this.auth.openLogin(),logoutAuth:()=>this.auth.openLogout(),openThemePicker:()=>{this.openThemeDialog()},selectMainView:i=>{this.selectMainView(i)},selectWorkspaceTool:i=>{this.openWorkspaceTool(i)},openTerminal:i=>{this.openTerminal(i)},refreshFiles:()=>this.files.refreshFiles(),refreshGit:()=>this.git.refreshGit(),refreshAppData:()=>this.refreshAppData(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:i=>this.deleteWorkspace(i),startSession:()=>this.withChatScrollTransition(()=>this.sessions.startSession()),archiveSession:()=>this.sessions.archiveSession(),reloadSession:()=>this.sessions.reloadSession(),deleteCachedNewSession:()=>this.sessions.deleteCachedNewSession(),stopActiveWork:()=>this.sessions.stopActiveWork()},e);return e("core")}async deleteWorkspace(e=this.state.selectedWorkspace){if(e===void 0)return;if(!ku(e)){this.setState({error:"Only secondary Git worktrees can be deleted"});return}if(Oa(this.state,e))return;const t=e.branch??e.label;if(!confirm(`Delete workspace ${t}?
|
|
2691
|
+
|
|
2692
|
+
This will run git worktree remove and delete:
|
|
2693
|
+
${e.path}
|
|
2694
|
+
|
|
2695
|
+
The Git branch will not be deleted.`))return;const s=g(this.state);try{const r=await bt.deleteWorkspace(e.projectId,e.id,s);if(g(this.state)!==s)return;this.recordWorkspaceDeletionRun(r,s);const o=await this.workspaceForCommandRun(r);if(g(this.state)!==s)return;o!==void 0&&this.openRuntimeTerminal(s,o,{terminalId:r.terminalId})}catch(r){g(this.state)===s&&this.setState({error:`Failed to start workspace deletion: ${Es(r)}`})}}async workspaceForCommandRun(e){let t=this.state.selectedProject?.id===e.projectId?this.state.workspaces:this.state.workspacesByProjectId[e.projectId];return(t===void 0||t.length===0)&&(t=await this.workspaces.refreshProjectWorkspaces(e.projectId)),t.find(i=>i.id===e.workspaceId)}recordWorkspaceDeletionRun(e,t){if(g(this.state)!==t)return;const i=Bs(e);i!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[i]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;const e=g(this.state),t=this.state.selectedProject;if(t===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{const i=await this.terminalCommandRunsForOrigin("core",e).listCommandRuns(uf(t.id));if(g(this.state)!==e)return;const s=ff(i);this.setState({workspaceDeletionRuns:s});for(const r of Object.values(s))Wi(r)||await this.handleCompletedWorkspaceDeletionRun(r,e)}catch(i){console.warn("Failed to refresh workspace deletion runs",i)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){const e=Object.values(this.state.workspaceDeletionRuns).some(Wi);if(e&&this.workspaceDeletionPollTimer===void 0){this.workspaceDeletionPollTimer=window.setInterval(()=>{this.refreshWorkspaceDeletionRuns()},1e3);return}!e&&this.workspaceDeletionPollTimer!==void 0&&(window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0)}async handleCompletedWorkspaceDeletionRun(e,t=g(this.state)){if(g(this.state)!==t)return;const i=Fn(t,e.id);if(this.handledWorkspaceDeletionRunIds.has(i))return;const s=Bs(e);if(s!==void 0){if(this.handledWorkspaceDeletionRunIds.add(i),e.status==="succeeded"){if(await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,s),g(this.state)!==t)return;this.setState({workspaceDeletionRuns:t0(this.state.workspaceDeletionRuns,s)}),this.updateWorkspaceDeletionPolling();return}e.status==="failed"&&(this.setState({error:"Workspace deletion failed. See terminal output."}),this.updateWorkspaceDeletionPolling())}}openMachineDialog(){this.setState({machineDialogOpen:!0,error:""})}async submitMachineDialog(e){await this.machines.addMachine(e)!==void 0&&(this.setState({machineDialogOpen:!1}),this.schedulePiWebStatusRefresh())}async removeMachine(e=this.state.selectedMachine){if(e===void 0||e.kind==="local"||!window.confirm(`Remove ${e.name}?
|
|
2696
|
+
|
|
2697
|
+
This only removes it from this PI WEB gateway.`))return;const t=this.state.selectedMachine?.id===e.id;t&&this.rememberCurrentMachineNavigation();const i=await this.machines.deleteMachine(e,{selectFallback:!t});this.state.machines.some(s=>s.id===e.id)||this.machineNavigation.forget(e.id),t&&i!==void 0&&await this.selectMachineWithMemory(i,{rememberCurrent:!1})}openSelectedMachine(){const e=this.state.selectedMachine;e?.kind!=="remote"||e.baseUrl===void 0||window.open(e.baseUrl,"_blank","noopener,noreferrer")}runAction(e){Promise.resolve().then(()=>e.run()).catch(t=>{const i=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${i}`})})}async openModelDialog(){const e=await this.sessions.listModels(),t=this.state.status?.model?.provider,i=this.state.status?.model?.id;this.setState({modelDialog:{title:"Select Model",...t!==void 0&&i!==void 0?{selectedValue:`${t}/${i}`}:{},options:e.map(s=>{const r=s.provider??"",o=s.id??"",n=r===t&&o===i;return{value:`${r}/${o}`,label:`${o}${n?" ✓ current":""}`,description:r}})}})}async pickModel(e){this.setState({modelDialog:void 0});const t=e.indexOf("/");t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openThemeDialog(){const e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),i=t.selectedTheme?.id,s=this.themePreference.auto?On:As;this.setState({themeDialog:{title:"Select Theme",selectedValue:i===void 0?s:`${di}${i}`,options:[{value:s,label:`Auto ${this.themePreference.auto?"✓ on":"off"}`,description:this.autoThemeDescription(t)},...e.map(r=>({value:`${di}${r.id}`,label:this.themeOptionLabel(r,i),description:this.themeOptionDescription(r)}))]}})}pickTheme(e){if(this.setState({themeDialog:void 0}),e===As||e===On){const s=this.resolveCurrentThemePreference().selectedTheme?.id;if(s===void 0)return;this.themePreference={themeId:s,auto:e===As},this.applyPreferredTheme(!0);return}if(!e.startsWith(di))return;const t=e.slice(di.length),i=this.plugins.getThemes().find(s=>s.id===t);i!==void 0&&(this.themePreference={themeId:i.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){const t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,sf(t),e&&tf(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return rf({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return Wa(this.plugins.getThemePairs(),e)}systemPrefersLight(){return this.systemLightThemeMedia?.matches??!1}autoThemeDescription(e){return!this.themePreference.auto||e.selectedTheme===void 0?"Follow the system light/dark preference when the selected theme has a pair.":e.selectedThemePair===void 0?"On, but the selected theme has no light/dark pair, so it will stay selected.":`On · ${e.selectedThemePair.name} follows the system ${this.systemPrefersLight()?"light":"dark"} preference.`}themeOptionLabel(e,t){const i=[...e.id===t?["selected"]:[],...e.id===this.activeThemeId&&e.id!==t?["active"]:[]];return i.length===0?e.name:`${e.name} ✓ ${i.join(" · ")}`}themeOptionDescription(e){const t=[e.colorScheme];return this.themePairForTheme(e.id)!==void 0&&t.push("auto pair"),e.description!==void 0&&t.push(e.description),t.join(" · ")}async openThinkingDialog(){const e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??"off";this.setState({thinkingDialog:{title:"Select Thinking Level",selectedValue:t,options:e.map(i=>{const s=i0(i);return{value:i,label:`${i}${i===t?" ✓ current":""}`,...s===void 0?{}:{description:s}}})}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),e!==""&&await this.sessions.setThinkingLevel(e)}sendPrompt(e,t,i,s){!(i!==void 0&&i.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)||this.sessions.send(e,t,i,s)}renderContextBar(){return this.appShell.isMobileNavigationLayout?l`
|
|
2698
|
+
<app-context-bar
|
|
2699
|
+
.machines=${this.state.machines}
|
|
2700
|
+
.machine=${this.state.selectedMachine}
|
|
2701
|
+
.project=${this.state.selectedProject}
|
|
2702
|
+
.workspace=${this.state.selectedWorkspace}
|
|
2703
|
+
.session=${this.state.selectedSession}
|
|
2704
|
+
.refreshControl=${this.appShell.shouldShowAppRefreshInContextBar()?this.renderAppRefresh():void 0}
|
|
2705
|
+
.onOpenSection=${e=>{this.openNavigationSection(e)}}
|
|
2706
|
+
.onShowActions=${()=>{this.setState({actionPaletteOpen:!0})}}
|
|
2707
|
+
></app-context-bar>
|
|
2708
|
+
`:null}renderMobileMainTabs(){return l`
|
|
2709
|
+
<app-mobile-main-tabs
|
|
2710
|
+
.tabs=${this.mobileMainTabs()}
|
|
2711
|
+
.selectedView=${this.state.mainView}
|
|
2712
|
+
.onSelect=${e=>{this.selectMainView(e)}}
|
|
2713
|
+
></app-mobile-main-tabs>
|
|
2714
|
+
`}mobileMainTabs(){return[{id:"navigation",label:"Sessions",icon:"navigation",className:"navigation-tab"},{id:"chat",label:"Chat",icon:"chat"},...this.visibleWorkspacePanels().map(e=>{const t=e.icon??this.mobilePanelIcon(e);return{id:e.id,label:e.title,...t===void 0?{}:{icon:t},badge:this.mobilePanelBadge(e)}})]}renderAppRefresh(){return l`<app-refresh-control .onReload=${()=>{this.hardReloadApp()}}></app-refresh-control>`}render(){const e=this.state;return l`
|
|
2715
|
+
<div class=${this.panelCollapse.shellClass(e.mainView)} style=${this.panelResize.shellStyle({navigation:this.resizablePanelConstraints("navigation"),workspace:this.resizablePanelConstraints("workspace")})}>
|
|
2716
|
+
<aside id="navigation-panel">${this.appShell.isMobileNavigationLayout?null:this.renderNavigationPanel()}</aside>
|
|
2717
|
+
${this.renderNavigationPanelEdgeControl()}
|
|
2718
|
+
<main class=${za(e.mainView)}>
|
|
2719
|
+
${this.renderContextBar()}
|
|
2720
|
+
${this.renderMobileMainTabs()}
|
|
2721
|
+
${e.error?l`<div class="error">${e.error}</div>`:null}
|
|
2722
|
+
<div class="mobile-navigation-panel">${this.appShell.isMobileNavigationLayout?this.renderNavigationPanel():null}</div>
|
|
2723
|
+
${e.selectedSession?l`
|
|
2724
|
+
<chat-view .sessionId=${e.selectedSession.id} .messages=${e.messages} .messageStart=${e.messagePageStart} .messageEnd=${e.messagePageEnd} .messageTotal=${e.messagePageTotal} .hasMore=${e.messagePageStart>0} .loadingMore=${e.isLoadingEarlierMessages} .isReceivingPartialStream=${e.isReceivingPartialStream} .isSendingPrompt=${e.sendingPrompts[e.selectedSession.id]===!0} .isCompacting=${e.status?.isCompacting===!0} .pendingMessageCount=${e.status?.pendingMessageCount??0} .status=${e.status} .activity=${e.activity} .onLoadMore=${()=>this.withChatPrependTransition(()=>this.sessions.loadEarlierMessages())}></chat-view>
|
|
2725
|
+
<prompt-editor .sessionId=${e.selectedSession.id} .cwd=${e.selectedWorkspace?.path} .machineId=${g(e)} .projectId=${e.selectedWorkspace?.projectId} .workspaceId=${e.selectedWorkspace?.id} .workspaceScopedFileSuggestions=${this.supportsWorkspaceFileSuggestions()} .disabled=${e.selectedSession.archived===!0} .canSteer=${e.status?.isStreaming===!0} .isCompacting=${e.status?.isCompacting===!0} .canStop=${e.status?.isStreaming===!0||e.status?.isBashRunning===!0||e.status?.isCompacting===!0||(e.status?.pendingMessageCount??0)>0} .status=${e.status} .availableThinkingLevels=${e.availableThinkingLevels} .sending=${e.sendingPrompts[e.selectedSession.id]===!0} .onSend=${(t,i,s,r)=>{this.sendPrompt(t,i,s,r)}} .onStop=${()=>this.sessions.stopActiveWork()} .onSelectModel=${()=>{this.openModelDialog()}} .onSelectThinking=${()=>{this.openThinkingDialog()}}></prompt-editor>
|
|
2726
|
+
<status-bar .status=${e.status}></status-bar>
|
|
2727
|
+
${e.commandDialog!==void 0?l`<command-picker .title=${e.commandDialog.title} .options=${e.commandDialog.options} .onPick=${t=>this.sessions.respondToCommand(e.commandDialog?.requestId??"",t)} .onCancel=${()=>{this.sessions.cancelCommand()}}></command-picker>`:null}
|
|
2728
|
+
${e.modelDialog!==void 0?l`<command-picker title=${e.modelDialog.title} .searchable=${!0} .options=${e.modelDialog.options} .selectedValue=${e.modelDialog.selectedValue} .onPick=${t=>{this.pickModel(t)}} .onCancel=${()=>{this.setState({modelDialog:void 0})}}></command-picker>`:null}
|
|
2729
|
+
${e.thinkingDialog!==void 0?l`<command-picker title=${e.thinkingDialog.title} .options=${e.thinkingDialog.options} .selectedValue=${e.thinkingDialog.selectedValue} .onPick=${t=>{this.pickThinking(t)}} .onCancel=${()=>{this.setState({thinkingDialog:void 0})}}></command-picker>`:null}
|
|
2730
|
+
${e.authDialog!==void 0?l`<auth-dialog .state=${e.authDialog} .onChooseMethod=${t=>{this.auth.chooseLoginMethod(t)}} .onSelectProvider=${(t,i)=>{this.auth.selectLoginProvider(t,i)}} .onApiKeyInput=${t=>{this.auth.updateApiKey(t)}} .onSaveApiKey=${()=>{this.auth.saveApiKey()}} .onLogoutProvider=${t=>{this.auth.logoutProvider(t)}} .onOAuthInput=${t=>{this.auth.updateOAuthInput(t)}} .onOAuthRespond=${t=>{this.auth.respondOAuth(t)}} .onOAuthCancel=${()=>{this.auth.cancelOAuth()}} .onCancel=${()=>{this.auth.closeDialog()}}></auth-dialog>`:null}
|
|
2731
|
+
`:l`<div class="empty">${this.sessionEmptyMessage()}</div>`}
|
|
2732
|
+
</main>
|
|
2733
|
+
${this.renderWorkspacePanelEdgeControl()}
|
|
2734
|
+
${this.renderWorkspacePanel()}
|
|
2735
|
+
${e.actionPaletteOpen?l`<action-palette .actions=${this.getActions()} .onRun=${t=>{this.setState({actionPaletteOpen:!1}),this.runAction(t)}} .onCancel=${()=>{this.setState({actionPaletteOpen:!1})}}></action-palette>`:null}
|
|
2736
|
+
${e.projectDialogOpen?l`<project-dialog .machineId=${g(e)} .onSubmit=${(t,i)=>this.projects.addProject(t,i)} .onCancel=${()=>{this.setState({projectDialogOpen:!1})}}></project-dialog>`:null}
|
|
2737
|
+
${e.machineDialogOpen?l`<machine-dialog .error=${e.error} .onSubmit=${t=>this.submitMachineDialog(t)} .onCancel=${()=>{this.setState({machineDialogOpen:!1})}}></machine-dialog>`:null}
|
|
2738
|
+
${this.sessionCleanupDialog!==void 0?l`<session-cleanup-dialog .canCleanup=${this.canCleanupSessions()} .unavailableMessage=${this.sessionCleanupUnavailableMessage()} .preview=${this.sessionCleanupDialog.preview} .previewRequest=${this.sessionCleanupDialog.previewRequest} .result=${this.sessionCleanupDialog.result} .loading=${this.sessionCleanupDialog.loading===!0} .running=${this.sessionCleanupDialog.running===!0} .error=${this.sessionCleanupDialog.error??""} .onPreview=${t=>{this.previewSessionCleanup(t)}} .onRun=${t=>{this.runSessionCleanup(t)}} .onClose=${()=>{this.closeSessionCleanupDialog()}}></session-cleanup-dialog>`:null}
|
|
2739
|
+
${e.themeDialog!==void 0?l`<command-picker title=${e.themeDialog.title} .options=${e.themeDialog.options} .selectedValue=${e.themeDialog.selectedValue} .onPick=${t=>{this.pickTheme(t)}} .onCancel=${()=>{this.setState({themeDialog:void 0})}}></command-picker>`:null}
|
|
2740
|
+
${this.settingsSection!==void 0?l`<settings-dialog .section=${this.settingsSection} .actions=${this.getDefaultActions()} .onNavigate=${t=>{this.navigateSettings(t)}} .onClose=${()=>{this.closeSettings()}} .onConfigSaved=${t=>{this.applyClientConfig(t)}}></settings-dialog>`:null}
|
|
2741
|
+
</div>
|
|
2742
|
+
`}};ne.styles=Rf;ve([v()],ne.prototype,"state",2);ve([z("chat-view")],ne.prototype,"chatView",2);ve([z("prompt-editor")],ne.prototype,"promptEditor",2);ve([z("app-navigation-panel")],ne.prototype,"navigationPanel",2);ve([z("#navigation-panel")],ne.prototype,"navigationPanelFrame",2);ve([z("#workspace-panel")],ne.prototype,"workspacePanelFrame",2);ve([v()],ne.prototype,"activeThemeId",2);ve([v()],ne.prototype,"isRefreshingApp",2);ve([v()],ne.prototype,"sessionCleanupDialog",2);ve([v()],ne.prototype,"settingsSection",2);ve([v()],ne.prototype,"shortcutConfig",2);ve([v()],ne.prototype,"workspaceUploadDefaultFolder",2);ne=ve([D("pi-web-app")],ne);function Qy(){const e=new yg;return e.register({id:"core",plugin:sg}),e.register({id:"themes",plugin:ag}),e}function jn(e){const t=e.selectedMachine;return t!==void 0?{id:t.id,name:t.name,kind:t.kind}:{id:"local",name:"local",kind:"local"}}function Jy(e,t){return e.machines!==t.machines||e.machineStatuses!==t.machineStatuses||(e.selectedMachine?.id??"local")!==(t.selectedMachine?.id??"local")}function Zy(e,t){return Pl(e,t)}function Pl(e,t){if(e.kind==="local")return!0;const i=t?.status??e.status;return i===void 0||i==="unknown"||i==="online"}function Xy(e,t){return Object.entries(t).some(([i,s])=>Reflect.get(e,i)!==s)}function _n(e){return Xe(e.status,e.activity)}function Yy(e){return e.type==="terminal.created"||e.type==="terminal.exited"||e.type==="terminal.closed"}function Ln(){return{}}function Fn(e,t){return JSON.stringify([e,t])}function e0(e){const t=Math.min(e,Ys.length-1);return Ys[t]??3e4}function Es(e){return e instanceof Error?e.message:String(e)}function t0(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}function Ds(){return new Promise(e=>requestAnimationFrame(()=>{e()}))}function i0(e){switch(e){case"off":return"No reasoning";case"minimal":return"Very brief reasoning (~1k tokens)";case"low":return"Light reasoning (~2k tokens)";case"medium":return"Moderate reasoning (~8k tokens)";case"high":return"Deep reasoning (~16k tokens)";case"xhigh":return"Maximum reasoning (~32k tokens)";default:return}}export{O as a,l as b,wt as c,g0 as d,u0 as e,z as f,M as i,d as n,v as r,f0 as s,D as t};
|